Browse Source

extend the range of extraops LDUNDEF/LDNULL, use BC as const index

pull/1/head
Sami Vaarala 11 years ago
parent
commit
7baa26f1ac
  1. 10
      src/duk_js_compiler.c
  2. 8
      src/duk_js_executor.c

10
src/duk_js_compiler.c

@ -1355,12 +1355,12 @@ static int ispec_toregconst_raw(duk_compiler_ctx *comp_ctx,
* the 'void' operator.
*/
int dest = (forced_reg >= 0 ? forced_reg : ALLOCTEMP(comp_ctx));
emit_extraop_b_c(comp_ctx, DUK_EXTRAOP_LDUNDEF, dest, 0);
emit_extraop_bc(comp_ctx, DUK_EXTRAOP_LDUNDEF, dest);
return dest;
}
case DUK_TAG_NULL: {
int dest = (forced_reg >= 0 ? forced_reg : ALLOCTEMP(comp_ctx));
emit_extraop_b_c(comp_ctx, DUK_EXTRAOP_LDNULL, dest, 0);
emit_extraop_bc(comp_ctx, DUK_EXTRAOP_LDNULL, dest);
return dest;
}
case DUK_TAG_BOOLEAN: {
@ -4666,7 +4666,7 @@ static void parse_throw_statement(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {
comp_ctx->curr_token.allow_auto_semi) { /* automatic semi will be inserted */
DUK_DDDPRINT("empty throw value -> undefined");
reg_val = ALLOCTEMP(comp_ctx);
emit_extraop_b_c(comp_ctx, DUK_EXTRAOP_LDUNDEF, reg_val, 0);
emit_extraop_bc(comp_ctx, DUK_EXTRAOP_LDUNDEF, reg_val);
} else {
DUK_DDDPRINT("throw with a value");
@ -5810,7 +5810,7 @@ static void parse_function_body(duk_compiler_ctx *comp_ctx, int expect_eof, int
* it here.
*/
#if 0
emit_extraop_b_c(comp_ctx, DUK_EXTRAOP_LDUNDEF, 0, 0);
emit_extraop_bc(comp_ctx, DUK_EXTRAOP_LDUNDEF, 0);
#endif
}
@ -5915,7 +5915,7 @@ static void parse_function_body(duk_compiler_ctx *comp_ctx, int expect_eof, int
*/
if (implicit_return_value) {
emit_extraop_b_c(comp_ctx, DUK_EXTRAOP_LDUNDEF, 0, 0);
emit_extraop_bc(comp_ctx, DUK_EXTRAOP_LDUNDEF, 0);
}
DUK_DDDPRINT("begin 2nd pass");

8
src/duk_js_executor.c

@ -2746,11 +2746,11 @@ void duk_js_execute_bytecode(duk_hthread *entry_thread) {
}
case DUK_EXTRAOP_LDUNDEF: {
int b = DUK_DEC_B(ins);
int bc = DUK_DEC_BC(ins);
duk_tval tv_tmp;
duk_tval *tv1;
tv1 = REGP(b);
tv1 = REGP(bc);
DUK_TVAL_SET_TVAL(&tv_tmp, tv1);
DUK_TVAL_SET_UNDEFINED_ACTUAL(tv1);
DUK_TVAL_DECREF(thr, &tv_tmp); /* side effects */
@ -2758,11 +2758,11 @@ void duk_js_execute_bytecode(duk_hthread *entry_thread) {
}
case DUK_EXTRAOP_LDNULL: {
int b = DUK_DEC_B(ins);
int bc = DUK_DEC_BC(ins);
duk_tval tv_tmp;
duk_tval *tv1;
tv1 = REGP(b);
tv1 = REGP(bc);
DUK_TVAL_SET_TVAL(&tv_tmp, tv1);
DUK_TVAL_SET_NULL(tv1);
DUK_TVAL_DECREF(thr, &tv_tmp); /* side effects */

Loading…
Cancel
Save