Fixing walker, adding traceback tests
parent
eeb2133ba2
commit
1d6e389d18
|
@ -17,7 +17,11 @@ IN: tools.walker.tests
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ { "Yo" 2 } ] [
|
[ { "Yo" 2 } ] [
|
||||||
[ 2 >r "Yo" r> ] test-walker
|
[ 2 [ "Yo" ] dip ] test-walker
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ { "Yo" 2 3 } ] [
|
||||||
|
[ 2 [ "Yo" ] dip 3 ] test-walker
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ { 2 } ] [
|
[ { 2 } ] [
|
||||||
|
|
|
@ -64,6 +64,12 @@ M: object add-breakpoint ;
|
||||||
|
|
||||||
: (step-into-quot) ( quot -- ) add-breakpoint call ;
|
: (step-into-quot) ( quot -- ) add-breakpoint call ;
|
||||||
|
|
||||||
|
: (step-into-dip) ( quot -- ) add-breakpoint dip ;
|
||||||
|
|
||||||
|
: (step-into-2dip) ( quot -- ) add-breakpoint 2dip ;
|
||||||
|
|
||||||
|
: (step-into-3dip) ( quot -- ) add-breakpoint 3dip ;
|
||||||
|
|
||||||
: (step-into-if) ( true false ? -- ) ? (step-into-quot) ;
|
: (step-into-if) ( true false ? -- ) ? (step-into-quot) ;
|
||||||
|
|
||||||
: (step-into-dispatch) ( array n -- ) nth (step-into-quot) ;
|
: (step-into-dispatch) ( array n -- ) nth (step-into-quot) ;
|
||||||
|
@ -130,6 +136,9 @@ SYMBOL: +stopped+
|
||||||
|
|
||||||
{
|
{
|
||||||
{ call [ (step-into-quot) ] }
|
{ call [ (step-into-quot) ] }
|
||||||
|
{ dip [ (step-into-dip) ] }
|
||||||
|
{ 2dip [ (step-into-2dip) ] }
|
||||||
|
{ 3dip [ (step-into-3dip) ] }
|
||||||
{ (throw) [ drop (step-into-quot) ] }
|
{ (throw) [ drop (step-into-quot) ] }
|
||||||
{ execute [ (step-into-execute) ] }
|
{ execute [ (step-into-execute) ] }
|
||||||
{ if [ (step-into-if) ] }
|
{ if [ (step-into-if) ] }
|
||||||
|
@ -152,13 +161,16 @@ SYMBOL: +stopped+
|
||||||
: step-into-msg ( continuation -- continuation' )
|
: step-into-msg ( continuation -- continuation' )
|
||||||
[
|
[
|
||||||
swap cut [
|
swap cut [
|
||||||
swap % unclip {
|
swap %
|
||||||
{ [ dup \ break eq? ] [ , ] }
|
[ \ break , ] [
|
||||||
{ [ dup quotation? ] [ add-breakpoint , \ break , ] }
|
unclip {
|
||||||
{ [ dup array? ] [ add-breakpoint , \ break , ] }
|
{ [ dup \ break eq? ] [ , ] }
|
||||||
{ [ dup word? ] [ literalize , \ (step-into-execute) , ] }
|
{ [ dup quotation? ] [ add-breakpoint , \ break , ] }
|
||||||
[ , \ break , ]
|
{ [ dup array? ] [ add-breakpoint , \ break , ] }
|
||||||
} cond %
|
{ [ dup word? ] [ literalize , \ (step-into-execute) , ] }
|
||||||
|
[ , \ break , ]
|
||||||
|
} cond %
|
||||||
|
] if-empty
|
||||||
] [ ] make
|
] [ ] make
|
||||||
] change-frame ;
|
] change-frame ;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
USING: arrays byte-arrays kernel kernel.private math memory
|
USING: arrays byte-arrays kernel kernel.private math memory
|
||||||
namespaces sequences tools.test math.private quotations
|
namespaces sequences tools.test math.private quotations
|
||||||
continuations prettyprint io.streams.string debugger assocs
|
continuations prettyprint io.streams.string debugger assocs
|
||||||
sequences.private ;
|
sequences.private accessors ;
|
||||||
IN: kernel.tests
|
IN: kernel.tests
|
||||||
|
|
||||||
[ 0 ] [ f size ] unit-test
|
[ 0 ] [ f size ] unit-test
|
||||||
|
@ -124,3 +124,42 @@ IN: kernel.tests
|
||||||
[ [ sq ] tri@ ] must-infer
|
[ [ sq ] tri@ ] must-infer
|
||||||
|
|
||||||
[ 4 ] [ 1 { [ 1 ] [ 2 ] } dispatch sq ] unit-test
|
[ 4 ] [ 1 { [ 1 ] [ 2 ] } dispatch sq ] unit-test
|
||||||
|
|
||||||
|
! Test traceback accuracy
|
||||||
|
: last-frame ( -- pair )
|
||||||
|
error-continuation get call>> callstack>array 4 head* 2 tail* ;
|
||||||
|
|
||||||
|
[
|
||||||
|
{ [ 1 2 [ 3 throw ] call 4 ] 3 }
|
||||||
|
] [
|
||||||
|
[ [ 1 2 [ 3 throw ] call 4 ] call ] ignore-errors
|
||||||
|
last-frame
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[
|
||||||
|
{ [ 1 2 [ 3 throw ] dip 4 ] 3 }
|
||||||
|
] [
|
||||||
|
[ [ 1 2 [ 3 throw ] dip 4 ] call ] ignore-errors
|
||||||
|
last-frame
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[
|
||||||
|
{ [ 1 2 3 throw [ ] call 4 ] 3 }
|
||||||
|
] [
|
||||||
|
[ [ 1 2 3 throw [ ] call 4 ] call ] ignore-errors
|
||||||
|
last-frame
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[
|
||||||
|
{ [ 1 2 3 throw [ ] dip 4 ] 3 }
|
||||||
|
] [
|
||||||
|
[ [ 1 2 3 throw [ ] dip 4 ] call ] ignore-errors
|
||||||
|
last-frame
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[
|
||||||
|
{ [ 1 2 3 throw [ ] [ ] if 4 ] 3 }
|
||||||
|
] [
|
||||||
|
[ [ 1 2 3 throw [ ] [ ] if 4 ] call ] ignore-errors
|
||||||
|
last-frame
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -348,8 +348,10 @@ worse than the duplication itself (eg, putting all state in some global
|
||||||
struct.) */
|
struct.) */
|
||||||
#define COUNT(name,scan) \
|
#define COUNT(name,scan) \
|
||||||
{ \
|
{ \
|
||||||
|
CELL size = array_capacity(code_to_emit(name)) * code_format; \
|
||||||
if(offset == 0) return scan - 1; \
|
if(offset == 0) return scan - 1; \
|
||||||
offset -= array_capacity(code_to_emit(name)) * code_format; \
|
if(offset < size) return scan + 1; \
|
||||||
|
offset -= size; \
|
||||||
}
|
}
|
||||||
|
|
||||||
F_FIXNUM quot_code_offset_to_scan(CELL quot, F_FIXNUM offset)
|
F_FIXNUM quot_code_offset_to_scan(CELL quot, F_FIXNUM offset)
|
||||||
|
@ -411,29 +413,28 @@ F_FIXNUM quot_code_offset_to_scan(CELL quot, F_FIXNUM offset)
|
||||||
if(stack_frame)
|
if(stack_frame)
|
||||||
COUNT(userenv[JIT_EPILOG],i)
|
COUNT(userenv[JIT_EPILOG],i)
|
||||||
|
|
||||||
i += 2;
|
|
||||||
|
|
||||||
COUNT(userenv[JIT_IF_JUMP],i)
|
COUNT(userenv[JIT_IF_JUMP],i)
|
||||||
|
i += 2;
|
||||||
|
|
||||||
tail_call = true;
|
tail_call = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(jit_fast_dip_p(untag_object(array),i))
|
else if(jit_fast_dip_p(untag_object(array),i))
|
||||||
{
|
{
|
||||||
i++;
|
|
||||||
COUNT(userenv[JIT_DIP],i)
|
COUNT(userenv[JIT_DIP],i)
|
||||||
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(jit_fast_2dip_p(untag_object(array),i))
|
else if(jit_fast_2dip_p(untag_object(array),i))
|
||||||
{
|
{
|
||||||
i++;
|
|
||||||
COUNT(userenv[JIT_2DIP],i)
|
COUNT(userenv[JIT_2DIP],i)
|
||||||
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(jit_fast_3dip_p(untag_object(array),i))
|
else if(jit_fast_3dip_p(untag_object(array),i))
|
||||||
{
|
{
|
||||||
i++;
|
|
||||||
COUNT(userenv[JIT_3DIP],i)
|
COUNT(userenv[JIT_3DIP],i)
|
||||||
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ARRAY_TYPE:
|
case ARRAY_TYPE:
|
||||||
|
|
Loading…
Reference in New Issue