| OLD | NEW |
| 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/builtins/builtins-constructor.h" | 9 #include "src/builtins/builtins-constructor.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1667 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 1668 // Materialize a regular expression literal. | 1668 // Materialize a regular expression literal. |
| 1669 builder()->CreateRegExpLiteral( | 1669 builder()->CreateRegExpLiteral( |
| 1670 expr->raw_pattern(), feedback_index(expr->literal_slot()), expr->flags()); | 1670 expr->raw_pattern(), feedback_index(expr->literal_slot()), expr->flags()); |
| 1671 } | 1671 } |
| 1672 | 1672 |
| 1673 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1673 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1674 // Deep-copy the literal boilerplate. | 1674 // Deep-copy the literal boilerplate. |
| 1675 uint8_t flags = CreateObjectLiteralFlags::Encode( | 1675 uint8_t flags = CreateObjectLiteralFlags::Encode( |
| 1676 expr->IsFastCloningSupported(), | 1676 expr->IsFastCloningSupported(), |
| 1677 ConstructorBuiltinsAssembler::FastCloneShallowObjectPropertiesCount( | 1677 ConstructorBuiltins::FastCloneShallowObjectPropertiesCount( |
| 1678 expr->properties_count()), | 1678 expr->properties_count()), |
| 1679 expr->ComputeFlags()); | 1679 expr->ComputeFlags()); |
| 1680 | 1680 |
| 1681 Register literal = register_allocator()->NewRegister(); | 1681 Register literal = register_allocator()->NewRegister(); |
| 1682 size_t entry; | 1682 size_t entry; |
| 1683 // If constant properties is an empty fixed array, use a cached empty fixed | 1683 // If constant properties is an empty fixed array, use a cached empty fixed |
| 1684 // array to ensure it's only added to the constant pool once. | 1684 // array to ensure it's only added to the constant pool once. |
| 1685 if (expr->properties_count() == 0) { | 1685 if (expr->properties_count() == 0) { |
| 1686 entry = builder()->EmptyFixedArrayConstantPoolEntry(); | 1686 entry = builder()->EmptyFixedArrayConstantPoolEntry(); |
| 1687 } else { | 1687 } else { |
| (...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 builder() | 3205 builder() |
| 3206 ->MoveRegister(builder()->Parameter(1), args[0]) | 3206 ->MoveRegister(builder()->Parameter(1), args[0]) |
| 3207 .LoadAccumulatorWithRegister(Register::function_closure()) | 3207 .LoadAccumulatorWithRegister(Register::function_closure()) |
| 3208 .StoreAccumulatorInRegister(args[1]) | 3208 .StoreAccumulatorInRegister(args[1]) |
| 3209 .LoadLiteral(scope) | 3209 .LoadLiteral(scope) |
| 3210 .StoreAccumulatorInRegister(args[2]) | 3210 .StoreAccumulatorInRegister(args[2]) |
| 3211 .CallRuntime(Runtime::kPushModuleContext, args); | 3211 .CallRuntime(Runtime::kPushModuleContext, args); |
| 3212 } else { | 3212 } else { |
| 3213 DCHECK(scope->is_function_scope() || scope->is_eval_scope()); | 3213 DCHECK(scope->is_function_scope() || scope->is_eval_scope()); |
| 3214 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 3214 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 3215 if (slot_count <= | 3215 if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) { |
| 3216 ConstructorBuiltinsAssembler::MaximumFunctionContextSlots()) { | |
| 3217 switch (scope->scope_type()) { | 3216 switch (scope->scope_type()) { |
| 3218 case EVAL_SCOPE: | 3217 case EVAL_SCOPE: |
| 3219 builder()->CreateEvalContext(slot_count); | 3218 builder()->CreateEvalContext(slot_count); |
| 3220 break; | 3219 break; |
| 3221 case FUNCTION_SCOPE: | 3220 case FUNCTION_SCOPE: |
| 3222 builder()->CreateFunctionContext(slot_count); | 3221 builder()->CreateFunctionContext(slot_count); |
| 3223 break; | 3222 break; |
| 3224 default: | 3223 default: |
| 3225 UNREACHABLE(); | 3224 UNREACHABLE(); |
| 3226 } | 3225 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3504 } | 3503 } |
| 3505 | 3504 |
| 3506 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3505 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
| 3507 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3506 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
| 3508 : Runtime::kStoreKeyedToSuper_Sloppy; | 3507 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 3509 } | 3508 } |
| 3510 | 3509 |
| 3511 } // namespace interpreter | 3510 } // namespace interpreter |
| 3512 } // namespace internal | 3511 } // namespace internal |
| 3513 } // namespace v8 | 3512 } // namespace v8 |
| OLD | NEW |