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

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

Issue 566553002: Add script streaming API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 3 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/compiler.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
new file mode 100644
index 0000000000000000000000000000000000000000..c7602a7defd7b698f7268b4d4b3ada4c1c4f3e71
--- /dev/null
+++ b/src/background-parsing-task.cc
@@ -0,0 +1,62 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/background-parsing-task.h"
+
+namespace v8 {
+namespace internal {
+
+BackgroundParsingTask::BackgroundParsingTask(
+ StreamedSource* source, ScriptCompiler::CompileOptions options,
+ int stack_size, Isolate* isolate)
+ : source_(source), options_(options), stack_size_(stack_size) {
+ // Prepare the data for the internalization phase and compilation phase, which
+ // will happen in the main thread after parsing.
+ source->info.Reset(new i::CompilationInfoWithZone(source->source_stream.get(),
+ source->encoding, isolate));
+ source->info->MarkAsGlobal();
+
+ // 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.
+ DCHECK(options == ScriptCompiler::kProduceParserCache ||
+ options == ScriptCompiler::kProduceCodeCache ||
+ options == ScriptCompiler::kNoCompileOptions);
+ source->allow_lazy =
+ !i::Compiler::DebuggerWantsEagerCompilation(source->info.get());
+ source->hash_seed = isolate->heap()->HashSeed();
+}
+
+
+void BackgroundParsingTask::Run() {
+ DisallowHeapAllocation no_allocation;
+ DisallowHandleAllocation no_handles;
+ DisallowHandleDereference no_deref;
+
+ ScriptData* script_data = NULL;
+ if (options_ == ScriptCompiler::kProduceParserCache ||
+ options_ == ScriptCompiler::kProduceCodeCache) {
+ source_->info->SetCachedData(&script_data, options_);
+ }
+
+ uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - stack_size_ * KB;
+ Parser::ParseInfo parse_info = {limit, source_->hash_seed,
+ &source_->unicode_cache};
+
+ // 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(), &parse_info));
+ source_->parser->set_allow_lazy(source_->allow_lazy);
+ source_->parser->ParseOnBackground();
+
+ if (script_data != NULL) {
+ source_->cached_data.Reset(new ScriptCompiler::CachedData(
+ script_data->data(), script_data->length(),
+ ScriptCompiler::CachedData::BufferOwned));
+ script_data->ReleaseDataOwnership();
+ delete script_data;
+ }
+}
+}
+} // namespace v8::internal
« no previous file with comments | « src/background-parsing-task.h ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698