calysto-scheme 2.0.0__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/PKG-INFO +1 -1
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/modules/test_all.ss +82 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/scheme.py +4034 -3350
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme.egg-info/PKG-INFO +1 -1
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/ChangeLog.md +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/Development.md +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/LICENSE.txt +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/MANIFEST.in +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/Makefile +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/README.md +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/__init__.py +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/__main__.py +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/fib.py +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/images/logo-32x32.png +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/images/logo-512x512.png +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/images/logo-64x64.png +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/kernel.json +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/kernel.py +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/modules/equality_predicates.ss +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme/modules/sllgen.ss +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme.egg-info/SOURCES.txt +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme.egg-info/dependency_links.txt +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme.egg-info/requires.txt +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/calysto_scheme.egg-info/top_level.txt +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/requirements.txt +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/scripts/calysto-scheme +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/scripts/calysto-scheme-debug +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/setup.cfg +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/setup.py +0 -0
- {calysto_scheme-2.0.0 → calysto_scheme-2.0.2}/tests/test_all.py +0 -0
|
@@ -1308,5 +1308,87 @@
|
|
|
1308
1308
|
(rator lc-exp?)
|
|
1309
1309
|
(rand lc-exp?)))
|
|
1310
1310
|
|
|
1311
|
+
(define-tests jit-edge-cases
|
|
1312
|
+
;; Phase 4: tail-call flattening -- guards against RecursionError past
|
|
1313
|
+
;; ~4,900-5,000 iterations (fixed by flattening self-recursive tail calls
|
|
1314
|
+
;; in the JIT and Phase 2 direct-eval interpreter)
|
|
1315
|
+
(define (jit-count-loop n acc) (if (= n 0) acc (jit-count-loop (- n 1) (+ acc 1))))
|
|
1316
|
+
(assert equal?
|
|
1317
|
+
200000
|
|
1318
|
+
(jit-count-loop 200000 0)
|
|
1319
|
+
"case 53")
|
|
1320
|
+
|
|
1321
|
+
;; Phase 4: mutual tail recursion (each side's JIT compilation depends on
|
|
1322
|
+
;; the other, so both safely fall back to the flattened Phase 2 path)
|
|
1323
|
+
(define (jit-even? n) (if (= n 0) #t (jit-odd? (- n 1))))
|
|
1324
|
+
(define (jit-odd? n) (if (= n 0) #f (jit-even? (- n 1))))
|
|
1325
|
+
(assert equal?
|
|
1326
|
+
#t
|
|
1327
|
+
(jit-even? 50000)
|
|
1328
|
+
"case 54")
|
|
1329
|
+
|
|
1330
|
+
;; Phase 5: closures over a function's own parameter, called repeatedly
|
|
1331
|
+
;; so make-adder gets a chance to JIT-compile -- and each closure keeps
|
|
1332
|
+
;; independent captured state
|
|
1333
|
+
(define (jit-make-adder k) (lambda (x) (+ x k)))
|
|
1334
|
+
(define (jit-adder-driver n acc)
|
|
1335
|
+
(if (= n 0) acc (jit-adder-driver (- n 1) (+ acc ((jit-make-adder n) 0)))))
|
|
1336
|
+
(assert equal?
|
|
1337
|
+
5050
|
|
1338
|
+
(jit-adder-driver 100 0)
|
|
1339
|
+
"case 55")
|
|
1340
|
+
(define jit-add5 (jit-make-adder 5))
|
|
1341
|
+
(define jit-add10 (jit-make-adder 10))
|
|
1342
|
+
(assert equal?
|
|
1343
|
+
(list 15 20 6)
|
|
1344
|
+
(list (jit-add5 10) (jit-add10 10) (jit-add5 1))
|
|
1345
|
+
"case 56")
|
|
1346
|
+
|
|
1347
|
+
;; Phase 5: nested closures -- the innermost lambda captures a variable
|
|
1348
|
+
;; two lexical levels out, not just its immediately enclosing frame
|
|
1349
|
+
(define (jit-make-adder2 a) (lambda (b) (lambda (c) (+ a b c))))
|
|
1350
|
+
(define (jit-adder2-driver n acc)
|
|
1351
|
+
(if (= n 0) acc (jit-adder2-driver (- n 1) (+ acc (((jit-make-adder2 n) 2) 3)))))
|
|
1352
|
+
(assert equal?
|
|
1353
|
+
5550
|
|
1354
|
+
(jit-adder2-driver 100 0)
|
|
1355
|
+
"case 57")
|
|
1356
|
+
|
|
1357
|
+
;; Phase 5: immediately-invoked lambda under JIT, e.g. ((lambda (x) ...) e)
|
|
1358
|
+
;; -- regression test for the "'tuple' object is not callable" bug caused
|
|
1359
|
+
;; by let/or/and desugaring to this shape
|
|
1360
|
+
(define (jit-iife k) ((lambda (x) (+ x k)) 100))
|
|
1361
|
+
(define (jit-run-iife n acc) (if (= n 0) acc (jit-run-iife (- n 1) (+ acc (jit-iife n)))))
|
|
1362
|
+
(assert equal?
|
|
1363
|
+
15050
|
|
1364
|
+
(jit-run-iife 100 0)
|
|
1365
|
+
"case 58")
|
|
1366
|
+
|
|
1367
|
+
;; Phase 6: a parameter used in operator position, called with a closure
|
|
1368
|
+
(define (jit-apply-twice f x) (f (f x)))
|
|
1369
|
+
(define (jit-apply-twice-driver n acc)
|
|
1370
|
+
(if (= n 0) acc (jit-apply-twice-driver (- n 1) (+ acc (jit-apply-twice (jit-make-adder 3) n)))))
|
|
1371
|
+
(assert equal?
|
|
1372
|
+
5650
|
|
1373
|
+
(jit-apply-twice-driver 100 0)
|
|
1374
|
+
"case 59")
|
|
1375
|
+
|
|
1376
|
+
;; Phase 6: a parameter used in operator position, called with a
|
|
1377
|
+
;; first-class primitive
|
|
1378
|
+
(define (jit-call-with f a b) (f a b))
|
|
1379
|
+
(define (jit-run-prim n acc) (if (= n 0) acc (jit-run-prim (- n 1) (+ acc (if (jit-call-with < n 999999) 1 0)))))
|
|
1380
|
+
(assert equal?
|
|
1381
|
+
100
|
|
1382
|
+
(jit-run-prim 100 0)
|
|
1383
|
+
"case 60")
|
|
1384
|
+
|
|
1385
|
+
;; Phase 6: a parameter used in operator position, called with a captured
|
|
1386
|
+
;; continuation from call/cc
|
|
1387
|
+
(define (jit-call-it f x) (f x))
|
|
1388
|
+
(assert equal?
|
|
1389
|
+
43
|
|
1390
|
+
(+ 1 (call/cc (lambda (k) (jit-call-it k 42) 999)))
|
|
1391
|
+
"case 61")
|
|
1392
|
+
)
|
|
1311
1393
|
|
|
1312
1394
|
(run-tests)
|