trying to fix benchmark for list-length, which is failing badly
This commit is contained in:
parent
e6877c3e19
commit
6d035504af
|
@ -525,13 +525,13 @@
|
||||||
(: compile-branch (Branch CompileTimeEnvironment Target Linkage -> InstructionSequence))
|
(: compile-branch (Branch CompileTimeEnvironment Target Linkage -> InstructionSequence))
|
||||||
;; Compiles a conditional branch.
|
;; Compiles a conditional branch.
|
||||||
(define (compile-branch exp cenv target linkage)
|
(define (compile-branch exp cenv target linkage)
|
||||||
(let: ([f-branch : Symbol (make-label 'falseBranch)]
|
(let: ([f-branch: : Symbol (make-label 'falseBranch)]
|
||||||
[after-if : Symbol (make-label 'afterIf)])
|
[after-if: : Symbol (make-label 'afterIf)])
|
||||||
(let ([consequent-linkage
|
(let ([consequent-linkage
|
||||||
(cond
|
(cond
|
||||||
[(NextLinkage? linkage)
|
[(NextLinkage? linkage)
|
||||||
(let ([context (NextLinkage-context linkage)])
|
(let ([context (NextLinkage-context linkage)])
|
||||||
(make-LabelLinkage after-if context))]
|
(make-LabelLinkage after-if: context))]
|
||||||
[(ReturnLinkage? linkage)
|
[(ReturnLinkage? linkage)
|
||||||
linkage]
|
linkage]
|
||||||
[(LabelLinkage? linkage)
|
[(LabelLinkage? linkage)
|
||||||
|
@ -542,11 +542,12 @@
|
||||||
(append-instruction-sequences
|
(append-instruction-sequences
|
||||||
p-code
|
p-code
|
||||||
(make-TestAndJumpStatement (make-TestFalse (make-Reg 'val))
|
(make-TestAndJumpStatement (make-TestFalse (make-Reg 'val))
|
||||||
f-branch)
|
f-branch:)
|
||||||
c-code
|
c-code
|
||||||
f-branch
|
f-branch: a-code
|
||||||
a-code
|
(if (NextLinkage? linkage)
|
||||||
after-if)))))
|
after-if:
|
||||||
|
empty-instruction-sequence))))))
|
||||||
|
|
||||||
|
|
||||||
(: compile-sequence ((Listof Expression) CompileTimeEnvironment Target Linkage -> InstructionSequence))
|
(: compile-sequence ((Listof Expression) CompileTimeEnvironment Target Linkage -> InstructionSequence))
|
||||||
|
|
11
examples/list-length.rkt
Normal file
11
examples/list-length.rkt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#lang planet dyoo/whalesong
|
||||||
|
|
||||||
|
(define (mylen x)
|
||||||
|
(cond
|
||||||
|
[(empty? x)
|
||||||
|
0]
|
||||||
|
[else
|
||||||
|
(add1 (mylen (rest x)))]))
|
||||||
|
"computing length"
|
||||||
|
(mylen (build-list 100000 (lambda (i) i)))
|
||||||
|
"done computing length"
|
|
@ -30,7 +30,8 @@
|
||||||
assemble-location
|
assemble-location
|
||||||
assemble-numeric-constant
|
assemble-numeric-constant
|
||||||
|
|
||||||
block-looks-like-context-expected-values?)
|
block-looks-like-context-expected-values?
|
||||||
|
block-looks-like-pop-multiple-values-and-continue?)
|
||||||
|
|
||||||
(require/typed typed/racket/base
|
(require/typed typed/racket/base
|
||||||
[regexp-split (Regexp String -> (Listof String))])
|
[regexp-split (Regexp String -> (Listof String))])
|
||||||
|
@ -429,6 +430,13 @@
|
||||||
#f]))
|
#f]))
|
||||||
|
|
||||||
|
|
||||||
|
(: block-looks-like-pop-multiple-values-and-continue? (BasicBlock -> (U False)))
|
||||||
|
(define (block-looks-like-pop-multiple-values-and-continue? a-block)
|
||||||
|
;; FIXME!
|
||||||
|
#f)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,13 @@ EOF
|
||||||
(munge-label-name (make-Label (BasicBlock-name a-basic-block)))
|
(munge-label-name (make-Label (BasicBlock-name a-basic-block)))
|
||||||
expected)
|
expected)
|
||||||
'ok]))]
|
'ok]))]
|
||||||
|
|
||||||
|
[(block-looks-like-pop-multiple-values-and-continue? a-basic-block)
|
||||||
|
=>
|
||||||
|
(lambda (target)
|
||||||
|
(fprintf op "~a=RT.si_pop_multiple-values-and-continue(~a);"
|
||||||
|
(munge-label-name (make-Label (BasicBlock-name a-basic-block)))
|
||||||
|
target))]
|
||||||
[else
|
[else
|
||||||
(default-assemble-basic-block a-basic-block blockht entry-points function-entry-and-exit-names op)]))
|
(default-assemble-basic-block a-basic-block blockht entry-points function-entry-and-exit-names op)]))
|
||||||
|
|
||||||
|
|
|
@ -263,10 +263,16 @@
|
||||||
var isList = function (x) {
|
var isList = function (x) {
|
||||||
var tortoise, hare;
|
var tortoise, hare;
|
||||||
tortoise = hare = x;
|
tortoise = hare = x;
|
||||||
if (hare === EMPTY) { return true; }
|
if (hare === EMPTY) {
|
||||||
|
tortoise._isList = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!(hare instanceof Cons)) { return false; }
|
if (!(hare instanceof Cons)) { return false; }
|
||||||
if (tortoise instanceof Cons) { tortoise = tortoise.rest; }
|
if (tortoise instanceof Cons) {
|
||||||
|
if (tortoise._isList === true) { return true; }
|
||||||
|
tortoise = tortoise.rest;
|
||||||
|
}
|
||||||
hare = hare.rest;
|
hare = hare.rest;
|
||||||
if (hare instanceof Cons) { hare = hare.rest; }
|
if (hare instanceof Cons) { hare = hare.rest; }
|
||||||
if (hare === EMPTY) { return true; }
|
if (hare === EMPTY) { return true; }
|
||||||
|
|
|
@ -790,10 +790,16 @@
|
||||||
};
|
};
|
||||||
var si_context_expected_1 = function(M) { raiseContextExpectedValuesError(M, 1); }
|
var si_context_expected_1 = function(M) { raiseContextExpectedValuesError(M, 1); }
|
||||||
|
|
||||||
|
// A block that omits the multiple values returned on the stack and
|
||||||
|
// continues on with the target function f.
|
||||||
|
var si_pop_multiple_values_and_continue = function(target) {
|
||||||
|
var f = function(M) {
|
||||||
|
if(--M.cbt<0) { throw f; }
|
||||||
|
M.e.length -= (M.a-1);
|
||||||
|
return target(M);
|
||||||
|
};
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
(provide version)
|
(provide version)
|
||||||
(: version String)
|
(: version String)
|
||||||
|
|
||||||
(define version "1.113")
|
(define version "1.114")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user