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

Side by Side 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, 4 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
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | 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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 4475 matching lines...) Expand 10 before | Expand all | Expand 10 after
4486 return result; 4486 return result;
4487 } 4487 }
4488 4488
4489 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { 4489 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const {
4490 assembler->Return( 4490 assembler->Return(
4491 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); 4491 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1)));
4492 } 4492 }
4493 4493
4494 void FastNewFunctionContextStub::GenerateAssembly( 4494 void FastNewFunctionContextStub::GenerateAssembly(
4495 CodeStubAssembler* assembler) const { 4495 CodeStubAssembler* assembler) const {
4496 typedef CodeStubAssembler::Label Label;
4496 typedef compiler::Node Node; 4497 typedef compiler::Node Node;
4498 typedef CodeStubAssembler::Variable Variable;
4497 4499
4498 int length = slots() + Context::MIN_CONTEXT_SLOTS;
4499 int size = length * kPointerSize + FixedArray::kHeaderSize;
4500
4501 // Get the function
4502 Node* function = 4500 Node* function =
4503 assembler->Parameter(FastNewFunctionContextDescriptor::kFunctionIndex); 4501 assembler->Parameter(FastNewFunctionContextDescriptor::kFunctionIndex);
4502 Node* slots =
4503 assembler->Parameter(FastNewFunctionContextDescriptor::kSlotsIndex);
4504 Node* context = 4504 Node* context =
4505 assembler->Parameter(FastNewFunctionContextDescriptor::kContextIndex); 4505 assembler->Parameter(FastNewFunctionContextDescriptor::kContextIndex);
4506 4506
4507 Node* min_context_slots =
4508 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS);
4509 Node* length = assembler->Int32Add(slots, min_context_slots);
4510 Node* size = assembler->Int32Add(
4511 assembler->Int32Mul(length, assembler->Int32Constant(kPointerSize)),
4512 assembler->Int32Constant(FixedArray::kHeaderSize));
4513
4507 // Create a new closure from the given function info in new space 4514 // Create a new closure from the given function info in new space
4508 Node* function_context = assembler->Allocate(size); 4515 Node* function_context = assembler->Allocate(size);
4509 4516
4510 assembler->StoreMapNoWriteBarrier( 4517 assembler->StoreMapNoWriteBarrier(
4511 function_context, 4518 function_context,
4512 assembler->HeapConstant(isolate()->factory()->function_context_map())); 4519 assembler->HeapConstant(isolate()->factory()->function_context_map()));
4513 assembler->StoreObjectFieldNoWriteBarrier( 4520 assembler->StoreObjectFieldNoWriteBarrier(function_context,
4514 function_context, Context::kLengthOffset, 4521 Context::kLengthOffset,
4515 assembler->SmiConstant(Smi::FromInt(length))); 4522 assembler->SmiFromWord32(length));
4516 4523
4517 // Set up the fixed slots. 4524 // Set up the fixed slots.
4518 assembler->StoreFixedArrayElement( 4525 assembler->StoreFixedArrayElement(
4519 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX), 4526 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX),
4520 function, SKIP_WRITE_BARRIER); 4527 function, SKIP_WRITE_BARRIER);
4521 assembler->StoreFixedArrayElement( 4528 assembler->StoreFixedArrayElement(
4522 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX), 4529 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX),
4523 context, SKIP_WRITE_BARRIER); 4530 context, SKIP_WRITE_BARRIER);
4524 assembler->StoreFixedArrayElement( 4531 assembler->StoreFixedArrayElement(
4525 function_context, assembler->Int32Constant(Context::EXTENSION_INDEX), 4532 function_context, assembler->Int32Constant(Context::EXTENSION_INDEX),
4526 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); 4533 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER);
4527 4534
4528 // Copy the native context from the previous context. 4535 // Copy the native context from the previous context.
4529 Node* native_context = assembler->LoadFixedArrayElement( 4536 Node* native_context = assembler->LoadFixedArrayElement(
4530 context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX)); 4537 context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX));
4531 assembler->StoreFixedArrayElement( 4538 assembler->StoreFixedArrayElement(
4532 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), 4539 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX),
4533 native_context, SKIP_WRITE_BARRIER); 4540 native_context, SKIP_WRITE_BARRIER);
4534 4541
4535 // Initialize the rest of the slots to undefined. 4542 // Initialize the rest of the slots to undefined.
4536 Node* undefined = assembler->UndefinedConstant(); 4543 Node* undefined = assembler->UndefinedConstant();
4537 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; ++i) { 4544 Variable var_slot_index(assembler, MachineType::PointerRepresentation());
4538 assembler->StoreFixedArrayElement(function_context, 4545 var_slot_index.Bind(min_context_slots);
4539 assembler->Int32Constant(i), undefined, 4546 Label loop(assembler, &var_slot_index), after_loop(assembler);
4547 assembler->Goto(&loop);
4548
4549 assembler->Bind(&loop);
4550 {
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.
4551 Node* slot_index = var_slot_index.value();
4552 assembler->StoreFixedArrayElement(function_context, slot_index, undefined,
4540 SKIP_WRITE_BARRIER); 4553 SKIP_WRITE_BARRIER);
4554 Node* one = assembler->Int32Constant(1);
4555 Node* next_index = assembler->Int32Add(slot_index, one);
4556 var_slot_index.Bind(next_index);
4557 assembler->Branch(assembler->Int32LessThan(next_index, length), &loop,
4558 &after_loop);
4541 } 4559 }
4560 assembler->Bind(&after_loop);
4542 4561
4543 assembler->Return(function_context); 4562 assembler->Return(function_context);
4544 } 4563 }
4545 4564
4546 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { 4565 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
4547 CreateAllocationSiteStub stub(isolate); 4566 CreateAllocationSiteStub stub(isolate);
4548 stub.GetCode(); 4567 stub.GetCode();
4549 } 4568 }
4550 4569
4551 4570
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
4862 if (type->Is(Type::UntaggedPointer())) { 4881 if (type->Is(Type::UntaggedPointer())) {
4863 return Representation::External(); 4882 return Representation::External();
4864 } 4883 }
4865 4884
4866 DCHECK(!type->Is(Type::Untagged())); 4885 DCHECK(!type->Is(Type::Untagged()));
4867 return Representation::Tagged(); 4886 return Representation::Tagged();
4868 } 4887 }
4869 4888
4870 } // namespace internal 4889 } // namespace internal
4871 } // namespace v8 4890 } // namespace v8
OLDNEW
« 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