Commit Graph

1078 Commits

Author SHA1 Message Date
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
Nathan Braswell
931dd9a8f5 Implement drop_redundent_veval and make veval properly re-partially-eval and update the env it's called with. Y combiner test added and works now, map still seems not to, about to look at it 2022-02-07 00:31:51 -05:00
Nathan Braswell
31a8002a11 Finally excise what I belive to be the final exponential behavior, namely by adding memoization and better traversals to check_for_env_id_in_result 2022-02-06 16:34:47 -05:00
Nathan Braswell
76065d1957 Implement veval and combiner_return_ok enhancements, now let4.3 behaves like the proper macro expansion. Compiling our test doesn't work though, it doesn't partial evalaute the vaus away as expected - changing let1 implementations does have an effect. Will need to investigate, as well as add support for compiling away veval 2022-02-05 12:14:13 -05:00
Nathan Braswell
7310eeaee3 Fix up inverted condition on combiner_return_ok, fix regression on error checking for parameters in calls. Hopfully proper now, just needs better combiner_return_ok (both memo and allowing further partial eval) and allowing-further-partial-eval for eval 2022-02-04 01:28:18 -05:00
Nathan Braswell
a8f8f9df89 Removed check_for_symbols, which was a bad idea generally. Simplify into combiner_return_ok, and fix *eval bug* - it didn't check for any sort of combiner_return_ok like thing, even though it's doing the same thing as a function call basically, by changing the env something is evaluated in.
Also just re-write eval using the parital_eval wrapper, enforce it taking in total-values.

In the future, can allow more partial eval
        1) veval, returned from eval and posssibly others, essentailly (unwrap eval), which allows embedding partially-complete evals places without having to do something ugly like (eval (ensure_val partially_evaluated))
        2) Relax paramter is total-value to head-value and check for env_id inside it

Immediatly: Debug bad partial evaluation on main test cases & crash with list index out of range
2022-02-03 02:41:14 -05:00
Nathan Braswell
dd28087818 Some more updates based on feedback 2022-02-02 01:41:19 -05:00
Nathan Braswell
6f3d8d514b Added quote example 2022-02-01 00:50:36 -05:00
Nathan Braswell
c05a7bd2d5 More slides work, expanding examples, proof reading, adding explanation 2022-01-31 23:42:27 -05:00
Nathan Braswell
2f395926d3 Fix 2022-01-31 18:35:14 -05:00
Nathan Braswell
3086ad4b01 First draft of presentation 2022-01-31 00:08:37 -05:00
Nathan Braswell
df76ae51e2 Start to fill in Abstract/Introduction/Related Work/Issues/Solution 2022-01-30 20:20:16 -05:00
Nathan Braswell
7f220c97b8 Finally make a clean sweep and delete / organize old files. Add skeleton for LaTeX formal writeup in doc/ and change license (since this is all new code from the past few years) to BSD-2-Clause-Patent 2022-01-30 16:57:21 -05:00