Commit 8558cbe5 authored by marja's avatar marja Committed by Commit bot

Quick fix: nullify Isolate in background parsing slightly later.

Parser ctor reads information from it.

BUG=632612

Review-Url: https://codereview.chromium.org/2197543002
Cr-Commit-Position: refs/heads/master@{#38167}
parent 8201579e
...@@ -11,7 +11,7 @@ namespace internal { ...@@ -11,7 +11,7 @@ namespace internal {
BackgroundParsingTask::BackgroundParsingTask( BackgroundParsingTask::BackgroundParsingTask(
StreamedSource* source, ScriptCompiler::CompileOptions options, StreamedSource* source, ScriptCompiler::CompileOptions options,
int stack_size, Isolate* isolate) 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 // 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 // thread cannot do anything with it anyway. We set it just before compilation
// on the foreground thread. // on the foreground thread.
...@@ -34,6 +34,14 @@ BackgroundParsingTask::BackgroundParsingTask( ...@@ -34,6 +34,14 @@ BackgroundParsingTask::BackgroundParsingTask(
info->set_compile_options(options); info->set_compile_options(options);
// Parse eagerly with ignition since we will compile eagerly. // Parse eagerly with ignition since we will compile eagerly.
info->set_allow_lazy_parsing(!(i::FLAG_ignition && i::FLAG_ignition_eager)); 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() { ...@@ -42,33 +50,26 @@ void BackgroundParsingTask::Run() {
DisallowHandleAllocation no_handles; DisallowHandleAllocation no_handles;
DisallowHandleDereference no_deref; DisallowHandleDereference no_deref;
ScriptData* script_data = NULL; // Reset the stack limit of the parser to reflect correctly that we're on a
ScriptCompiler::CompileOptions options = source_->info->compile_options(); // background thread.
if (options == ScriptCompiler::kProduceParserCache || uintptr_t stack_limit =
options == ScriptCompiler::kProduceCodeCache) { reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB;
source_->info->set_cached_data(&script_data); source_->parser->set_stack_limit(stack_limit);
}
// Nullify the Isolate temporarily so that the background parser doesn't // Nullify the Isolate temporarily so that the background parser doesn't
// accidentally use it. // accidentally use it.
Isolate* isolate = source_->info->isolate(); Isolate* isolate = source_->info->isolate();
source_->info->set_isolate(nullptr); 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()); source_->parser->ParseOnBackground(source_->info.get());
if (script_data != NULL) { if (script_data_ != nullptr) {
source_->cached_data.reset(new ScriptCompiler::CachedData( source_->cached_data.reset(new ScriptCompiler::CachedData(
script_data->data(), script_data->length(), script_data_->data(), script_data_->length(),
ScriptCompiler::CachedData::BufferOwned)); ScriptCompiler::CachedData::BufferOwned));
script_data->ReleaseDataOwnership(); script_data_->ReleaseDataOwnership();
delete script_data; delete script_data_;
script_data_ = nullptr;
} }
source_->info->set_isolate(isolate); source_->info->set_isolate(isolate);
} }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class ScriptData;
// Internal representation of v8::ScriptCompiler::StreamedSource. Contains all // Internal representation of v8::ScriptCompiler::StreamedSource. Contains all
// data which needs to be transmitted between threads for background parsing, // data which needs to be transmitted between threads for background parsing,
// finalizing it on the main thread, and compiling on the main thread. // finalizing it on the main thread, and compiling on the main thread.
...@@ -54,6 +56,7 @@ class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask { ...@@ -54,6 +56,7 @@ class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask {
private: private:
StreamedSource* source_; // Not owned. StreamedSource* source_; // Not owned.
int stack_size_; int stack_size_;
ScriptData* script_data_;
}; };
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -252,6 +252,8 @@ class ParserBase : public Traits { ...@@ -252,6 +252,8 @@ class ParserBase : public Traits {
uintptr_t stack_limit() const { return stack_limit_; } uintptr_t stack_limit() const { return stack_limit_; }
void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
protected: protected:
enum AllowRestrictedIdentifiers { enum AllowRestrictedIdentifiers {
kAllowRestrictedIdentifiers, kAllowRestrictedIdentifiers,
......
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