Commit Graph

1140 Commits

Author SHA1 Message Date
Nathan Braswell
7116012be1 Better debug parameter message 2022-04-06 00:24:34 -04:00
Nathan Braswell
dcc81ac2eb make prints of top level strings not include the quotes 2022-04-06 00:13:46 -04:00
Nathan Braswell
db7c258d39 Make printing stack/env nicer 2022-04-05 23:59:18 -04:00
Nathan Braswell
29f02810f8 More debug work, including adding the code tracking throught marked_array for the stack traces, calling into debug when eval has a symbol not defined error (just the first error spot to do this, we can add them all gradually), allowing abort for debug, and adding (exit val) for debug that resumes execution 2022-04-05 00:30:03 -04:00
Nathan Braswell
99e24ac6a0 Add rough stack trace 2022-04-04 01:35:06 -04:00
Nathan Braswell
00299a8d3a Fixed read, started in on a debug function with a repl and ability to exit. Haven't actually added any other debug functionality, but thought about how to do stack traces (linked list of env functional val pairs). 2022-04-02 01:01:34 -04:00
Nathan Braswell
d5b11ca037 compile static calls to static wasm calls 2022-04-01 01:06:40 -04:00
Nathan Braswell
b87afc6a12 Round allocated blocks up to the nearest 8 words, and split blocks that are >= 2x needed number of words. Now only allocates 1 wasm page for both compiled and interpreted versions at fib 30, a 269-538x improvement! 2022-03-30 21:27:01 -04:00
Nathan Braswell
b85873b240 Fixed a terrible bug where turns out I used the same name for a block and a parameter in the comparison meta-function -
they share the same namespace in the wasm DSL, so when I used it like a parameter in a loop it resolved to the number of scopes between the statement and the block'th parameter
which had the same type and the calculation worked fine, but it overwrote the parameter I thought wasn't being used and called a function later with.

Also, that seemed like that last of the really bad leaks & corruption, so re-enabling the freelist and am able to run some less-trivial benchmarks, namely (fib 30)!
The compiled version is between 4.7x and 65x slower than Python, depending on if you're using wasmer, wasmtime, wasm3. Would like to try WAVM as well.
A solid place to start, I think, and hopefully we'll be faster than Python once I implement a variety of dont-be-dumb optimizations (real-er malloc, static calls of statically known functions, etc)
2022-03-29 23:49:51 -04:00
Nathan Braswell
cb41fe3fc8 Added a singlely-linked list with the value-created 2 word header to mallocd blocks that tracks everything ever malloced, and an assertion on free that the refcount is 0. Found what I think was a (the?) key source of corruption - drop moving the ptr forwards to drop subs, but then freeing that moved ptr. Now fixed, things look much less weird, but there are remaining memory leaks to track down 2022-03-28 23:57:38 -04:00
Nathan Braswell
f5ba367096 Debugging refcounting, fixed 3 mem leaks so far 2022-03-24 01:58:49 -04:00
Nathan Braswell
5c1473d32c Continue brain-dumping psudocode and notes. I think I've got most everything critical now 2022-03-21 23:52:07 -04:00
Nathan Braswell
b3122f62d1 Started brain-dumping psudocode and descriptions of interesting points/contributions, the reason all macro-like combiners should be partially-evaled away, the invarients we must maintain, etc 2022-03-21 01:03:54 -04:00
Nathan Braswell
0c554078bd Found the offending code for the infinate recursion, though not exactly why it happens. Minimal reproducer seemingly found 2022-03-20 20:50:39 -04:00
Nathan Braswell
eb3a732f99 Add fib_let test and script to run all of them. Indeed, the version with the let is worse when interpreted and the same/better when partially-evaled and compiled 2022-03-20 16:01:38 -04:00
Nathan Braswell
6fa2c44619 Add no_compile option to test more staight dynamic eval with a fib and fact test. Compiled is faster, though only 2x on fib - I imagine the hot inner loop isn't actually doing a lot that can be partial evaled, it's the outside. Will need tests that excercise more 2022-03-19 01:48:58 -04:00
Nathan Braswell
f0d68c3efe Finally implemented runtime vau with varadic, which involved a half-rewrite 2022-03-17 23:20:22 -04:00
Nathan Braswell
f10be4511f Add support for de to runtime vaus as well as parameter length checking. Do need to add support for varidac functions... 2022-03-17 00:35:21 -04:00
Nathan Braswell
1a2ecd65b0 Implemented runtime vau, but still need to add support for functions taking in the dynamic env (gotta shift those env arrays around) 2022-03-16 02:10:29 -04:00
Nathan Braswell
67ba716003 Add runtime version of cond 2022-03-15 02:13:42 -04:00
Nathan Braswell
31ee20be7b Implemented wasm eval and fixed slice 2022-03-13 22:56:04 -04:00
Nathan Braswell
1b220023bc Fix cond to not die on guarded errors, implement a new if in macro-style, port some more over to_compile.kp. Stopped just before 'vau, which seems to loop forever or somesuch 2022-03-13 15:11:30 -04:00
Nathan Braswell
947d854ebb Implement array functions (len idx slice concat) for strings in wasm versions. All work - note I think slice is broken (or at least exposes brokenness) for arrays (not the newly adding strings)! 2022-03-13 01:44:38 -05:00
Nathan Braswell
d1b6e520f9 Added support for strings to array functions for evaluator (compiled is next) 2022-03-12 20:19:00 -05:00
Nathan Braswell
d87f292c1c Additional optimization using intset for env_stack, some small bugfixes regarding not making a marked_array out of components that errored, moved over a lot of code to to_compile.kp. 2022-03-10 01:06:44 -05:00
Nathan Braswell
a08415e1e6 Cleanup & some demo code for presentation 2022-03-08 15:55:59 -05:00
Nathan Braswell
7fed3a58f5 Added more to to_compile.kp and runtime started growing again - main bottleneck was the silly using lists as sets thing, changed the small-int uses of these to a new custom bitset and brought the time from 47s back down to 6s. There is a remaining hotspot where partial_eval_helper matches needed_for_progress vs the bitset, but that'll have to wait for tomorrow. Thinking of maintaining a env_stack bitset and adding a bitset_union_nonempty function. Note the new bitset does use some cons/car/cdr operations that'll be a bit different in Kraken, which I'll need to look at. Maybe when porting I can just use indexing if there's not a great way to unify them. 2022-03-08 02:54:26 -05:00
Nathan Braswell
90fe8e1bfa Bunch of optimization that took us from 3:50 to 0:04 for the current to_compile.kp. Mainly pulling len out of hot loops and using a naive binary tree instead of alists for maps 2022-03-07 02:10:42 -05:00
Nathan Braswell
c8c9bba429 Have nodes carry around information about the additional non-real envs that aren't real because of a non-real env in their chain. These envs don't show up in needed partial idxs, since it's the up the chain env that actually needs progressing, but allow us to do check-for-env-id normally in essentially O(1). This made the function much more efficient by number of invocations and cut some of the other hottest functions by nearly an order of magnitude, but only took 15-20 seconds off of a 4 minute compile. This is unfortunate (Chez profile only shows invocation numbers, not time numbers, so this is hard to tell) but at least this part is better now. 2022-03-06 03:22:35 -05:00
Nathan Braswell
bf1f81cdf3 Implement and and or. Looks like nil doesn't currently count as false, based false? and it seems to be avoided even with the compiled 'vcond, though it looks like it shouldn't (oh this is probs it being partially evaled ahead of time, isn't it?) Anyway, we might want to finish this and remove it from vcond too 2022-03-03 09:28:01 -05:00
Nathan Braswell
8cdf41826b Starting to port over & self-host! 2022-03-03 00:33:25 -05:00
Nathan Braswell
4a273c9ba2 Bigfix error infinite recursion, error printing, wrap_level not being in hash_comb, extend to_compile.kp a bit 2022-03-02 01:44:20 -05:00
Nathan Braswell
dd0463d059 Comment out generated debugging and other log based code for large speedup - tried several other optimizations but they counterintitively made things worse 2022-02-28 23:47:02 -05:00
Nathan Braswell
3f26a3ad7d Finish porting mif and fixing up other inconsistancies. Fix bug for emitting signed numbers as hex in compile. Runs correctly in both Chez and Chicken interpreter now, which Chez being about 3x faster 2022-02-28 00:27:19 -05:00
Nathan Braswell
ea15f48d6f Implement dlambda and correct dlet. More attempt at Gambit 2022-02-23 16:43:03 -05:00
Nathan Braswell
54097ac074 Port the let+ macro from http://www.phyast.pitt.edu/~micheles/scheme/scheme15.html over mostly, and it works in both Chez and Chicken! Will massage some more to get it to be the same as our previous dlet, but it is working! 2022-02-23 00:56:46 -05:00
Nathan Braswell
f8bab2ada5 I caught the Chicken compiler red handed, it's compiled version has zip change behavior part way through, caught in the act with some prints. Where it does so changes based on optimization level, which is a bad sign. Starting a (hopfully quick) port to more standard scheme - looking to support Chez and Gambit in addition to Chicken, with at least some commented out code if not some sort of conditional compilation. We're off to a roaring start with define-syntax broken in Gambit 4.9.3, from 2019, but there was a new version released last month that I think should fix it. 2022-02-22 02:19:17 -05:00
Nathan Braswell
58f3d7858e Rework the destructuring lambda in what I'm now calling the true-macro-style, so that helper functions don't close over the dynamic env and cause it to not partially evaluate away 2022-02-20 23:42:09 -05:00
Nathan Braswell
2874be3332 Fix the bug with de getting seperate dynamic envs, now unified but no opts for now (doing it seperetly was broken because of tyring to access it from inner closures. Also add a lot more runtime logging 2022-02-20 22:12:21 -05:00
Nathan Braswell
7ce2db21ff Actually, make sure to always include it if there are other progress_idxs 2022-02-19 00:43:27 -05:00
Nathan Braswell
6cd9dd0831 Move over much more code, including the tricky destructuring lambda which revealed bug in the need_for_progress system - a call that takes in the dynamic env that failed and had to be re-constructed would set attempted on the call to true, but would not note the dynamic environment as one of the needed-for-progress idxs. Often I think it would be anyway, so this didn't come up too often, and of course finally revealed itself when doing nested let/lambda destructuring stuff. Fixed by having attempted record not just true or false, but in the case where it's a call that takes in the dynamic env, makes it that env's id, which gets added to the for_progress_idxs. 2022-02-19 00:14:36 -05:00
Nathan Braswell
dd2191f75d Made vapply and lapply primitives for efficiency/partial eval reasons. It means they can exist in emitted code without calling out to eval, which is good. to_compile.kp now both compiles and runs! Now to add more 2022-02-15 23:16:27 -05:00
Nathan Braswell
fd37fa9b00 Had missed handling the empty call case () as an error in compile, which will happen when specutively compiling as code a nil that should be passed unevaluated, etc 2022-02-12 12:10:08 -05:00
Nathan Braswell
d5ea55fa08 And we're compiling again! Smaller tests seem to work, including compiling and running a minor factorial (not Y comb). to_compile.kp errors out with a weird nil coming from somewhere, that will be have to be investigated tomorrow. 2022-02-12 02:05:45 -05:00
Nathan Braswell
bd00933763 Fixup cond to partially eval as much as it can without incuring infinate recursion! 2022-02-11 02:21:18 -05:00
Nathan Braswell
69fd587989 Fixed the Y combiner not partial evaluating as far as it should thing by adding infinite-recursion-blocking-hash-tracking to the needed_for_progress infrustracture. Only arrays need to track it, since at function boundries you won't want to reevaluate it anyway until the function is called. Having a hash from the IRBHT be not in your memo counts as a #t true need to re-partial eval. 2022-02-10 01:15:02 -05:00
Nathan Braswell
325afd773e Added partial_evaling to drop_redundent_veval (a bit hacky, have to pass partial_eval to it to break mutual recursion & had to add a 'force' option to partial_eval to force re-evaluation for situations where drop_rdundent_veval has changed something but the needed_for_progress wouldn't pick up on it.) This theme continues with the current problem with the Y combiner test, which is that recursion protection trips on the partial eval of the recursive application (x x) in the Y combiner, but it doesn't actually need any other external values, so when the time comes that it is actually needed as a value it skips it and ends up only evaluating a single level even for a value-only top level recursive invocation. Finally, still need to figure out a better situation for cond/vcond to partially evaluate itself without triggering even more infinate recursion (that's truely value-only, without a cond to stop it). 2022-02-09 22:49:06 -05:00
Nathan Braswell
6e18a66e3b Make drop_redundent_veval recursive, but realized we now need to re-partial eval in the cases where it does change. Added fail points with error messages for things I know I still need to do - veval is in a tricky space now because it *can't* have the main calling code re-evaluate it's parameters, but with the new prim comb works like regular change, it does. Maybe a negative evaluation level? 2022-02-09 01:11:13 -05:00
Nathan Braswell
5a67c704e0 Bugfixes and initial implementation for cond. Many tests passing now, though cond should further evaluate it's members without causing infinite recursion and drop_redundent_veval needs to be able to traverse for drops, since we allow returning whole function calls 2022-02-08 23:51:00 -05:00
Nathan Braswell
9daff0f482 Work in progress commit to make it so that anything unevaluated is already a value of the code that it is, which is the proper way to not have to ensure_unval which is fundamentally broken and causes mis-partial-evals. Refactor parameter evaluation and have prim combs mostly use that as well. Remaining is implementing cond properly and fixing bugs/typos 2022-02-08 02:48:40 -05:00