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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2399463008: Create multiple compilation jobs for ignition if compiling multiple literals (Closed)
Patch Set: updates Created 4 years, 2 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/compile-time-value.h" 7 #include "src/ast/compile-time-value.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-info.h" 10 #include "src/compilation-info.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 void AddFunctionDeclaration(FeedbackVectorSlot slot, FunctionLiteral* func) { 498 void AddFunctionDeclaration(FeedbackVectorSlot slot, FunctionLiteral* func) {
499 DCHECK(!slot.IsInvalid()); 499 DCHECK(!slot.IsInvalid());
500 declarations_.push_back(std::make_pair(slot, func)); 500 declarations_.push_back(std::make_pair(slot, func));
501 } 501 }
502 502
503 void AddUndefinedDeclaration(FeedbackVectorSlot slot) { 503 void AddUndefinedDeclaration(FeedbackVectorSlot slot) {
504 DCHECK(!slot.IsInvalid()); 504 DCHECK(!slot.IsInvalid());
505 declarations_.push_back(std::make_pair(slot, nullptr)); 505 declarations_.push_back(std::make_pair(slot, nullptr));
506 } 506 }
507 507
508 Handle<FixedArray> AllocateDeclarationPairs(CompilationInfo* info) { 508 Handle<FixedArray> AllocateDeclarationPairs(CompilationInfo* info,
509 ShouldCompile should_compile) {
509 DCHECK(has_constant_pool_entry_); 510 DCHECK(has_constant_pool_entry_);
510 int array_index = 0; 511 int array_index = 0;
511 Handle<FixedArray> pairs = info->isolate()->factory()->NewFixedArray( 512 Handle<FixedArray> pairs = info->isolate()->factory()->NewFixedArray(
512 static_cast<int>(declarations_.size() * 2), TENURED); 513 static_cast<int>(declarations_.size() * 2), TENURED);
513 for (std::pair<FeedbackVectorSlot, FunctionLiteral*> declaration : 514 for (std::pair<FeedbackVectorSlot, FunctionLiteral*> declaration :
514 declarations_) { 515 declarations_) {
515 FunctionLiteral* func = declaration.second; 516 FunctionLiteral* func = declaration.second;
516 Handle<Object> initial_value; 517 Handle<Object> initial_value;
517 if (func == nullptr) { 518 if (func == nullptr) {
518 initial_value = info->isolate()->factory()->undefined_value(); 519 initial_value = info->isolate()->factory()->undefined_value();
519 } else { 520 } else {
520 initial_value = 521 initial_value = Compiler::GetSharedFunctionInfo(func, info->script(),
521 Compiler::GetSharedFunctionInfo(func, info->script(), info); 522 info, should_compile);
522 } 523 }
523 524
524 // Return a null handle if any initial values can't be created. Caller 525 // Return a null handle if any initial values can't be created. Caller
525 // will set stack overflow. 526 // will set stack overflow.
526 if (initial_value.is_null()) return Handle<FixedArray>(); 527 if (initial_value.is_null()) return Handle<FixedArray>();
527 528
528 pairs->set(array_index++, Smi::FromInt(declaration.first.ToInt())); 529 pairs->set(array_index++, Smi::FromInt(declaration.first.ToInt()));
529 pairs->set(array_index++, *initial_value); 530 pairs->set(array_index++, *initial_value);
530 } 531 }
531 return pairs; 532 return pairs;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 execution_control_(nullptr), 568 execution_control_(nullptr),
568 execution_context_(nullptr), 569 execution_context_(nullptr),
569 execution_result_(nullptr), 570 execution_result_(nullptr),
570 generator_resume_points_(info->literal()->yield_count(), info->zone()), 571 generator_resume_points_(info->literal()->yield_count(), info->zone()),
571 generator_state_(), 572 generator_state_(),
572 loop_depth_(0), 573 loop_depth_(0),
573 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), 574 home_object_symbol_(info->isolate()->factory()->home_object_symbol()),
574 prototype_string_(info->isolate()->factory()->prototype_string()) { 575 prototype_string_(info->isolate()->factory()->prototype_string()) {
575 } 576 }
576 577
577 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { 578 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
578 AllocateDeferredConstants(); 579 Isolate* isolate, ShouldCompile should_compile) {
580 AllocateDeferredConstants(should_compile);
579 if (HasStackOverflow()) return Handle<BytecodeArray>(); 581 if (HasStackOverflow()) return Handle<BytecodeArray>();
580 return builder()->ToBytecodeArray(isolate); 582 return builder()->ToBytecodeArray(isolate);
581 } 583 }
582 584
583 void BytecodeGenerator::AllocateDeferredConstants() { 585 void BytecodeGenerator::AllocateDeferredConstants(
586 ShouldCompile should_compile) {
584 // Build global declaration pair arrays. 587 // Build global declaration pair arrays.
585 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { 588 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) {
586 Handle<FixedArray> declarations = 589 Handle<FixedArray> declarations =
587 globals_builder->AllocateDeclarationPairs(info()); 590 globals_builder->AllocateDeclarationPairs(info(), should_compile);
588 if (declarations.is_null()) return SetStackOverflow(); 591 if (declarations.is_null()) return SetStackOverflow();
589 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), 592 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(),
590 declarations); 593 declarations);
591 } 594 }
592 595
593 // Find or build shared function infos. 596 // Find or build shared function infos.
594 for (std::pair<FunctionLiteral*, size_t> literal : function_literals_) { 597 for (std::pair<FunctionLiteral*, size_t> literal : function_literals_) {
595 FunctionLiteral* expr = literal.first; 598 FunctionLiteral* expr = literal.first;
596 Handle<SharedFunctionInfo> shared_info = 599 Handle<SharedFunctionInfo> shared_info = Compiler::GetSharedFunctionInfo(
597 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); 600 expr, info()->script(), info(), should_compile);
598 if (shared_info.is_null()) return SetStackOverflow(); 601 if (shared_info.is_null()) return SetStackOverflow();
599 builder()->InsertConstantPoolEntryAt(literal.second, shared_info); 602 builder()->InsertConstantPoolEntryAt(literal.second, shared_info);
600 } 603 }
601 604
602 // Find or build shared function infos for the native function templates. 605 // Find or build shared function infos for the native function templates.
603 for (std::pair<NativeFunctionLiteral*, size_t> literal : 606 for (std::pair<NativeFunctionLiteral*, size_t> literal :
604 native_function_literals_) { 607 native_function_literals_) {
605 NativeFunctionLiteral* expr = literal.first; 608 NativeFunctionLiteral* expr = literal.first;
606 Handle<SharedFunctionInfo> shared_info = 609 Handle<SharedFunctionInfo> shared_info =
607 Compiler::GetSharedFunctionInfoForNative(expr->extension(), 610 Compiler::GetSharedFunctionInfoForNative(expr->extension(),
(...skipping 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 } 3189 }
3187 3190
3188 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3191 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3189 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3192 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3190 : Runtime::kStoreKeyedToSuper_Sloppy; 3193 : Runtime::kStoreKeyedToSuper_Sloppy;
3191 } 3194 }
3192 3195
3193 } // namespace interpreter 3196 } // namespace interpreter
3194 } // namespace internal 3197 } // namespace internal
3195 } // namespace v8 3198 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698