vm: rename some primitives, and some cleanup.

* quot-compiled? => quotation-compiled?
* optimized? => word-optimized?
db4
John Benediktsson 2015-07-15 11:13:52 -07:00
parent 5f29e1c131
commit 4c2c8f133f
17 changed files with 66 additions and 59 deletions

View 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

View File

@ -32,7 +32,7 @@ gc
: compile-unoptimized ( words -- )
[ [ subwords ] map ] keep suffix concat
[ optimized? ] reject compile ;
[ word-optimized? ] reject compile ;
"debug-compiler" get [

View 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

View 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

View 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) ] }

View File

@ -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 ;

View File

@ -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 ) }

View 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 ( -- )

View 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 )

View 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 )

View 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;

View 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();
}
}

View 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. */

View 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) \

View 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 */

View File

@ -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();

View 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()));
}