From 10ce5150d49b33056f2cce8dc7586010dc443490 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 31 Jan 2008 23:15:10 +0000 Subject: [PATCH] reference clarifications on immutable literals; JIT tweak svn: r8491 --- collects/scribblings/reference/reader.scrbl | 5 +++-- collects/scribblings/reference/syntax.scrbl | 19 ++++++++++++++----- .../mzscheme/benchmarks/shootout/nsieve.ss | 2 +- .../tests/mzscheme/benchmarks/shootout/run.ss | 15 +++++++++------ src/mzscheme/src/jit.c | 16 ++++++++++++++-- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/collects/scribblings/reference/reader.scrbl b/collects/scribblings/reference/reader.scrbl index ccf99c723c..5988cb26e0 100644 --- a/collects/scribblings/reference/reader.scrbl +++ b/collects/scribblings/reference/reader.scrbl @@ -553,7 +553,8 @@ is used for all slots. In @scheme[read-syntax] mode, each recursive read for the vector elements is also in @scheme[read-syntax] mode, so that the wrapped -vector's elements are also wraped as syntax objects. +vector's elements are also wraped as syntax objects, and the vector is +immutable. @reader-examples[ "#(1 apple 3)" @@ -598,7 +599,7 @@ datum. In @scheme[read-syntax] mode, the recursive read for the box content is also in @scheme[read-syntax] mode, so that the wrapped box's -content is also wraped as a syntax object. +content is also wraped as a syntax object, and the box is immutable. @reader-examples[ "#&17" diff --git a/collects/scribblings/reference/syntax.scrbl b/collects/scribblings/reference/syntax.scrbl index 3237101266..2faa19412a 100644 --- a/collects/scribblings/reference/syntax.scrbl +++ b/collects/scribblings/reference/syntax.scrbl @@ -54,30 +54,39 @@ Within such specifications, @;------------------------------------------------------------------------ @section[#:tag "quote"]{Literals: @scheme[quote] and @scheme[#%datum]} +Many forms are implicitly quoted (via @scheme[#%datum]) as literals. See +@secref["expand-steps"] for more information. + @guideintro["quote"]{@scheme[quote]} @defform[(quote datum)]{ Produces a constant value corresponding to @scheme[datum] (i.e., the -actual representation of the program fragment) without its -@tech{lexical information} or source location. +representation of the program fragment) without its @tech{lexical +information}, source location, etc. Quoted pairs, vectors, and boxes +are immutable. @examples[ (eval:alts (#,(schemekeywordfont "quote") x) 'x) (eval:alts (#,(schemekeywordfont "quote") (+ 1 2)) '(+ 1 2)) +(+ 1 2) ] } @defform[(#%datum . datum)]{ -Expands to @scheme[(#,(schemekeywordfont "quote") datum)]. See also @secref["expand-steps"] -for information on how the expander introduces @schemeidfont{#%datum} -identifiers. +Expands to @scheme[(#,(schemekeywordfont "quote") datum)], as long as +@scheme[datum] is not a keyword. If @scheme[datum] is a keyword, and +syntax error is reported. + +See also @secref["expand-steps"] for information on how the expander +introduces @schemeidfont{#%datum} identifiers. @examples[ (#%datum . 10) (#%datum . x) +(#%datum . #:x) ] } diff --git a/collects/tests/mzscheme/benchmarks/shootout/nsieve.ss b/collects/tests/mzscheme/benchmarks/shootout/nsieve.ss index 1386c675d6..d41208b70c 100644 --- a/collects/tests/mzscheme/benchmarks/shootout/nsieve.ss +++ b/collects/tests/mzscheme/benchmarks/shootout/nsieve.ss @@ -7,7 +7,7 @@ ;; Written by Dima Dorfman, 2004 ;; Converted to MzScheme by Brent Fulgham -(module nseive mzscheme +(module nsieve mzscheme (require (only (lib "13.ss" "srfi") string-index string-pad)) (define (nsieve m) diff --git a/collects/tests/mzscheme/benchmarks/shootout/run.ss b/collects/tests/mzscheme/benchmarks/shootout/run.ss index 2277a77123..39a822ab54 100644 --- a/collects/tests/mzscheme/benchmarks/shootout/run.ss +++ b/collects/tests/mzscheme/benchmarks/shootout/run.ss @@ -4,7 +4,7 @@ ("ackermann.ss" "11") ("ary.ss" "9000") ("binarytrees.ss" "16") - ("chameneos.ss") + ("chameneos.ss" "1000000") ("cheapconcurrency.ss" "15000") ("echo.ss" "150000") ("except.ss" "2500000") @@ -20,15 +20,15 @@ ("moments.ss") ; 200 somethings... ("nbody.ss" "20000000") ("nestedloop.ss" "18") - ("nsieve.ss") - ("nsievebits.ss") + ("nsieve.ss" "9") + ("nsievebits.ss" "11") ("partialsums.ss" "2500000") - ("pidigits.ss") + ("pidigits.ss" "2500") ("pidigits1.ss") ("random.ss" "900000") ("recursive.ss" "11") ("regexmatch.ss") - ("regexpdna.ss") + ("regexpdna.ss" #f ,(lambda () (mk-regexpdna-input))) ("reversecomplement.ss" #f ,(lambda () (mk-revcomp-input))) ("k-nucleotide.ss" #f ,(lambda () (mk-knuc-input))) ("reversefile.ss") @@ -42,7 +42,7 @@ )) (define (dynreq f) - (dynamic-require `(lib ,f "tests" "mzscheme" "benchmarks" "shootout") #f)) + (dynamic-require f #f)) (define (mk-fasta n suffix) (let ([f (build-path (find-system-path 'temp-dir) (string-append "fasta-" suffix))]) @@ -60,6 +60,9 @@ (define (mk-knuc-input) (mk-fasta "1000000" "1m")) + (define (mk-regexpdna-input) + (mk-fasta "5000000" "5m")) + (define (mk-sumcol-input) (let ([f (build-path (find-system-path 'temp-dir) "sumcol-21k")]) (unless (file-exists? f) diff --git a/src/mzscheme/src/jit.c b/src/mzscheme/src/jit.c index 5cb0b31f81..545363315c 100644 --- a/src/mzscheme/src/jit.c +++ b/src/mzscheme/src/jit.c @@ -156,8 +156,15 @@ typedef struct { void *self_restart_code; Scheme_Native_Closure *nc; /* for extract_globals, only */ Scheme_Closure_Data *self_data; + void *status_at_ptr; + int reg_status; } mz_jit_state; +#define mz_RECORD_STATUS(s) (jitter->status_at_ptr = _jit.x.pc, jitter->reg_status = (s)) +#define mz_CURRENT_STATUS() ((jitter->status_at_ptr == _jit.x.pc) ? jitter->reg_status : 0) + +#define mz_RS_R0_HAS_RUNSTACK0 0x1 + typedef int (*Native_Check_Arity_Proc)(Scheme_Object *o, int argc, int dummy); typedef Scheme_Object *(*Native_Get_Arity_Proc)(Scheme_Object *o, int dumm1, int dummy2); static Native_Check_Arity_Proc check_arity_code; @@ -434,6 +441,7 @@ static void *generate_one(mz_jit_state *old_jitter, jitter->max_extra_pushed = max_extra_pushed; jitter->self_pos = 1; /* beyond end of stack */ jitter->self_toplevel_pos = -1; + jitter->status_at_ptr = NULL; ok = generate(jitter, data); @@ -4562,8 +4570,10 @@ static int generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int m START_JIT_DATA(); LOG_IT(("local\n")); pos = mz_remap(SCHEME_LOCAL_POS(obj)); - jit_ldxi_p(JIT_R0, JIT_RUNSTACK, WORDS_TO_BYTES(pos)); - VALIDATE_RESULT(JIT_R0); + if (pos || (mz_CURRENT_STATUS() != mz_RS_R0_HAS_RUNSTACK0)) { + jit_ldxi_p(JIT_R0, JIT_RUNSTACK, WORDS_TO_BYTES(pos)); + VALIDATE_RESULT(JIT_R0); + } END_JIT_DATA(2); return 1; } @@ -5305,6 +5315,8 @@ static int generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int m LOG_IT(("...in\n")); + mz_RECORD_STATUS(mz_RS_R0_HAS_RUNSTACK0); + return generate(lv->body, jitter, is_tail, multi_ok); } case scheme_with_cont_mark_type: