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

Side by Side Diff: src/background-parsing-task.cc

Issue 366153002: Add script streaming API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cleanup & better comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/background-parsing-task.h"
6
7 #include "src/parser.h"
8
9 namespace v8 {
10 namespace internal {
11
12 static const int kBackgroundParserThreadStackSize = 64 * KB;
jochen (gone - plz use gerrit) 2014/09/09 08:06:20 should this be FLAG_stack_size
marja 2014/09/09 11:46:30 Done.
13
14 StreamedSource::~StreamedSource() {
15 delete source_stream;
16 delete cached_data;
17 delete info;
18 delete parser;
19 }
20
21
22 BackgroundParsingTask::BackgroundParsingTask(
23 StreamedSource* source, ScriptCompiler::CompileOptions options,
24 Isolate* isolate)
25 : source_(source), options_(options) {
26 // Prepare the data for the internalization phase and compilation phase, which
27 // will happen in the main thread after parsing.
28 source->info = new i::CompilationInfoWithZone(source->source_stream,
29 source->encoding, isolate);
30 source->info->MarkAsGlobal();
31
32 // We don't set the context to the CompilationInfo yet, because the background
33 // thread cannot do anything with it anyway. We set it just before compilation
34 // on the foreground thread.
35 DCHECK(options == ScriptCompiler::kProduceParserCache ||
36 options == ScriptCompiler::kProduceCodeCache ||
37 options == ScriptCompiler::kNoCompileOptions);
38 source->allow_lazy =
39 !i::Compiler::DebuggerWantsEagerCompilation(source->info);
40 source->hash_seed = isolate->heap()->HashSeed();
41 }
42
43
44 void BackgroundParsingTask::Run() {
45 DisallowHeapAllocation no_allocation;
46 DisallowHandleAllocation no_handles;
47 DisallowHandleDereference no_deref;
48
49 ScriptData* script_data = NULL;
50 if (options_ == ScriptCompiler::kProduceParserCache ||
51 options_ == ScriptCompiler::kProduceCodeCache) {
52 source_->info->SetCachedData(&script_data, options_);
53 }
54
55 uintptr_t limit =
56 reinterpret_cast<uintptr_t>(&limit) - kBackgroundParserThreadStackSize;
57 Parser::ParseInfo parse_info = {limit, source_->hash_seed,
58 &source_->unicode_cache};
59
60 // Parser needs to stay alive for finalizing the parsing on the main
61 // thread. Passing &parse_info is OK because Parser doesn't store it.
62 source_->parser = new Parser(source_->info, &parse_info);
63 source_->parser->set_allow_lazy(source_->allow_lazy);
64 source_->parser->ParseOnBackground();
65
66 if (script_data != NULL) {
67 source_->cached_data = new ScriptCompiler::CachedData(
68 script_data->data(), script_data->length(),
69 ScriptCompiler::CachedData::BufferOwned);
70 script_data->ReleaseDataOwnership();
71 delete script_data;
72 }
73 }
74 }
jochen (gone - plz use gerrit) 2014/09/09 08:06:20 nit // namespace internal also, empty line above
marja 2014/09/09 11:46:30 git cl format removes the empty line if I put one
marja 2014/09/09 11:46:30 Counter nit: this seems pretty customary: $ git g
75 } // namespace v8::internal
jochen (gone - plz use gerrit) 2014/09/09 08:06:20 // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698