2020-09-13 21:32:55 -04:00
|
|
|
#pragma once
|
|
|
|
|
2020-09-17 21:47:52 -04:00
|
|
|
#include "common/goos/Object.h"
|
2022-06-22 23:37:46 -04:00
|
|
|
#include "common/type_system/TypeSpec.h"
|
2020-09-12 13:11:42 -04:00
|
|
|
|
|
|
|
// note - we cannot easily reuse the GOOS argument system because GOAL's is slightly different.
|
|
|
|
// there's no rest or keyword support.
|
|
|
|
struct GoalArg {
|
[goalc] Cleaned up speedups (#3066)
Started at 349,880,038 allocations and 42s
- Switched to making `Symbol` in GOOS be a "fixed type", just a wrapper
around a `const char*` pointing to the string in the symbol table. This
is a step toward making a lot of things better, but by itself not a huge
improvement. Some things may be worse due to more temp `std::string`
allocations, but one day all these can be removed. On linux it saved
allocations (347,685,429), and saved a second or two (41 s).
- cache `#t` and `#f` in interpreter, better lookup for special
forms/builtins (hashtable of pointers instead of strings, vector for the
small special form list). Dropped time to 38s.
- special-case in quasiquote when splicing is the last thing in a list.
Allocation dropped to 340,603,082
- custom hash table for environment lookups (lexical vars). Dropped to
36s and 314,637,194
- less allocation in `read_list` 311,613,616. Time about the same.
- `let` and `let*` in Interpreter.cpp 191,988,083, time down to 28s.
2023-10-07 10:48:17 -04:00
|
|
|
std::string name; // todo intern
|
2020-09-12 13:11:42 -04:00
|
|
|
TypeSpec type;
|
|
|
|
};
|
|
|
|
|
2020-09-05 18:55:07 -04:00
|
|
|
struct Lambda {
|
|
|
|
std::string debug_name;
|
2020-09-12 13:11:42 -04:00
|
|
|
std::vector<GoalArg> params;
|
|
|
|
goos::Object body;
|
2020-09-05 18:55:07 -04:00
|
|
|
};
|
|
|
|
|
2023-02-24 18:32:30 -05:00
|
|
|
struct InlineableFunction {
|
|
|
|
Lambda lambda;
|
|
|
|
TypeSpec type;
|
|
|
|
bool inline_by_default = false;
|
|
|
|
};
|