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

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

Issue 2637123002: Revert of [complier] Enable parallel eager inner function compilation with compiler dispatcher. (Closed)
Patch Set: Created 3 years, 11 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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 DISALLOW_COPY_AND_ASSIGN(TwoByteWrapper); 60 DISALLOW_COPY_AND_ASSIGN(TwoByteWrapper);
61 }; 61 };
62 62
63 } // namespace 63 } // namespace
64 64
65 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate, 65 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
66 CompilerDispatcherTracer* tracer, 66 CompilerDispatcherTracer* tracer,
67 Handle<SharedFunctionInfo> shared, 67 Handle<SharedFunctionInfo> shared,
68 size_t max_stack_size) 68 size_t max_stack_size)
69 : status_(CompileJobStatus::kInitial), 69 : isolate_(isolate),
70 isolate_(isolate),
71 tracer_(tracer), 70 tracer_(tracer),
72 shared_(Handle<SharedFunctionInfo>::cast( 71 shared_(Handle<SharedFunctionInfo>::cast(
73 isolate_->global_handles()->Create(*shared))), 72 isolate_->global_handles()->Create(*shared))),
74 max_stack_size_(max_stack_size), 73 max_stack_size_(max_stack_size),
75 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { 74 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
76 HandleScope scope(isolate_); 75 HandleScope scope(isolate_);
77 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_)); 76 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_));
78 Handle<Script> script(Script::cast(shared_->script()), isolate_); 77 Handle<Script> script(Script::cast(shared_->script()), isolate_);
79 Handle<String> source(String::cast(script->source()), isolate_); 78 Handle<String> source(String::cast(script->source()), isolate_);
80 if (trace_compiler_dispatcher_jobs_) { 79 if (trace_compiler_dispatcher_jobs_) {
81 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); 80 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
82 shared_->ShortPrint(); 81 shared_->ShortPrint();
83 PrintF(" in initial state.\n"); 82 PrintF("\n");
84 } 83 }
85 } 84 }
86 85
87 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
88 CompilerDispatcherTracer* tracer,
89 Handle<SharedFunctionInfo> shared,
90 FunctionLiteral* literal,
91 size_t max_stack_size)
92 : status_(CompileJobStatus::kAnalyzed),
93 isolate_(isolate),
94 tracer_(tracer),
95 shared_(Handle<SharedFunctionInfo>::cast(
96 isolate_->global_handles()->Create(*shared))),
97 max_stack_size_(max_stack_size),
98 zone_(new Zone(isolate->allocator(), ZONE_NAME)),
99 parse_info_(new ParseInfo(
100 zone_.get(), Handle<Script>(Script::cast(shared->script())))),
101 compile_info_(
102 new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())),
103 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
104 parse_info_->set_literal(literal);
105 parse_info_->set_shared_info(shared);
106 parse_info_->set_function_literal_id(shared->function_literal_id());
107 parse_info_->set_language_mode(literal->scope()->language_mode());
108 if (trace_compiler_dispatcher_jobs_) {
109 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
110 shared_->ShortPrint();
111 PrintF(" in Analyzed state.\n");
112 }
113 }
114
115 CompilerDispatcherJob::~CompilerDispatcherJob() { 86 CompilerDispatcherJob::~CompilerDispatcherJob() {
116 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 87 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
117 DCHECK(status_ == CompileJobStatus::kInitial || 88 DCHECK(status_ == CompileJobStatus::kInitial ||
118 status_ == CompileJobStatus::kDone); 89 status_ == CompileJobStatus::kDone);
119 i::GlobalHandles::Destroy(Handle<Object>::cast(shared_).location()); 90 i::GlobalHandles::Destroy(Handle<Object>::cast(shared_).location());
120 } 91 }
121 92
122 bool CompilerDispatcherJob::IsAssociatedWith( 93 bool CompilerDispatcherJob::IsAssociatedWith(
123 Handle<SharedFunctionInfo> shared) const { 94 Handle<SharedFunctionInfo> shared) const {
124 return *shared_ == *shared; 95 return *shared_ == *shared;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 source_ = Handle<String>::null(); 245 source_ = Handle<String>::null();
275 } 246 }
276 if (!wrapper_.is_null()) { 247 if (!wrapper_.is_null()) {
277 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location()); 248 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location());
278 wrapper_ = Handle<String>::null(); 249 wrapper_ = Handle<String>::null();
279 } 250 }
280 251
281 if (parse_info_->literal() == nullptr) { 252 if (parse_info_->literal() == nullptr) {
282 status_ = CompileJobStatus::kFailed; 253 status_ = CompileJobStatus::kFailed;
283 } else { 254 } else {
284 status_ = CompileJobStatus::kReadyToAnalyze; 255 status_ = CompileJobStatus::kReadyToAnalyse;
285 } 256 }
286 257
287 DeferredHandleScope scope(isolate_); 258 DeferredHandleScope scope(isolate_);
288 { 259 {
289 Handle<Script> script(Script::cast(shared_->script()), isolate_); 260 Handle<Script> script(Script::cast(shared_->script()), isolate_);
290 261
291 parse_info_->set_script(script); 262 parse_info_->set_script(script);
292 Handle<ScopeInfo> outer_scope_info( 263 Handle<ScopeInfo> outer_scope_info(
293 handle(ScopeInfo::cast(shared_->outer_scope_info()))); 264 handle(ScopeInfo::cast(shared_->outer_scope_info())));
294 if (outer_scope_info->length() > 0) { 265 if (outer_scope_info->length() > 0) {
(...skipping 10 matching lines...) Expand all
305 parse_info_->set_unicode_cache(nullptr); 276 parse_info_->set_unicode_cache(nullptr);
306 parser_.reset(); 277 parser_.reset();
307 unicode_cache_.reset(); 278 unicode_cache_.reset();
308 character_stream_.reset(); 279 character_stream_.reset();
309 } 280 }
310 handles_from_parsing_.reset(scope.Detach()); 281 handles_from_parsing_.reset(scope.Detach());
311 282
312 return status_ != CompileJobStatus::kFailed; 283 return status_ != CompileJobStatus::kFailed;
313 } 284 }
314 285
315 bool CompilerDispatcherJob::AnalyzeOnMainThread() { 286 bool CompilerDispatcherJob::PrepareToCompileOnMainThread() {
316 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 287 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
317 DCHECK(status() == CompileJobStatus::kReadyToAnalyze); 288 DCHECK(status() == CompileJobStatus::kReadyToAnalyse);
318 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kAnalyze); 289 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToCompile);
319 if (trace_compiler_dispatcher_jobs_) { 290 if (trace_compiler_dispatcher_jobs_) {
320 PrintF("CompilerDispatcherJob[%p]: Analyzing\n", static_cast<void*>(this)); 291 PrintF("CompilerDispatcherJob[%p]: Preparing to compile\n",
292 static_cast<void*>(this));
321 } 293 }
322 294
323 compile_info_.reset( 295 compile_info_.reset(
324 new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())); 296 new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null()));
325 297
326 DeferredHandleScope scope(isolate_); 298 DeferredHandleScope scope(isolate_);
327 { 299 if (Compiler::Analyze(parse_info_.get())) {
328 if (Compiler::Analyze(parse_info_.get())) { 300 compile_job_.reset(
329 status_ = CompileJobStatus::kAnalyzed; 301 Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
330 } else {
331 status_ = CompileJobStatus::kFailed;
332 if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
333 }
334 } 302 }
335 compile_info_->set_deferred_handles(scope.Detach()); 303 compile_info_->set_deferred_handles(scope.Detach());
336 304
337 return status_ != CompileJobStatus::kFailed;
338 }
339
340 bool CompilerDispatcherJob::PrepareToCompileOnMainThread() {
341 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
342 DCHECK(status() == CompileJobStatus::kAnalyzed);
343 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToCompile);
344
345 compile_job_.reset(
346 Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
347 if (!compile_job_.get()) { 305 if (!compile_job_.get()) {
348 if (!isolate_->has_pending_exception()) isolate_->StackOverflow(); 306 if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
349 status_ = CompileJobStatus::kFailed; 307 status_ = CompileJobStatus::kFailed;
350 return false; 308 return false;
351 } 309 }
352 310
353 CHECK(compile_job_->can_execute_on_background_thread()); 311 CHECK(compile_job_->can_execute_on_background_thread());
354 status_ = CompileJobStatus::kReadyToCompile; 312 status_ = CompileJobStatus::kReadyToCompile;
355 return true; 313 return true;
356 } 314 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 case CompileJobStatus::kInitial: 394 case CompileJobStatus::kInitial:
437 return tracer_->EstimatePrepareToParseInMs(); 395 return tracer_->EstimatePrepareToParseInMs();
438 396
439 case CompileJobStatus::kReadyToParse: 397 case CompileJobStatus::kReadyToParse:
440 return tracer_->EstimateParseInMs(parse_info_->end_position() - 398 return tracer_->EstimateParseInMs(parse_info_->end_position() -
441 parse_info_->start_position()); 399 parse_info_->start_position());
442 400
443 case CompileJobStatus::kParsed: 401 case CompileJobStatus::kParsed:
444 return tracer_->EstimateFinalizeParsingInMs(); 402 return tracer_->EstimateFinalizeParsingInMs();
445 403
446 case CompileJobStatus::kReadyToAnalyze: 404 case CompileJobStatus::kReadyToAnalyse:
447 return tracer_->EstimateAnalyzeInMs();
448
449 case CompileJobStatus::kAnalyzed:
450 return tracer_->EstimatePrepareToCompileInMs(); 405 return tracer_->EstimatePrepareToCompileInMs();
451 406
452 case CompileJobStatus::kReadyToCompile: 407 case CompileJobStatus::kReadyToCompile:
453 return tracer_->EstimateCompileInMs( 408 return tracer_->EstimateCompileInMs(
454 parse_info_->literal()->ast_node_count()); 409 parse_info_->literal()->ast_node_count());
455 410
456 case CompileJobStatus::kCompiled: 411 case CompileJobStatus::kCompiled:
457 return tracer_->EstimateFinalizeCompilingInMs(); 412 return tracer_->EstimateFinalizeCompilingInMs();
458 413
459 case CompileJobStatus::kFailed: 414 case CompileJobStatus::kFailed:
460 case CompileJobStatus::kDone: 415 case CompileJobStatus::kDone:
461 return 0.0; 416 return 0.0;
462 } 417 }
463 418
464 UNREACHABLE(); 419 UNREACHABLE();
465 return 0.0; 420 return 0.0;
466 } 421 }
467 422
468 void CompilerDispatcherJob::ShortPrint() { 423 void CompilerDispatcherJob::ShortPrint() {
469 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 424 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
470 shared_->ShortPrint(); 425 shared_->ShortPrint();
471 } 426 }
472 427
473 } // namespace internal 428 } // namespace internal
474 } // namespace v8 429 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.h ('k') | src/compiler-dispatcher/compiler-dispatcher-tracer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698