]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 18 Mar 2009 15:39:05 +0000 (08:39 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 18 Mar 2009 15:39:05 +0000 (08:39 -0700)
113 files changed:
basis/alien/c-types/c-types.factor
basis/bootstrap/image/image.factor
basis/bootstrap/stage2.factor
basis/call/authors.txt [deleted file]
basis/call/call-docs.factor [deleted file]
basis/call/call-tests.factor [deleted file]
basis/call/call.factor [deleted file]
basis/call/summary.txt [deleted file]
basis/call/tags.txt [deleted file]
basis/cocoa/messages/messages.factor
basis/cocoa/subclassing/subclassing.factor
basis/command-line/command-line.factor
basis/compiler/codegen/codegen.factor
basis/compiler/compiler.factor
basis/compiler/constants/constants.factor
basis/compiler/tree/propagation/inlining/inlining.factor
basis/core-foundation/fsevents/fsevents.factor
basis/debugger/debugger.factor
basis/editors/editors.factor
basis/eval/eval.factor
basis/functors/functors.factor
basis/furnace/actions/actions.factor
basis/furnace/boilerplate/boilerplate.factor
basis/furnace/referrer/referrer.factor
basis/help/help.factor
basis/help/lint/lint.factor
basis/help/markup/markup.factor
basis/html/forms/forms.factor
basis/html/templates/chloe/chloe.factor
basis/html/templates/chloe/compiler/compiler.factor
basis/html/templates/fhtml/fhtml.factor
basis/html/templates/templates.factor
basis/http/server/static/static.factor
basis/inverse/inverse.factor
basis/io/pipes/pipes.factor
basis/io/servers/connection/connection.factor
basis/listener/listener.factor
basis/lists/lazy/lazy.factor
basis/models/arrow/arrow.factor
basis/peg/ebnf/ebnf.factor
basis/peg/peg.factor
basis/regexp/regexp.factor
basis/stack-checker/call-effect/authors.txt [new file with mode: 0644]
basis/stack-checker/call-effect/call-effect-tests.factor [new file with mode: 0644]
basis/stack-checker/call-effect/call-effect.factor [new file with mode: 0644]
basis/stack-checker/known-words/known-words.factor
basis/stack-checker/stack-checker.factor
basis/stack-checker/transforms/authors.txt
basis/stack-checker/transforms/transforms-tests.factor
basis/stack-checker/transforms/transforms.factor
basis/threads/threads.factor
basis/tools/annotations/annotations.factor
basis/tools/deploy/deploy-docs.factor
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/shaker/strip-call.factor
basis/tools/deploy/test/12/12.factor
basis/tools/test/test.factor
basis/tools/vocabs/browser/browser.factor
basis/tools/walker/walker.factor
basis/tr/tr.factor
basis/ui/backend/cocoa/cocoa.factor
basis/ui/commands/commands.factor
basis/ui/gadgets/buttons/buttons.factor
basis/ui/gadgets/editors/editors.factor
basis/ui/gadgets/panes/panes.factor
basis/ui/gadgets/worlds/worlds.factor
basis/ui/gestures/gestures.factor
basis/ui/operations/operations.factor
basis/ui/tools/walker/walker.factor
basis/ui/ui.factor
basis/wrap/wrap.factor
basis/xmode/loader/syntax/syntax.factor
core/bootstrap/primitives.factor
core/bootstrap/syntax.factor
core/classes/predicate/predicate-tests.factor
core/classes/predicate/predicate.factor
core/classes/tuple/parser/parser.factor
core/combinators/authors.txt
core/combinators/combinators-docs.factor
core/combinators/combinators-tests.factor
core/combinators/combinators.factor
core/continuations/continuations-docs.factor
core/continuations/continuations.factor
core/effects/effects.factor
core/effects/parser/parser.factor
core/generic/parser/parser.factor
core/init/init.factor
core/io/backend/backend.factor
core/kernel/kernel.factor
core/parser/parser-tests.factor
core/parser/parser.factor
core/strings/parser/parser.factor
core/syntax/syntax-docs.factor
core/syntax/syntax.factor
core/vocabs/loader/loader.factor
core/vocabs/vocabs.factor
core/words/words.factor
extra/4DNav/4DNav.factor
extra/monads/monads-tests.factor
extra/monads/monads.factor
extra/promises/promises.factor
extra/ui/gadgets/lists/lists.factor
vm/callstack.h
vm/cpu-x86.32.S
vm/cpu-x86.64.S
vm/errors.c
vm/errors.h
vm/layouts.h
vm/primitives.c
vm/quotations.c
vm/run.c
vm/run.h

index c3fd41e68973ee64545218b49d216003782c5dba..dc35f8bbb05fb94f0345c512c0907241df5f1721 100755 (executable)
@@ -4,7 +4,7 @@ USING: byte-arrays arrays assocs kernel kernel.private libc math
 namespaces make parser sequences strings words assocs splitting
 math.parser cpu.architecture alien alien.accessors quotations
 layouts system compiler.units io.files io.encodings.binary
-accessors combinators effects continuations fry call classes ;
+accessors combinators effects continuations fry classes ;
 IN: alien.c-types
 
 DEFER: <int>
index aeedef39bdc7e2b5e391ea52e404d095b13fbc9e..a2621f4c32500d7b8b468d8f6a84f3cbf393a362 100644 (file)
@@ -446,6 +446,8 @@ M: quotation '
         quotation type-number object tag-number [
             emit ! array
             f ' emit ! compiled
+            f ' emit ! cached-effect
+            f ' emit ! cache-counter
             0 emit ! xt
             0 emit ! code
         ] emit-object
index 070618ebb487eaa39c9266aaa71d21d19b393af6..6c824b6155745e7b1cdac3be454ae76a128c896d 100644 (file)
@@ -30,7 +30,7 @@ SYMBOL: bootstrap-time
     [ "bootstrap." prepend require ] each ;
 
 : count-words ( pred -- )
-    all-words swap count number>string write ;
+    all-words swap count number>string write ; inline
 
 : print-time ( ms -- )
     1000 /i
diff --git a/basis/call/authors.txt b/basis/call/authors.txt
deleted file mode 100644 (file)
index 33616a2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Daniel Ehrenberg
-Slava Pestov
diff --git a/basis/call/call-docs.factor b/basis/call/call-docs.factor
deleted file mode 100644 (file)
index 5f76f53..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-! Copyright (C) 2009 Daniel Ehrenberg.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax quotations effects words call.private ;
-IN: call
-
-ABOUT: "call"
-
-ARTICLE: "call" "Calling code with known stack effects"
-"The " { $vocab-link "call" } " vocabulary allows for arbitrary quotations to be called from code accepted by the optimizing compiler. This is done by specifying the stack effect of the quotation literally. It is checked at runtime that the stack effect is accurate."
-$nl
-"Quotations:"
-{ $subsection POSTPONE: call( }
-{ $subsection call-effect }
-"Words:"
-{ $subsection POSTPONE: execute( }
-{ $subsection execute-effect }
-"Unsafe calls:"
-{ $subsection POSTPONE: execute-unsafe( }
-{ $subsection execute-effect-unsafe } ;
-
-HELP: call(
-{ $syntax "call( stack -- effect )" }
-{ $description "Calls the quotation on the top of the stack, asserting that it has the given stack effect. The quotation does not need to be known at compile time." } ;
-
-HELP: call-effect
-{ $values { "quot" quotation } { "effect" effect } }
-{ $description "Given a quotation and a stack effect, calls the quotation, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary quotation which is not required at compile time." } ;
-
-HELP: execute(
-{ $syntax "execute( stack -- effect )" }
-{ $description "Calls the word on the top of the stack, asserting that it has the given stack effect. The word does not need to be known at compile time." } ;
-
-HELP: execute-effect
-{ $values { "word" word } { "effect" effect } }
-{ $description "Given a word and a stack effect, executes the word, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary word which is not required at compile time." } ;
-
-HELP: execute-unsafe(
-{ $syntax "execute-unsafe( stack -- effect )" }
-{ $description "Calls the word on the top of the stack, blindly declaring that it has the given stack effect. The word does not need to be known at compile time." }
-{ $warning "If the word being executed has an incorrect stack effect, undefined behavior will result. User code should use " { $link POSTPONE: execute( } " instead." } ;
-HELP: execute-effect-unsafe
-{ $values { "word" word } { "effect" effect } }
-{ $description "Given a word and a stack effect, executes the word, blindly declaring at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary word which is not required at compile time." }
-{ $warning "If the word being executed has an incorrect stack effect, undefined behavior will result. User code should use " { $link execute-effect-unsafe } " instead." } ;
-    
-{ call-effect execute-effect execute-effect-unsafe } related-words
-{ POSTPONE: call( POSTPONE: execute( POSTPONE: execute-unsafe( } related-words
\ No newline at end of file
diff --git a/basis/call/call-tests.factor b/basis/call/call-tests.factor
deleted file mode 100644 (file)
index 4e45c3c..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-! Copyright (C) 2009 Daniel Ehrenberg.
-! See http://factorcode.org/license.txt for BSD license.
-USING: math tools.test call call.private kernel accessors ;
-IN: call.tests
-
-[ 3 ] [ 1 2 [ + ] call( x y -- z ) ] unit-test
-[ 1 2 [ + ] call( -- z ) ] must-fail
-[ 1 2 [ + ] call( x y -- z a ) ] must-fail
-[ 1 2 3 { 4 } ] [ 1 2 3 4 [ datastack nip ] call( x -- y ) ] unit-test
-[ [ + ] call( x y -- z ) ] must-infer
-
-[ 3 ] [ 1 2 \ + execute( x y -- z ) ] unit-test
-[ 1 2 \ + execute( -- z ) ] must-fail
-[ 1 2 \ + execute( x y -- z a ) ] must-fail
-[ \ + execute( x y -- z ) ] must-infer
-
-: compile-execute(-test-1 ( a b -- c ) \ + execute( a b -- c ) ;
-
-[ t ] [ \ compile-execute(-test-1 optimized>> ] unit-test
-[ 4 ] [ 1 3 compile-execute(-test-1 ] unit-test
-
-: compile-execute(-test-2 ( a b w -- c ) execute( a b -- c ) ;
-
-[ t ] [ \ compile-execute(-test-2 optimized>> ] unit-test
-[ 4 ] [ 1 3 \ + compile-execute(-test-2 ] unit-test
-[ 5 ] [ 1 4 \ + compile-execute(-test-2 ] unit-test
-[ -3 ] [ 1 4 \ - compile-execute(-test-2 ] unit-test
-[ 5 ] [ 1 4 \ + compile-execute(-test-2 ] unit-test
-
-[ t ] [ \ + (( a b -- c )) execute-effect-unsafe? ] unit-test
-[ t ] [ \ + (( a b c -- d e )) execute-effect-unsafe? ] unit-test
-[ f ] [ \ + (( a b c -- d )) execute-effect-unsafe? ] unit-test
-[ f ] [ \ call (( x -- )) execute-effect-unsafe? ] unit-test
diff --git a/basis/call/call.factor b/basis/call/call.factor
deleted file mode 100644 (file)
index 0c1b5bb..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-! Copyright (C) 2009 Daniel Ehrenberg, Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel macros fry summary sequences sequences.private
-generalizations accessors continuations effects effects.parser
-parser words ;
-IN: call
-
-ERROR: wrong-values values quot length-required ;
-
-M: wrong-values summary
-    drop "Wrong number of values returned from quotation" ;
-
-<PRIVATE
-
-: firstn-safe ( array quot n -- ... )
-    3dup nip swap length = [ nip firstn ] [ wrong-values ] if ; inline
-
-: parse-call( ( accum word -- accum )
-    [ ")" parse-effect parsed ] dip parsed ;
-
-PRIVATE>
-
-MACRO: call-effect ( effect -- quot )
-    [ in>> length ] [ out>> length ] bi
-    '[ [ _ narray ] dip [ with-datastack ] keep _ firstn-safe ] ;
-
-: call( \ call-effect parse-call( ; parsing
-
-<PRIVATE
-
-: execute-effect-unsafe ( word effect -- )
-    drop execute ;
-
-: execute-unsafe( \ execute-effect-unsafe parse-call( ; parsing
-
-: execute-effect-slow ( word effect -- )
-    [ [ execute ] curry ] dip call-effect ; inline
-
-: cache-hit? ( word ic -- ? ) first-unsafe eq? ; inline
-
-: cache-hit ( word effect ic -- ) drop execute-effect-unsafe ; inline
-
-: execute-effect-unsafe? ( word effect -- ? )
-    over optimized>> [ [ stack-effect ] dip effect<= ] [ 2drop f ] if ; inline
-
-: cache-miss ( word effect ic -- )
-    [ 2dup execute-effect-unsafe? ] dip
-    '[ [ drop _ set-first ] [ execute-effect-unsafe ] 2bi ]
-    [ execute-effect-slow ] if ; inline
-
-: execute-effect-ic ( word effect ic -- )
-    #! ic is a mutable cell { effect }
-    3dup nip cache-hit? [ cache-hit ] [ cache-miss ] if ; inline
-
-PRIVATE>
-
-MACRO: execute-effect ( effect -- )
-    { f } clone '[ _ _ execute-effect-ic ] ;
-
-: execute( \ execute-effect parse-call( ; parsing
diff --git a/basis/call/summary.txt b/basis/call/summary.txt
deleted file mode 100644 (file)
index d449497..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Calling arbitrary quotations and executing arbitrary words with a static stack effect
diff --git a/basis/call/tags.txt b/basis/call/tags.txt
deleted file mode 100644 (file)
index f427429..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extensions
index 8818c9a217a6f241231db53ba6d05555cc148863..f71b9f3f56a7f6987f36421caead7c646010699e 100644 (file)
@@ -5,7 +5,7 @@ continuations combinators compiler compiler.alien stack-checker kernel
 math namespaces make parser quotations sequences strings words
 cocoa.runtime io macros memoize io.encodings.utf8 effects libc
 libc.private parser lexer init core-foundation fry generalizations
-specialized-arrays.direct.alien call ;
+specialized-arrays.direct.alien ;
 IN: cocoa.messages
 
 : make-sender ( method function -- quot )
index 394f45bef39fdfd25082233118e2045c85acf5be..c3f1b471e0a72dcfbb4b352cba8ba99aa12d21c2 100644 (file)
@@ -8,7 +8,7 @@ IN: cocoa.subclassing
 
 : init-method ( method -- sel imp types )
     first3 swap
-    [ sel_registerName ] [ execute ] [ utf8 string>alien ]
+    [ sel_registerName ] [ execute( -- xt ) ] [ utf8 string>alien ]
     tri* ;
 
 : throw-if-false ( obj what -- )
index 38d40d84828b0055873718a7c3be9221e151d3c1..73a01aa352a7640fae860fb429a51243ed602caf 100644 (file)
@@ -54,7 +54,7 @@ SYMBOL: main-vocab-hook
     embedded? [
         "alien.remote-control"
     ] [
-        main-vocab-hook get [ call ] [ "listener" ] if*
+        main-vocab-hook get [ call( -- vocab ) ] [ "listener" ] if*
     ] if ;
 
 : default-cli-args ( -- )
index d915b29ae56834b020c246983bb6b8831e6508ca..40b1f56f8b121eca5e6eebb445600cb079666e97 100755 (executable)
@@ -464,7 +464,7 @@ TUPLE: callback-context ;
     dup current-callback eq? [
         drop
     ] [
-        yield-hook get call wait-to-return
+        yield-hook get call( -- ) wait-to-return
     ] if ;
 
 : do-callback ( quot token -- )
index 349d50fe353bef20ccc2631ccba8a36407f37c87..c8e1e5fd0f49fa37fc2d6598c91e0652664d75a2 100644 (file)
@@ -111,7 +111,7 @@ t compile-dependencies? set-global
     ] with-return ;
 
 : compile-loop ( deque -- )
-    [ (compile) yield-hook get assert-depth ] slurp-deque ;
+    [ (compile) yield-hook get call( -- ) ] slurp-deque ;
 
 : decompile ( word -- )
     f 2array 1array modify-code-heap ;
index e03c062e9e0249ad6485fbf21e94a92bd67309bc..f82b6d479f1bfc46c2fc002e6468723831f6a00e 100644 (file)
@@ -20,7 +20,7 @@ CONSTANT: deck-bits 18
 : tuple-class-offset ( -- n ) bootstrap-cell tuple tag-number - ; inline
 : class-hash-offset ( -- n ) bootstrap-cell object tag-number - ; inline
 : word-xt-offset ( -- n ) 9 bootstrap-cells object tag-number - ; inline
-: quot-xt-offset ( -- n ) 3 bootstrap-cells object tag-number - ; inline
+: quot-xt-offset ( -- n ) 5 bootstrap-cells object tag-number - ; inline
 : word-code-offset ( -- n ) 10 bootstrap-cells object tag-number - ; inline
 : array-start-offset ( -- n ) 2 bootstrap-cells object tag-number - ; inline
 : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline
index 953956c3bd20b738be8a6e685f28e2c42e1d21f0..f18cfcd3a3aad1e48c56ddd3d12a4c0cf5798fb5 100755 (executable)
@@ -1,6 +1,6 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel arrays sequences math math.order call
+USING: accessors kernel arrays sequences math math.order
 math.partial-dispatch generic generic.standard generic.math
 classes.algebra classes.union sets quotations assocs combinators
 words namespaces continuations classes fry combinators.smart
index 06b9c6407bddf3647bc802296d132a6e3e76e76b..46f6639ab8f4b6b57693659944b1ec591dc9c092 100644 (file)
@@ -167,7 +167,7 @@ SYMBOL: event-stream-callbacks
     eventFlags numEvents <direct-int-array>
     eventIds numEvents <direct-longlong-array>
     3array flip
-    info event-stream-callbacks get at [ drop ] or call ;
+    info event-stream-callbacks get at [ drop ] or call( changes -- ) ;
 
 : master-event-source-callback ( -- alien )
     "void"
index 627fd953843f1e361ce3a874da3dc20e3c085a40..efd35ab2803055b47556bbf552bc73c1e7d991c9 100644 (file)
@@ -325,3 +325,5 @@ M: bad-literal-tuple summary drop "Bad literal tuple" ;
 M: check-mixin-class summary drop "Not a mixin class" ;
 
 M: not-found-in-roots summary drop "Cannot resolve vocab: path" ;
+
+M: wrong-values summary drop "Quotation called with wrong stack effect" ;
\ No newline at end of file
index d060a3dfe67450042c47370bcb433cbc09fcc052..0003b508fb2c6903aad9e5532e3a2777d1d98bab 100644 (file)
@@ -28,7 +28,7 @@ SYMBOL: edit-hook
 
 : edit-location ( file line -- )
     [ (normalize-path) ] dip edit-hook get-global
-    [ call ] [ no-edit-hook edit-location ] if* ;
+    [ call( file line -- ) ] [ no-edit-hook edit-location ] if* ;
 
 ERROR: cannot-find-source definition ;
 
index dfa9baf418d2806859f2388e3eb717f2df36ea0c..3672337a584d0f17f8860a816246f6ef87d93348 100644 (file)
@@ -4,7 +4,7 @@ USING: splitting parser compiler.units kernel namespaces
 debugger io.streams.string fry ;
 IN: eval
 
-: parse-string ( str -- )
+: parse-string ( str -- quot )
     [ string-lines parse-lines ] with-compilation-unit ;
 
 : (eval) ( str -- )
index 6592a3c4f241fe938a135067b8b80d882276d47d..caa41d6c2962a0e651bc70792363fe136c81ee6c 100644 (file)
@@ -36,7 +36,7 @@ M: array fake-quotations> [ fake-quotations> ] map ;
 
 M: object fake-quotations> ;
 
-: parse-definition* ( -- )
+: parse-definition* ( accum -- accum )
     parse-definition >fake-quotations parsed \ fake-quotations> parsed ;
 
 : DEFINE* ( accum -- accum ) effect get parsed \ define* parsed ;
index b0814db4dd93efc34fdf68d58e814d25759d72aa..a582755dc4e6cce6802f81477139acb081ca4a8e 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: accessors sequences kernel assocs combinators\r
 validators http hashtables namespaces fry continuations locals\r
-io arrays math boxes splitting urls call\r
+io arrays math boxes splitting urls\r
 xml.entities\r
 http.server\r
 http.server.responses\r
index 84b29bf831f1af0be6bdc1c480ebaab954663f77..b4bc574ae224e66bbfc30293ddb9351874b859c6 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2008, 2009 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel math.order namespaces combinators.short-circuit call
+USING: accessors kernel math.order namespaces combinators.short-circuit
 html.forms
 html.templates
 html.templates.chloe
index acd4563cd6f07179673d0adbf18b5bb4e7d0f860..0eb00bac2796f7c415b7881eef4ee9fed72fb67c 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel http.server http.server.filters
-http.server.responses furnace.utilities call ;
+http.server.responses furnace.utilities ;
 IN: furnace.referrer
 
 TUPLE: referrer-check < filter-responder quot ;
index 27a81f9948b1eb50ac1bf05c1cfef40dcdc649d4..6fa4473d970eed65355f5ec0909926230d7f8014 100644 (file)
@@ -5,7 +5,7 @@ parser prettyprint sequences words words.symbol assocs
 definitions generic quotations effects slots continuations
 classes.tuple debugger combinators vocabs help.stylesheet
 help.topics help.crossref help.markup sorting classes
-vocabs.loader call ;
+vocabs.loader ;
 IN: help
 
 GENERIC: word-help* ( word -- content )
@@ -140,7 +140,7 @@ help-hook [ [ print-topic ] ] initialize
     sort-articles [ \ $subsection swap 2array ] map print-element ;
 
 : $index ( element -- )
-    first call [ ($index) ] unless-empty ;
+    first call( -- seq ) [ ($index) ] unless-empty ;
 
 : $about ( element -- )
     first vocab-help [ 1array $subsection ] when* ;
index 2281c295c394429fa0a9d57e5253e28497e4037c..7ec8c59ba6be75f0442004aed6d285527f3db086 100755 (executable)
@@ -7,20 +7,20 @@ combinators combinators.short-circuit splitting debugger
 hashtables sorting effects vocabs vocabs.loader assocs editors
 continuations classes.predicate macros math sets eval
 vocabs.parser words.symbol values grouping unicode.categories
-sequences.deep call ;
+sequences.deep ;
 IN: help.lint
 
 SYMBOL: vocabs-quot
 
 : check-example ( element -- )
-    [
-        rest [
+    '[
+        rest [
             but-last "\n" join
             [ (eval>string) ] call( code -- output )
             "\n" ?tail drop
         ] keep
         peek assert=
-    ] vocabs-quot get call ;
+    ] vocabs-quot get call( quot -- ) ;
 
 : check-examples ( element -- )
     \ $example swap elements [ check-example ] each ;
index ea64def75194a6ab606baf947f447b5a4625d23e..8ea36d62fbb810d4c21bc1f2ff04773e9942b088 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors arrays definitions generic io kernel assocs
 hashtables namespaces make parser prettyprint sequences strings
 io.styles vectors words math sorting splitting classes slots fry
 sets vocabs help.stylesheet help.topics vocabs.loader quotations
-combinators call see ;
+combinators see ;
 IN: help.markup
 
 PREDICATE: simple-element < array
index 4cab87acfaa9bca720f7a7cc44fe85d567e00b6c..cc8b4f0a1595cc36566fae4b4dc08b5f2e1a5cd0 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors strings namespaces assocs hashtables io call
+USING: kernel accessors strings namespaces assocs hashtables io
 mirrors math fry sequences words continuations
 xml.entities xml.writer xml.syntax ;
 IN: html.forms
index da0d45a9d4f1489556896b4e093f11a54804ec31..1fe90b08d3d51f56afbd204214c2aa7809a61a9d 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors kernel sequences combinators kernel fry
 namespaces make classes.tuple assocs splitting words arrays io
 io.files io.files.info io.encodings.utf8 io.streams.string
 unicode.case mirrors math urls present multiline quotations xml
-logging call
+logging
 xml.data xml.writer xml.syntax strings
 html.forms
 html
index 3cb7523bdc204bf10acaf144b4c055308c4ba6fe..92e4a8dc494ea63d558f07cda1e4f4cc732e7653 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs namespaces make kernel sequences accessors
 combinators strings splitting io io.streams.string present
-xml.writer xml.data xml.entities html.forms call
+xml.writer xml.data xml.entities html.forms
 html.templates html.templates.chloe.syntax ;
 IN: html.templates.chloe.compiler
 
index 78202d6460ac96460ba53858dee3d1de90e0eff8..f3539f6a0fb826e8006650a3f1cd63a5b35f44f7 100644 (file)
@@ -3,7 +3,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: continuations sequences kernel namespaces debugger
 combinators math quotations generic strings splitting accessors
-assocs fry vocabs.parser parser lexer io io.files call
+assocs fry vocabs.parser parser lexer io io.files
 io.streams.string io.encodings.utf8 html.templates ;
 IN: html.templates.fhtml
 
@@ -65,7 +65,7 @@ DEFER: <% delimiter
     ] with-file-vocabs ;
 
 : eval-template ( string -- )
-    parse-template call ;
+    parse-template call( -- ) ;
 
 TUPLE: fhtml path ;
 
index fcb1b28b1ae271500b3304d32fdde3a9effce063..aebae701ed07d4a85c78f3d6c9d6413e0bd0ac73 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel fry io io.encodings.utf8 io.files
 debugger prettyprint continuations namespaces boxes sequences
-arrays strings html io.streams.string assocs call
+arrays strings html io.streams.string assocs
 quotations xml.data xml.writer xml.syntax ;
 IN: html.templates
 
index 13b9efc86d55bd16d54f11a86ded7491be5b190b..bbca70d84591dab79913dc8a0ebf68f107c69d9b 100644 (file)
@@ -6,7 +6,7 @@ sorting logging calendar.format accessors splitting io io.files
 io.files.info io.directories io.pathnames io.encodings.binary\r
 fry xml.entities destructors urls html xml.syntax\r
 html.templates.fhtml http http.server http.server.responses\r
-http.server.redirection xml.writer call ;\r
+http.server.redirection xml.writer ;\r
 IN: http.server.static\r
 \r
 TUPLE: file-responder root hook special allow-listings ;\r
index 9dc79e91b5a013376997467bfd08622bfc8785af..3a86703cafb1a49ffc12c2bb8ad09b66e17449b5 100755 (executable)
@@ -5,7 +5,7 @@ sequences assocs math arrays stack-checker effects generalizations
 continuations debugger classes.tuple namespaces make vectors
 bit-arrays byte-arrays strings sbufs math.functions macros
 sequences.private combinators mirrors splitting
-combinators.short-circuit fry words.symbol generalizations call ;
+combinators.short-circuit fry words.symbol generalizations ;
 RENAME: _ fry => __
 IN: inverse
 
index 9cadb3f6cc2b6df7eb3917e5f27b348b363b0617..c15663b0319c714e5ebaa09552b37d1f1a3a2f8c 100644 (file)
@@ -1,8 +1,8 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.encodings io.backend io.ports io.streams.duplex
 io splitting grouping sequences namespaces kernel
-destructors math concurrency.combinators accessors
+destructors math concurrency.combinators accessors fry
 arrays continuations quotations system vocabs.loader combinators ;
 IN: io.pipes
 
@@ -29,11 +29,12 @@ HOOK: (pipe) io-backend ( -- pipe )
 : ?writer ( handle/f -- stream )
     [ <output-port> &dispose ] [ output-stream get ] if* ;
 
-GENERIC: run-pipeline-element ( input-fd output-fd obj -- quot )
+GENERIC: run-pipeline-element ( input-fd output-fd obj -- result )
 
 M: callable run-pipeline-element
     [
-        [ [ ?reader ] [ ?writer ] bi* ] dip with-streams*
+        [ [ ?reader ] [ ?writer ] bi* ] dip
+        '[ _ call( -- result ) ] with-streams*
     ] with-destructors ;
 
 : <pipes> ( n -- pipes )
index 5a3233afa9471d1281fb34f5569f1c303223be7f..8eafe1b5bf24a6f0e63330f556f771ce2be4f64f 100644 (file)
@@ -7,7 +7,7 @@ fry accessors arrays io io.sockets io.encodings.ascii
 io.sockets.secure io.files io.streams.duplex io.timeouts
 io.encodings threads make concurrency.combinators
 concurrency.semaphores concurrency.flags
-combinators.short-circuit call ;
+combinators.short-circuit ;
 IN: io.servers.connection
 
 TUPLE: threaded-server
index 78a9c03d205d2f401511bc986220dffbc044f215..4f7ccf227e54e12567e6e4d7f47916fa123278d5 100644 (file)
@@ -4,7 +4,7 @@ USING: arrays hashtables io kernel math math.parser memory
 namespaces parser lexer sequences strings io.styles
 vectors words generic system combinators continuations debugger
 definitions compiler.units accessors colors prettyprint fry
-sets vocabs.parser call ;
+sets vocabs.parser ;
 IN: listener
 
 GENERIC: stream-read-quot ( stream -- quot/f )
index d3b08a11fb9e16440b3462c20bfe8823df4e907f..139f6726e8bc61c419abcfb03b204b8c3de2522e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2008 Chris Double, Matthew Willis, James Cash.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences math vectors arrays namespaces make
-quotations promises combinators io lists accessors call ;
+quotations promises combinators io lists accessors ;
 IN: lists.lazy
 
 M: promise car ( promise -- car )
index fcdfd166c5acc119f97cf2a61543e0bc9f1897d1..e0cf73c7f115560c689e49b7731c6f78d115dccb 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-USING: accessors models kernel call ;\r
+USING: accessors models kernel ;\r
 IN: models.arrow\r
 \r
 TUPLE: arrow < model model quot ;\r
index db29ce1ee76af515de7dae81890e128a6e0ecd0e..1f526d47f2bd3122a02197bf55d839fd2b2430ad 100644 (file)
@@ -5,7 +5,7 @@ sequences quotations vectors namespaces make math assocs
 continuations peg peg.parsers unicode.categories multiline\r
 splitting accessors effects sequences.deep peg.search\r
 combinators.short-circuit lexer io.streams.string stack-checker\r
-io combinators parser call ;\r
+io combinators parser ;\r
 IN: peg.ebnf\r
 \r
 : rule ( name word -- parser )\r
index 01891a1da17cfd97d7854d5a593888b3847809c7..6c0772aacc3269d883872d0874b25d8beeef14d1 100644 (file)
@@ -4,7 +4,7 @@ USING: kernel sequences strings fry namespaces make math assocs
 io vectors arrays math.parser math.order vectors combinators
 classes sets unicode.categories compiler.units parser words
 quotations effects memoize accessors locals effects splitting
-combinators.short-circuit generalizations call ;
+combinators.short-circuit generalizations ;
 IN: peg
 
 TUPLE: parse-result remaining ast ;
index 63a2f25885b06308da29e7cdc932fef9fe362089..5889b19e476d122b2212a87bbf1b5270e81c4667 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors combinators kernel kernel.private math sequences
 sequences.private strings sets assocs prettyprint.backend
 prettyprint.custom make lexer namespaces parser arrays fry locals
 regexp.parser splitting sorting regexp.ast regexp.negation
-regexp.compiler compiler.units words call call.private math.ranges ;
+regexp.compiler compiler.units words math.ranges ;
 IN: regexp
 
 TUPLE: regexp
@@ -35,7 +35,7 @@ M: lookbehind question>quot ! Returns ( index string -- ? )
 : match-index-from ( i string regexp -- index/f )
     ! This word is unsafe. It assumes that i is a fixnum
     ! and that string is a string.
-    dup dfa>> execute-unsafe( index string regexp -- i/f ) ; inline
+    dup dfa>> execute( index string regexp -- i/f ) ; inline
 
 GENERIC: end/start ( string regexp -- end start )
 M: regexp end/start drop length 0 ;
@@ -68,7 +68,7 @@ PRIVATE>
 
 : do-next-match ( i string regexp -- i start end ? )
     dup next-match>>
-    execute-unsafe( i string regexp -- i start end ? ) ; inline
+    execute( i string regexp -- i start end ? ) ; inline
 
 :: (each-match) ( i string regexp quot: ( start end string -- ) -- )
     i string regexp do-next-match [| i' start end |
diff --git a/basis/stack-checker/call-effect/authors.txt b/basis/stack-checker/call-effect/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/stack-checker/call-effect/call-effect-tests.factor b/basis/stack-checker/call-effect/call-effect-tests.factor
new file mode 100644 (file)
index 0000000..e5c0f23
--- /dev/null
@@ -0,0 +1,7 @@
+USING: stack-checker.call-effect tools.test math kernel ;
+IN: stack-checker.call-effect.tests
+
+[ t ] [ \ + (( a b -- c )) execute-effect-unsafe? ] unit-test
+[ t ] [ \ + (( a b c -- d e )) execute-effect-unsafe? ] unit-test
+[ f ] [ \ + (( a b c -- d )) execute-effect-unsafe? ] unit-test
+[ f ] [ \ call (( x -- )) execute-effect-unsafe? ] unit-test
\ No newline at end of file
diff --git a/basis/stack-checker/call-effect/call-effect.factor b/basis/stack-checker/call-effect/call-effect.factor
new file mode 100644 (file)
index 0000000..bd1f7c7
--- /dev/null
@@ -0,0 +1,95 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators combinators.private effects fry
+kernel kernel.private make sequences continuations quotations
+stack-checker stack-checker.transforms ;
+IN: stack-checker.call-effect
+
+! call( and execute( have complex expansions.
+
+! call( uses the following strategy:
+! - Inline caching. If the quotation is the same as last time, just call it unsafely
+! - Effect inference. Infer quotation's effect, caching it in the cached-effect slot,
+!   and compare it with declaration. If matches, call it unsafely.
+! - Fallback. If the above doesn't work, call it and compare the datastack before
+!   and after to make sure it didn't mess anything up.
+
+! execute( uses a similar strategy.
+
+TUPLE: inline-cache value ;
+
+: cache-hit? ( word/quot ic -- ? ) value>> eq? ; inline
+
+SYMBOL: +unknown+
+
+GENERIC: cached-effect ( quot -- effect )
+
+M: object cached-effect drop +unknown+ ;
+
+M: quotation cached-effect
+    dup cached-effect>>
+    [ ] [
+        [ [ infer ] [ 2drop +unknown+ ] recover dup ] keep
+        (>>cached-effect)
+    ] ?if ;
+
+: call-effect-unsafe? ( quot effect -- ? )
+    [ cached-effect ] dip
+    over +unknown+ eq?
+    [ 2drop f ] [ effect<= ] if ; inline
+
+: (call-effect-slow>quot) ( in out effect -- quot )
+    [
+        [ [ datastack ] dip dip ] %
+        [ [ , ] bi@ \ check-datastack , ] dip
+        '[ _ wrong-values ] , \ unless ,
+    ] [ ] make ;
+
+: call-effect-slow>quot ( effect -- quot )
+    [ in>> length ] [ out>> length ] [ ] tri
+    [ (call-effect-slow>quot) ] keep add-effect-input
+    [ call-effect-unsafe ] 2curry ;
+
+: call-effect-slow ( quot effect -- ) drop call ;
+
+\ call-effect-slow [ call-effect-slow>quot ] 1 define-transform
+
+: call-effect-fast ( quot effect inline-cache -- )
+    2over call-effect-unsafe?
+    [ [ nip (>>value) ] [ drop call-effect-unsafe ] 3bi ]
+    [ drop call-effect-slow ]
+    if ; inline
+
+\ call-effect [
+    inline-cache new '[
+        _
+        3dup nip cache-hit? [
+            drop call-effect-unsafe
+        ] [
+            call-effect-fast
+        ] if
+    ]
+] 0 define-transform
+
+: execute-effect-slow ( word effect -- )
+    [ '[ _ execute ] ] dip call-effect-slow ; inline
+
+: execute-effect-unsafe? ( word effect -- ? )
+    over optimized>> [ [ stack-effect ] dip effect<= ] [ 2drop f ] if ; inline
+
+: execute-effect-fast ( word effect inline-cache -- )
+    2over execute-effect-unsafe?
+    [ [ nip (>>value) ] [ drop execute-effect-unsafe ] 3bi ]
+    [ drop execute-effect-slow ]
+    if ; inline
+
+: execute-effect-ic ( word effect inline-cache -- )
+    3dup nip cache-hit?
+    [ drop execute-effect-unsafe ]
+    [ execute-effect-fast ]
+    if ; inline
+
+: execute-effect>quot ( effect -- quot )
+    inline-cache new '[ _ _ execute-effect-ic ] ;
+
+\ execute-effect [ execute-effect>quot ] 1 define-transform
index e366073326e1f5d5ae762127780247f76ce1dde0..a7f348d36b624a84c9745c103acf70c35e5cbb62 100644 (file)
@@ -11,7 +11,7 @@ strings.private system threads.private classes.tuple
 classes.tuple.private vectors vectors.private words definitions
 words.private assocs summary compiler.units system.private
 combinators locals locals.backend locals.types words.private
-quotations.private call call.private stack-checker.values
+quotations.private combinators.private stack-checker.values
 stack-checker.alien
 stack-checker.state
 stack-checker.errors
@@ -135,17 +135,16 @@ M: object infer-call*
     peek-d literal value>> second 1+ { tuple } <effect>
     apply-word/effect ;
 
-: infer-(throw) ( -- )
-    \ (throw)
-    peek-d literal value>> 2 + { "*" } <effect>
+: infer-effect-unsafe ( word -- )
+    pop-literal nip
+    add-effect-input
     apply-word/effect ;
 
 : infer-execute-effect-unsafe ( -- )
-    \ execute
-    pop-literal nip
-    [ in>> "word" suffix ] [ out>> ] [ terminated?>> ] tri
-    effect boa
-    apply-word/effect ;
+    \ execute infer-effect-unsafe ;
+
+: infer-call-effect-unsafe ( -- )
+    \ call infer-effect-unsafe ;
 
 : infer-exit ( -- )
     \ exit (( n -- * )) apply-word/effect ;
@@ -186,10 +185,10 @@ M: object infer-call*
         { \ execute [ infer-execute ] }
         { \ (execute) [ infer-execute ] }
         { \ execute-effect-unsafe [ infer-execute-effect-unsafe ] }
+        { \ call-effect-unsafe [ infer-call-effect-unsafe ] }
         { \ if [ infer-if ] }
         { \ dispatch [ infer-dispatch ] }
         { \ <tuple-boa> [ infer-<tuple-boa> ] }
-        { \ (throw) [ infer-(throw) ] }
         { \ exit [ infer-exit ] }
         { \ load-local [ 1 infer->r ] }
         { \ load-locals [ infer-load-locals ] }
@@ -212,9 +211,10 @@ M: object infer-call*
 
 {
     declare call (call) slip 2slip 3slip dip 2dip 3dip curry compose
-    execute (execute) execute-effect-unsafe if dispatch <tuple-boa>
-    (throw) exit load-local load-locals get-local drop-locals
-    do-primitive alien-invoke alien-indirect alien-callback
+    execute (execute) call-effect-unsafe execute-effect-unsafe if
+    dispatch <tuple-boa> exit load-local load-locals get-local
+    drop-locals do-primitive alien-invoke alien-indirect
+    alien-callback
 } [ t "special" set-word-prop ] each
 
 { call execute dispatch load-locals get-local drop-locals }
@@ -627,6 +627,9 @@ M: object infer-call*
 \ datastack { } { array } define-primitive
 \ datastack make-flushable
 
+\ check-datastack { array integer integer } { object } define-primitive
+\ check-datastack make-flushable
+
 \ retainstack { } { array } define-primitive
 \ retainstack make-flushable
 
index ff283ce9cab53e91b59954b013ec8e9e0b281874..e18a6f08406d49b86b158b750cd92183e77e9c00 100644 (file)
@@ -1,7 +1,7 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel io effects namespaces sequences quotations vocabs
-generic words stack-checker.backend stack-checker.state
+vocabs.loader generic words stack-checker.backend stack-checker.state
 stack-checker.known-words stack-checker.transforms
 stack-checker.errors stack-checker.inlining
 stack-checker.visitor.dummy ;
@@ -28,3 +28,5 @@ M: callable infer ( quot -- effect )
         dup subwords [ f "inferred-effect" set-word-prop ] each
         f "inferred-effect" set-word-prop
     ] each ;
+
+"stack-checker.call-effect" require
\ No newline at end of file
index 1901f27a24507e2512d93a1f956aaaa0d2f05714..a44f8d7f8d462129605979ca2bec95cc98dc3a48 100644 (file)
@@ -1 +1,2 @@
 Slava Pestov
+Daniel Ehrenberg
index fe580084c06977e77d0d7ec39b988d269eceb6b6..521cf9fcb7064c33cd489d682bbeb6618c4465c7 100644 (file)
@@ -3,8 +3,8 @@ USING: sequences stack-checker.transforms tools.test math kernel
 quotations stack-checker accessors combinators words arrays
 classes classes.tuple ;
 
-: compose-n-quot ( word -- quot' ) <repetition> >quotation ;
-: compose-n ( quot -- ) compose-n-quot call ;
+: compose-n-quot ( word -- quot' ) <repetition> >quotation ;
+: compose-n ( quot -- ) compose-n-quot call ;
 \ compose-n [ compose-n-quot ] 2 define-transform
 : compose-n-test ( a b c -- x ) 2 \ + compose-n ;
 
index ecc2365cf906932cd9a922169ccd05f3deb5bc49..3b783ce46783d3ba03fd88a7167ee2e2a360a6af 100755 (executable)
@@ -1,11 +1,12 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: fry accessors arrays kernel words sequences generic math
-namespaces make quotations assocs combinators classes.tuple
-classes.tuple.private effects summary hashtables classes generic
-sets definitions generic.standard slots.private continuations locals
-generalizations stack-checker.backend stack-checker.state
-stack-checker.visitor stack-checker.errors stack-checker.values
+USING: fry accessors arrays kernel kernel.private combinators.private
+words sequences generic math namespaces make quotations assocs
+combinators classes.tuple classes.tuple.private effects summary
+hashtables classes generic sets definitions generic.standard
+slots.private continuations locals generalizations
+stack-checker.backend stack-checker.state stack-checker.visitor
+stack-checker.errors stack-checker.values
 stack-checker.recursive-state ;
 IN: stack-checker.transforms
 
@@ -141,8 +142,12 @@ CONSTANT: bit-member-n 256
     dup bit-member? [
         bit-member-quot
     ] [
-        [ literalize [ t ] ] { } map>assoc
-        [ drop f ] suffix [ case ] curry
+        dup length 4 <= [
+            [ drop f ] swap
+            [ literalize [ t ] ] { } map>assoc linear-case-quot
+        ] [
+            unique [ key? ] curry
+        ] if
     ] if ;
 
 \ member? [
index 3f4267df15e7771614719d259e390d36a1ec737c..cacc628e2a5a6c7dff401bbc2cbf51b0f056de62 100644 (file)
@@ -1,10 +1,10 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
 ! Copyright (C) 2005 Mackenzie Straight.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays hashtables heaps kernel kernel.private math
 namespaces sequences vectors continuations continuations.private
-dlists assocs system combinators init boxes accessors
-math.order deques strings quotations fry ;
+dlists assocs system combinators combinators.private init boxes
+accessors math.order deques strings quotations fry ;
 IN: threads
 
 SYMBOL: initial-thread
@@ -126,7 +126,7 @@ DEFER: stop
         { } set-retainstack
         { } set-datastack
         self quot>> [ call stop ] call-clear
-    ] 2 (throw) ;
+    ] (( namestack thread -- * )) call-effect-unsafe ;
 
 DEFER: next
 
@@ -160,7 +160,7 @@ DEFER: next
 PRIVATE>
 
 : stop ( -- )
-    self [ exit-handler>> call ] [ unregister-thread ] bi next ;
+    self [ exit-handler>> call( -- ) ] [ unregister-thread ] bi next ;
 
 : suspend ( quot state -- obj )
     [
index 293a22d2bb95ea8e23a8f3eff39eb85d8b42f0b9..8c3d95f2b877e017892ebf2074fbc5c74cc2f91a 100644 (file)
@@ -39,13 +39,13 @@ ERROR: cannot-annotate-twice word ;
     dup def>> "unannotated-def" set-word-prop ;
 
 : (annotate) ( word quot -- )
-    [ dup def>> ] dip call define ; inline
+    [ dup def>> ] dip call( old -- new ) define ;
 
 PRIVATE>
 
 : annotate ( word quot -- )
     [ method-spec>word check-annotate-twice ] dip
-    [ over save-unannotated-def (annotate) ] with-compilation-unit ; inline
+    [ over save-unannotated-def (annotate) ] with-compilation-unit ;
 
 <PRIVATE
 
index a47b3dca32a7a98fd7a5ad7cee2c9cf14a12383a..4c03047eb86960ea856790387553076ac1acb339 100644 (file)
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax words alien.c-types assocs
-kernel call call.private tools.deploy.config ;
+kernel combinators combinators.private tools.deploy.config ;
 IN: tools.deploy
 
 ARTICLE: "prepare-deploy" "Preparing to deploy an application"
@@ -28,7 +28,7 @@ ARTICLE: "tools.deploy.caveats" "Deploy tool caveats"
 { $heading "Behavior of " { $link boa } }
 "In deployed applications, the " { $link boa } " word does not verify that the parameters on the stack satisfy the tuple's slot declarations, if any. This reduces deploy image size but can make bugs harder to track down. Make sure your program is fully debugged before deployment."
 { $heading "Behavior of " { $link POSTPONE: execute( } }
-"Similarly, the " { $link POSTPONE: execute( } " word does not check word stack effects in deployed applications, since stack effects are stripped out, and so it behaves exactly like " { $link POSTPONE: execute-unsafe( } "."
+"Similarly, the " { $link POSTPONE: execute( } " word does not check word stack effects in deployed applications, since stack effects are stripped out, and so it behaves exactly like " { $link POSTPONE: execute-effect-unsafe } "."
 { $heading "Error reporting" }
 "If the " { $link deploy-reflection } " level in the configuration is low enough, the debugger is stripped out, and error messages can be rather cryptic. Increase the reflection level to get readable error messages."
 { $heading "Choosing the right deploy flags" }
index 40c4ae57215376471bda83ae39bab4b560911ad7..3a2f960fc93713b346f70eeadd3f601406eeabc7 100644 (file)
@@ -1,10 +1,9 @@
 IN: tools.deploy.tests\r
 USING: tools.test system io.pathnames io.files io.files.info\r
-io.files.temp kernel tools.deploy.config\r
-tools.deploy.config.editor tools.deploy.backend math sequences\r
-io.launcher arrays namespaces continuations layouts accessors\r
-io.encodings.ascii urls math.parser io.directories\r
-tools.deploy.test ;\r
+io.files.temp kernel tools.deploy.config tools.deploy.config.editor\r
+tools.deploy.backend math sequences io.launcher arrays namespaces\r
+continuations layouts accessors io.encodings.ascii urls math.parser\r
+io.directories tools.deploy.test ;\r
 \r
 [ t ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test\r
 \r
index 98fc06a9899a62e752920b5b0dd3f2c1c4afb448..239d34b86460b2c733c9cf29aa8a4b9b8e5a533d 100755 (executable)
@@ -122,6 +122,7 @@ IN: tools.deploy.shaker
                 "inline"
                 "inlined-block"
                 "input-classes"
+                "instances"
                 "interval"
                 "intrinsics"
                 "lambda"
@@ -344,7 +345,8 @@ IN: tools.deploy.shaker
     ] 2each ;
 
 : compress-quotations ( -- )
-    [ quotation? ] [ remain-compiled ] "quotations" compress ;
+    [ quotation? ] [ remain-compiled ] "quotations" compress
+    [ quotation? ] instances [ f >>cached-effect f >>cache-counter drop ] each ;
 
 : compress-strings ( -- )
     [ string? ] [ ] "strings" compress ;
index 425989593661a1cf4778d14df7cbd4fd2d6e1b62..860a0f38492fa2e80400f8a77fd7ea8bce0be905 100644 (file)
@@ -5,4 +5,6 @@ IN: tools.deploy.shaker.call
 IN: call
 USE: call.private
 
+: call-effect ( word effect -- ) call-effect-unsafe ; inline
+
 : execute-effect ( word effect -- ) execute-effect-unsafe ; inline
\ No newline at end of file
index 3ee0643c38f3966eda297d0694b46a8d5b06888a..3bc2af3da475411a3576d7e6b4e367070caa3246 100644 (file)
@@ -1,10 +1,12 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: call math.parser io math ;
+USING: math.parser io math ;
 IN: tools.deploy.test.12
 
 : execute-test ( a b w -- c ) execute( a b -- c ) ;
 
-: foo ( -- ) 1 2 \ + execute-test number>string print ;
+: call-test ( a b q -- c ) call( a b -- c ) ;
+
+: foo ( -- ) 1 2 \ + execute-test 4 [ * ] call-test number>string print ;
 
 MAIN: foo
\ No newline at end of file
index 704a7f1bd5430d828ff504b1228f48ad382bf259..c6dea08d181556e9051b3dd3a310daa763b6b681 100644 (file)
@@ -23,7 +23,7 @@ SYMBOL: this-test
         [ this-test get failure ] recover
     ] [
         call
-    ] if ;
+    ] if ; inline
 
 : unit-test ( output input -- )
     [ 2array ] 2keep '[
index 6a3f2df8a37b3ecd8f33f1a6048e5d010660579e..c9ade7aae27877e35c8100cc941f9d6380cd3eb7 100644 (file)
@@ -244,11 +244,7 @@ C: <vocab-author> vocab-author
     } cleave ;
 
 : keyed-vocabs ( str quot -- seq )
-    all-vocabs [
-        swap [
-            [ [ 2dup ] dip swap call member? ] filter
-        ] dip swap
-    ] assoc-map 2nip ; inline
+    [ all-vocabs ] 2dip '[ [ _ swap @ member? ] filter ] assoc-map ; inline
 
 : tagged ( tag -- assoc )
     [ vocab-tags ] keyed-vocabs ;
index f0d9a084b13677494a1df9859cbf6c5f9f5eb0df..b4ace6b770aef27a1eea84532c21c05121a0977c 100644 (file)
@@ -139,7 +139,6 @@ SYMBOL: +stopped+
     { dip [ (step-into-dip) ] }
     { 2dip [ (step-into-2dip) ] }
     { 3dip [ (step-into-3dip) ] }
-    { (throw) [ drop (step-into-quot) ] }
     { execute [ (step-into-execute) ] }
     { if [ (step-into-if) ] }
     { dispatch [ (step-into-dispatch) ] }
index ce535f335aa9e1eeb1b2b4ab67c6a9e67e3248f3..66c0276055d460bc94242032f00289082e6f30b7 100644 (file)
@@ -17,7 +17,8 @@ M: bad-tr summary
     [ [ ascii? ] all? ] both? [ bad-tr ] unless ;
 
 : compute-tr ( quot from to -- mapping )
-    zip [ 128 ] 2dip '[ [ @ _ at ] keep or ] B{ } map-as ; inline
+    [ 128 ] 3dip zip
+    '[ [ _ call( x -- y ) _ at ] keep or ] B{ } map-as ; inline
 
 : tr-hints ( word -- )
     { { byte-array } { string } } "specializer" set-word-prop ;
index 5cb02f5ad6084f8ac3f231936cdfda7f84f6443f..fc392c595d40e0dc13f940211c3a5d5d3f030b14 100755 (executable)
@@ -8,7 +8,7 @@ ui.backend ui.clipboards ui.gadgets ui.gadgets.worlds
 ui.backend.cocoa.views core-foundation core-foundation.run-loop
 core-graphics.types threads math.rectangles fry libc
 generalizations alien.c-types cocoa.views
-combinators io.thread locals call ;
+combinators io.thread locals ;
 IN: ui.backend.cocoa
 
 TUPLE: handle ;
index d6c7c7905be1aa9b9f3191561ca455a233c767a1..28529b013bf9ca19e7da6ea57d0fea955a8d471b 100644 (file)
@@ -2,8 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions kernel sequences strings
 math assocs words generic namespaces make assocs quotations
-splitting ui.gestures unicode.case unicode.categories tr fry
-call ;
+splitting ui.gestures unicode.case unicode.categories tr fry ;
 IN: ui.commands
 
 SYMBOL: +nullary+
index ebac290f4bdfc4fc4152d29bbdc912d9bfe1ded7..0504231972e655c3b1010ee50aef53156b922042 100644 (file)
@@ -6,7 +6,7 @@ classes.tuple opengl opengl.gl math.vectors ui.commands ui.gadgets
 ui.gadgets.borders ui.gadgets.labels ui.gadgets.tracks
 ui.gadgets.packs ui.gadgets.worlds ui.gestures ui.pens ui.pens.solid
 ui.pens.image ui.pens.tile math.rectangles locals fry
-combinators.smart call ;
+combinators.smart ;
 IN: ui.gadgets.buttons
 
 TUPLE: button < border pressed? selected? quot ;
index 9adb33a164dcb5d3e9f926f22149ff572b33408a..bda9938f8a97e838f78f50f827a1fc8f03fa060f 100755 (executable)
@@ -413,8 +413,7 @@ editor "caret-motion" f {
 } define-command-map
 
 : clear-editor ( editor -- )
-    #! The with-datastack is a kludge to make it infer. Stupid.
-    model>> 1array [ clear-doc ] with-datastack drop ;
+    model>> clear-doc ;
 
 : select-all ( editor -- ) doc-elt select-elt ;
 
@@ -619,7 +618,7 @@ TUPLE: action-field < field quot ;
     [ editor>> editor-string ]
     [ editor>> clear-editor ]
     [ quot>> ]
-    tri call ;
+    tri call( string -- ) ;
 
 action-field H{
     { T{ key-down f f "RET" } [ invoke-action-field ] }
index 6019d6a95492268fc5c7f0b12ccec8b7d2836fef..44da013f2cecf90e2edb46d959b31e3892f1affb 100644 (file)
@@ -10,7 +10,7 @@ ui.gadgets.paragraphs ui.gadgets.incremental ui.gadgets.packs
 ui.gadgets.menus ui.clipboards ui.gestures ui.traverse ui.render
 ui.text ui.gadgets.presentations ui.gadgets.grids ui.gadgets.tracks
 ui.gadgets.icons ui.gadgets.grid-lines ui.baseline-alignment
-colors call io.styles ;
+colors io.styles ;
 IN: ui.gadgets.panes
 
 TUPLE: pane < track
index ccfa83334b202079c81c1500535c27135a7fb13c..163dbff514493b244aaa248c9a22f013a98be76f 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs continuations kernel math models
-call namespaces opengl sequences io combinators
-combinators.short-circuit fry math.vectors math.rectangles cache
-ui.gadgets ui.gestures ui.render ui.text ui.text.private
-ui.backend ui.gadgets.tracks ui.commands ;
+namespaces opengl sequences io combinators combinators.short-circuit
+fry math.vectors math.rectangles cache ui.gadgets ui.gestures
+ui.render ui.text ui.text.private ui.backend ui.gadgets.tracks
+ui.commands ;
 IN: ui.gadgets.worlds
 
 TUPLE: world < track
index 2e52a2fe1e54460a6d772924f6528b46e0f88067..c7db0839d7b08c0f8f139ffd5c25ccffe4a65b49 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors arrays assocs kernel math math.order models
 namespaces make sequences words strings system hashtables math.parser
 math.vectors classes.tuple classes boxes calendar alarms combinators
 sets columns fry deques ui.gadgets ui.gadgets.private unicode.case
-unicode.categories combinators.short-circuit call ;
+unicode.categories combinators.short-circuit ;
 IN: ui.gestures
 
 GENERIC: handle-gesture ( gesture gadget -- ? )
index 2f9cfba961adf3795f1de6eeba25b25c2f8aac85..db6048061e47997dc2291e8a85337475a9bbb399 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions kernel ui.commands
 ui.gestures sequences strings math words generic namespaces
-hashtables help.markup quotations assocs fry call linked-assocs ;
+hashtables help.markup quotations assocs fry linked-assocs ;
 IN: ui.operations
 
 SYMBOL: +keyboard+
index 1f427d9405b8defa1fd33640c52a9fef4b528056..6728fb8338ecb155ee0d08c0bc7a44ea15327bd1 100644 (file)
@@ -105,5 +105,5 @@ walker-gadget "multitouch" f {
 
 [
     dup find-walker-window dup
-    [ raise-window 3drop ] [ drop [ walker-window ] with-ui ] if
+    [ raise-window 3drop ] [ drop '[ _ _ _ walker-window ] with-ui ] if
 ] show-walker-hook set-global
index fe318101ee8475e7d5b7a4f3302a923f7efd91d5..8ce8f57cf0e0e31c773c170b63df3848f1c1c8f3 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs io kernel math models namespaces make dlists
-deques sequences threads sequences words continuations init call
+deques sequences threads sequences words continuations init
 combinators hashtables concurrency.flags sets accessors calendar fry
 destructors ui.gadgets ui.gadgets.private ui.gadgets.worlds
 ui.gadgets.tracks ui.gestures ui.backend ui.render ui.text
index 0b7f869141a47dd61d64e3d3e04570297880434f..58957ba8e74265239d2e2346fd839a267c1553f6 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences math arrays locals fry accessors
-lists splitting call make combinators.short-circuit namespaces
+lists splitting make combinators.short-circuit namespaces
 grouping splitting.monotonic ;
 IN: wrap
 
index 60318e669e7fea9cffb97649a07d07c21a2236d7..4cbf58c8aa62c59a244c631a72db353c5854e2a4 100644 (file)
@@ -12,7 +12,7 @@ IN: xmode.loader.syntax
 
 : RULE:
     scan scan-word scan-word [
-        parse-definition { } make
+        [ parse-definition call( -- ) ] { } make
         swap [ (parse-rule-tag) ] 2curry
     ] dip swap define-tag ; parsing
 
index 083059cec5706d4acad392f2217d05fe17bf6ccb..48aae3667e29eaf4a77d1383c15e7da91da706e4 100644 (file)
@@ -140,9 +140,6 @@ bootstrapping? on
 "word" "words" create register-builtin
 "byte-array" "byte-arrays" create register-builtin
 
-! For predicate classes
-"predicate-instance?" "classes.predicate" create drop
-
 ! We need this before defining c-ptr below
 "f" "syntax" lookup { } define-builtin
 
@@ -243,6 +240,8 @@ bi
 "quotation" "quotations" create {
     { "array" { "array" "arrays" } read-only }
     { "compiled" read-only }
+    "cached-effect"
+    "cache-counter"
 } define-builtin
 
 "dll" "alien" create {
@@ -491,7 +490,6 @@ tuple
     { "set-alien-double" "alien.accessors" }
     { "alien-cell" "alien.accessors" }
     { "set-alien-cell" "alien.accessors" }
-    { "(throw)" "kernel.private" }
     { "alien-address" "alien" }
     { "set-slot" "slots.private" }
     { "string-nth" "strings.private" }
@@ -533,6 +531,7 @@ tuple
     { "gc-reset" "memory" }
     { "jit-compile" "quotations" }
     { "load-locals" "locals.backend" }
+    { "check-datastack" "kernel.private" }
 }
 [ [ first2 ] dip make-primitive ] each-index
 
index 654a8f5f3468b61f29b1b3b4b601350b9ec43081..1c97ee5a500cf482428bc25d74e0cd5fbc41b30d 100644 (file)
@@ -78,6 +78,8 @@ IN: bootstrap.syntax
     "call-next-method"
     "initial:"
     "read-only"
+    "call("
+    "execute("
 } [ "syntax" create drop ] each
 
 "t" "syntax" lookup define-symbol
index d4c929a69bfe4724dcab6b02ba53c6de94f9ab07..a947b9ddc09af419925ab52d60e65a979fdda998 100644 (file)
@@ -18,10 +18,4 @@ M: positive abs ;
 
 [ 10 ] [ -10 abs ] unit-test
 [ 10 ] [ 10 abs ] unit-test
-[ 0 ] [ 0 abs ] unit-test
-
-PREDICATE: blah < word blah eq? ;
-
-[ f ] [ \ predicate-instance? "compiled-uses" word-prop keys \ blah swap memq? ] unit-test
-
-FORGET: blah
\ No newline at end of file
+[ 0 ] [ 0 abs ] unit-test
\ No newline at end of file
index 7d757772f40055dfe5693243f8b9660d4602eaf9..188a2ed794b6e88b3f9455420d4fcec978b96c53 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes classes.algebra kernel namespaces make words
 sequences quotations arrays kernel.private assocs combinators ;
@@ -7,21 +7,6 @@ IN: classes.predicate
 PREDICATE: predicate-class < class
     "metaclass" word-prop predicate-class eq? ;
 
-DEFER: predicate-instance? ( object class -- ? )
-
-: update-predicate-instance ( -- )
-    \ predicate-instance? bootstrap-word
-    classes [ predicate-class? ] filter [
-        [ literalize ]
-        [
-            [ superclass 1array [ declare ] curry ]
-            [ "predicate-definition" word-prop ]
-            bi compose
-        ]
-        bi
-    ] { } map>assoc [ case ] curry
-    define ;
-
 : predicate-quot ( class -- quot )
     [
         \ dup ,
@@ -38,19 +23,17 @@ DEFER: predicate-instance? ( object class -- ? )
         [ dup predicate-quot define-predicate ]
         [ update-classes ]
         bi
-    ]
-    3tri
-    update-predicate-instance ;
+    ] 3tri ;
 
 M: predicate-class reset-class
-    [ call-next-method ] [ { "predicate-definition" } reset-props ] bi
-    update-predicate-instance ;
+    [ call-next-method ] [ { "predicate-definition" } reset-props ] bi ;
 
 M: predicate-class rank-class drop 1 ;
 
 M: predicate-class instance?
-    2dup superclass instance?
-    [ predicate-instance? ] [ 2drop f ] if ;
+    2dup superclass instance? [
+        "predicate-definition" word-prop call( object -- ? )
+    ] [ 2drop f ] if ;
 
 M: predicate-class (flatten-class)
     superclass (flatten-class) ;
index 659195edbf3cc99416dfde3917e6de86daaf1b9e..5e12322a4868cceaee6a96a3864f5dcbe5db44f7 100644 (file)
@@ -30,7 +30,7 @@ ERROR: duplicate-slot-names names ;
 
 ERROR: invalid-slot-name name ;
 
-: parse-long-slot-name ( -- )
+: parse-long-slot-name ( -- spec )
     [ scan , \ } parse-until % ] { } make ;
 
 : parse-slot-name ( string/f -- ? )
@@ -64,7 +64,7 @@ ERROR: bad-literal-tuple ;
 
 : parse-slot-value ( -- )
     scan scan-object 2array , scan {
-        { f [ unexpected-eof ] }
+        { f [ \ } unexpected-eof ] }
         { "}" [ ] }
         [ bad-literal-tuple ]
     } case ;
@@ -72,13 +72,13 @@ ERROR: bad-literal-tuple ;
 : (parse-slot-values) ( -- )
     parse-slot-value
     scan {
-        { f [ unexpected-eof ] }
+        { f [ \ } unexpected-eof ] }
         { "{" [ (parse-slot-values) ] }
         { "}" [ ] }
         [ bad-literal-tuple ]
     } case ;
 
-: parse-slot-values ( -- )
+: parse-slot-values ( -- values )
     [ (parse-slot-values) ] { } make ;
 
 : boa>tuple ( class slots -- tuple )
index 1901f27a24507e2512d93a1f956aaaa0d2f05714..a44f8d7f8d462129605979ca2bec95cc98dc3a48 100644 (file)
@@ -1 +1,2 @@
 Slava Pestov
+Daniel Ehrenberg
index a26c2fbe5d1db84517d0a4af7ab758ef0c782274..cc502140ad18db3284fab98ee088b2144ab7f20f 100644 (file)
@@ -1,6 +1,7 @@
 USING: arrays help.markup help.syntax strings sbufs vectors
 kernel quotations generic generic.standard classes
-math assocs sequences sequences.private ;
+math assocs sequences sequences.private combinators.private
+effects words ;
 IN: combinators
 
 ARTICLE: "combinators-quot" "Quotation construction utilities"
@@ -9,6 +10,19 @@ ARTICLE: "combinators-quot" "Quotation construction utilities"
 { $subsection case>quot }
 { $subsection alist>quot } ;
 
+ARTICLE: "call" "Calling code with known stack effects"
+"Arbitrary quotations and words can be called from code accepted by the optimizing compiler. This is done by specifying the stack effect of the quotation literally. It is checked at runtime that the stack effect is accurate."
+$nl
+"Quotations:"
+{ $subsection POSTPONE: call( }
+{ $subsection call-effect }
+"Words:"
+{ $subsection POSTPONE: execute( }
+{ $subsection execute-effect }
+"Unsafe calls:"
+{ $subsection call-effect-unsafe }
+{ $subsection execute-effect-unsafe } ;
+
 ARTICLE: "combinators" "Additional combinators"
 "The " { $vocab-link "combinators" } " vocabulary provides a few useful combinators."
 $nl
@@ -27,11 +41,27 @@ $nl
 $nl
 "A combinator which can help with implementing methods on " { $link hashcode* } ":"
 { $subsection recursive-hashcode }
+{ $subsection "call" }
 { $subsection "combinators-quot" }
 { $see-also "quotations" "dataflow" } ;
 
 ABOUT: "combinators"
 
+HELP: call-effect
+{ $values { "quot" quotation } { "effect" effect } }
+{ $description "Given a quotation and a stack effect, calls the quotation, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary quotation which is not required at compile time." } ;
+
+HELP: execute-effect
+{ $values { "word" word } { "effect" effect } }
+{ $description "Given a word and a stack effect, executes the word, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary word which is not required at compile time." } ;
+
+HELP: execute-effect-unsafe
+{ $values { "word" word } { "effect" effect } }
+{ $description "Given a word and a stack effect, executes the word, blindly declaring at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary word which is not required at compile time." }
+{ $warning "If the word being executed has an incorrect stack effect, undefined behavior will result. User code should use " { $link POSTPONE: execute( } " instead." } ;
+    
+{ call-effect call-effect-unsafe execute-effect execute-effect-unsafe } related-words
+
 HELP: cleave
 { $values { "x" object } { "seq" "a sequence of quotations with stack effect " { $snippet "( x -- ... )" } } }
 { $description "Applies each quotation to the object in turn." }
index 1ee3a4e3ed9c15b981625c2b9d4f6f391f4609e9..be7d93873e40328595f1fefac15c919e53c379a1 100644 (file)
@@ -3,6 +3,38 @@ namespaces combinators words classes sequences accessors
 math.functions arrays ;
 IN: combinators.tests
 
+[ 3 ] [ 1 2 [ + ] call( x y -- z ) ] unit-test
+[ 1 2 [ + ] call( -- z ) ] must-fail
+[ 1 2 [ + ] call( x y -- z a ) ] must-fail
+[ 1 2 3 { 1 2 3 4 } ] [ 1 2 3 4 [ datastack nip ] call( x -- y ) ] unit-test
+[ [ + ] call( x y -- z ) ] must-infer
+
+[ 3 ] [ 1 2 \ + execute( x y -- z ) ] unit-test
+[ 1 2 \ + execute( -- z ) ] must-fail
+[ 1 2 \ + execute( x y -- z a ) ] must-fail
+[ \ + execute( x y -- z ) ] must-infer
+
+: compile-execute(-test-1 ( a b -- c ) \ + execute( a b -- c ) ;
+
+[ t ] [ \ compile-execute(-test-1 optimized>> ] unit-test
+[ 4 ] [ 1 3 compile-execute(-test-1 ] unit-test
+
+: compile-execute(-test-2 ( a b w -- c ) execute( a b -- c ) ;
+
+[ t ] [ \ compile-execute(-test-2 optimized>> ] unit-test
+[ 4 ] [ 1 3 \ + compile-execute(-test-2 ] unit-test
+[ 5 ] [ 1 4 \ + compile-execute(-test-2 ] unit-test
+[ -3 ] [ 1 4 \ - compile-execute(-test-2 ] unit-test
+[ 5 ] [ 1 4 \ + compile-execute(-test-2 ] unit-test
+
+: compile-call(-test-1 ( a b q -- c ) call( a b -- c ) ;
+
+[ t ] [ \ compile-call(-test-1 optimized>> ] unit-test
+[ 4 ] [ 1 3 [ + ] compile-call(-test-1 ] unit-test
+[ 7 ] [ 1 3 2 [ * + ] curry compile-call(-test-1 ] unit-test
+[ 7 ] [ 1 3 [ 2 * ] [ + ] compose compile-call(-test-1 ] unit-test
+[ 4 ] [ 1 3 [ { + } [ ] like call ] compile-call(-test-1 ] unit-test
+
 ! Compiled
 : cond-test-1 ( obj -- str )
     {
index daf247d678b438b9e0c24c54daace8d17a642451..4c600e06ca76bee4ed4c2e683e589c0176431489 100755 (executable)
@@ -1,10 +1,34 @@
-! Copyright (C) 2006, 2008 Slava Pestov.
+! Copyright (C) 2006, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays sequences sequences.private math.private
 kernel kernel.private math assocs quotations vectors
 hashtables sorting words sets math.order make ;
 IN: combinators
 
+<PRIVATE
+
+: call-effect-unsafe ( quot effect -- ) drop call ;
+
+: execute-effect-unsafe ( word effect -- ) drop execute ;
+
+M: object throw 5 getenv [ die ] or (( error -- * )) call-effect-unsafe ;
+
+PRIVATE>
+
+ERROR: wrong-values effect ;
+
+! We can't USE: effects here so we forward reference slots instead
+SLOT: in
+SLOT: out
+
+: call-effect ( quot effect -- )
+    [ [ datastack ] dip dip ] dip
+    [ in>> length ] [ out>> length ] [ ] tri [ check-datastack ] dip
+    [ wrong-values ] curry unless ;
+
+: execute-effect ( word effect -- )
+    [ [ execute ] curry ] dip call-effect ;
+
 ! cleave
 : cleave ( x seq -- )
     [ call ] with each ;
index 0d66829898dc2f3762b3aa32b9d8cff712ac5380..0627ed5265dc78ebc614d872170f35e7adb74827 100644 (file)
@@ -83,7 +83,6 @@ $nl
 { $subsection with-return }
 "Reflecting the datastack:"
 { $subsection with-datastack }
-{ $subsection assert-depth }
 "Continuations serve as the building block for a number of higher-level abstractions, such as " { $link "errors" } " and " { $link "threads" } "."
 { $subsection "continuations.private" } ;
 
@@ -217,10 +216,6 @@ HELP: with-datastack
     { $example "USING: continuations math prettyprint ;" "{ 3 7 } [ + ] with-datastack ." "{ 10 }" }
 } ;
 
-HELP: assert-depth
-{ $values { "quot" "a quotation" } }
-{ $description "Runs a quotation. Throws an error if the quotation attempts to take input values from the stack, or leave outputs on the stack." } ;
-
 HELP: attempt-all
 { $values
      { "seq" sequence } { "quot" quotation }
index 37418b85f5adc672319e45338a94d380e8f6991b..051d28d8c23eeca8a60a31c5343c60e641927987 100644 (file)
@@ -1,8 +1,8 @@
-! Copyright (C) 2003, 2008 Slava Pestov.
+! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays vectors kernel kernel.private sequences
 namespaces make math splitting sorting quotations assocs
-combinators accessors ;
+combinators combinators.private accessors ;
 IN: continuations
 
 SYMBOL: error
@@ -73,7 +73,7 @@ C: <continuation> continuation
 
 <PRIVATE
 
-: (continue) ( continuation -- )
+: (continue) ( continuation -- )
     >continuation<
     set-catchstack
     set-namestack
@@ -81,19 +81,18 @@ C: <continuation> continuation
     [ set-datastack ] dip
     set-callstack ;
 
-: (continue-with) ( obj continuation -- )
-    swap 4 setenv
-    >continuation<
-    set-catchstack
-    set-namestack
-    set-retainstack
-    [ set-datastack drop 4 getenv f 4 setenv f ] dip
-    set-callstack ;
-
 PRIVATE>
 
 : continue-with ( obj continuation -- * )
-    [ (continue-with) ] 2 (throw) ;
+    [
+        swap 4 setenv
+        >continuation<
+        set-catchstack
+        set-namestack
+        set-retainstack
+        [ set-datastack drop 4 getenv f 4 setenv f ] dip
+        set-callstack
+    ] (( obj continuation -- * )) call-effect-unsafe ;
 
 : continue ( continuation -- * )
     f swap continue-with ;
@@ -111,12 +110,9 @@ SYMBOL: return-continuation
         [
             [ [ { } like set-datastack ] dip call datastack ] dip
             continue-with
-        ] 3 (throw)
+        ] (( stack quot continuation -- * )) call-effect-unsafe
     ] callcc1 2nip ;
 
-: assert-depth ( quot -- )
-    { } swap with-datastack { } assert= ; inline
-
 GENERIC: compute-restarts ( error -- seq )
 
 <PRIVATE
@@ -133,7 +129,7 @@ SYMBOL: thread-error-hook
     dup save-error
     catchstack* empty? [
         thread-error-hook get-global
-        [ 1 (throw) ] [ die ] if*
+        [ (( error -- * )) call-effect-unsafe ] [ die ] if*
     ] when
     c> continue-with ;
 
index d21132aebb7b9e37c7dcb5f84f535792fba000dd..142b9120a8d5c3692846013348dac3641b6c7904 100644 (file)
@@ -63,3 +63,6 @@ M: effect clone
 
 : shuffle ( stack shuffle -- newstack )
     shuffle-mapping swap nths ;
+
+: add-effect-input ( effect -- effect' )
+    [ in>> "obj" suffix ] [ out>> ] [ terminated?>> ] tri effect boa ;
index a009db76b1245e3186265d57db274dd3d96f4f3b..04dc42712ce027ff0d3648c7b6da12a7189f6afa 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: lexer sets sequences kernel splitting effects
 combinators arrays parser ;
@@ -26,3 +26,6 @@ ERROR: bad-effect ;
 : parse-effect ( end -- effect )
     parse-effect-tokens { "--" } split1 dup
     [ <effect> ] [ "Stack effect declaration must contain --" throw ] if ;
+
+: parse-call( ( accum word -- accum )
+    [ ")" parse-effect parsed ] dip parsed ;
\ No newline at end of file
index 0852459c34101c26cf1f891af5b9e49a64cd4f16..bf9cdb19f5de56506a91c7693bb7c51ef42a2bf0 100644 (file)
@@ -18,6 +18,6 @@ SYMBOL: current-method
 : with-method-definition ( method quot -- )
     over current-method set call current-method off ; inline
 
-: (M:) ( method def -- )
+: (M:) ( -- method def )
     CREATE-METHOD [ parse-definition ] with-method-definition ;
 
index 953340b985a5c064ece12fbc4516ba5e7b50e22d..5d8e88b85f5b2ee4a78109e618f868d8773cf913 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: continuations continuations.private kernel
 kernel.private sequences assocs namespaces namespaces.private ;
@@ -9,10 +9,10 @@ SYMBOL: init-hooks
 init-hooks global [ drop V{ } clone ] cache drop
 
 : do-init-hooks ( -- )
-    init-hooks get [ nip call ] assoc-each ;
+    init-hooks get [ nip call( -- ) ] assoc-each ;
 
 : add-init-hook ( quot name -- )
-    dup init-hooks get at [ over call ] unless
+    dup init-hooks get at [ over call( -- ) ] unless
     init-hooks get set-at ;
 
 : boot ( -- ) init-namespaces init-catchstack init-error-handler ;
index 2f0bb1063f80d4d7b46c7dcfc7efc17a1fe8e49c..4c91a519c6c93624710e77ec3991a0baf8d4118f 100644 (file)
@@ -39,7 +39,7 @@ M: object normalize-directory normalize-path ;
 
 : set-io-backend ( io-backend -- )
     io-backend set-global init-io init-stdio
-    "io.files" init-hooks get at call ;
+    "io.files" init-hooks get at call( -- ) ;
 
 ! Note that we have 'alien' in our using list so that the alien
 ! init hook runs before this one.
index cf4bf95db96afeff4a604aaccd53a2a18664cf9e..52529892f42008f2460e24a91391e1c83bef2a9a 100644 (file)
@@ -22,6 +22,8 @@ DEFER: 3dip
 ! Combinators
 GENERIC: call ( callable -- )
 
+GENERIC: execute ( word -- )
+
 DEFER: if
 
 : ? ( ? true false -- true/false )
@@ -235,7 +237,7 @@ GENERIC: boa ( ... class -- tuple )
 
 ! Error handling -- defined early so that other files can
 ! throw errors before continuations are loaded
-: throw ( error -- * ) 5 getenv [ die ] or 1 (throw) ;
+GENERIC: throw ( error -- * )
 
 ERROR: assert got expect ;
 
index 6b90abecede6d0608f7c899c7cca09fbb84c3a5e..adf1c8adcf84d377811804bb1f2a423b2ea5b8d8 100644 (file)
@@ -402,9 +402,7 @@ IN: parser.tests
     [ t ] [ "foo" "parser.tests" lookup symbol? ] unit-test
 ] times
 
-[ "vocab:parser/test/assert-depth.factor" run-file ]
-[ got>> { 1 2 3 } sequence= ]
-must-fail-with
+[ "vocab:parser/test/assert-depth.factor" run-file ] must-fail
 
 2 [
     [ ] [
index c68d453b154b8f0554aecf00584c75a121e42a9f..1f4d377b27ce599374cc7b72e2116dfa91eed77a 100644 (file)
@@ -1,11 +1,10 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
+! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays definitions generic assocs kernel math namespaces
-sequences strings vectors words words.symbol quotations io
-combinators sorting splitting math.parser effects continuations
-io.files vocabs io.encodings.utf8 source-files
-classes hashtables compiler.errors compiler.units accessors sets
-lexer vocabs.parser slots ;
+sequences strings vectors words words.symbol quotations io combinators
+sorting splitting math.parser effects continuations io.files vocabs
+io.encodings.utf8 source-files classes hashtables compiler.errors
+compiler.units accessors sets lexer vocabs.parser slots ;
 IN: parser
 
 : location ( -- loc )
@@ -90,9 +89,9 @@ SYMBOL: auto-use?
 
 ERROR: staging-violation word ;
 
-: execute-parsing ( word -- )
+: execute-parsing ( accum word -- accum )
     dup changed-definitions get key? [ staging-violation ] when
-    execute ;
+    execute( accum -- accum ) ;
 
 : scan-object ( -- object )
     scan-word dup parsing-word?
@@ -125,7 +124,7 @@ M: f parse-quotation \ ] parse-until >quotation ;
     [ f parse-until >quotation ] with-lexer ;
 
 : parse-lines ( lines -- quot )
-    lexer-factory get call (parse-lines) ;
+    lexer-factory get call( lines -- lexer ) (parse-lines) ;
 
 : parse-literal ( accum end quot -- accum )
     [ parse-until ] dip call parsed ; inline
@@ -214,7 +213,7 @@ print-use-hook [ [ ] ] initialize
     [
         V{ } clone amended-use set
         parse-lines
-        amended-use get empty? [ print-use-hook get call ] unless
+        amended-use get empty? [ print-use-hook get call( -- ) ] unless
     ] with-file-vocabs ;
 
 : parsing-file ( file -- )
@@ -288,7 +287,7 @@ print-use-hook [ [ ] ] initialize
     ] recover ;
 
 : run-file ( file -- )
-    [ parse-file call ] curry assert-depth ;
+    parse-file call( -- ) ;
 
 : ?run-file ( path -- )
     dup exists? [ run-file ] [ drop ] if ;
index 8c9d0b555794faa169b47962953c0db2e1bf2343..c6e58f659a5bd6e1d53d908d1135fd32590de84e 100644 (file)
@@ -29,7 +29,7 @@ name>char-hook [
 : unicode-escape ( str -- ch str' )
     "{" ?head-slice [
         CHAR: } over index cut-slice
-        [ >string name>char-hook get call ] dip
+        [ >string name>char-hook get call( name -- char ) ] dip
         rest-slice
     ] [
         6 cut-slice [ hex> ] dip
@@ -45,10 +45,10 @@ name>char-hook [
 : (parse-string) ( str -- m )
     dup [ "\"\\" member? ] find dup [
         [ cut-slice [ % ] dip rest-slice ] dip
-        dup CHAR: " = [
-            drop from>>
+        CHAR: " = [
+            from>>
         ] [
-            drop next-escape [ , ] dip (parse-string)
+            next-escape [ , ] dip (parse-string)
         ] if
     ] [
         "Unterminated string" throw
@@ -59,8 +59,8 @@ name>char-hook [
         [ swap tail-slice (parse-string) ] "" make swap
     ] change-lexer-column ;
 
-: (unescape-string) ( str -- str' )
-    dup [ CHAR: \\ = ] find [
+: (unescape-string) ( str -- )
+    CHAR: \\ over index dup [
         cut-slice [ % ] dip rest-slice
         next-escape [ , ] dip
         (unescape-string)
index 25b963c574331bd53b05c661ffbdbeef96bde2d5..1a61845fd183d50ce42f34f25cc0a43b03ab17cb 100644 (file)
@@ -770,3 +770,13 @@ HELP: call-next-method
 { POSTPONE: call-next-method (call-next-method) next-method } related-words
 
 { POSTPONE: << POSTPONE: >> } related-words
+
+HELP: call(
+{ $syntax "call( stack -- effect )" }
+{ $description "Calls the quotation on the top of the stack, asserting that it has the given stack effect. The quotation does not need to be known at compile time." } ;
+
+HELP: execute(
+{ $syntax "execute( stack -- effect )" }
+{ $description "Calls the word on the top of the stack, asserting that it has the given stack effect. The word does not need to be known at compile time." } ;
+
+{ POSTPONE: call( POSTPONE: execute( } related-words
\ No newline at end of file
index de3be98ceb28b201dd729e67daa1fc357561dcbc..d01a9ebb2c2422ed64e1c38c29d3efd288abaead 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien arrays byte-arrays definitions generic
 hashtables kernel math namespaces parser lexer sequences strings
@@ -80,7 +80,7 @@ IN: bootstrap.syntax
         scan {
             { [ dup length 1 = ] [ first ] }
             { [ "\\" ?head ] [ next-escape >string "" assert= ] }
-            [ name>char-hook get call ]
+            [ name>char-hook get call( name -- char ) ]
         } cond parsed
     ] define-syntax
 
@@ -231,7 +231,7 @@ IN: bootstrap.syntax
     "<<" [
         [
             \ >> parse-until >quotation
-        ] with-nested-compilation-unit call
+        ] with-nested-compilation-unit call( -- )
     ] define-syntax
 
     "call-next-method" [
@@ -246,4 +246,8 @@ IN: bootstrap.syntax
     "initial:" "syntax" lookup define-symbol
     
     "read-only" "syntax" lookup define-symbol
+
+    "call(" [ \ call-effect parse-call( ] define-syntax
+
+    "execute(" [ \ execute-effect parse-call( ] define-syntax
 ] with-compilation-unit
index 00c4df92a63ab88e07a07c9cc24a60920691cb89..4f9005e11061fed8915062e79b77c3d838be274f 100644 (file)
@@ -64,7 +64,7 @@ SYMBOL: load-help?
         +parsing+ >>source-loaded?
         dup vocab-source-path [ parse-file ] [ [ ] ] if*
         [ +parsing+ >>source-loaded? ] dip
-        [ % ] [ assert-depth ] if-bootstrapping
+        [ % ] [ call( -- ) ] if-bootstrapping
         +done+ >>source-loaded? drop
     ] [ ] [ f >>source-loaded? ] cleanup ;
 
@@ -90,7 +90,7 @@ PRIVATE>
 
 : run ( vocab -- )
     dup load-vocab vocab-main [
-        execute
+        execute( -- )
     ] [
         "The " write vocab-name write
         " vocabulary does not define an entry point." print
index 977eac2b35950846616337b3e498324813484a50..b9f38dfef3b6a0391efc445609ae2fc898003ec7 100644 (file)
@@ -105,4 +105,4 @@ M: vocab-spec forget* forget-vocab ;
 
 SYMBOL: load-vocab-hook ! ( name -- vocab )
 
-: load-vocab ( name -- vocab ) load-vocab-hook get call ;
\ No newline at end of file
+: load-vocab ( name -- vocab ) load-vocab-hook get call( name -- vocab ) ;
\ No newline at end of file
index cd11fb2db19b35e653d51dbcae5677b52a7d4ba0..c4a94f0a4cfae8ea4d50e91759141a7ceeeb6618 100755 (executable)
@@ -1,4 +1,4 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions graphs assocs kernel
 kernel.private slots.private math namespaces sequences strings
@@ -10,8 +10,6 @@ IN: words
 
 : set-word ( word -- ) \ word set-global ;
 
-GENERIC: execute ( word -- )
-
 M: word execute (execute) ;
 
 M: word <=>
index f6c00154bbd0b4b0e237d6b6402dcc623fd6f4f5..ee37b33fbff41b7765b82ea2c1009089458d2e55 100755 (executable)
@@ -17,7 +17,6 @@ colors
 colors.constants\r
 prettyprint\r
 vars\r
-call\r
 quotations\r
 io\r
 io.directories\r
index 44234bc4bc538242503e11d55e3664c9439630d2..ee63b14f3c27d999d6556881af3522ab5291957c 100644 (file)
@@ -79,7 +79,7 @@ IN: monads.tests
 LAZY: nats-from ( n -- list )
     dup 1+ nats-from cons ;
 
-: nats 0 nats-from ;
+: nats ( -- list ) 0 nats-from ;
 
 [ 3 ] [
     {
index e9ae1675323d53170bb47ccdd76739088b60c76e..6b35772596f92e59e06c18b8ff6055e19ab6720d 100644 (file)
@@ -6,7 +6,7 @@ shuffle ;
 IN: monads
 
 ! Functors
-GENERIC# fmap 1 ( functor quot -- functor' ) inline
+GENERIC# fmap 1 ( functor quot -- functor' )
 
 ! Monads
 
@@ -21,7 +21,7 @@ GENERIC: >>= ( mvalue -- quot )
 M: monad return monad-of return ;
 M: monad fail   monad-of fail   ;
 
-: bind ( mvalue quot -- mvalue' ) swap >>= call ;
+: bind ( mvalue quot -- mvalue' ) swap >>= call( quot -- mvalue ) ;
 : >>   ( mvalue k -- mvalue' ) '[ drop _ ] bind ;
 
 :: lift-m2 ( m1 m2 f monad -- m3 )
@@ -30,14 +30,14 @@ M: monad fail   monad-of fail   ;
 :: apply ( mvalue mquot monad -- result )
     mvalue [| value |
         mquot [| quot |
-            value quot call monad return
+            value quot call( value -- mvalue ) monad return
         ] bind
     ] bind ;
 
 M: monad fmap over '[ @ _ return ] bind ;
 
 ! 'do' notation
-: do ( quots -- result ) unclip dip [ bind ] each ;
+: do ( quots -- result ) unclip [ call( -- mvalue ) ] curry dip [ bind ] each ;
 
 ! Identity
 SINGLETON: identity-monad
@@ -51,7 +51,7 @@ M: identity monad-of drop identity-monad ;
 M: identity-monad return drop identity boa ;
 M: identity-monad fail   "Fail" throw ;
 
-M: identity >>= value>> '[ _ swap call ] ;
+M: identity >>= value>> '[ _ swap call( x -- y ) ] ;
 
 : run-identity ( identity -- value ) value>> ;
 
@@ -73,7 +73,7 @@ M: maybe-monad return drop just ;
 M: maybe-monad fail   2drop nothing ;
 
 M: nothing >>= '[ drop _ ] ;
-M: just    >>= value>> '[ _ swap call ] ;
+M: just    >>= value>> '[ _ swap call( x -- y ) ] ;
 
 : if-maybe ( maybe just-quot nothing-quot -- )
     pick nothing? [ 2nip call ] [ drop [ value>> ] dip call ] if ; inline
@@ -97,7 +97,7 @@ M: either-monad return  drop right ;
 M: either-monad fail    drop left ;
 
 M: left  >>= '[ drop _ ] ;
-M: right >>= value>> '[ _ swap call ] ;
+M: right >>= value>> '[ _ swap call( x -- y ) ] ;
 
 : if-either ( value left-quot right-quot -- )
     [ [ value>> ] [ left? ] bi ] 2dip if ; inline
@@ -140,14 +140,14 @@ M: state monad-of drop state-monad ;
 M: state-monad return drop '[ _ 2array ] state ;
 M: state-monad fail   "Fail" throw ;
 
-: mcall ( state -- ) quot>> call ;
+: mcall ( x state -- y ) quot>> call( x -- y ) ;
 
 M: state >>= '[ _ swap '[ _ mcall first2 @ mcall ] state ] ;
 
 : get-st ( -- state ) [ dup 2array ] state ;
 : put-st ( value -- state ) '[ drop _ f 2array ] state ;
 
-: run-st ( state initial -- ) swap mcall second ;
+: run-st ( state initial -- value ) swap mcall second ;
 
 : return-st ( value -- mvalue ) state-monad return ;
 
@@ -166,7 +166,7 @@ M: reader-monad fail   "Fail" throw ;
 
 M: reader >>= '[ _ swap '[ dup _ mcall @ mcall ] reader ] ;
 
-: run-reader ( reader env -- ) swap mcall ;
+: run-reader ( reader env -- value ) swap quot>> call( env -- value ) ;
 
 : ask ( -- reader ) [ ] reader ;
 : local ( reader quot -- reader' ) swap '[ @ _ mcall ] reader ;
@@ -187,6 +187,6 @@ M: writer-monad fail   "Fail" throw ;
 
 M: writer >>= '[ [ _ run-writer ] dip '[ @ run-writer ] dip append writer ] ;
 
-: pass ( writer -- writer' ) run-writer [ first2 ] dip swap call writer ;
+: pass ( writer -- writer' ) run-writer [ first2 ] dip swap call( x -- y ) writer ;
 : listen ( writer -- writer' ) run-writer [ 2array ] keep writer ;
 : tell ( seq -- writer ) f swap writer ;
index bec2761e5337327253fee9efc4c9af31fc1f1540..0e193741ebba35be1f1e7cad179dd691062fe385 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2006 Chris Double, Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays kernel sequences math vectors arrays namespaces call
+USING: arrays kernel sequences math vectors arrays namespaces
 make quotations parser effects stack-checker words accessors ;
 IN: promises
 
index 982aabe2e8c6f9217d7dfc4fe7603d66de01bfdd..d7301ca042b77539972e181abd05ff7d2b5669da 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors math.vectors classes.tuple math.rectangles colors
-kernel sequences models opengl math math.order namespaces call
+kernel sequences models opengl math math.order namespaces
 ui.commands ui.gestures ui.render ui.gadgets ui.gadgets.labels
 ui.gadgets.scrollers ui.gadgets.presentations ui.gadgets.viewports
 ui.gadgets.packs ;
index 68937980f6ed0667030c686a7c58b13ca4f4416a..3c13e7b1cdf39d47473872f40c8803c3eabf291b 100755 (executable)
@@ -14,8 +14,6 @@ CELL frame_scan(F_STACK_FRAME *frame);
 CELL frame_type(F_STACK_FRAME *frame);
 
 void primitive_callstack(void);
-void primitive_set_datastack(void);
-void primitive_set_retainstack(void);
 void primitive_set_callstack(void);
 void primitive_callstack_to_array(void);
 void primitive_innermost_stack_frame_quot(void);
index 36db5d6c80bcdc489db117f0ff4a162a0a610429..7a8e579c6227a282e9fb684b7b537f3a6a6bacdf 100755 (executable)
@@ -29,7 +29,7 @@ and the callstack top is passed in EDX */
        pop %ebp ; \
        pop %ebx
 
-#define QUOT_XT_OFFSET 9
+#define QUOT_XT_OFFSET 17
 
 /* We pass a function pointer to memcpy to work around a Mac OS X
 ABI limitation which would otherwise require us to do a bizzaro PC-relative
index 7b5b5f3167fdfb9eb0ef43bc4fa4b423b5cad0bc..8cf8fb9ae71ff0718761654a6f7dd9fa1bfbb8bf 100644 (file)
@@ -61,7 +61,7 @@
 
 #endif
 
-#define QUOT_XT_OFFSET 21
+#define QUOT_XT_OFFSET 37
 
 /* We pass a function pointer to memcpy to work around a Mac OS X
 ABI limitation which would otherwise require us to do a bizzaro PC-relative
index 7c06ec1310568a98a7058e1ff2bfa7a244a3e67e..9b7b7843d247fa4aac507490d269c37a1a006f73 100755 (executable)
@@ -144,12 +144,6 @@ void misc_signal_handler_impl(void)
        signal_error(signal_number,signal_callstack_top);
 }
 
-void primitive_throw(void)
-{
-       dpop();
-       throw_impl(dpop(),stack_chain->callstack_top);
-}
-
 void primitive_call_clear(void)
 {
        throw_impl(dpop(),stack_chain->callstack_bottom);
index c7f8bc8712a5a918235c5199f7dbd9f91949cd41..da3ee8bbe04bf04c3136acdb7799f8599925dabb 100755 (executable)
@@ -32,7 +32,6 @@ void signal_error(int signal, F_STACK_FRAME *native_stack);
 void type_error(CELL type, CELL tagged);
 void not_implemented_error(void);
 
-void primitive_throw(void);
 void primitive_call_clear(void);
 
 INLINE void type_check(CELL type, CELL tagged)
index 94e2f623a3190443d0c770be06197d9791a17e90..5b417f92ddd4306a0fd28d9968e0bf66d5c19e84 100755 (executable)
@@ -172,6 +172,10 @@ typedef struct {
        CELL array;
        /* tagged */
        CELL compiledp;
+       /* tagged */
+       CELL cached_effect;
+       /* tagged */
+       CELL cache_counter;
        /* UNTAGGED */
        XT xt;
        /* UNTAGGED compiled code block */
index 2bce9eedb7659d4e85fe829d784155d5600bc30d..00103ac0471c6bc31e2a369a2b5f8dc88271a53c 100755 (executable)
@@ -102,7 +102,6 @@ void *primitives[] = {
        primitive_set_alien_double,
        primitive_alien_cell,
        primitive_set_alien_cell,
-       primitive_throw,
        primitive_alien_address,
        primitive_set_slot,
        primitive_string_nth,
@@ -144,4 +143,5 @@ void *primitives[] = {
        primitive_clear_gc_stats,
        primitive_jit_compile,
        primitive_load_locals,
+       primitive_check_datastack
 };
index ca1a8bb3b56eefc291a13253a6734247f291432c..8ea2d5839bb94876db2b3178e7557d6a5fc3eaa5 100755 (executable)
@@ -514,6 +514,8 @@ void primitive_array_to_quotation(void)
        quot->array = dpeek();
        quot->xt = lazy_jit_compile;
        quot->compiledp = F;
+       quot->cached_effect = F;
+       quot->cache_counter = F;
        drepl(tag_object(quot));
 }
 
index c7002eb0ecaadcccd23f935ff72e9ff8af9fad9a..e55eb904a74c9c93a768eacba40c04b10fe294c6 100755 (executable)
--- a/vm/run.c
+++ b/vm/run.c
@@ -155,6 +155,32 @@ void primitive_set_retainstack(void)
        rs = array_to_stack(untag_array(dpop()),rs_bot);
 }
 
+/* Used to implement call( */
+void primitive_check_datastack(void)
+{
+       F_FIXNUM out = to_fixnum(dpop());
+       F_FIXNUM in = to_fixnum(dpop());
+       F_FIXNUM height = out - in;
+       F_ARRAY *array = untag_array(dpop());
+       F_FIXNUM length = array_capacity(array);
+       F_FIXNUM depth = (ds - ds_bot + CELLS) / CELLS;
+       if(depth - height != length)
+               dpush(F);
+       else
+       {
+               F_FIXNUM i;
+               for(i = 0; i < length - in; i++)
+               {
+                       if(get(ds_bot + i * CELLS) != array_nth(array,i))
+                       {
+                               dpush(F);
+                               return;
+                       }
+               }
+               dpush(T);
+       }
+}
+
 void primitive_getenv(void)
 {
        F_FIXNUM e = untag_fixnum_fast(dpeek());
index 06b631701508d282f0640a22d34e1709e26c2657..2acff2cd5acd0a3ac6021f919781b0f5df03e265 100755 (executable)
--- a/vm/run.h
+++ b/vm/run.h
@@ -236,6 +236,9 @@ void init_stacks(CELL ds_size, CELL rs_size);
 
 void primitive_datastack(void);
 void primitive_retainstack(void);
+void primitive_set_datastack(void);
+void primitive_set_retainstack(void);
+void primitive_check_datastack(void);
 void primitive_getenv(void);
 void primitive_setenv(void);
 void primitive_exit(void);