Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Unified Diff: src/background-parsing-task.cc

Issue 2197543002: Quick fix: nullify Isolate in background parsing slightly later. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: a better fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/background-parsing-task.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/background-parsing-task.cc
diff --git a/src/background-parsing-task.cc b/src/background-parsing-task.cc
index cbfaae5fe98eaa9ea39f9851b293bb59301890cf..99d9e9f74e0350d72a52b3ccf4137684a4e0c8d1 100644
--- a/src/background-parsing-task.cc
+++ b/src/background-parsing-task.cc
@@ -11,7 +11,7 @@ namespace internal {
BackgroundParsingTask::BackgroundParsingTask(
StreamedSource* source, ScriptCompiler::CompileOptions options,
int stack_size, Isolate* isolate)
- : source_(source), stack_size_(stack_size) {
+ : source_(source), stack_size_(stack_size), script_data_(nullptr) {
// We don't set the context to the CompilationInfo yet, because the background
// thread cannot do anything with it anyway. We set it just before compilation
// on the foreground thread.
@@ -34,6 +34,14 @@ BackgroundParsingTask::BackgroundParsingTask(
info->set_compile_options(options);
// Parse eagerly with ignition since we will compile eagerly.
info->set_allow_lazy_parsing(!(i::FLAG_ignition && i::FLAG_ignition_eager));
+
+ if (options == ScriptCompiler::kProduceParserCache ||
+ options == ScriptCompiler::kProduceCodeCache) {
+ source_->info->set_cached_data(&script_data_);
+ }
+ // Parser needs to stay alive for finalizing the parsing on the main
+ // thread.
+ source_->parser.reset(new Parser(source_->info.get()));
}
@@ -42,33 +50,26 @@ void BackgroundParsingTask::Run() {
DisallowHandleAllocation no_handles;
DisallowHandleDereference no_deref;
- ScriptData* script_data = NULL;
- ScriptCompiler::CompileOptions options = source_->info->compile_options();
- if (options == ScriptCompiler::kProduceParserCache ||
- options == ScriptCompiler::kProduceCodeCache) {
- source_->info->set_cached_data(&script_data);
- }
+ // Reset the stack limit of the parser to reflect correctly that we're on a
+ // background thread.
+ uintptr_t stack_limit =
+ reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB;
+ source_->parser->set_stack_limit(stack_limit);
// Nullify the Isolate temporarily so that the background parser doesn't
// accidentally use it.
Isolate* isolate = source_->info->isolate();
source_->info->set_isolate(nullptr);
- uintptr_t stack_limit =
- reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB;
-
- source_->info->set_stack_limit(stack_limit);
- // Parser needs to stay alive for finalizing the parsing on the main
- // thread. Passing &parse_info is OK because Parser doesn't store it.
- source_->parser.reset(new Parser(source_->info.get()));
source_->parser->ParseOnBackground(source_->info.get());
- if (script_data != NULL) {
+ if (script_data_ != nullptr) {
source_->cached_data.reset(new ScriptCompiler::CachedData(
- script_data->data(), script_data->length(),
+ script_data_->data(), script_data_->length(),
ScriptCompiler::CachedData::BufferOwned));
- script_data->ReleaseDataOwnership();
- delete script_data;
+ script_data_->ReleaseDataOwnership();
+ delete script_data_;
+ script_data_ = nullptr;
}
source_->info->set_isolate(isolate);
}
« no previous file with comments | « src/background-parsing-task.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698