Module: wine Branch: master Commit: 2c21d0344cae7ee0c3205393b518a75ab882d535 URL: https://source.winehq.org/git/wine.git/?a=commit;h=2c21d0344cae7ee0c3205393b...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Jun 4 17:28:56 2020 +0200
jscript: Don't realloc interpreter stack.
We share the stack for all calls in script instance, so it no loner makes sense.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/engine.c | 27 ++++++++++----------------- dlls/jscript/jscript.h | 1 - 2 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index c39c59e3ab..548bc2560c 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -62,25 +62,12 @@ typedef struct { } u; } exprval_t;
+static const size_t stack_size = 0x4000; + static HRESULT stack_push(script_ctx_t *ctx, jsval_t v) { - if(!ctx->stack_size) { - ctx->stack = heap_alloc(16*sizeof(*ctx->stack)); - if(!ctx->stack) - return E_OUTOFMEMORY; - ctx->stack_size = 16; - }else if(ctx->stack_size == ctx->stack_top) { - jsval_t *new_stack; - - new_stack = heap_realloc(ctx->stack, ctx->stack_size*2*sizeof(*new_stack)); - if(!new_stack) { - jsval_release(v); - return E_OUTOFMEMORY; - } - - ctx->stack = new_stack; - ctx->stack_size *= 2; - } + if(ctx->stack_top == stack_size) + return E_OUTOFMEMORY;
ctx->stack[ctx->stack_top++] = v; return S_OK; @@ -3006,6 +2993,12 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi unsigned i; HRESULT hres;
+ if(!ctx->stack) { + ctx->stack = heap_alloc(stack_size * sizeof(*ctx->stack)); + if(!ctx->stack) + return E_OUTOFMEMORY; + } + if(bytecode->named_item) { if(!bytecode->named_item->script_obj) { hres = create_named_item_script_obj(ctx, bytecode->named_item); diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 40b9f794ae..2a2250d3e9 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -425,7 +425,6 @@ struct _script_ctx_t { heap_pool_t tmp_heap;
jsval_t *stack; - unsigned stack_size; unsigned stack_top; jsval_t acc;