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

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

Issue 2448323004: [Interpreter] Don't require a CanonicalHandleScope for parse / renumbering (Closed)
Patch Set: Created 4 years, 1 month 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/interpreter/bytecode-generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "src/compiler.h" 11 #include "src/compiler.h"
12 #include "src/interpreter/bytecode-flags.h" 12 #include "src/interpreter/bytecode-flags.h"
13 #include "src/interpreter/bytecode-label.h" 13 #include "src/interpreter/bytecode-label.h"
14 #include "src/interpreter/bytecode-register-allocator.h" 14 #include "src/interpreter/bytecode-register-allocator.h"
15 #include "src/interpreter/control-flow-builders.h" 15 #include "src/interpreter/control-flow-builders.h"
16 #include "src/objects.h" 16 #include "src/objects.h"
17 #include "src/parsing/parse-info.h"
17 #include "src/parsing/token.h" 18 #include "src/parsing/token.h"
18 19
19 namespace v8 { 20 namespace v8 {
20 namespace internal { 21 namespace internal {
21 namespace interpreter { 22 namespace interpreter {
22 23
23 // Scoped class tracking context objects created by the visitor. Represents 24 // Scoped class tracking context objects created by the visitor. Represents
24 // mutations of the context chain within the function body, allowing pushing and 25 // mutations of the context chain within the function body, allowing pushing and
25 // popping of the current {context_register} during visitation. 26 // popping of the current {context_register} during visitation.
26 class BytecodeGenerator::ContextScope BASE_EMBEDDED { 27 class BytecodeGenerator::ContextScope BASE_EMBEDDED {
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 global_declarations_(0, info->zone()), 565 global_declarations_(0, info->zone()),
565 function_literals_(0, info->zone()), 566 function_literals_(0, info->zone()),
566 native_function_literals_(0, info->zone()), 567 native_function_literals_(0, info->zone()),
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 empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()) {
576 AstValueFactory* ast_value_factory = info->parse_info()->ast_value_factory();
577 const AstRawString* prototype_string = ast_value_factory->prototype_string();
578 ast_value_factory->Internalize(info->isolate());
579 prototype_string_ = prototype_string->string();
575 } 580 }
576 581
577 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { 582 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) {
578 AllocateDeferredConstants(); 583 AllocateDeferredConstants();
579 if (HasStackOverflow()) return Handle<BytecodeArray>(); 584 if (HasStackOverflow()) return Handle<BytecodeArray>();
580 return builder()->ToBytecodeArray(isolate); 585 return builder()->ToBytecodeArray(isolate);
581 } 586 }
582 587
583 void BytecodeGenerator::AllocateDeferredConstants() { 588 void BytecodeGenerator::AllocateDeferredConstants() {
584 // Build global declaration pair arrays. 589 // Build global declaration pair arrays.
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), 1566 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(),
1562 expr->flags()); 1567 expr->flags());
1563 } 1568 }
1564 1569
1565 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1570 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1566 // Copy the literal boilerplate. 1571 // Copy the literal boilerplate.
1567 uint8_t flags = CreateObjectLiteralFlags::Encode( 1572 uint8_t flags = CreateObjectLiteralFlags::Encode(
1568 FastCloneShallowObjectStub::IsSupported(expr), 1573 FastCloneShallowObjectStub::IsSupported(expr),
1569 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count()), 1574 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count()),
1570 expr->ComputeFlags()); 1575 expr->ComputeFlags());
1571 // Allocate in the outer scope since this register is used to return the 1576 // If constant properties is an empty fixed array, use our cached
1572 // expression's results to the caller. 1577 // empty_fixed_array to ensure it's only added to the constant pool once.
1578 Handle<FixedArray> constant_properties = expr->properties_count() == 0
1579 ? empty_fixed_array()
1580 : expr->constant_properties();
1573 Register literal = register_allocator()->NewRegister(); 1581 Register literal = register_allocator()->NewRegister();
1574 builder()->CreateObjectLiteral(expr->constant_properties(), 1582 builder()->CreateObjectLiteral(constant_properties, expr->literal_index(),
1575 expr->literal_index(), flags, literal); 1583 flags, literal);
1576 1584
1577 // Store computed values into the literal. 1585 // Store computed values into the literal.
1578 int property_index = 0; 1586 int property_index = 0;
1579 AccessorTable accessor_table(zone()); 1587 AccessorTable accessor_table(zone());
1580 for (; property_index < expr->properties()->length(); property_index++) { 1588 for (; property_index < expr->properties()->length(); property_index++) {
1581 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1589 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1582 if (property->is_computed_name()) break; 1590 if (property->is_computed_name()) break;
1583 if (property->IsCompileTimeValue()) continue; 1591 if (property->IsCompileTimeValue()) continue;
1584 1592
1585 RegisterAllocationScope inner_register_scope(this); 1593 RegisterAllocationScope inner_register_scope(this);
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3208 } 3216 }
3209 3217
3210 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3218 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3211 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3219 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3212 : Runtime::kStoreKeyedToSuper_Sloppy; 3220 : Runtime::kStoreKeyedToSuper_Sloppy;
3213 } 3221 }
3214 3222
3215 } // namespace interpreter 3223 } // namespace interpreter
3216 } // namespace internal 3224 } // namespace internal
3217 } // namespace v8 3225 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698