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

Side by Side Diff: src/code-stubs.cc

Issue 2380953002: [stubs] Generalize loop handling in CodeStubAssembler and improve common loop performance (Closed)
Patch Set: Rebase 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
« src/code-stub-assembler.cc ('K') | « src/code-stub-assembler.cc ('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 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 5161 matching lines...) Expand 10 before | Expand all | Expand 10 after
5172 5172
5173 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { 5173 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const {
5174 assembler->Return( 5174 assembler->Return(
5175 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); 5175 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1)));
5176 } 5176 }
5177 5177
5178 // static 5178 // static
5179 compiler::Node* FastNewFunctionContextStub::Generate( 5179 compiler::Node* FastNewFunctionContextStub::Generate(
5180 CodeStubAssembler* assembler, compiler::Node* function, 5180 CodeStubAssembler* assembler, compiler::Node* function,
5181 compiler::Node* slots, compiler::Node* context) { 5181 compiler::Node* slots, compiler::Node* context) {
5182 typedef CodeStubAssembler::Label Label;
5183 typedef compiler::Node Node; 5182 typedef compiler::Node Node;
5184 typedef CodeStubAssembler::Variable Variable;
5185 5183
5186 Node* min_context_slots = 5184 Node* min_context_slots =
5187 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); 5185 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS);
5188 Node* length = assembler->Int32Add(slots, min_context_slots); 5186 Node* length = assembler->Int32Add(slots, min_context_slots);
5189 Node* size = assembler->Int32Add( 5187 Node* size = assembler->Int32Add(
5190 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)), 5188 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)),
5191 assembler->Int32Constant(FixedArray::kHeaderSize)); 5189 assembler->Int32Constant(FixedArray::kHeaderSize));
5192 5190
5193 // Create a new closure from the given function info in new space 5191 // Create a new closure from the given function info in new space
5194 Node* function_context = assembler->Allocate(size); 5192 Node* function_context = assembler->Allocate(size);
(...skipping 18 matching lines...) Expand all
5213 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); 5211 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER);
5214 5212
5215 // Copy the native context from the previous context. 5213 // Copy the native context from the previous context.
5216 Node* native_context = assembler->LoadNativeContext(context); 5214 Node* native_context = assembler->LoadNativeContext(context);
5217 assembler->StoreFixedArrayElement( 5215 assembler->StoreFixedArrayElement(
5218 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), 5216 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX),
5219 native_context, SKIP_WRITE_BARRIER); 5217 native_context, SKIP_WRITE_BARRIER);
5220 5218
5221 // Initialize the rest of the slots to undefined. 5219 // Initialize the rest of the slots to undefined.
5222 Node* undefined = assembler->UndefinedConstant(); 5220 Node* undefined = assembler->UndefinedConstant();
5223 Variable var_slot_index(assembler, MachineRepresentation::kWord32); 5221 assembler->BuildFastFixedArrayForEach(
5224 var_slot_index.Bind(min_context_slots); 5222 function_context, FAST_ELEMENTS, min_context_slots, length,
5225 Label loop(assembler, &var_slot_index), after_loop(assembler); 5223 [undefined](CodeStubAssembler* assembler, Node* context, Node* offset) {
5226 assembler->Goto(&loop); 5224 assembler->StoreNoWriteBarrier(MachineType::PointerRepresentation(),
5227 5225 context, offset, undefined);
5228 assembler->Bind(&loop); 5226 });
5229 {
5230 Node* slot_index = var_slot_index.value();
5231 assembler->GotoUnless(assembler->Int32LessThan(slot_index, length),
5232 &after_loop);
5233 assembler->StoreFixedArrayElement(function_context, slot_index, undefined,
5234 SKIP_WRITE_BARRIER);
5235 Node* one = assembler->Int32Constant(1);
5236 Node* next_index = assembler->Int32Add(slot_index, one);
5237 var_slot_index.Bind(next_index);
5238 assembler->Goto(&loop);
5239 }
5240 assembler->Bind(&after_loop);
5241 5227
5242 return function_context; 5228 return function_context;
5243 } 5229 }
5244 5230
5245 void FastNewFunctionContextStub::GenerateAssembly( 5231 void FastNewFunctionContextStub::GenerateAssembly(
5246 CodeStubAssembler* assembler) const { 5232 CodeStubAssembler* assembler) const {
5247 typedef compiler::Node Node; 5233 typedef compiler::Node Node;
5248 Node* function = assembler->Parameter(Descriptor::kFunction); 5234 Node* function = assembler->Parameter(Descriptor::kFunction);
5249 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots); 5235 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots);
5250 Node* context = assembler->Parameter(Descriptor::kContext); 5236 Node* context = assembler->Parameter(Descriptor::kContext);
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
5872 5858
5873 if (type == MachineType::Pointer()) { 5859 if (type == MachineType::Pointer()) {
5874 return Representation::External(); 5860 return Representation::External();
5875 } 5861 }
5876 5862
5877 return Representation::Tagged(); 5863 return Representation::Tagged();
5878 } 5864 }
5879 5865
5880 } // namespace internal 5866 } // namespace internal
5881 } // namespace v8 5867 } // namespace v8
OLDNEW
« src/code-stub-assembler.cc ('K') | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698