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

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: fix arm{,64},mips{,64} and remove ppc,s390,x87 again 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
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);
klaasb 2016/07/26 17:04:52 I've used int32 throughout, as it was used before
4509 Node* length = assembler->Int32Add(slots, min_context_slots);
4510 Node* size = assembler->Int32Add(
4511 assembler->Int32Mul(length, assembler->Int32Constant(kPointerSize)),
rmcilroy 2016/07/27 11:11:38 You could probably shift by kPointerSizeLog2 inste
klaasb 2016/07/27 17:06:31 TF does it on the graph itself before instruction
rmcilroy 2016/07/28 15:04:27 I don't think this phase is run on code generated
klaasb 2016/07/28 15:34:47 Done.
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);
4540 SKIP_WRITE_BARRIER); 4547 assembler->Goto(&loop);
4548
4549 assembler->Bind(&loop);
4550 {
4551 Node* slot_index = var_slot_index.value();
4552 Label initialize_slot(assembler);
4553 assembler->Branch(assembler->Int32LessThan(slot_index, length),
4554 &initialize_slot, &after_loop);
rmcilroy 2016/07/27 11:11:38 You could do this check on the backward branch - y
klaasb 2016/07/27 17:06:31 Done.
4555
4556 assembler->Bind(&initialize_slot);
4557 {
4558 assembler->StoreFixedArrayElement(function_context,
4559 var_slot_index.value(), undefined,
4560 SKIP_WRITE_BARRIER);
4561 Node* one = assembler->Int32Constant(1);
4562 Node* next_index = assembler->Int32Add(var_slot_index.value(), one);
4563 var_slot_index.Bind(next_index);
4564 assembler->Goto(&loop);
4565 }
4541 } 4566 }
4567 assembler->Bind(&after_loop);
4542 4568
4543 assembler->Return(function_context); 4569 assembler->Return(function_context);
4544 } 4570 }
4545 4571
4546 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { 4572 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
4547 CreateAllocationSiteStub stub(isolate); 4573 CreateAllocationSiteStub stub(isolate);
4548 stub.GetCode(); 4574 stub.GetCode();
4549 } 4575 }
4550 4576
4551 4577
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
4862 if (type->Is(Type::UntaggedPointer())) { 4888 if (type->Is(Type::UntaggedPointer())) {
4863 return Representation::External(); 4889 return Representation::External();
4864 } 4890 }
4865 4891
4866 DCHECK(!type->Is(Type::Untagged())); 4892 DCHECK(!type->Is(Type::Untagged()));
4867 return Representation::Tagged(); 4893 return Representation::Tagged();
4868 } 4894 }
4869 4895
4870 } // namespace internal 4896 } // namespace internal
4871 } // namespace v8 4897 } // namespace v8
OLDNEW
« src/code-stubs.h ('K') | « 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