Commit 02d63cb3 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

jscript: Rename jsheap_t to heap_pool_t.

parent 2b5babc3
...@@ -118,7 +118,7 @@ static HRESULT compile_statement(compiler_ctx_t*,statement_ctx_t*,statement_t*); ...@@ -118,7 +118,7 @@ static HRESULT compile_statement(compiler_ctx_t*,statement_ctx_t*,statement_t*);
static inline void *compiler_alloc(bytecode_t *code, size_t size) static inline void *compiler_alloc(bytecode_t *code, size_t size)
{ {
return jsheap_alloc(&code->heap, size); return heap_pool_alloc(&code->heap, size);
} }
static jsstr_t *compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len) static jsstr_t *compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len)
...@@ -1806,7 +1806,7 @@ void release_bytecode(bytecode_t *code) ...@@ -1806,7 +1806,7 @@ void release_bytecode(bytecode_t *code)
jsstr_release(code->str_pool[i]); jsstr_release(code->str_pool[i]);
heap_free(code->source); heap_free(code->source);
jsheap_free(&code->heap); heap_pool_free(&code->heap);
heap_free(code->bstr_pool); heap_free(code->bstr_pool);
heap_free(code->str_pool); heap_free(code->str_pool);
heap_free(code->instrs); heap_free(code->instrs);
...@@ -1820,7 +1820,7 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source) ...@@ -1820,7 +1820,7 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
compiler->code->ref = 1; compiler->code->ref = 1;
jsheap_init(&compiler->code->heap); heap_pool_init(&compiler->code->heap);
compiler->code->source = heap_strdupW(source); compiler->code->source = heap_strdupW(source);
if(!compiler->code->source) { if(!compiler->code->source) {
......
...@@ -33,7 +33,7 @@ typedef struct { ...@@ -33,7 +33,7 @@ typedef struct {
BOOL lexer_error; BOOL lexer_error;
HRESULT hres; HRESULT hres;
jsheap_t heap; heap_pool_t heap;
} parser_ctx_t; } parser_ctx_t;
#define OP_LIST \ #define OP_LIST \
...@@ -166,7 +166,7 @@ typedef struct _bytecode_t { ...@@ -166,7 +166,7 @@ typedef struct _bytecode_t {
LONG ref; LONG ref;
instr_t *instrs; instr_t *instrs;
jsheap_t heap; heap_pool_t heap;
function_code_t global_code; function_code_t global_code;
...@@ -198,12 +198,12 @@ int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN; ...@@ -198,12 +198,12 @@ int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size) static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
{ {
return jsheap_alloc(&ctx->heap, size); return heap_pool_alloc(&ctx->heap, size);
} }
static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size) static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
{ {
return jsheap_alloc(&ctx->script->tmp_heap, size); return heap_pool_alloc(&ctx->script->tmp_heap, size);
} }
typedef struct _scope_chain_t { typedef struct _scope_chain_t {
......
...@@ -71,7 +71,7 @@ void script_release(script_ctx_t *ctx) ...@@ -71,7 +71,7 @@ void script_release(script_ctx_t *ctx)
clear_ei(ctx); clear_ei(ctx);
if(ctx->cc) if(ctx->cc)
release_cc(ctx->cc); release_cc(ctx->cc);
jsheap_free(&ctx->tmp_heap); heap_pool_free(&ctx->tmp_heap);
if(ctx->last_match) if(ctx->last_match)
jsstr_release(ctx->last_match); jsstr_release(ctx->last_match);
...@@ -717,7 +717,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface) ...@@ -717,7 +717,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
ctx->safeopt = This->safeopt; ctx->safeopt = This->safeopt;
ctx->version = This->version; ctx->version = This->version;
ctx->ei.val = jsval_undefined(); ctx->ei.val = jsval_undefined();
jsheap_init(&ctx->tmp_heap); heap_pool_init(&ctx->tmp_heap);
hres = create_jscaller(ctx); hres = create_jscaller(ctx);
if(FAILED(hres)) { if(FAILED(hres)) {
......
...@@ -46,14 +46,14 @@ typedef struct { ...@@ -46,14 +46,14 @@ typedef struct {
DWORD offset; DWORD offset;
BOOL mark; BOOL mark;
struct list custom_blocks; struct list custom_blocks;
} jsheap_t; } heap_pool_t;
void jsheap_init(jsheap_t*) DECLSPEC_HIDDEN; void heap_pool_init(heap_pool_t*) DECLSPEC_HIDDEN;
void *jsheap_alloc(jsheap_t*,DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN; void *heap_pool_alloc(heap_pool_t*,DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN;
void *jsheap_grow(jsheap_t*,void*,DWORD,DWORD) DECLSPEC_HIDDEN; void *heap_pool_grow(heap_pool_t*,void*,DWORD,DWORD) DECLSPEC_HIDDEN;
void jsheap_clear(jsheap_t*) DECLSPEC_HIDDEN; void heap_pool_clear(heap_pool_t*) DECLSPEC_HIDDEN;
void jsheap_free(jsheap_t*) DECLSPEC_HIDDEN; void heap_pool_free(heap_pool_t*) DECLSPEC_HIDDEN;
jsheap_t *jsheap_mark(jsheap_t*) DECLSPEC_HIDDEN; heap_pool_t *heap_pool_mark(heap_pool_t*) DECLSPEC_HIDDEN;
static inline void *heap_alloc(size_t len) static inline void *heap_alloc(size_t len)
{ {
...@@ -383,7 +383,7 @@ struct _script_ctx_t { ...@@ -383,7 +383,7 @@ struct _script_ctx_t {
JSCaller *jscaller; JSCaller *jscaller;
jsexcept_t ei; jsexcept_t ei;
jsheap_t tmp_heap; heap_pool_t tmp_heap;
IDispatch *host_global; IDispatch *host_global;
......
...@@ -90,13 +90,13 @@ static inline DWORD block_size(DWORD block) ...@@ -90,13 +90,13 @@ static inline DWORD block_size(DWORD block)
return MIN_BLOCK_SIZE << block; return MIN_BLOCK_SIZE << block;
} }
void jsheap_init(jsheap_t *heap) void heap_pool_init(heap_pool_t *heap)
{ {
memset(heap, 0, sizeof(*heap)); memset(heap, 0, sizeof(*heap));
list_init(&heap->custom_blocks); list_init(&heap->custom_blocks);
} }
void *jsheap_alloc(jsheap_t *heap, DWORD size) void *heap_pool_alloc(heap_pool_t *heap, DWORD size)
{ {
struct list *list; struct list *list;
void *tmp; void *tmp;
...@@ -149,7 +149,7 @@ void *jsheap_alloc(jsheap_t *heap, DWORD size) ...@@ -149,7 +149,7 @@ void *jsheap_alloc(jsheap_t *heap, DWORD size)
return list+1; return list+1;
} }
void *jsheap_grow(jsheap_t *heap, void *mem, DWORD size, DWORD inc) void *heap_pool_grow(heap_pool_t *heap, void *mem, DWORD size, DWORD inc)
{ {
void *ret; void *ret;
...@@ -159,13 +159,13 @@ void *jsheap_grow(jsheap_t *heap, void *mem, DWORD size, DWORD inc) ...@@ -159,13 +159,13 @@ void *jsheap_grow(jsheap_t *heap, void *mem, DWORD size, DWORD inc)
return mem; return mem;
} }
ret = jsheap_alloc(heap, size+inc); ret = heap_pool_alloc(heap, size+inc);
if(ret) /* FIXME: avoid copying for custom blocks */ if(ret) /* FIXME: avoid copying for custom blocks */
memcpy(ret, mem, size); memcpy(ret, mem, size);
return ret; return ret;
} }
void jsheap_clear(jsheap_t *heap) void heap_pool_clear(heap_pool_t *heap)
{ {
struct list *tmp; struct list *tmp;
...@@ -188,20 +188,20 @@ void jsheap_clear(jsheap_t *heap) ...@@ -188,20 +188,20 @@ void jsheap_clear(jsheap_t *heap)
heap->mark = FALSE; heap->mark = FALSE;
} }
void jsheap_free(jsheap_t *heap) void heap_pool_free(heap_pool_t *heap)
{ {
DWORD i; DWORD i;
jsheap_clear(heap); heap_pool_clear(heap);
for(i=0; i < heap->block_cnt; i++) for(i=0; i < heap->block_cnt; i++)
heap_free(heap->blocks[i]); heap_free(heap->blocks[i]);
heap_free(heap->blocks); heap_free(heap->blocks);
jsheap_init(heap); heap_pool_init(heap);
} }
jsheap_t *jsheap_mark(jsheap_t *heap) heap_pool_t *heap_pool_mark(heap_pool_t *heap)
{ {
if(heap->mark) if(heap->mark)
return NULL; return NULL;
......
...@@ -1487,7 +1487,7 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source) ...@@ -1487,7 +1487,7 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source)
void parser_release(parser_ctx_t *ctx) void parser_release(parser_ctx_t *ctx)
{ {
script_release(ctx->script); script_release(ctx->script);
jsheap_free(&ctx->heap); heap_pool_free(&ctx->heap);
heap_free(ctx); heap_free(ctx);
} }
...@@ -1495,7 +1495,7 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite ...@@ -1495,7 +1495,7 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite
parser_ctx_t **ret) parser_ctx_t **ret)
{ {
parser_ctx_t *parser_ctx; parser_ctx_t *parser_ctx;
jsheap_t *mark; heap_pool_t *mark;
HRESULT hres; HRESULT hres;
const WCHAR html_tagW[] = {'<','/','s','c','r','i','p','t','>',0}; const WCHAR html_tagW[] = {'<','/','s','c','r','i','p','t','>',0};
...@@ -1513,11 +1513,11 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite ...@@ -1513,11 +1513,11 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite
script_addref(ctx); script_addref(ctx);
parser_ctx->script = ctx; parser_ctx->script = ctx;
mark = jsheap_mark(&ctx->tmp_heap); mark = heap_pool_mark(&ctx->tmp_heap);
jsheap_init(&parser_ctx->heap); heap_pool_init(&parser_ctx->heap);
parser_parse(parser_ctx); parser_parse(parser_ctx);
jsheap_clear(mark); heap_pool_clear(mark);
hres = parser_ctx->hres; hres = parser_ctx->hres;
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("parser failed around %s\n", WARN("parser failed around %s\n",
......
...@@ -312,7 +312,7 @@ typedef struct REGlobalData { ...@@ -312,7 +312,7 @@ typedef struct REGlobalData {
size_t backTrackCount; /* how many times we've backtracked */ size_t backTrackCount; /* how many times we've backtracked */
size_t backTrackLimit; /* upper limit on backtrack states */ size_t backTrackLimit; /* upper limit on backtrack states */
jsheap_t *pool; /* It's faster to use one malloc'd pool heap_pool_t *pool; /* It's faster to use one malloc'd pool
than to malloc/free the three items than to malloc/free the three items
that are allocated from this pool */ that are allocated from this pool */
} REGlobalData; } REGlobalData;
...@@ -468,7 +468,7 @@ NewRENode(CompilerState *state, REOp op) ...@@ -468,7 +468,7 @@ NewRENode(CompilerState *state, REOp op)
{ {
RENode *ren; RENode *ren;
ren = jsheap_alloc(&state->context->tmp_heap, sizeof(*ren)); ren = heap_pool_alloc(&state->context->tmp_heap, sizeof(*ren));
if (!ren) { if (!ren) {
/* js_ReportOutOfScriptQuota(cx); */ /* js_ReportOutOfScriptQuota(cx); */
return NULL; return NULL;
...@@ -2001,7 +2001,7 @@ PushBackTrackState(REGlobalData *gData, REOp op, ...@@ -2001,7 +2001,7 @@ PushBackTrackState(REGlobalData *gData, REOp op,
JS_COUNT_OPERATION(gData->cx, JSOW_ALLOCATION); JS_COUNT_OPERATION(gData->cx, JSOW_ALLOCATION);
btincr = ((btincr+btsize-1)/btsize)*btsize; btincr = ((btincr+btsize-1)/btsize)*btsize;
gData->backTrackStack = jsheap_grow(gData->pool, gData->backTrackStack, btsize, btincr); gData->backTrackStack = heap_pool_grow(gData->pool, gData->backTrackStack, btsize, btincr);
if (!gData->backTrackStack) { if (!gData->backTrackStack) {
js_ReportOutOfScriptQuota(gData->cx); js_ReportOutOfScriptQuota(gData->cx);
gData->ok = FALSE; gData->ok = FALSE;
...@@ -2358,7 +2358,7 @@ ReallocStateStack(REGlobalData *gData) ...@@ -2358,7 +2358,7 @@ ReallocStateStack(REGlobalData *gData)
size_t limit = gData->stateStackLimit; size_t limit = gData->stateStackLimit;
size_t sz = sizeof(REProgState) * limit; size_t sz = sizeof(REProgState) * limit;
gData->stateStack = jsheap_grow(gData->pool, gData->stateStack, sz, sz); gData->stateStack = heap_pool_grow(gData->pool, gData->stateStack, sz, sz);
if (!gData->stateStack) { if (!gData->stateStack) {
js_ReportOutOfScriptQuota(gData->cx); js_ReportOutOfScriptQuota(gData->cx);
gData->ok = FALSE; gData->ok = FALSE;
...@@ -3164,7 +3164,7 @@ static REMatchState *InitMatch(script_ctx_t *cx, REGlobalData *gData, JSRegExp * ...@@ -3164,7 +3164,7 @@ static REMatchState *InitMatch(script_ctx_t *cx, REGlobalData *gData, JSRegExp *
UINT i; UINT i;
gData->backTrackStackSize = INITIAL_BACKTRACK; gData->backTrackStackSize = INITIAL_BACKTRACK;
gData->backTrackStack = jsheap_alloc(gData->pool, INITIAL_BACKTRACK); gData->backTrackStack = heap_pool_alloc(gData->pool, INITIAL_BACKTRACK);
if (!gData->backTrackStack) if (!gData->backTrackStack)
goto bad; goto bad;
...@@ -3174,7 +3174,7 @@ static REMatchState *InitMatch(script_ctx_t *cx, REGlobalData *gData, JSRegExp * ...@@ -3174,7 +3174,7 @@ static REMatchState *InitMatch(script_ctx_t *cx, REGlobalData *gData, JSRegExp *
gData->backTrackLimit = 0; gData->backTrackLimit = 0;
gData->stateStackLimit = INITIAL_STATESTACK; gData->stateStackLimit = INITIAL_STATESTACK;
gData->stateStack = jsheap_alloc(gData->pool, sizeof(REProgState) * INITIAL_STATESTACK); gData->stateStack = heap_pool_alloc(gData->pool, sizeof(REProgState) * INITIAL_STATESTACK);
if (!gData->stateStack) if (!gData->stateStack)
goto bad; goto bad;
...@@ -3183,7 +3183,7 @@ static REMatchState *InitMatch(script_ctx_t *cx, REGlobalData *gData, JSRegExp * ...@@ -3183,7 +3183,7 @@ static REMatchState *InitMatch(script_ctx_t *cx, REGlobalData *gData, JSRegExp *
gData->regexp = re; gData->regexp = re;
gData->ok = TRUE; gData->ok = TRUE;
result = jsheap_alloc(gData->pool, offsetof(REMatchState, parens) + re->parenCount * sizeof(RECapture)); result = heap_pool_alloc(gData->pool, offsetof(REMatchState, parens) + re->parenCount * sizeof(RECapture));
if (!result) if (!result)
goto bad; goto bad;
...@@ -3221,7 +3221,7 @@ static JSRegExp * ...@@ -3221,7 +3221,7 @@ static JSRegExp *
js_NewRegExp(script_ctx_t *cx, jsstr_t *str, UINT flags, BOOL flat) js_NewRegExp(script_ctx_t *cx, jsstr_t *str, UINT flags, BOOL flat)
{ {
JSRegExp *re; JSRegExp *re;
jsheap_t *mark; heap_pool_t *mark;
CompilerState state; CompilerState state;
size_t resize; size_t resize;
jsbytecode *endPC; jsbytecode *endPC;
...@@ -3229,7 +3229,7 @@ js_NewRegExp(script_ctx_t *cx, jsstr_t *str, UINT flags, BOOL flat) ...@@ -3229,7 +3229,7 @@ js_NewRegExp(script_ctx_t *cx, jsstr_t *str, UINT flags, BOOL flat)
size_t len; size_t len;
re = NULL; re = NULL;
mark = jsheap_mark(&cx->tmp_heap); mark = heap_pool_mark(&cx->tmp_heap);
len = jsstr_length(str); len = jsstr_length(str);
state.context = cx; state.context = cx;
...@@ -3306,7 +3306,7 @@ js_NewRegExp(script_ctx_t *cx, jsstr_t *str, UINT flags, BOOL flat) ...@@ -3306,7 +3306,7 @@ js_NewRegExp(script_ctx_t *cx, jsstr_t *str, UINT flags, BOOL flat)
re->source = str; re->source = str;
out: out:
jsheap_clear(mark); heap_pool_clear(mark);
return re; return re;
} }
...@@ -3428,17 +3428,17 @@ HRESULT regexp_match_next(script_ctx_t *ctx, jsdisp_t *dispex, DWORD rem_flags, ...@@ -3428,17 +3428,17 @@ HRESULT regexp_match_next(script_ctx_t *ctx, jsdisp_t *dispex, DWORD rem_flags,
match_result_t *ret) match_result_t *ret)
{ {
RegExpInstance *regexp = (RegExpInstance*)dispex; RegExpInstance *regexp = (RegExpInstance*)dispex;
jsheap_t *mark; heap_pool_t *mark;
HRESULT hres; HRESULT hres;
if((rem_flags & REM_CHECK_GLOBAL) && !(regexp->jsregexp->flags & JSREG_GLOB)) if((rem_flags & REM_CHECK_GLOBAL) && !(regexp->jsregexp->flags & JSREG_GLOB))
return S_FALSE; return S_FALSE;
mark = jsheap_mark(&ctx->tmp_heap); mark = heap_pool_mark(&ctx->tmp_heap);
hres = do_regexp_match_next(ctx, regexp, rem_flags, str, cp, parens, parens_size, parens_cnt, ret); hres = do_regexp_match_next(ctx, regexp, rem_flags, str, cp, parens, parens_size, parens_cnt, ret);
jsheap_clear(mark); heap_pool_clear(mark);
return hres; return hres;
} }
...@@ -3449,10 +3449,10 @@ static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *str, B ...@@ -3449,10 +3449,10 @@ static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *str, B
match_result_t *ret = NULL, cres; match_result_t *ret = NULL, cres;
const WCHAR *cp = str->str; const WCHAR *cp = str->str;
DWORD i=0, ret_size = 0; DWORD i=0, ret_size = 0;
jsheap_t *mark; heap_pool_t *mark;
HRESULT hres; HRESULT hres;
mark = jsheap_mark(&ctx->tmp_heap); mark = heap_pool_mark(&ctx->tmp_heap);
while(1) { while(1) {
hres = do_regexp_match_next(ctx, This, 0, str, &cp, NULL, NULL, NULL, &cres); hres = do_regexp_match_next(ctx, This, 0, str, &cp, NULL, NULL, NULL, &cres);
...@@ -3488,7 +3488,7 @@ static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *str, B ...@@ -3488,7 +3488,7 @@ static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *str, B
} }
} }
jsheap_clear(mark); heap_pool_clear(mark);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(ret); heap_free(ret);
return hres; return hres;
......
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