Module: wine Branch: master Commit: 983bbab5315b55d15dd3473e3ecd1db9d8dca8bc URL: http://source.winehq.org/git/wine.git/?a=commit;h=983bbab5315b55d15dd3473e3e...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Aug 4 13:40:44 2016 +0200
jscript: Replaced OP_ident with static binding when possible.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/compile.c | 10 +++++++++- dlls/jscript/engine.c | 51 +++++++++++++++++++++++++++++++++++++------------- dlls/jscript/engine.h | 1 + 3 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index d894b98..a1b2207 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -434,6 +434,14 @@ static HRESULT emit_identifier_ref(compiler_ctx_t *ctx, const WCHAR *identifier, return push_instr_bstr_uint(ctx, OP_identid, identifier, flags); }
+static HRESULT emit_identifier(compiler_ctx_t *ctx, const WCHAR *identifier) +{ + int local_ref; + if(bind_local(ctx, identifier, &local_ref)) + return push_instr_int(ctx, OP_local, local_ref); + return push_instr_bstr(ctx, OP_ident, identifier); +} + static HRESULT compile_memberid_expression(compiler_ctx_t *ctx, expression_t *expr, unsigned flags) { HRESULT hres = S_OK; @@ -994,7 +1002,7 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr, BOOL hres = compile_binary_expression(ctx, (binary_expression_t*)expr, OP_gteq); break; case EXPR_IDENT: - hres = push_instr_bstr(ctx, OP_ident, ((identifier_expression_t*)expr)->identifier); + hres = emit_identifier(ctx, ((identifier_expression_t*)expr)->identifier); break; case EXPR_IN: hres = compile_binary_expression(ctx, (binary_expression_t*)expr, OP_in); diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 2f74d8a..afa2b4b 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -1225,6 +1225,26 @@ static HRESULT interp_identifier_ref(script_ctx_t *ctx, BSTR identifier, unsigne return stack_push_exprval(ctx, &exprval); }
+static HRESULT identifier_value(script_ctx_t *ctx, BSTR identifier) +{ + exprval_t exprval; + jsval_t v; + HRESULT hres; + + hres = identifier_eval(ctx, identifier, &exprval); + if(FAILED(hres)) + return hres; + + if(exprval.type == EXPRVAL_INVALID) + return throw_type_error(ctx, exprval.u.hres, identifier); + + hres = exprval_to_value(ctx, &exprval, &v); + if(FAILED(hres)) + return hres; + + return stack_push(ctx, v); +} + static HRESULT interp_local_ref(script_ctx_t *ctx) { const int arg = get_op_int(ctx, 0); @@ -1242,28 +1262,33 @@ static HRESULT interp_local_ref(script_ctx_t *ctx) return stack_push_exprval(ctx, &ref); }
-/* ECMA-262 3rd Edition 10.1.4 */ -static HRESULT interp_ident(script_ctx_t *ctx) +static HRESULT interp_local(script_ctx_t *ctx) { - const BSTR arg = get_op_bstr(ctx, 0); - exprval_t exprval; - jsval_t v; + const int arg = get_op_int(ctx, 0); + call_frame_t *frame = ctx->call_ctx; + jsval_t copy; HRESULT hres;
- TRACE("%s\n", debugstr_w(arg)); + TRACE("%d\n", arg);
- hres = identifier_eval(ctx, arg, &exprval); + if(!frame->base_scope || !frame->base_scope->frame) + return identifier_value(ctx, local_name(frame, arg)); + + hres = jsval_copy(ctx->stack[local_off(frame, arg)], ©); if(FAILED(hres)) return hres;
- if(exprval.type == EXPRVAL_INVALID) - return throw_type_error(ctx, exprval.u.hres, arg); + return stack_push(ctx, copy); +}
- hres = exprval_to_value(ctx, &exprval, &v); - if(FAILED(hres)) - return hres; +/* ECMA-262 3rd Edition 10.1.4 */ +static HRESULT interp_ident(script_ctx_t *ctx) +{ + const BSTR arg = get_op_bstr(ctx, 0);
- return stack_push(ctx, v); + TRACE("%s\n", debugstr_w(arg)); + + return identifier_value(ctx, arg); }
/* ECMA-262 3rd Edition 10.1.4 */ diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index f515bef..3ac8169 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -48,6 +48,7 @@ X(int, 1, ARG_INT, 0) \ X(jmp, 0, ARG_ADDR, 0) \ X(jmp_z, 0, ARG_ADDR, 0) \ + X(local, 1, ARG_INT, 0) \ X(local_ref, 1, ARG_INT, ARG_UINT) \ X(lshift, 1, 0,0) \ X(lt, 1, 0,0) \