Commit a120ecbe authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Store instruction pointer in call_frame_t.

parent fa5d9b3d
...@@ -568,33 +568,38 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re ...@@ -568,33 +568,38 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re
} }
static inline BSTR get_op_bstr(exec_ctx_t *ctx, int i){ static inline BSTR get_op_bstr(exec_ctx_t *ctx, int i){
return ctx->script->call_ctx->bytecode->instrs[ctx->ip].u.arg[i].bstr; call_frame_t *frame = ctx->script->call_ctx;
return frame->bytecode->instrs[frame->ip].u.arg[i].bstr;
} }
static inline unsigned get_op_uint(exec_ctx_t *ctx, int i){ static inline unsigned get_op_uint(exec_ctx_t *ctx, int i){
return ctx->script->call_ctx->bytecode->instrs[ctx->ip].u.arg[i].uint; call_frame_t *frame = ctx->script->call_ctx;
return frame->bytecode->instrs[frame->ip].u.arg[i].uint;
} }
static inline unsigned get_op_int(exec_ctx_t *ctx, int i){ static inline unsigned get_op_int(exec_ctx_t *ctx, int i){
return ctx->script->call_ctx->bytecode->instrs[ctx->ip].u.arg[i].lng; call_frame_t *frame = ctx->script->call_ctx;
return frame->bytecode->instrs[frame->ip].u.arg[i].lng;
} }
static inline jsstr_t *get_op_str(exec_ctx_t *ctx, int i){ static inline jsstr_t *get_op_str(exec_ctx_t *ctx, int i){
return ctx->script->call_ctx->bytecode->instrs[ctx->ip].u.arg[i].str; call_frame_t *frame = ctx->script->call_ctx;
return frame->bytecode->instrs[frame->ip].u.arg[i].str;
} }
static inline double get_op_double(exec_ctx_t *ctx){ static inline double get_op_double(exec_ctx_t *ctx){
return ctx->script->call_ctx->bytecode->instrs[ctx->ip].u.dbl; call_frame_t *frame = ctx->script->call_ctx;
return frame->bytecode->instrs[frame->ip].u.dbl;
} }
static inline void jmp_next(exec_ctx_t *ctx) static inline void jmp_next(exec_ctx_t *ctx)
{ {
ctx->ip++; ctx->script->call_ctx->ip++;
} }
static inline void jmp_abs(exec_ctx_t *ctx, unsigned dst) static inline void jmp_abs(exec_ctx_t *ctx, unsigned dst)
{ {
ctx->ip = dst; ctx->script->call_ctx->ip = dst;
} }
/* ECMA-262 3rd Edition 12.2 */ /* ECMA-262 3rd Edition 12.2 */
...@@ -2428,7 +2433,7 @@ static HRESULT unwind_exception(exec_ctx_t *ctx) ...@@ -2428,7 +2433,7 @@ static HRESULT unwind_exception(exec_ctx_t *ctx)
while(except_frame->scope != ctx->scope_chain) while(except_frame->scope != ctx->scope_chain)
scope_pop(&ctx->scope_chain); scope_pop(&ctx->scope_chain);
ctx->ip = except_frame->catch_off; frame->ip = except_frame->catch_off;
except_val = ctx->script->ei.val; except_val = ctx->script->ei.val;
ctx->script->ei.val = jsval_undefined(); ctx->script->ei.val = jsval_undefined();
...@@ -2466,7 +2471,7 @@ static HRESULT unwind_exception(exec_ctx_t *ctx) ...@@ -2466,7 +2471,7 @@ static HRESULT unwind_exception(exec_ctx_t *ctx)
static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t *ret) static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t *ret)
{ {
exec_ctx_t *exec_ctx = ctx->call_ctx->exec_ctx; exec_ctx_t *exec_ctx = ctx->call_ctx->exec_ctx;
unsigned prev_ip, prev_top; unsigned prev_top;
scope_chain_t *prev_scope; scope_chain_t *prev_scope;
call_frame_t *frame; call_frame_t *frame;
jsop_t op; jsop_t op;
...@@ -2477,11 +2482,9 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t ...@@ -2477,11 +2482,9 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t
frame = ctx->call_ctx; frame = ctx->call_ctx;
prev_top = exec_ctx->top; prev_top = exec_ctx->top;
prev_scope = exec_ctx->scope_chain; prev_scope = exec_ctx->scope_chain;
prev_ip = exec_ctx->ip;
exec_ctx->ip = func->instr_off;
while(exec_ctx->ip != -1) { while(frame->ip != -1) {
op = frame->bytecode->instrs[exec_ctx->ip].op; op = frame->bytecode->instrs[frame->ip].op;
hres = op_funcs[op](exec_ctx); hres = op_funcs[op](exec_ctx);
if(FAILED(hres)) { if(FAILED(hres)) {
TRACE("EXCEPTION %08x\n", hres); TRACE("EXCEPTION %08x\n", hres);
...@@ -2493,12 +2496,10 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t ...@@ -2493,12 +2496,10 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t
if(FAILED(hres)) if(FAILED(hres))
break; break;
}else { }else {
exec_ctx->ip += op_move[op]; frame->ip += op_move[op];
} }
} }
exec_ctx->ip = prev_ip;
assert(ctx->call_ctx == frame); assert(ctx->call_ctx == frame);
ctx->call_ctx = frame->prev_frame; ctx->call_ctx = frame->prev_frame;
release_call_frame(frame); release_call_frame(frame);
...@@ -2566,6 +2567,8 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_ ...@@ -2566,6 +2567,8 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_
frame->bytecode = bytecode; frame->bytecode = bytecode;
frame->function = function; frame->function = function;
frame->ip = function->instr_off;
frame->exec_ctx = ctx; frame->exec_ctx = ctx;
frame->prev_frame = ctx->script->call_ctx; frame->prev_frame = ctx->script->call_ctx;
......
...@@ -191,6 +191,7 @@ typedef struct _except_frame_t except_frame_t; ...@@ -191,6 +191,7 @@ typedef struct _except_frame_t except_frame_t;
struct _parser_ctx_t; struct _parser_ctx_t;
typedef struct _call_frame_t { typedef struct _call_frame_t {
unsigned ip;
except_frame_t *except_frame; except_frame_t *except_frame;
bytecode_t *bytecode; bytecode_t *bytecode;
...@@ -213,8 +214,6 @@ struct _exec_ctx_t { ...@@ -213,8 +214,6 @@ struct _exec_ctx_t {
unsigned stack_size; unsigned stack_size;
unsigned top; unsigned top;
jsval_t ret; jsval_t ret;
unsigned ip;
}; };
static inline void exec_addref(exec_ctx_t *ctx) static inline void exec_addref(exec_ctx_t *ctx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment