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

Unified Diff: src/code-stubs.cc

Issue 2177273002: Make FastNewFunctionContextStub take slots parameter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: move loop check Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 0fb866e9491049d7e165d43da0f7c7923845a657..8ae620ed58cd2e0e88a0cdae275f273cbe24fff5 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -4493,26 +4493,33 @@ void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const {
void FastNewFunctionContextStub::GenerateAssembly(
CodeStubAssembler* assembler) const {
+ typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
+ typedef CodeStubAssembler::Variable Variable;
- int length = slots() + Context::MIN_CONTEXT_SLOTS;
- int size = length * kPointerSize + FixedArray::kHeaderSize;
-
- // Get the function
Node* function =
assembler->Parameter(FastNewFunctionContextDescriptor::kFunctionIndex);
+ Node* slots =
+ assembler->Parameter(FastNewFunctionContextDescriptor::kSlotsIndex);
Node* context =
assembler->Parameter(FastNewFunctionContextDescriptor::kContextIndex);
+ Node* min_context_slots =
+ assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS);
+ Node* length = assembler->Int32Add(slots, min_context_slots);
+ Node* size = assembler->Int32Add(
+ assembler->Int32Mul(length, assembler->Int32Constant(kPointerSize)),
+ assembler->Int32Constant(FixedArray::kHeaderSize));
+
// Create a new closure from the given function info in new space
Node* function_context = assembler->Allocate(size);
assembler->StoreMapNoWriteBarrier(
function_context,
assembler->HeapConstant(isolate()->factory()->function_context_map()));
- assembler->StoreObjectFieldNoWriteBarrier(
- function_context, Context::kLengthOffset,
- assembler->SmiConstant(Smi::FromInt(length)));
+ assembler->StoreObjectFieldNoWriteBarrier(function_context,
+ Context::kLengthOffset,
+ assembler->SmiFromWord32(length));
// Set up the fixed slots.
assembler->StoreFixedArrayElement(
@@ -4534,11 +4541,23 @@ void FastNewFunctionContextStub::GenerateAssembly(
// Initialize the rest of the slots to undefined.
Node* undefined = assembler->UndefinedConstant();
- for (int i = Context::MIN_CONTEXT_SLOTS; i < length; ++i) {
- assembler->StoreFixedArrayElement(function_context,
- assembler->Int32Constant(i), undefined,
+ Variable var_slot_index(assembler, MachineType::PointerRepresentation());
+ var_slot_index.Bind(min_context_slots);
+ Label loop(assembler, &var_slot_index), after_loop(assembler);
+ assembler->Goto(&loop);
+
+ assembler->Bind(&loop);
+ {
rmcilroy 2016/07/28 15:04:27 Please add a comment that there will always be at
klaasb 2016/07/28 15:34:47 Done.
+ Node* slot_index = var_slot_index.value();
+ assembler->StoreFixedArrayElement(function_context, slot_index, undefined,
SKIP_WRITE_BARRIER);
+ Node* one = assembler->Int32Constant(1);
+ Node* next_index = assembler->Int32Add(slot_index, one);
+ var_slot_index.Bind(next_index);
+ assembler->Branch(assembler->Int32LessThan(next_index, length), &loop,
+ &after_loop);
}
+ assembler->Bind(&after_loop);
assembler->Return(function_context);
}
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698