From 817bc02392dd2e3f7e6fdfbc6e35475a52e0edeb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 29 Jan 2010 20:15:19 +1300 Subject: [PATCH] compiler.tree.propagation.call-effect: clear out dependency tracking variables to ensure that infer calls made by call( as part of the compile process doesn't pollute the dependencies of the word being compiled --- .../tree/propagation/call-effect/call-effect.factor | 13 +++++++++---- .../stack-checker/dependencies/dependencies.factor | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/basis/compiler/tree/propagation/call-effect/call-effect.factor b/basis/compiler/tree/propagation/call-effect/call-effect.factor index 04320ee792..0feeb211a0 100644 --- a/basis/compiler/tree/propagation/call-effect/call-effect.factor +++ b/basis/compiler/tree/propagation/call-effect/call-effect.factor @@ -2,14 +2,19 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays combinators combinators.private effects fry kernel kernel.private make sequences continuations -quotations words math stack-checker combinators.short-circuit -stack-checker.transforms compiler.tree.propagation.info +quotations words math stack-checker stack-checker.dependencies +combinators.short-circuit stack-checker.transforms +compiler.tree.propagation.info compiler.tree.propagation.inlining compiler.units ; IN: compiler.tree.propagation.call-effect ! call( and execute( have complex expansions. -! call( uses the following strategy: +! If the input quotation is a literal, or built up from curry and +! compose with terminal quotations literal, it is inlined at the +! call site. + +! For dynamic call sites, 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. @@ -58,7 +63,7 @@ M: compose cached-effect [ first>> ] [ second>> ] bi [ cached-effect ] bi@ compose-effects* ; : safe-infer ( quot -- effect ) - [ infer ] [ 2drop +unknown+ ] recover ; + [ [ infer ] [ 2drop +unknown+ ] recover ] without-dependencies ; : cached-effect-valid? ( quot -- ? ) cache-counter>> effect-counter eq? ; inline diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index d3cda71478..74cc5f32d4 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -35,3 +35,10 @@ SYMBOL: generic-dependencies : depends-on-generic ( class generic -- ) generic-dependencies get dup [ [ ?class-or ] change-at ] [ 3drop ] if ; + +: without-dependencies ( quot -- ) + [ + dependencies off + generic-dependencies off + call + ] with-scope ; inline