| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 5117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5128 | 5128 |
| 5129 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 5129 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
| 5130 assembler->Return( | 5130 assembler->Return( |
| 5131 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); | 5131 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); |
| 5132 } | 5132 } |
| 5133 | 5133 |
| 5134 // static | 5134 // static |
| 5135 compiler::Node* FastNewFunctionContextStub::Generate( | 5135 compiler::Node* FastNewFunctionContextStub::Generate( |
| 5136 CodeStubAssembler* assembler, compiler::Node* function, | 5136 CodeStubAssembler* assembler, compiler::Node* function, |
| 5137 compiler::Node* slots, compiler::Node* context) { | 5137 compiler::Node* slots, compiler::Node* context) { |
| 5138 typedef CodeStubAssembler::Label Label; | |
| 5139 typedef compiler::Node Node; | 5138 typedef compiler::Node Node; |
| 5140 typedef CodeStubAssembler::Variable Variable; | |
| 5141 | 5139 |
| 5142 Node* min_context_slots = | 5140 Node* min_context_slots = |
| 5143 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); | 5141 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); |
| 5144 Node* length = assembler->Int32Add(slots, min_context_slots); | 5142 Node* length = assembler->Int32Add(slots, min_context_slots); |
| 5145 Node* size = assembler->Int32Add( | 5143 Node* size = assembler->Int32Add( |
| 5146 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)), | 5144 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)), |
| 5147 assembler->Int32Constant(FixedArray::kHeaderSize)); | 5145 assembler->Int32Constant(FixedArray::kHeaderSize)); |
| 5148 | 5146 |
| 5149 // Create a new closure from the given function info in new space | 5147 // Create a new closure from the given function info in new space |
| 5150 Node* function_context = assembler->Allocate(size); | 5148 Node* function_context = assembler->Allocate(size); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5169 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); | 5167 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); |
| 5170 | 5168 |
| 5171 // Copy the native context from the previous context. | 5169 // Copy the native context from the previous context. |
| 5172 Node* native_context = assembler->LoadNativeContext(context); | 5170 Node* native_context = assembler->LoadNativeContext(context); |
| 5173 assembler->StoreFixedArrayElement( | 5171 assembler->StoreFixedArrayElement( |
| 5174 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), | 5172 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), |
| 5175 native_context, SKIP_WRITE_BARRIER); | 5173 native_context, SKIP_WRITE_BARRIER); |
| 5176 | 5174 |
| 5177 // Initialize the rest of the slots to undefined. | 5175 // Initialize the rest of the slots to undefined. |
| 5178 Node* undefined = assembler->UndefinedConstant(); | 5176 Node* undefined = assembler->UndefinedConstant(); |
| 5179 Variable var_slot_index(assembler, MachineRepresentation::kWord32); | 5177 assembler->BuildFastFixedArrayForEach( |
| 5180 var_slot_index.Bind(min_context_slots); | 5178 function_context, FAST_ELEMENTS, min_context_slots, length, |
| 5181 Label loop(assembler, &var_slot_index), after_loop(assembler); | 5179 [undefined](CodeStubAssembler* assembler, Node* context, Node* offset) { |
| 5182 assembler->Goto(&loop); | 5180 assembler->StoreNoWriteBarrier(MachineType::PointerRepresentation(), |
| 5183 | 5181 context, offset, undefined); |
| 5184 assembler->Bind(&loop); | 5182 }); |
| 5185 { | |
| 5186 Node* slot_index = var_slot_index.value(); | |
| 5187 assembler->GotoUnless(assembler->Int32LessThan(slot_index, length), | |
| 5188 &after_loop); | |
| 5189 assembler->StoreFixedArrayElement(function_context, slot_index, undefined, | |
| 5190 SKIP_WRITE_BARRIER); | |
| 5191 Node* one = assembler->Int32Constant(1); | |
| 5192 Node* next_index = assembler->Int32Add(slot_index, one); | |
| 5193 var_slot_index.Bind(next_index); | |
| 5194 assembler->Goto(&loop); | |
| 5195 } | |
| 5196 assembler->Bind(&after_loop); | |
| 5197 | 5183 |
| 5198 return function_context; | 5184 return function_context; |
| 5199 } | 5185 } |
| 5200 | 5186 |
| 5201 void FastNewFunctionContextStub::GenerateAssembly( | 5187 void FastNewFunctionContextStub::GenerateAssembly( |
| 5202 CodeStubAssembler* assembler) const { | 5188 CodeStubAssembler* assembler) const { |
| 5203 typedef compiler::Node Node; | 5189 typedef compiler::Node Node; |
| 5204 Node* function = assembler->Parameter(Descriptor::kFunction); | 5190 Node* function = assembler->Parameter(Descriptor::kFunction); |
| 5205 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots); | 5191 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots); |
| 5206 Node* context = assembler->Parameter(Descriptor::kContext); | 5192 Node* context = assembler->Parameter(Descriptor::kContext); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5828 | 5814 |
| 5829 if (type == MachineType::Pointer()) { | 5815 if (type == MachineType::Pointer()) { |
| 5830 return Representation::External(); | 5816 return Representation::External(); |
| 5831 } | 5817 } |
| 5832 | 5818 |
| 5833 return Representation::Tagged(); | 5819 return Representation::Tagged(); |
| 5834 } | 5820 } |
| 5835 | 5821 |
| 5836 } // namespace internal | 5822 } // namespace internal |
| 5837 } // namespace v8 | 5823 } // namespace v8 |
| OLD | NEW |