summaryrefslogtreecommitdiff
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-05-11 13:27:50 -0400
committerAdrian Thurston <thurston@colm.net>2018-05-11 13:27:50 -0400
commit316f164db25fac2f2837c7a2a16bca646b2b9cbc (patch)
tree03cec255051d011db6aaa507fa70ce11e31d5c0e /src/bytecode.c
parent4e30cb2e2e135bc51b8896ba381a9bc6501c67d0 (diff)
downloadcolm-316f164db25fac2f2837c7a2a16bca646b2b9cbc.tar.gz
track at runtime if revert is enabled
This works for some instructions only. Sometimes we have revert enabled, but need to use non-revert instructions since the objects are local to the runtime stack. For other instructions we will take advantage of the availability of a revert state bit in order to simplify the implementation.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index c4bc1324..b244a19c 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -742,6 +742,8 @@ again:
case IN_LOAD_GLOBAL_WV: {
debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_WV\n" );
+ assert( exec->WV );
+
vm_push_struct( prg->global );
/* Set up the reverse instruction. */
@@ -752,6 +754,8 @@ again:
case IN_LOAD_GLOBAL_WC: {
debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_WC\n" );
+ assert( !exec->WV );
+
/* This is identical to the _R version, but using it for writing
* would be confusing. */
vm_push_struct( prg->global );
@@ -774,6 +778,8 @@ again:
case IN_LOAD_INPUT_WV: {
debug( prg, REALM_BYTECODE, "IN_LOAD_INPUT_WV\n" );
+ assert( exec->WV );
+
assert( exec->stream->parser != 0 );
vm_push_stream( exec->stream->parser->input );
@@ -786,6 +792,8 @@ again:
case IN_LOAD_INPUT_WC: {
debug( prg, REALM_BYTECODE, "IN_LOAD_INPUT_WC\n" );
+ assert( !exec->WV );
+
assert( exec->stream->parser != 0 );
vm_push_stream( exec->stream->parser->input );
break;
@@ -810,6 +818,8 @@ again:
case IN_LOAD_CONTEXT_WV: {
debug( prg, REALM_BYTECODE, "IN_LOAD_CONTEXT_WV\n" );
+ assert( exec->WV );
+
vm_push_type( struct_t *, exec->stream->parser->pda_run->context );
/* Set up the reverse instruction. */
@@ -820,6 +830,8 @@ again:
case IN_LOAD_CONTEXT_WC: {
debug( prg, REALM_BYTECODE, "IN_LOAD_CONTEXT_WC\n" );
+ assert( !exec->WV );
+
/* This is identical to the _R version, but using it for writing
* would be confusing. */
vm_push_type( struct_t *, exec->stream->parser->pda_run->context );
@@ -2432,7 +2444,7 @@ again:
frame_size = fi->frame_size;
}
- vm_contiguous( 7 + frame_size );
+ vm_contiguous( 8 + frame_size );
vm_push_type( tree_t**, exec->frame_ptr );
vm_push_type( tree_t**, exec->iframe_ptr );
@@ -2440,6 +2452,7 @@ again:
vm_push_type( word_t, exec->steps );
vm_push_type( word_t, exec->pcr );
vm_push_stream( exec->stream );
+ vm_push_type( word_t, exec->WV );
/* Return location one instruction back. Depends on the size of of
* the frag/finish. */
@@ -2453,6 +2466,7 @@ again:
exec->stream = stream;
instr = stream->parser->pda_run->code;
+ exec->WV = 1;
exec->frame_id = stream->parser->pda_run->frame_id;
@@ -2484,6 +2498,8 @@ again:
}
instr = vm_pop_type(code_t*);
+
+ exec->WV = vm_pop_type(word_t);
exec->stream = vm_pop_stream();
exec->pcr = vm_pop_type(word_t);
exec->steps = vm_pop_type(word_t);
@@ -2512,6 +2528,7 @@ again:
vm_push_stream( stream );
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_WC %hd\n", stop_id );
+ assert( !exec->WV );
exec->pcr = colm_parse_frag( prg, sp, stream->parser->pda_run,
stream->parser->input, stop_id, exec->pcr );
@@ -2525,6 +2542,7 @@ again:
case IN_PARSE_FRAG_EXIT_WC: {
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_WC\n" );
+ assert( !exec->WV );
stream_t *stream = vm_pop_stream();
vm_push_stream( stream );
@@ -2543,6 +2561,7 @@ again:
vm_push_stream( stream );
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_WV %hd\n", stop_id );
+ assert( exec->WV );
exec->pcr = colm_parse_frag( prg, sp, stream->parser->pda_run,
stream->parser->input, stop_id, exec->pcr );
@@ -2556,6 +2575,7 @@ again:
case IN_PARSE_FRAG_EXIT_WV: {
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_WV \n" );
+ assert( exec->WV );
stream_t *stream = vm_pop_stream();
vm_push_stream( stream );
@@ -2609,6 +2629,7 @@ again:
vm_push_stream( stream );
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_WC %hd\n", stop_id );
+ assert( !exec->WV );
tree_t *result = 0;
exec->pcr = colm_parse_finish( &result, prg, sp,
@@ -2626,6 +2647,7 @@ again:
case IN_PARSE_FINISH_EXIT_WC: {
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_WC\n" );
+ assert( !exec->WV );
stream_t *stream = vm_pop_stream();
vm_push_stream( stream );
@@ -2644,6 +2666,7 @@ again:
vm_push_stream( stream );
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_WV %hd\n", stop_id );
+ assert( exec->WV );
tree_t *result = 0;
exec->pcr = colm_parse_finish( &result, prg, sp,
@@ -2659,6 +2682,7 @@ again:
case IN_PARSE_FINISH_EXIT_WV: {
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_WV\n" );
+ assert( exec->WV );
stream_t *stream = vm_pop_stream();
vm_push_stream( stream );