diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-08-29 15:09:14 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-08-29 15:09:14 +0900 |
| commit | 3c4cd5428a1cfc43516f57506c1faf775c2a4abc (patch) | |
| tree | b16e23cb072e8b9cd541c0178cbb4d02a304c8d5 | |
| parent | 56384139a842f5ffd0ed9609d81fde53050549da (diff) | |
| download | mruby-3c4cd5428a1cfc43516f57506c1faf775c2a4abc.tar.gz mruby-3c4cd5428a1cfc43516f57506c1faf775c2a4abc.zip | |
allow no_optimize esp. for debugger
| -rw-r--r-- | include/mruby/compile.h | 2 | ||||
| -rw-r--r-- | src/codegen.c | 10 | ||||
| -rw-r--r-- | src/parse.y | 1 |
3 files changed, 12 insertions, 1 deletions
diff --git a/include/mruby/compile.h b/include/mruby/compile.h index 5efdef213..a85939998 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -29,6 +29,7 @@ typedef struct mrbc_context { mrb_bool dump_result:1; mrb_bool no_exec:1; mrb_bool keep_lv:1; + mrb_bool no_optimize:1; } mrbc_context; mrbc_context* mrbc_context_new(mrb_state *mrb); @@ -143,6 +144,7 @@ struct mrb_parser_state { size_t nwarn; mrb_ast_node *tree; + mrb_bool no_optimize:1; mrb_bool capture_errors:1; struct mrb_parser_message error_buffer[10]; struct mrb_parser_message warn_buffer[10]; diff --git a/src/codegen.c b/src/codegen.c index 031605eb7..78d641faf 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -162,11 +162,19 @@ genop(codegen_scope *s, mrb_code i) #define NOVAL 0 #define VAL 1 +static mrb_bool +no_optimize(codegen_scope *s) +{ + if (s && s->parser && s->parser->no_optimize) + return TRUE; + return FALSE; +} + static int genop_peep(codegen_scope *s, mrb_code i, int val) { /* peephole optimization */ - if (s->lastlabel != s->pc && s->pc > 0) { + if (!no_optimize(s) && s->lastlabel != s->pc && s->pc > 0) { mrb_code i0 = s->iseq[s->pc-1]; int c1 = GET_OPCODE(i); int c0 = GET_OPCODE(i0); diff --git a/src/parse.y b/src/parse.y index 7a3088f0e..d73ef8d1e 100644 --- a/src/parse.y +++ b/src/parse.y @@ -5330,6 +5330,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt) } } p->capture_errors = cxt->capture_errors; + p->no_optimize = cxt->no_optimize; if (cxt->partial_hook) { p->cxt = cxt; } |
