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

Side by Side Diff: src/compiler-dispatcher/compiler-dispatcher-job.cc

Issue 2220463002: Hook up compiler dispatcher jobs to lazy parser. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | src/parsing/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" 5 #include "src/compiler-dispatcher/compiler-dispatcher-job.h"
6 6
7 #include "src/assert-scope.h" 7 #include "src/assert-scope.h"
8 #include "src/global-handles.h" 8 #include "src/global-handles.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 void CompilerDispatcherJob::PrepareToParseOnMainThread() { 41 void CompilerDispatcherJob::PrepareToParseOnMainThread() {
42 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 42 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
43 DCHECK(status() == CompileJobStatus::kInitial); 43 DCHECK(status() == CompileJobStatus::kInitial);
44 HandleScope scope(isolate_); 44 HandleScope scope(isolate_);
45 unicode_cache_.reset(new UnicodeCache()); 45 unicode_cache_.reset(new UnicodeCache());
46 zone_.reset(new Zone(isolate_->allocator())); 46 zone_.reset(new Zone(isolate_->allocator()));
47 Handle<SharedFunctionInfo> shared(function_->shared(), isolate_); 47 Handle<SharedFunctionInfo> shared(function_->shared(), isolate_);
48 Handle<Script> script(Script::cast(shared->script()), isolate_); 48 Handle<Script> script(Script::cast(shared->script()), isolate_);
49 DCHECK(script->type() != Script::TYPE_NATIVE);
50
49 Handle<String> source(String::cast(script->source()), isolate_); 51 Handle<String> source(String::cast(script->source()), isolate_);
50 if (source->IsExternalTwoByteString()) { 52 if (source->IsExternalTwoByteString()) {
51 character_stream_.reset(new ExternalTwoByteStringUtf16CharacterStream( 53 character_stream_.reset(new ExternalTwoByteStringUtf16CharacterStream(
52 Handle<ExternalTwoByteString>::cast(source), shared->start_position(), 54 Handle<ExternalTwoByteString>::cast(source), shared->start_position(),
53 shared->end_position())); 55 shared->end_position()));
54 } else if (source->IsExternalOneByteString()) { 56 } else if (source->IsExternalOneByteString()) {
55 character_stream_.reset(new ExternalOneByteStringUtf16CharacterStream( 57 character_stream_.reset(new ExternalOneByteStringUtf16CharacterStream(
56 Handle<ExternalOneByteString>::cast(source), shared->start_position(), 58 Handle<ExternalOneByteString>::cast(source), shared->start_position(),
57 shared->end_position())); 59 shared->end_position()));
58 } else { 60 } else {
59 source = String::Flatten(source); 61 source = String::Flatten(source);
60 // Have to globalize the reference here, so it survives between function 62 // Have to globalize the reference here, so it survives between function
61 // calls. 63 // calls.
62 source_ = Handle<String>::cast(isolate_->global_handles()->Create(*source)); 64 source_ = Handle<String>::cast(isolate_->global_handles()->Create(*source));
63 character_stream_.reset(new GenericStringUtf16CharacterStream( 65 character_stream_.reset(new GenericStringUtf16CharacterStream(
64 source_, shared->start_position(), shared->end_position())); 66 source_, shared->start_position(), shared->end_position()));
65 } 67 }
66 parse_info_.reset(new ParseInfo(zone_.get())); 68 parse_info_.reset(new ParseInfo(zone_.get()));
67 parse_info_->set_isolate(isolate_); 69 parse_info_->set_isolate(isolate_);
68 parse_info_->set_character_stream(character_stream_.get()); 70 parse_info_->set_character_stream(character_stream_.get());
69 parse_info_->set_hash_seed(isolate_->heap()->HashSeed()); 71 parse_info_->set_lazy();
marja 2016/08/05 09:43:05 Why don't you need the hash seed any more?
jochen (gone - plz use gerrit) 2016/08/05 11:20:16 Oops, didn't want to delete that
marja 2016/08/05 09:43:05 Why? Don't we need to at least check some FLAG_s t
jochen (gone - plz use gerrit) 2016/08/05 11:20:15 In the spirit of ParseLazy this flag means that th
72 parse_info_->set_is_named_expression(shared->is_named_expression());
73 parse_info_->set_calls_eval(shared->scope_info()->CallsEval());
74 parse_info_->set_compiler_hints(shared->compiler_hints());
75 parse_info_->set_start_position(shared->start_position());
76 parse_info_->set_end_position(shared->end_position());
70 parse_info_->set_unicode_cache(unicode_cache_.get()); 77 parse_info_->set_unicode_cache(unicode_cache_.get());
78 parse_info_->set_language_mode(shared->language_mode());
79
71 parser_.reset(new Parser(parse_info_.get())); 80 parser_.reset(new Parser(parse_info_.get()));
72 parser_->DeserializeScopeChain( 81 parser_->DeserializeScopeChain(
73 parse_info_.get(), handle(function_->context(), isolate_), 82 parse_info_.get(), handle(function_->context(), isolate_),
74 Scope::DeserializationMode::kDeserializeOffHeap); 83 Scope::DeserializationMode::kDeserializeOffHeap);
84
85 Handle<String> name(String::cast(shared->name()));
86 parse_info_->set_function_name(
87 parse_info_->ast_value_factory()->GetString(name));
75 status_ = CompileJobStatus::kReadyToParse; 88 status_ = CompileJobStatus::kReadyToParse;
76 } 89 }
77 90
78 void CompilerDispatcherJob::Parse() { 91 void CompilerDispatcherJob::Parse() {
79 DCHECK(can_parse_on_background_thread_ || 92 DCHECK(can_parse_on_background_thread_ ||
80 ThreadId::Current().Equals(isolate_->thread_id())); 93 ThreadId::Current().Equals(isolate_->thread_id()));
81 DCHECK(status() == CompileJobStatus::kReadyToParse); 94 DCHECK(status() == CompileJobStatus::kReadyToParse);
82 95
83 DisallowHeapAllocation no_allocation; 96 DisallowHeapAllocation no_allocation;
84 DisallowHandleAllocation no_handles; 97 DisallowHandleAllocation no_handles;
(...skipping 26 matching lines...) Expand all
111 if (!source_.is_null()) { 124 if (!source_.is_null()) {
112 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); 125 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
113 source_ = Handle<String>::null(); 126 source_ = Handle<String>::null();
114 } 127 }
115 128
116 if (parse_info_->literal() == nullptr) { 129 if (parse_info_->literal() == nullptr) {
117 status_ = CompileJobStatus::kFailed; 130 status_ = CompileJobStatus::kFailed;
118 return; 131 return;
119 } 132 }
120 133
134 {
135 HandleScope scope(isolate_);
136 Handle<String> inferred_name(function_->shared()->inferred_name());
137 parse_info_->literal()->set_inferred_name(inferred_name);
138 }
marja 2016/08/05 09:43:05 Why is this good - the HandleScope goes out of Sco
jochen (gone - plz use gerrit) 2016/08/05 11:20:15 True. I'll just do that when preparing the compila
139
121 InternalizeParsingResult(); 140 InternalizeParsingResult();
122 141
123 status_ = CompileJobStatus::kReadyToCompile; 142 status_ = CompileJobStatus::kReadyToCompile;
124 } 143 }
125 144
126 void CompilerDispatcherJob::ReportErrorsOnMainThread() { 145 void CompilerDispatcherJob::ReportErrorsOnMainThread() {
127 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 146 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
128 DCHECK(status() == CompileJobStatus::kFailed); 147 DCHECK(status() == CompileJobStatus::kFailed);
129 148
130 // Internalizing the parsing result will throw the error. 149 // Internalizing the parsing result will throw the error.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 188
170 parse_info_->set_character_stream(nullptr); 189 parse_info_->set_character_stream(nullptr);
171 parse_info_->set_unicode_cache(nullptr); 190 parse_info_->set_unicode_cache(nullptr);
172 parser_.reset(); 191 parser_.reset();
173 unicode_cache_.reset(); 192 unicode_cache_.reset();
174 character_stream_.reset(); 193 character_stream_.reset();
175 } 194 }
176 195
177 } // namespace internal 196 } // namespace internal
178 } // namespace v8 197 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698