]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: rename some primitives, and some cleanup.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 18:13:52 +0000 (11:13 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 18:13:52 +0000 (11:13 -0700)
* quot-compiled? => quotation-compiled?
* optimized? => word-optimized?

17 files changed:
basis/alien/remote-control/remote-control.factor
basis/bootstrap/compiler/compiler.factor
basis/compiler/tree/propagation/call-effect/call-effect.factor
basis/stack-checker/known-words/known-words.factor
basis/tools/continuations/continuations.factor
basis/tools/deploy/shaker/shaker.factor
core/bootstrap/primitives.factor
core/kernel/kernel.factor
core/quotations/quotations.factor
core/words/words.factor
vm/callstack.cpp
vm/code_blocks.cpp
vm/image.cpp
vm/primitives.hpp
vm/quotations.cpp
vm/vm.hpp
vm/words.cpp

index fabb4f7f49a09ff4db567467b984431c7bed5195..58161f50902756d2c35f5f36cd455e0a3923f584 100644 (file)
@@ -15,7 +15,7 @@ IN: alien.remote-control
     void { long } cdecl [ sleep ] alien-callback ;
 
 : ?callback ( word -- alien )
-    dup optimized? [ execute ] [ drop f ] if ; inline
+    dup word-optimized? [ execute ] [ drop f ] if ; inline
 
 : init-remote-control ( -- )
     \ eval-callback ?callback OBJ-EVAL-CALLBACK set-special-object
index 6ce7a3d44ef952d9d12fe1141eb0c835df9884e4..dd6ef784cb9b3b438d3b1c07cbb2f9f1578b88e8 100644 (file)
@@ -32,7 +32,7 @@ gc
 
 : compile-unoptimized ( words -- )
     [ [ subwords ] map ] keep suffix concat
-    [ optimized? ] reject compile ;
+    [ word-optimized? ] reject compile ;
 
 "debug-compiler" get [
 
index 16e75bee8dd9de30266b9e9c0feeac27f526bc62..361bb012867334eefd5c0b32b0258ee6d9999699 100644 (file)
@@ -91,7 +91,7 @@ M: quotation cached-effect
     [ '[ _ execute ] ] dip call-effect-slow ; inline
 
 : execute-effect-unsafe? ( word effect -- ? )
-    over optimized?
+    over word-optimized?
     [ [ stack-effect { effect } declare ] dip effect<= ]
     [ 2drop f ]
     if ; inline
index 3c04748488f7cfffee427f4413ee186674647a64..c3a0cc490eb7acc527cb71e1e5726981a9ae8382 100644 (file)
@@ -429,12 +429,11 @@ M: object infer-call* \ call bad-macro-input ;
 \ minor-gc { } { } define-primitive
 \ modify-code-heap { array object object } { } define-primitive
 \ nano-count { } { integer } define-primitive \ nano-count make-flushable
-\ optimized? { word } { object } define-primitive
 \ profiling { object } { } define-primitive
 \ (get-samples) { } { object } define-primitive
 \ (clear-samples) { } { } define-primitive
-\ quot-compiled? { quotation } { object } define-primitive
 \ quotation-code { quotation } { integer integer } define-primitive \ quotation-code make-flushable
+\ quotation-compiled? { quotation } { object } define-primitive
 \ reset-dispatch-stats { } { } define-primitive
 \ resize-array { integer array } { array } define-primitive
 \ resize-byte-array { integer byte-array } { byte-array } define-primitive
@@ -456,7 +455,7 @@ M: object infer-call* \ call bad-macro-input ;
 \ set-alien-unsigned-cell { integer c-ptr integer } { } define-primitive
 \ set-context-object { object fixnum } { } define-primitive
 \ set-fpu-state { } { } define-primitive
-\ set-innermost-frame-quot { quotation callstack } { } define-primitive
+\ set-innermost-frame-quotation { quotation callstack } { } define-primitive
 \ set-slot { object object fixnum } { } define-primitive
 \ set-special-object { object fixnum } { } define-primitive
 \ set-string-nth-fast { fixnum fixnum string } { } define-primitive
@@ -469,3 +468,4 @@ M: object infer-call* \ call bad-macro-input ;
 \ tag { object } { fixnum } define-primitive \ tag make-foldable
 \ unimplemented { } { } define-primitive
 \ word-code { word } { integer integer } define-primitive \ word-code make-flushable
+\ word-optimized? { word } { object } define-primitive
index 2760afe83e70f977658480e8e08bdd34fac71cb2..bc64fea98dbc13aafaaa056a9a19e5510968fcf1 100644 (file)
@@ -39,7 +39,7 @@ M: array add-breakpoint
 
 M: object add-breakpoint ;
 
-: (step-into-quot) ( quot -- ) add-breakpoint call ;
+: (step-into-quotation) ( quot -- ) add-breakpoint call ;
 
 : (step-into-dip) ( quot -- ) add-breakpoint dip ;
 
@@ -47,9 +47,9 @@ M: object add-breakpoint ;
 
 : (step-into-3dip) ( quot -- ) add-breakpoint 3dip ;
 
-: (step-into-if) ( true false ? -- ) ? (step-into-quot) ;
+: (step-into-if) ( true false ? -- ) ? (step-into-quotation) ;
 
-: (step-into-dispatch) ( array n -- ) nth (step-into-quot) ;
+: (step-into-dispatch) ( array n -- ) nth (step-into-quotation) ;
 
 : (step-into-execute) ( word -- )
     {
@@ -57,7 +57,7 @@ M: object add-breakpoint ;
         { [ dup single-generic? ] [ effective-method (step-into-execute) ] }
         { [ dup uses \ suspend swap member? ] [ execute break ] }
         { [ dup primitive? ] [ execute break ] }
-        [ def>> (step-into-quot) ]
+        [ def>> (step-into-quotation) ]
     } cond ;
 
 \ (step-into-execute) t "step-into?" set-word-prop
@@ -66,10 +66,10 @@ M: object add-breakpoint ;
     current-continuation callstack >>call break ;
 
 : (step-into-call-next-method) ( method -- )
-    next-method-quot (step-into-quot) ;
+    next-method-quot (step-into-quotation) ;
 
 << {
-    (step-into-quot)
+    (step-into-quotation)
     (step-into-dip)
     (step-into-2dip)
     (step-into-3dip)
@@ -85,7 +85,10 @@ M: object add-breakpoint ;
 
 : (change-frame) ( callstack quot -- callstack' )
     [ dup innermost-frame-executing quotation? ] dip '[
-        clone [ >innermost-frame< @ ] [ set-innermost-frame-quot ] [ ] tri
+        clone
+        [ >innermost-frame< @ ]
+        [ set-innermost-frame-quotation ]
+        [ ] tri
     ] when ; inline
 
 : change-frame ( continuation quot -- continuation' )
@@ -108,7 +111,7 @@ PRIVATE>
     [ nip \ break suffix ] change-frame ;
 
 {
-    { call [ (step-into-quot) ] }
+    { call [ (step-into-quotation) ] }
     { dip [ (step-into-dip) ] }
     { 2dip [ (step-into-2dip) ] }
     { 3dip [ (step-into-3dip) ] }
index a4763d6d90e1a5499a08941b80e78a4db7e3d9ba..36bb513ee892296f6667226900c4c868609a5682 100755 (executable)
@@ -474,7 +474,7 @@ IN: tools.deploy.shaker
     ! Quotations which were formerly compiled must remain
     ! compiled.
     2dup [
-        2dup [ quot-compiled? ] [ quot-compiled? not ] bi* and
+        2dup [ quotation-compiled? ] [ quotation-compiled? not ] bi* and
         [ nip jit-compile ] [ 2drop ] if
     ] 2each ;
 
index 1d83b10f0dc1f1b04399f5f7fb84bec3da458038..e7a0bbed7d63353cdb66e2b471230d5cc0d34a01 100755 (executable)
@@ -466,7 +466,7 @@ tuple
     { "innermost-frame-scan" "kernel.private" "primitive_innermost_stack_frame_scan" ( callstack -- n ) }
     { "set-context-object" "kernel.private" "primitive_set_context_object" ( obj n -- ) }
     { "set-datastack" "kernel.private" "primitive_set_datastack" ( array -- ) }
-    { "set-innermost-frame-quot" "kernel.private" "primitive_set_innermost_stack_frame_quot" ( n callstack -- ) }
+    { "set-innermost-frame-quotation" "kernel.private" "primitive_set_innermost_stack_frame_quotation" ( n callstack -- ) }
     { "set-retainstack" "kernel.private" "primitive_set_retainstack" ( array -- ) }
     { "set-special-object" "kernel.private" "primitive_set_special_object" ( obj n -- ) }
     { "special-object" "kernel.private" "primitive_special_object" ( n -- obj ) }
@@ -532,8 +532,8 @@ tuple
     { "size" "memory" "primitive_size" ( obj -- n ) }
     { "(save-image)" "memory.private" "primitive_save_image" ( path1 path2 then-die? -- ) }
     { "jit-compile" "quotations" "primitive_jit_compile" ( quot -- ) }
-    { "quot-compiled?" "quotations" "primitive_quot_compiled_p" ( quot -- ? ) }
     { "quotation-code" "quotations" "primitive_quotation_code" ( quot -- start end ) }
+    { "quotation-compiled?" "quotations" "primitive_quotation_compiled_p" ( quot -- ? ) }
     { "array>quotation" "quotations.private" "primitive_array_to_quotation" ( array -- quot ) }
     { "set-slot" "slots.private" "primitive_set_slot" ( value obj n -- ) }
     { "<string>" "strings" "primitive_string" ( n ch -- string ) }
@@ -548,8 +548,8 @@ tuple
     { "retainstack-for" "threads.private" "primitive_retainstack_for" ( context -- array ) }
     { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" ( -- stats ) }
     { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" ( -- ) }
-    { "optimized?" "words" "primitive_optimized_p" ( word -- ? ) }
     { "word-code" "words" "primitive_word_code" ( word -- start end ) }
+    { "word-optimized?" "words" "primitive_word_optimized_p" ( word -- ? ) }
     { "(word)" "words.private" "primitive_word" ( name vocab hashcode -- word ) }
     { "profiling" "tools.profiler.sampling.private" "primitive_sampling_profiler" ( ? -- ) }
     { "(get-samples)" "tools.profiler.sampling.private" "primitive_get_samples" ( -- samples/f ) }
index 1f83aeb316eb05cbb6fd17ceaaaf77251e499041..d73d480d80f6184e46b6e2443195b1eb5e991697 100644 (file)
@@ -55,7 +55,7 @@ PRIMITIVE: set-callstack ( callstack -- * )
 PRIMITIVE: set-context-object ( obj n -- )
 PRIMITIVE: set-datastack ( array -- )
 PRIMITIVE: set-fpu-state ( -- )
-PRIMITIVE: set-innermost-frame-quot ( n callstack -- )
+PRIMITIVE: set-innermost-frame-quotation ( n callstack -- )
 PRIMITIVE: set-retainstack ( array -- )
 PRIMITIVE: set-special-object ( obj n -- )
 PRIMITIVE: signal-handler ( -- )
index 1cf8f6ff6478a11fd3749acc2e41ac8f6398d292..b4817bf81c89fbdaf54e6d652e53c4fb9ffad2b8 100644 (file)
@@ -10,8 +10,8 @@ BUILTIN: quotation
     cache-counter ;
 
 PRIMITIVE: jit-compile ( quot -- )
-PRIMITIVE: quot-compiled? ( quot -- ? )
 PRIMITIVE: quotation-code ( quot -- start end )
+PRIMITIVE: quotation-compiled? ( quot -- ? )
 
 <PRIVATE
 PRIMITIVE: array>quotation ( array -- quot )
index 8c7946e2bb53611de0e6a05d4a9f1c92483fab80..6e1fb31bac281cde567aebe6fb72964c8547d39f 100644 (file)
@@ -11,8 +11,8 @@ BUILTIN: word
 { def quotation initial: [ ] } props pic-def pic-tail-def
 { sub-primitive read-only } ;
 
-PRIMITIVE: optimized? ( word -- ? )
 PRIMITIVE: word-code ( word -- start end )
+PRIMITIVE: word-optimized? ( word -- ? )
 
 <PRIVATE
 PRIMITIVE: (word) ( name vocab hashcode -- word )
index 7ead848d79f34250b4acb7f5b41228cf83e660b1..46570df6cfc6ae4b6526e2105c7b21ac0feaf8ac 100644 (file)
@@ -106,15 +106,15 @@ void factor_vm::primitive_innermost_stack_frame_scan() {
   ctx->replace(code->code_block_for_address(addr)->scan(this, addr));
 }
 
-/* Allocates memory (jit_compile_quot) */
-void factor_vm::primitive_set_innermost_stack_frame_quot() {
+/* Allocates memory (jit_compile_quotation) */
+void factor_vm::primitive_set_innermost_stack_frame_quotation() {
   data_root<callstack> stack(ctx->pop(), this);
   data_root<quotation> quot(ctx->pop(), this);
 
   stack.untag_check(this);
   quot.untag_check(this);
 
-  jit_compile_quot(quot.value(), true);
+  jit_compile_quotation(quot.value(), true);
 
   void* inner = stack->top();
   cell addr = *(cell*)inner;
index f5f8b3be2d6223fcd21be8c8624311e684073436..af992de54563c2be8f06397643fd22f8e41cebcf 100644 (file)
@@ -43,7 +43,7 @@ cell factor_vm::compute_entry_point_pic_address(word* w, cell tagged_quot) {
     return w->entry_point;
   else {
     quotation* quot = untag<quotation>(tagged_quot);
-    if (quot_compiled_p(quot))
+    if (quotation_compiled_p(quot))
       return quot->entry_point;
     else
       return w->entry_point;
@@ -486,6 +486,7 @@ void factor_vm::undefined_symbol() {
     general_error(ERROR_UNDEFINED_SYMBOL, symbol, library);
 }
 
-void undefined_symbol() { return current_vm()->undefined_symbol(); }
-
+void undefined_symbol() {
+  return current_vm()->undefined_symbol();
+}
 }
index 2bb653c1d3a1ea754808a7b9af9f66835be1c4d2..972b30c1aa563b92692d478e2e52bd14a60e93ff 100644 (file)
@@ -300,8 +300,8 @@ void factor_vm::primitive_save_image() {
      where we might throw an error, so we have to throw an error here since
      later steps destroy the current image. */
   bool then_die = to_boolean(ctx->pop());
-  byte_array* path2 = tagged<byte_array>(ctx->pop()).untag_check(this);
-  byte_array* path1 = tagged<byte_array>(ctx->pop()).untag_check(this);
+  byte_array* path2 = untag_check<byte_array>(ctx->pop());
+  byte_array* path1 = untag_check<byte_array>(ctx->pop());
 
   /* Copy the paths to non-gc memory to avoid them hanging around in
      the saved image. */
index 7bb89f36a2ddc4363ffb1c4dce8d46c80d6e57ff..0209a4e6f64486256745db9aa82c7b6e29359cc2 100644 (file)
@@ -27,15 +27,16 @@ namespace factor {
       _(full_gc) _(fwrite) _(get_samples) _(identity_hashcode)                 \
       _(innermost_stack_frame_executing) _(innermost_stack_frame_scan)         \
       _(jit_compile) _(load_locals) _(lookup_method) _(mega_cache_miss)        \
-      _(minor_gc) _(modify_code_heap) _(nano_count) _(optimized_p)             \
-      _(quot_compiled_p) _(quotation_code) _(reset_dispatch_stats)             \
-      _(resize_array) _(resize_byte_array) _(resize_string) _(retainstack)     \
-      _(retainstack_for) _(sampling_profiler) _(save_image)                    \
-      _(set_context_object) _(set_datastack) _(set_innermost_stack_frame_quot) \
+      _(minor_gc) _(modify_code_heap) _(nano_count) _(quotation_code)          \
+      _(quotation_compiled_p) _(reset_dispatch_stats) _(resize_array)          \
+      _(resize_byte_array) _(resize_string) _(retainstack) _(retainstack_for)  \
+      _(sampling_profiler) _(save_image) _(set_context_object)                 \
+      _(set_datastack) _(set_innermost_stack_frame_quotation)                  \
       _(set_retainstack) _(set_slot) _(set_special_object)                     \
       _(set_string_nth_fast) _(size) _(sleep) _(special_object) _(string)      \
       _(strip_stack_traces) _(tuple) _(tuple_boa) _(unimplemented)             \
-      _(uninitialized_byte_array) _(word) _(word_code) _(wrapper)
+      _(uninitialized_byte_array) _(word) _(word_code) _(word_optimized_p)     \
+      _(wrapper)
 
 #define EACH_ALIEN_PRIMITIVE(_)                               \
   _(signed_cell, fixnum, from_signed_cell, to_fixnum)         \
index 45f3aa074f7892aed20d5dab3479774100bfc264..88b0d227953316d99b9c8ace72ac22c46d0c7bc1 100644 (file)
@@ -167,7 +167,7 @@ void quotation_jit::emit_quot(cell quot_) {
     literal(array_nth(elements, 0));
   else {
     if (compiling)
-      parent->jit_compile_quot(quot.value(), relocate);
+      parent->jit_compile_quotation(quot.value(), relocate);
     literal(quot.value());
   }
 }
@@ -300,8 +300,8 @@ cell quotation_jit::word_stack_frame_size(cell obj) {
 }
 
 /* Allocates memory */
-code_block* factor_vm::jit_compile_quot(cell owner_, cell quot_,
-                                        bool relocating) {
+code_block* factor_vm::jit_compile_quotation(cell owner_, cell quot_,
+                                             bool relocating) {
   data_root<object> owner(owner_, this);
   data_root<quotation> quot(quot_, this);
 
@@ -320,17 +320,19 @@ code_block* factor_vm::jit_compile_quot(cell owner_, cell quot_,
 }
 
 /* Allocates memory */
-void factor_vm::jit_compile_quot(cell quot_, bool relocating) {
+void factor_vm::jit_compile_quotation(cell quot_, bool relocating) {
   data_root<quotation> quot(quot_, this);
-  if (!quot_compiled_p(quot.untagged())) {
+  if (!quotation_compiled_p(quot.untagged())) {
     code_block* compiled =
-        jit_compile_quot(quot.value(), quot.value(), relocating);
+        jit_compile_quotation(quot.value(), quot.value(), relocating);
     quot.untagged()->entry_point = compiled->entry_point();
   }
 }
 
 /* Allocates memory */
-void factor_vm::primitive_jit_compile() { jit_compile_quot(ctx->pop(), true); }
+void factor_vm::primitive_jit_compile() {
+  jit_compile_quotation(ctx->pop(), true);
+}
 
 cell factor_vm::lazy_jit_compile_entry_point() {
   return untag<word>(special_objects[LAZY_JIT_COMPILE_WORD])->entry_point;
@@ -374,9 +376,10 @@ fixnum factor_vm::quot_code_offset_to_scan(cell quot_, cell offset) {
 cell factor_vm::lazy_jit_compile(cell quot_) {
   data_root<quotation> quot(quot_, this);
 
-  FACTOR_ASSERT(!quot_compiled_p(quot.untagged()));
+  FACTOR_ASSERT(!quotation_compiled_p(quot.untagged()));
 
-  code_block* compiled = jit_compile_quot(quot.value(), quot.value(), true);
+  code_block* compiled =
+      jit_compile_quotation(quot.value(), quot.value(), true);
   quot.untagged()->entry_point = compiled->entry_point();
 
   return quot.value();
@@ -387,15 +390,14 @@ VM_C_API cell lazy_jit_compile(cell quot, factor_vm* parent) {
   return parent->lazy_jit_compile(quot);
 }
 
-bool factor_vm::quot_compiled_p(quotation* quot) {
+bool factor_vm::quotation_compiled_p(quotation* quot) {
   return quot->entry_point != 0 &&
          quot->entry_point != lazy_jit_compile_entry_point();
 }
 
-void factor_vm::primitive_quot_compiled_p() {
-  tagged<quotation> quot(ctx->pop());
-  quot.untag_check(this);
-  ctx->push(tag_boolean(quot_compiled_p(quot.untagged())));
+void factor_vm::primitive_quotation_compiled_p() {
+  quotation* quot = untag_check<quotation>(ctx->pop());
+  ctx->push(tag_boolean(quotation_compiled_p(quot)));
 }
 
 /* Allocates memory */
index 8529ff6e244b536d0708410d8fe309e364120afe..d1120a6fab784011fa4ba399ffe10f96212042ff 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -450,7 +450,7 @@ struct factor_vm {
   word* allot_word(cell name_, cell vocab_, cell hashcode_);
   void primitive_word();
   void primitive_word_code();
-  void primitive_optimized_p();
+  void primitive_word_optimized_p();
   void primitive_wrapper();
   void jit_compile_word(cell word_, cell def_, bool relocating);
   cell find_all_words();
@@ -630,7 +630,7 @@ struct factor_vm {
   void primitive_callstack_to_array();
   void primitive_innermost_stack_frame_executing();
   void primitive_innermost_stack_frame_scan();
-  void primitive_set_innermost_stack_frame_quot();
+  void primitive_set_innermost_stack_frame_quotation();
   void primitive_callstack_bounds();
 
   template <typename Iterator, typename Fixup>
@@ -660,12 +660,12 @@ struct factor_vm {
   cell lazy_jit_compile_entry_point();
   void primitive_array_to_quotation();
   void primitive_quotation_code();
-  code_block* jit_compile_quot(cell owner_, cell quot_, bool relocating);
-  void jit_compile_quot(cell quot_, bool relocating);
+  code_block* jit_compile_quotation(cell owner_, cell quot_, bool relocating);
+  void jit_compile_quotation(cell quot_, bool relocating);
   fixnum quot_code_offset_to_scan(cell quot_, cell offset);
   cell lazy_jit_compile(cell quot);
-  bool quot_compiled_p(quotation* quot);
-  void primitive_quot_compiled_p();
+  bool quotation_compiled_p(quotation* quot);
+  void primitive_quotation_compiled_p();
   cell find_all_quotations();
   void initialize_all_quotations();
 
index 68daf0732a9c886d3fd8f52e9ec932947f5058dc..f171868d0e34d3d174bd13d95ddb60705ff399e7 100644 (file)
@@ -15,13 +15,13 @@ void factor_vm::jit_compile_word(cell word_, cell def_, bool relocating) {
     return;
 
   code_block* compiled =
-      jit_compile_quot(word.value(), def.value(), relocating);
+      jit_compile_quotation(word.value(), def.value(), relocating);
   word->entry_point = compiled->entry_point();
 
   if (to_boolean(word->pic_def))
-    jit_compile_quot(word->pic_def, relocating);
+    jit_compile_quotation(word->pic_def, relocating);
   if (to_boolean(word->pic_tail_def))
-    jit_compile_quot(word->pic_tail_def, relocating);
+    jit_compile_quotation(word->pic_tail_def, relocating);
 }
 
 /* Allocates memory */
@@ -81,7 +81,7 @@ void factor_vm::primitive_word_code() {
   ctx->push(from_unsigned_cell((cell)w->code() + w->code()->size()));
 }
 
-void factor_vm::primitive_optimized_p() {
+void factor_vm::primitive_word_optimized_p() {
   word* w = untag_check<word>(ctx->peek());
   ctx->replace(tag_boolean(w->code()->optimized_p()));
 }