Bug 928050 - Don't GC when initializing IonRuntime, r=jandem.

This commit is contained in:
Brian Hackett 2013-11-09 19:53:03 -07:00
Родитель 50f8b65717
Коммит 23130f7a48
10 изменённых файлов: 52 добавлений и 40 удалений

Просмотреть файл

@ -108,7 +108,7 @@ BaselineCompiler::compile()
return Method_Error;
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::BASELINE_CODE);
IonCode *code = linker.newCode<CanGC>(cx, JSC::BASELINE_CODE);
if (!code)
return Method_Error;

Просмотреть файл

@ -587,7 +587,7 @@ ICStubCompiler::getStubCode()
if (!generateStubCode(masm))
return nullptr;
Linker linker(masm);
Rooted<IonCode *> newStubCode(cx, linker.newCode(cx, JSC::BASELINE_CODE));
Rooted<IonCode *> newStubCode(cx, linker.newCode<CanGC>(cx, JSC::BASELINE_CODE));
if (!newStubCode)
return nullptr;

Просмотреть файл

@ -4580,7 +4580,7 @@ JitCompartment::generateStringConcatStub(JSContext *cx, ExecutionMode mode)
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<CanGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "StringConcatStub");
@ -5800,7 +5800,7 @@ CodeGenerator::link(JSContext *cx, types::CompilerConstraintList *constraints)
Linker linker(masm);
IonCode *code = (executionMode == SequentialExecution)
? linker.newCodeForIonScript(cx)
: linker.newCode(cx, JSC::ION_CODE);
: linker.newCode<CanGC>(cx, JSC::ION_CODE);
if (!code) {
// Use js_free instead of IonScript::Destroy: the cache list and
// backedge list are still uninitialized.

Просмотреть файл

@ -606,10 +606,11 @@ JitRuntime::getVMWrapper(const VMFunction &f)
return p->value;
}
template <AllowGC allowGC>
IonCode *
IonCode::New(JSContext *cx, uint8_t *code, uint32_t bufferSize, JSC::ExecutablePool *pool)
{
IonCode *codeObj = gc::NewGCThing<IonCode, CanGC>(cx, gc::FINALIZE_IONCODE, sizeof(IonCode), gc::DefaultHeap);
IonCode *codeObj = gc::NewGCThing<IonCode, allowGC>(cx, gc::FINALIZE_IONCODE, sizeof(IonCode), gc::DefaultHeap);
if (!codeObj) {
pool->release();
return nullptr;
@ -619,6 +620,14 @@ IonCode::New(JSContext *cx, uint8_t *code, uint32_t bufferSize, JSC::ExecutableP
return codeObj;
}
template
IonCode *
IonCode::New<CanGC>(JSContext *cx, uint8_t *code, uint32_t bufferSize, JSC::ExecutablePool *pool);
template
IonCode *
IonCode::New<NoGC>(JSContext *cx, uint8_t *code, uint32_t bufferSize, JSC::ExecutablePool *pool);
void
IonCode::copyFrom(MacroAssembler &masm)
{

Просмотреть файл

@ -106,7 +106,7 @@ IonCache::LinkStatus
IonCache::linkCode(JSContext *cx, MacroAssembler &masm, IonScript *ion, IonCode **code)
{
Linker linker(masm);
*code = linker.newCode(cx, JSC::ION_CODE);
*code = linker.newCode<CanGC>(cx, JSC::ION_CODE);
if (!*code)
return LINK_ERROR;

Просмотреть файл

@ -131,6 +131,7 @@ class IonCode : public gc::BarrieredCell<IonCode>
// Allocates a new IonCode object which will be managed by the GC. If no
// object can be allocated, nullptr is returned. On failure, |pool| is
// automatically released, so the code may be freed.
template <AllowGC allowGC>
static IonCode *New(JSContext *cx, uint8_t *code, uint32_t bufferSize, JSC::ExecutablePool *pool);
public:

Просмотреть файл

@ -28,6 +28,7 @@ class Linker
return nullptr;
}
template <AllowGC allowGC>
IonCode *newCode(JSContext *cx, JSC::ExecutableAllocator *execAlloc, JSC::CodeKind kind) {
JS_ASSERT(kind == JSC::ION_CODE ||
kind == JSC::BASELINE_CODE ||
@ -53,8 +54,8 @@ class Linker
// Bump the code up to a nice alignment.
codeStart = (uint8_t *)AlignBytes((uintptr_t)codeStart, CodeAlignment);
uint32_t headerSize = codeStart - result;
IonCode *code = IonCode::New(cx, codeStart,
bytesNeeded - headerSize, pool);
IonCode *code = IonCode::New<allowGC>(cx, codeStart,
bytesNeeded - headerSize, pool);
if (!code)
return nullptr;
if (masm.oom())
@ -75,14 +76,15 @@ class Linker
masm.finish();
}
template <AllowGC allowGC>
IonCode *newCode(JSContext *cx, JSC::CodeKind kind) {
return newCode(cx, cx->compartment()->jitCompartment()->execAlloc(), kind);
return newCode<allowGC>(cx, cx->compartment()->jitCompartment()->execAlloc(), kind);
}
IonCode *newCodeForIonScript(JSContext *cx) {
#ifdef JS_CPU_ARM
// ARM does not yet use implicit interrupt checks, see bug 864220.
return newCode(cx, JSC::ION_CODE);
return newCode<CanGC>(cx, JSC::ION_CODE);
#else
// The caller must lock the runtime against operation callback triggers,
// as the triggering thread may use the executable allocator below.
@ -92,7 +94,7 @@ class Linker
if (!alloc)
return nullptr;
return newCode(cx, alloc, JSC::ION_CODE);
return newCode<CanGC>(cx, alloc, JSC::ION_CODE);
#endif
}
};

Просмотреть файл

@ -339,7 +339,7 @@ JitRuntime::generateEnterJIT(JSContext *cx, EnterJitType type)
GenerateReturn(masm, true);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "EnterJIT");
@ -400,7 +400,7 @@ JitRuntime::generateInvalidator(JSContext *cx)
masm.branch(bailoutTail);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
IonSpew(IonSpew_Invalidate, " invalidation thunk created at %p", (void *) code->raw());
#ifdef JS_ION_PERF
@ -502,7 +502,7 @@ JitRuntime::generateArgumentsRectifier(JSContext *cx, ExecutionMode mode, void *
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
CodeOffsetLabel returnLabel(returnOffset);
returnLabel.fixup(&masm);
@ -626,7 +626,7 @@ JitRuntime::generateBailoutTable(JSContext *cx, uint32_t frameClass)
GenerateBailoutThunk(cx, masm, frameClass);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutTable");
@ -642,7 +642,7 @@ JitRuntime::generateBailoutHandler(JSContext *cx)
GenerateBailoutThunk(cx, masm, NO_FRAME_SIZE_CLASS_ID);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutHandler");
@ -815,7 +815,7 @@ JitRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
f.extraValuesToPop * sizeof(Value)));
Linker linker(masm);
IonCode *wrapper = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *wrapper = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
if (!wrapper)
return nullptr;
@ -863,7 +863,7 @@ JitRuntime::generatePreBarrier(JSContext *cx, MIRType type)
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "PreBarrier");
@ -918,7 +918,7 @@ JitRuntime::generateDebugTrapHandler(JSContext *cx)
masm.ret();
Linker linker(masm);
IonCode *codeDbg = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *codeDbg = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(codeDbg, "DebugTrapHandler");
@ -935,7 +935,7 @@ JitRuntime::generateExceptionTailStub(JSContext *cx)
masm.handleFailureWithHandlerTail();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "ExceptionTailStub");
@ -952,7 +952,7 @@ JitRuntime::generateBailoutTailStub(JSContext *cx)
masm.generateBailoutTail(r1, r2);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutTailStub");

Просмотреть файл

@ -292,7 +292,7 @@ JitRuntime::generateEnterJIT(JSContext *cx, EnterJitType type)
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "EnterJIT");
@ -341,7 +341,7 @@ JitRuntime::generateInvalidator(JSContext *cx)
masm.jmp(bailoutTail);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "Invalidator");
@ -425,7 +425,7 @@ JitRuntime::generateArgumentsRectifier(JSContext *cx, ExecutionMode mode, void *
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "ArgumentsRectifier");
@ -491,7 +491,7 @@ JitRuntime::generateBailoutHandler(JSContext *cx)
GenerateBailoutThunk(cx, masm, NO_FRAME_SIZE_CLASS_ID);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutHandler");
@ -671,7 +671,7 @@ JitRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
f.extraValuesToPop * sizeof(Value)));
Linker linker(masm);
IonCode *wrapper = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *wrapper = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
if (!wrapper)
return nullptr;
@ -713,7 +713,7 @@ JitRuntime::generatePreBarrier(JSContext *cx, MIRType type)
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "PreBarrier");
@ -772,7 +772,7 @@ JitRuntime::generateDebugTrapHandler(JSContext *cx)
masm.ret();
Linker linker(masm);
IonCode *codeDbg = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *codeDbg = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(codeDbg, "DebugTrapHandler");
@ -789,7 +789,7 @@ JitRuntime::generateExceptionTailStub(JSContext *cx)
masm.handleFailureWithHandlerTail();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "ExceptionTailStub");
@ -806,7 +806,7 @@ JitRuntime::generateBailoutTailStub(JSContext *cx)
masm.generateBailoutTail(rdx, r9);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutTailStub");

Просмотреть файл

@ -275,7 +275,7 @@ JitRuntime::generateEnterJIT(JSContext *cx, EnterJitType type)
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "EnterJIT");
@ -332,7 +332,7 @@ JitRuntime::generateInvalidator(JSContext *cx)
masm.jmp(bailoutTail);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
IonSpew(IonSpew_Invalidate, " invalidation thunk created at %p", (void *) code->raw());
#ifdef JS_ION_PERF
@ -429,7 +429,7 @@ JitRuntime::generateArgumentsRectifier(JSContext *cx, ExecutionMode mode, void *
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "ArgumentsRectifier");
@ -509,7 +509,7 @@ JitRuntime::generateBailoutTable(JSContext *cx, uint32_t frameClass)
GenerateBailoutThunk(cx, masm, frameClass);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutHandler");
@ -526,7 +526,7 @@ JitRuntime::generateBailoutHandler(JSContext *cx)
GenerateBailoutThunk(cx, masm, NO_FRAME_SIZE_CLASS_ID);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutHandler");
@ -700,7 +700,7 @@ JitRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
f.extraValuesToPop * sizeof(Value)));
Linker linker(masm);
IonCode *wrapper = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *wrapper = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
if (!wrapper)
return nullptr;
@ -749,7 +749,7 @@ JitRuntime::generatePreBarrier(JSContext *cx, MIRType type)
masm.ret();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "PreBarrier");
@ -808,7 +808,7 @@ JitRuntime::generateDebugTrapHandler(JSContext *cx)
masm.ret();
Linker linker(masm);
IonCode *codeDbg = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *codeDbg = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(codeDbg, "DebugTrapHandler");
@ -825,7 +825,7 @@ JitRuntime::generateExceptionTailStub(JSContext *cx)
masm.handleFailureWithHandlerTail();
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "ExceptionTailStub");
@ -842,7 +842,7 @@ JitRuntime::generateBailoutTailStub(JSContext *cx)
masm.generateBailoutTail(edx, ecx);
Linker linker(masm);
IonCode *code = linker.newCode(cx, JSC::OTHER_CODE);
IonCode *code = linker.newCode<NoGC>(cx, JSC::OTHER_CODE);
#ifdef JS_ION_PERF
writePerfSpewerIonCodeProfile(code, "BailoutTailStub");