Commit 2c21d034 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0841b60b
...@@ -62,25 +62,12 @@ typedef struct { ...@@ -62,25 +62,12 @@ typedef struct {
} u; } u;
} exprval_t; } exprval_t;
static const size_t stack_size = 0x4000;
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v) static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
{ {
if(!ctx->stack_size) { if(ctx->stack_top == stack_size)
ctx->stack = heap_alloc(16*sizeof(*ctx->stack)); return E_OUTOFMEMORY;
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;
}
ctx->stack[ctx->stack_top++] = v; ctx->stack[ctx->stack_top++] = v;
return S_OK; return S_OK;
...@@ -3006,6 +2993,12 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi ...@@ -3006,6 +2993,12 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
unsigned i; unsigned i;
HRESULT hres; 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) {
if(!bytecode->named_item->script_obj) { if(!bytecode->named_item->script_obj) {
hres = create_named_item_script_obj(ctx, bytecode->named_item); hres = create_named_item_script_obj(ctx, bytecode->named_item);
......
...@@ -425,7 +425,6 @@ struct _script_ctx_t { ...@@ -425,7 +425,6 @@ struct _script_ctx_t {
heap_pool_t tmp_heap; heap_pool_t tmp_heap;
jsval_t *stack; jsval_t *stack;
unsigned stack_size;
unsigned stack_top; unsigned stack_top;
jsval_t acc; jsval_t acc;
......
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