Bug 911204 - Directly heap allocate CompileErrors when parsing off thread, r=billm.

This commit is contained in:
Brian Hackett 2013-09-02 10:06:43 -07:00
parent f93fdc5148
commit 2209a370c7
2 changed files with 10 additions and 4 deletions

View File

@ -202,6 +202,9 @@ ParseTask::~ParseTask()
// ParseTask takes over ownership of its input exclusive context.
js_delete(cx);
for (size_t i = 0; i < errors.length(); i++)
js_delete(errors[i]);
}
bool
@ -550,7 +553,7 @@ WorkerThreadState::finishParseTask(JSContext *maybecx, JSRuntime *rt, void *toke
if (maybecx) {
AutoCompartment ac(maybecx, parseTask->scopeChain);
for (size_t i = 0; i < parseTask->errors.length(); i++)
parseTask->errors[i].throwError(maybecx);
parseTask->errors[i]->throwError(maybecx);
}
JSScript *script = parseTask->script;
@ -677,9 +680,12 @@ ExclusiveContext::setWorkerThread(WorkerThread *workerThread)
frontend::CompileError &
ExclusiveContext::addPendingCompileError()
{
if (!workerThread->parseTask->errors.append(frontend::CompileError()))
frontend::CompileError *error = js_new<frontend::CompileError>();
if (!error)
MOZ_CRASH();
return workerThread->parseTask->errors.back();
if (!workerThread->parseTask->errors.append(error))
MOZ_CRASH();
return *error;
}
void

View File

@ -389,7 +389,7 @@ struct ParseTask
// Any errors or warnings produced during compilation. These are reported
// when finishing the script.
Vector<frontend::CompileError> errors;
Vector<frontend::CompileError *> errors;
ParseTask(ExclusiveContext *cx, const CompileOptions &options,
const jschar *chars, size_t length, JSObject *scopeChain,