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

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

Issue 2686673002: [Compiler] Avoid blocking on inner function parallel compilation. (Closed)
Patch Set: Fix outer_scope_info handling Created 3 years, 10 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
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/compilation-info.h" 8 #include "src/compilation-info.h"
9 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" 9 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
11 #include "src/flags.h" 11 #include "src/flags.h"
12 #include "src/global-handles.h" 12 #include "src/global-handles.h"
13 #include "src/isolate.h" 13 #include "src/isolate.h"
14 #include "src/objects-inl.h" 14 #include "src/objects-inl.h"
15 #include "src/parsing/parse-info.h" 15 #include "src/parsing/parse-info.h"
16 #include "src/parsing/parser.h" 16 #include "src/parsing/parser.h"
17 #include "src/parsing/scanner-character-streams.h" 17 #include "src/parsing/scanner-character-streams.h"
18 #include "src/unicode-cache.h" 18 #include "src/unicode-cache.h"
19 #include "src/utils.h" 19 #include "src/utils.h"
20 #include "src/zone/zone.h"
21 20
22 namespace v8 { 21 namespace v8 {
23 namespace internal { 22 namespace internal {
24 23
25 namespace { 24 namespace {
26 25
27 class OneByteWrapper : public v8::String::ExternalOneByteStringResource { 26 class OneByteWrapper : public v8::String::ExternalOneByteStringResource {
28 public: 27 public:
29 OneByteWrapper(const void* data, int length) : data_(data), length_(length) {} 28 OneByteWrapper(const void* data, int length) : data_(data), length_(length) {}
30 ~OneByteWrapper() override = default; 29 ~OneByteWrapper() override = default;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 size_t max_stack_size) 67 size_t max_stack_size)
69 : status_(CompileJobStatus::kInitial), 68 : status_(CompileJobStatus::kInitial),
70 isolate_(isolate), 69 isolate_(isolate),
71 tracer_(tracer), 70 tracer_(tracer),
72 context_(Handle<Context>::cast( 71 context_(Handle<Context>::cast(
73 isolate_->global_handles()->Create(isolate->context()))), 72 isolate_->global_handles()->Create(isolate->context()))),
74 shared_(Handle<SharedFunctionInfo>::cast( 73 shared_(Handle<SharedFunctionInfo>::cast(
75 isolate_->global_handles()->Create(*shared))), 74 isolate_->global_handles()->Create(*shared))),
76 max_stack_size_(max_stack_size), 75 max_stack_size_(max_stack_size),
77 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { 76 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
77 DCHECK(!shared_->is_toplevel());
78 HandleScope scope(isolate_); 78 HandleScope scope(isolate_);
79 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_));
80 Handle<Script> script(Script::cast(shared_->script()), isolate_); 79 Handle<Script> script(Script::cast(shared_->script()), isolate_);
81 Handle<String> source(String::cast(script->source()), isolate_); 80 Handle<String> source(String::cast(script->source()), isolate_);
82 if (trace_compiler_dispatcher_jobs_) { 81 if (trace_compiler_dispatcher_jobs_) {
83 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); 82 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
84 shared_->ShortPrint(); 83 shared_->ShortPrint();
85 PrintF(" in initial state.\n"); 84 PrintF(" in initial state.\n");
86 } 85 }
87 } 86 }
88 87
89 CompilerDispatcherJob::CompilerDispatcherJob( 88 CompilerDispatcherJob::CompilerDispatcherJob(
90 Isolate* isolate, CompilerDispatcherTracer* tracer, 89 Isolate* isolate, CompilerDispatcherTracer* tracer, Handle<Script> script,
91 Handle<SharedFunctionInfo> shared, FunctionLiteral* literal, 90 Handle<SharedFunctionInfo> shared, FunctionLiteral* literal,
92 std::shared_ptr<Zone> parse_zone, 91 std::shared_ptr<Zone> parse_zone,
93 std::shared_ptr<DeferredHandles> parse_handles, 92 std::shared_ptr<DeferredHandles> parse_handles,
94 std::shared_ptr<DeferredHandles> compile_handles, size_t max_stack_size) 93 std::shared_ptr<DeferredHandles> compile_handles, size_t max_stack_size)
95 : status_(CompileJobStatus::kAnalyzed), 94 : status_(CompileJobStatus::kAnalyzed),
96 isolate_(isolate), 95 isolate_(isolate),
97 tracer_(tracer), 96 tracer_(tracer),
98 context_(Handle<Context>::cast( 97 context_(Handle<Context>::cast(
99 isolate_->global_handles()->Create(isolate->context()))), 98 isolate_->global_handles()->Create(isolate->context()))),
100 shared_(Handle<SharedFunctionInfo>::cast( 99 shared_(Handle<SharedFunctionInfo>::cast(
101 isolate_->global_handles()->Create(*shared))), 100 isolate_->global_handles()->Create(*shared))),
102 max_stack_size_(max_stack_size), 101 max_stack_size_(max_stack_size),
103 parse_info_(new ParseInfo(shared_)), 102 parse_info_(new ParseInfo(shared_)),
104 parse_zone_(parse_zone), 103 parse_zone_(parse_zone),
105 compile_info_(new CompilationInfo(parse_info_->zone(), parse_info_.get(), 104 compile_info_(new CompilationInfo(parse_info_->zone(), parse_info_.get(),
106 Handle<JSFunction>::null())), 105 Handle<JSFunction>::null())),
107 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { 106 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
108 parse_info_->set_literal(literal); 107 parse_info_->set_literal(literal);
108 parse_info_->set_script(script);
109 parse_info_->set_deferred_handles(parse_handles); 109 parse_info_->set_deferred_handles(parse_handles);
110 compile_info_->set_deferred_handles(compile_handles); 110 compile_info_->set_deferred_handles(compile_handles);
111 111
112 if (trace_compiler_dispatcher_jobs_) { 112 if (trace_compiler_dispatcher_jobs_) {
113 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); 113 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
114 shared_->ShortPrint(); 114 shared_->ShortPrint();
115 PrintF(" in Analyzed state.\n"); 115 PrintF(" in Analyzed state.\n");
116 } 116 }
117 } 117 }
118 118
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 parse_info_->set_hash_seed(isolate_->heap()->HashSeed()); 217 parse_info_->set_hash_seed(isolate_->heap()->HashSeed());
218 parse_info_->set_is_named_expression(shared_->is_named_expression()); 218 parse_info_->set_is_named_expression(shared_->is_named_expression());
219 parse_info_->set_compiler_hints(shared_->compiler_hints()); 219 parse_info_->set_compiler_hints(shared_->compiler_hints());
220 parse_info_->set_start_position(shared_->start_position()); 220 parse_info_->set_start_position(shared_->start_position());
221 parse_info_->set_end_position(shared_->end_position()); 221 parse_info_->set_end_position(shared_->end_position());
222 parse_info_->set_unicode_cache(unicode_cache_.get()); 222 parse_info_->set_unicode_cache(unicode_cache_.get());
223 parse_info_->set_language_mode(shared_->language_mode()); 223 parse_info_->set_language_mode(shared_->language_mode());
224 parse_info_->set_function_literal_id(shared_->function_literal_id()); 224 parse_info_->set_function_literal_id(shared_->function_literal_id());
225 225
226 parser_.reset(new Parser(parse_info_.get())); 226 parser_.reset(new Parser(parse_info_.get()));
227 Handle<ScopeInfo> outer_scope_info( 227 MaybeHandle<ScopeInfo> outer_scope_info;
228 handle(ScopeInfo::cast(shared_->outer_scope_info()))); 228 if (!shared_->outer_scope_info()->IsTheHole(isolate_) &&
229 parser_->DeserializeScopeChain(parse_info_.get(), 229 ScopeInfo::cast(shared_->outer_scope_info())->length() > 0) {
230 outer_scope_info->length() > 0 230 outer_scope_info = handle(ScopeInfo::cast(shared_->outer_scope_info()));
231 ? MaybeHandle<ScopeInfo>(outer_scope_info) 231 }
232 : MaybeHandle<ScopeInfo>()); 232 parser_->DeserializeScopeChain(parse_info_.get(), outer_scope_info);
233 233
234 Handle<String> name(String::cast(shared_->name())); 234 Handle<String> name(String::cast(shared_->name()));
235 parse_info_->set_function_name( 235 parse_info_->set_function_name(
236 parse_info_->ast_value_factory()->GetString(name)); 236 parse_info_->ast_value_factory()->GetString(name));
237 status_ = CompileJobStatus::kReadyToParse; 237 status_ = CompileJobStatus::kReadyToParse;
238 } 238 }
239 239
240 void CompilerDispatcherJob::Parse() { 240 void CompilerDispatcherJob::Parse() {
241 DCHECK(status() == CompileJobStatus::kReadyToParse); 241 DCHECK(status() == CompileJobStatus::kReadyToParse);
242 COMPILER_DISPATCHER_TRACE_SCOPE_WITH_NUM( 242 COMPILER_DISPATCHER_TRACE_SCOPE_WITH_NUM(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 parser_->ReportErrors(isolate_, script); 288 parser_->ReportErrors(isolate_, script);
289 status_ = CompileJobStatus::kFailed; 289 status_ = CompileJobStatus::kFailed;
290 } else { 290 } else {
291 status_ = CompileJobStatus::kReadyToAnalyze; 291 status_ = CompileJobStatus::kReadyToAnalyze;
292 } 292 }
293 parser_->UpdateStatistics(isolate_, script); 293 parser_->UpdateStatistics(isolate_, script);
294 294
295 DeferredHandleScope scope(isolate_); 295 DeferredHandleScope scope(isolate_);
296 { 296 {
297 parse_info_->ReopenHandlesInNewHandleScope(); 297 parse_info_->ReopenHandlesInNewHandleScope();
298 Handle<ScopeInfo> outer_scope_info( 298
299 handle(ScopeInfo::cast(shared_->outer_scope_info()))); 299 if (!shared_->outer_scope_info()->IsTheHole(isolate_) &&
300 if (outer_scope_info->length() > 0) { 300 ScopeInfo::cast(shared_->outer_scope_info())->length() > 0) {
301 Handle<ScopeInfo> outer_scope_info(
302 handle(ScopeInfo::cast(shared_->outer_scope_info())));
301 parse_info_->set_outer_scope_info(outer_scope_info); 303 parse_info_->set_outer_scope_info(outer_scope_info);
302 } 304 }
303 parse_info_->set_shared_info(shared_); 305 parse_info_->set_shared_info(shared_);
304 306
305 // Internalize ast values on the main thread. 307 // Internalize ast values on the main thread.
306 parse_info_->ast_value_factory()->Internalize(isolate_); 308 parse_info_->ast_value_factory()->Internalize(isolate_);
307 parser_->HandleSourceURLComments(isolate_, script); 309 parser_->HandleSourceURLComments(isolate_, script);
308 310
309 parse_info_->set_character_stream(nullptr); 311 parse_info_->set_character_stream(nullptr);
310 parse_info_->set_unicode_cache(nullptr); 312 parse_info_->set_unicode_cache(nullptr);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return 0.0; 473 return 0.0;
472 } 474 }
473 475
474 void CompilerDispatcherJob::ShortPrint() { 476 void CompilerDispatcherJob::ShortPrint() {
475 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 477 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
476 shared_->ShortPrint(); 478 shared_->ShortPrint();
477 } 479 }
478 480
479 } // namespace internal 481 } // namespace internal
480 } // namespace v8 482 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.h ('k') | test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698