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

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

Issue 2650883002: Reland: [Compiler] Enable handles created during parsing and scope analysis to be deferred. (Closed)
Patch Set: Remove unused variable 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
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.h ('k') | src/handles.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/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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_)); 77 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_));
78 Handle<Script> script(Script::cast(shared_->script()), isolate_); 78 Handle<Script> script(Script::cast(shared_->script()), isolate_);
79 Handle<String> source(String::cast(script->source()), isolate_); 79 Handle<String> source(String::cast(script->source()), isolate_);
80 if (trace_compiler_dispatcher_jobs_) { 80 if (trace_compiler_dispatcher_jobs_) {
81 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); 81 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
82 shared_->ShortPrint(); 82 shared_->ShortPrint();
83 PrintF(" in initial state.\n"); 83 PrintF(" in initial state.\n");
84 } 84 }
85 } 85 }
86 86
87 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate, 87 CompilerDispatcherJob::CompilerDispatcherJob(
88 CompilerDispatcherTracer* tracer, 88 Isolate* isolate, CompilerDispatcherTracer* tracer,
89 Handle<SharedFunctionInfo> shared, 89 Handle<SharedFunctionInfo> shared, FunctionLiteral* literal,
90 FunctionLiteral* literal, 90 std::shared_ptr<Zone> parse_zone,
91 size_t max_stack_size) 91 std::shared_ptr<DeferredHandles> parse_handles,
92 std::shared_ptr<DeferredHandles> compile_handles, size_t max_stack_size)
92 : status_(CompileJobStatus::kAnalyzed), 93 : status_(CompileJobStatus::kAnalyzed),
93 isolate_(isolate), 94 isolate_(isolate),
94 tracer_(tracer), 95 tracer_(tracer),
95 shared_(Handle<SharedFunctionInfo>::cast( 96 shared_(Handle<SharedFunctionInfo>::cast(
96 isolate_->global_handles()->Create(*shared))), 97 isolate_->global_handles()->Create(*shared))),
97 max_stack_size_(max_stack_size), 98 max_stack_size_(max_stack_size),
98 parse_info_( 99 parse_info_(new ParseInfo(shared_)),
99 new ParseInfo(Handle<Script>(Script::cast(shared->script())))), 100 parse_zone_(parse_zone),
100 compile_info_(new CompilationInfo(parse_info_->zone(), parse_info_.get(), 101 compile_info_(new CompilationInfo(parse_info_->zone(), parse_info_.get(),
101 Handle<JSFunction>::null())), 102 Handle<JSFunction>::null())),
102 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { 103 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
103 parse_info_->set_literal(literal); 104 parse_info_->set_literal(literal);
104 parse_info_->set_shared_info(shared); 105 parse_info_->set_deferred_handles(parse_handles);
105 parse_info_->set_function_literal_id(shared->function_literal_id()); 106 compile_info_->set_deferred_handles(compile_handles);
106 parse_info_->set_language_mode(literal->scope()->language_mode()); 107
107 if (trace_compiler_dispatcher_jobs_) { 108 if (trace_compiler_dispatcher_jobs_) {
108 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); 109 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
109 shared_->ShortPrint(); 110 shared_->ShortPrint();
110 PrintF(" in Analyzed state.\n"); 111 PrintF(" in Analyzed state.\n");
111 } 112 }
112 } 113 }
113 114
114 CompilerDispatcherJob::~CompilerDispatcherJob() { 115 CompilerDispatcherJob::~CompilerDispatcherJob() {
115 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 116 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
116 DCHECK(status_ == CompileJobStatus::kInitial || 117 DCHECK(status_ == CompileJobStatus::kInitial ||
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 270
270 if (!source_.is_null()) { 271 if (!source_.is_null()) {
271 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); 272 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
272 source_ = Handle<String>::null(); 273 source_ = Handle<String>::null();
273 } 274 }
274 if (!wrapper_.is_null()) { 275 if (!wrapper_.is_null()) {
275 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location()); 276 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location());
276 wrapper_ = Handle<String>::null(); 277 wrapper_ = Handle<String>::null();
277 } 278 }
278 279
280 Handle<Script> script(Script::cast(shared_->script()), isolate_);
281 parse_info_->set_script(script);
279 if (parse_info_->literal() == nullptr) { 282 if (parse_info_->literal() == nullptr) {
283 parser_->ReportErrors(isolate_, script);
280 status_ = CompileJobStatus::kFailed; 284 status_ = CompileJobStatus::kFailed;
281 } else { 285 } else {
282 status_ = CompileJobStatus::kReadyToAnalyze; 286 status_ = CompileJobStatus::kReadyToAnalyze;
283 } 287 }
288 parser_->UpdateStatistics(isolate_, script);
284 289
285 DeferredHandleScope scope(isolate_); 290 DeferredHandleScope scope(isolate_);
286 { 291 {
287 Handle<Script> script(Script::cast(shared_->script()), isolate_); 292 parse_info_->ReopenHandlesInNewHandleScope();
288
289 parse_info_->set_script(script);
290 Handle<ScopeInfo> outer_scope_info( 293 Handle<ScopeInfo> outer_scope_info(
291 handle(ScopeInfo::cast(shared_->outer_scope_info()))); 294 handle(ScopeInfo::cast(shared_->outer_scope_info())));
292 if (outer_scope_info->length() > 0) { 295 if (outer_scope_info->length() > 0) {
293 parse_info_->set_outer_scope_info(outer_scope_info); 296 parse_info_->set_outer_scope_info(outer_scope_info);
294 } 297 }
295 parse_info_->set_shared_info(shared_); 298 parse_info_->set_shared_info(shared_);
296 299
297 // Do the parsing tasks which need to be done on the main thread. This 300 // Internalize ast values on the main thread.
298 // will also handle parse errors. 301 parse_info_->ast_value_factory()->Internalize(isolate_);
299 parser_->Internalize(isolate_, script, parse_info_->literal() == nullptr);
300 parser_->HandleSourceURLComments(isolate_, script); 302 parser_->HandleSourceURLComments(isolate_, script);
301 303
302 parse_info_->set_character_stream(nullptr); 304 parse_info_->set_character_stream(nullptr);
303 parse_info_->set_unicode_cache(nullptr); 305 parse_info_->set_unicode_cache(nullptr);
304 parser_.reset(); 306 parser_.reset();
305 unicode_cache_.reset(); 307 unicode_cache_.reset();
306 character_stream_.reset(); 308 character_stream_.reset();
307 } 309 }
308 handles_from_parsing_.reset(scope.Detach()); 310 parse_info_->set_deferred_handles(scope.Detach());
309 311
310 return status_ != CompileJobStatus::kFailed; 312 return status_ != CompileJobStatus::kFailed;
311 } 313 }
312 314
313 bool CompilerDispatcherJob::AnalyzeOnMainThread() { 315 bool CompilerDispatcherJob::AnalyzeOnMainThread() {
314 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 316 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
315 DCHECK(status() == CompileJobStatus::kReadyToAnalyze); 317 DCHECK(status() == CompileJobStatus::kReadyToAnalyze);
316 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kAnalyze); 318 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kAnalyze);
317 if (trace_compiler_dispatcher_jobs_) { 319 if (trace_compiler_dispatcher_jobs_) {
318 PrintF("CompilerDispatcherJob[%p]: Analyzing\n", static_cast<void*>(this)); 320 PrintF("CompilerDispatcherJob[%p]: Analyzing\n", static_cast<void*>(this));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 388
387 if (compile_job_->state() == CompilationJob::State::kFailed || 389 if (compile_job_->state() == CompilationJob::State::kFailed ||
388 !Compiler::FinalizeCompilationJob(compile_job_.release())) { 390 !Compiler::FinalizeCompilationJob(compile_job_.release())) {
389 if (!isolate_->has_pending_exception()) isolate_->StackOverflow(); 391 if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
390 status_ = CompileJobStatus::kFailed; 392 status_ = CompileJobStatus::kFailed;
391 return false; 393 return false;
392 } 394 }
393 395
394 compile_job_.reset(); 396 compile_job_.reset();
395 compile_info_.reset(); 397 compile_info_.reset();
396 handles_from_parsing_.reset(); 398 parse_zone_.reset();
397 parse_info_.reset(); 399 parse_info_.reset();
398 400
399 status_ = CompileJobStatus::kDone; 401 status_ = CompileJobStatus::kDone;
400 return true; 402 return true;
401 } 403 }
402 404
403 void CompilerDispatcherJob::ResetOnMainThread() { 405 void CompilerDispatcherJob::ResetOnMainThread() {
404 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 406 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
405 407
406 if (trace_compiler_dispatcher_jobs_) { 408 if (trace_compiler_dispatcher_jobs_) {
407 PrintF("CompilerDispatcherJob[%p]: Resetting\n", static_cast<void*>(this)); 409 PrintF("CompilerDispatcherJob[%p]: Resetting\n", static_cast<void*>(this));
408 } 410 }
409 411
410 compile_job_.reset(); 412 compile_job_.reset();
411 compile_info_.reset(); 413 compile_info_.reset();
414 parse_zone_.reset();
412 parser_.reset(); 415 parser_.reset();
413 unicode_cache_.reset(); 416 unicode_cache_.reset();
414 character_stream_.reset(); 417 character_stream_.reset();
415 handles_from_parsing_.reset();
416 parse_info_.reset(); 418 parse_info_.reset();
417 419
418 if (!source_.is_null()) { 420 if (!source_.is_null()) {
419 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); 421 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
420 source_ = Handle<String>::null(); 422 source_ = Handle<String>::null();
421 } 423 }
422 if (!wrapper_.is_null()) { 424 if (!wrapper_.is_null()) {
423 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location()); 425 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location());
424 wrapper_ = Handle<String>::null(); 426 wrapper_ = Handle<String>::null();
425 } 427 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return 0.0; 463 return 0.0;
462 } 464 }
463 465
464 void CompilerDispatcherJob::ShortPrint() { 466 void CompilerDispatcherJob::ShortPrint() {
465 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 467 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
466 shared_->ShortPrint(); 468 shared_->ShortPrint();
467 } 469 }
468 470
469 } // namespace internal 471 } // namespace internal
470 } // namespace v8 472 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698