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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 4496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4507 return result; | 4507 return result; |
4508 } | 4508 } |
4509 | 4509 |
4510 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 4510 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
4511 assembler->Return( | 4511 assembler->Return( |
4512 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); | 4512 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); |
4513 } | 4513 } |
4514 | 4514 |
4515 void FastNewFunctionContextStub::GenerateAssembly( | 4515 void FastNewFunctionContextStub::GenerateAssembly( |
4516 CodeStubAssembler* assembler) const { | 4516 CodeStubAssembler* assembler) const { |
| 4517 typedef CodeStubAssembler::Label Label; |
4517 typedef compiler::Node Node; | 4518 typedef compiler::Node Node; |
| 4519 typedef CodeStubAssembler::Variable Variable; |
4518 | 4520 |
4519 int length = slots() + Context::MIN_CONTEXT_SLOTS; | 4521 Node* function = assembler->Parameter(Descriptor::kFunction); |
4520 int size = length * kPointerSize + FixedArray::kHeaderSize; | 4522 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots); |
| 4523 Node* context = assembler->Parameter(Descriptor::kContext); |
4521 | 4524 |
4522 // Get the function | 4525 Node* min_context_slots = |
4523 Node* function = assembler->Parameter(Descriptor::kFunction); | 4526 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); |
4524 Node* context = assembler->Parameter(Descriptor::kContext); | 4527 Node* length = assembler->Int32Add(slots, min_context_slots); |
| 4528 Node* size = assembler->Int32Add( |
| 4529 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)), |
| 4530 assembler->Int32Constant(FixedArray::kHeaderSize)); |
4525 | 4531 |
4526 // Create a new closure from the given function info in new space | 4532 // Create a new closure from the given function info in new space |
4527 Node* function_context = assembler->Allocate(size); | 4533 Node* function_context = assembler->Allocate(size); |
4528 | 4534 |
4529 assembler->StoreMapNoWriteBarrier( | 4535 assembler->StoreMapNoWriteBarrier( |
4530 function_context, | 4536 function_context, |
4531 assembler->HeapConstant(isolate()->factory()->function_context_map())); | 4537 assembler->HeapConstant(isolate()->factory()->function_context_map())); |
4532 assembler->StoreObjectFieldNoWriteBarrier( | 4538 assembler->StoreObjectFieldNoWriteBarrier(function_context, |
4533 function_context, Context::kLengthOffset, | 4539 Context::kLengthOffset, |
4534 assembler->SmiConstant(Smi::FromInt(length))); | 4540 assembler->SmiFromWord32(length)); |
4535 | 4541 |
4536 // Set up the fixed slots. | 4542 // Set up the fixed slots. |
4537 assembler->StoreFixedArrayElement( | 4543 assembler->StoreFixedArrayElement( |
4538 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX), | 4544 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX), |
4539 function, SKIP_WRITE_BARRIER); | 4545 function, SKIP_WRITE_BARRIER); |
4540 assembler->StoreFixedArrayElement( | 4546 assembler->StoreFixedArrayElement( |
4541 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX), | 4547 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX), |
4542 context, SKIP_WRITE_BARRIER); | 4548 context, SKIP_WRITE_BARRIER); |
4543 assembler->StoreFixedArrayElement( | 4549 assembler->StoreFixedArrayElement( |
4544 function_context, assembler->Int32Constant(Context::EXTENSION_INDEX), | 4550 function_context, assembler->Int32Constant(Context::EXTENSION_INDEX), |
4545 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); | 4551 assembler->TheHoleConstant(), SKIP_WRITE_BARRIER); |
4546 | 4552 |
4547 // Copy the native context from the previous context. | 4553 // Copy the native context from the previous context. |
4548 Node* native_context = assembler->LoadFixedArrayElement( | 4554 Node* native_context = assembler->LoadFixedArrayElement( |
4549 context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX)); | 4555 context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX)); |
4550 assembler->StoreFixedArrayElement( | 4556 assembler->StoreFixedArrayElement( |
4551 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), | 4557 function_context, assembler->Int32Constant(Context::NATIVE_CONTEXT_INDEX), |
4552 native_context, SKIP_WRITE_BARRIER); | 4558 native_context, SKIP_WRITE_BARRIER); |
4553 | 4559 |
4554 // Initialize the rest of the slots to undefined. | 4560 // Initialize the rest of the slots to undefined. |
4555 Node* undefined = assembler->UndefinedConstant(); | 4561 Node* undefined = assembler->UndefinedConstant(); |
4556 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; ++i) { | 4562 Variable var_slot_index(assembler, MachineRepresentation::kWord32); |
4557 assembler->StoreFixedArrayElement(function_context, | 4563 var_slot_index.Bind(min_context_slots); |
4558 assembler->Int32Constant(i), undefined, | 4564 Label loop(assembler, &var_slot_index), after_loop(assembler); |
| 4565 assembler->Goto(&loop); |
| 4566 |
| 4567 assembler->Bind(&loop); |
| 4568 { |
| 4569 Node* slot_index = var_slot_index.value(); |
| 4570 // check for < length later, there are at least Context::MIN_CONTEXT_SLOTS |
| 4571 assembler->StoreFixedArrayElement(function_context, slot_index, undefined, |
4559 SKIP_WRITE_BARRIER); | 4572 SKIP_WRITE_BARRIER); |
| 4573 Node* one = assembler->Int32Constant(1); |
| 4574 Node* next_index = assembler->Int32Add(slot_index, one); |
| 4575 var_slot_index.Bind(next_index); |
| 4576 assembler->Branch(assembler->Int32LessThan(next_index, length), &loop, |
| 4577 &after_loop); |
4560 } | 4578 } |
| 4579 assembler->Bind(&after_loop); |
4561 | 4580 |
4562 assembler->Return(function_context); | 4581 assembler->Return(function_context); |
4563 } | 4582 } |
4564 | 4583 |
4565 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 4584 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
4566 CreateAllocationSiteStub stub(isolate); | 4585 CreateAllocationSiteStub stub(isolate); |
4567 stub.GetCode(); | 4586 stub.GetCode(); |
4568 } | 4587 } |
4569 | 4588 |
4570 | 4589 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4932 if (type->Is(Type::UntaggedPointer())) { | 4951 if (type->Is(Type::UntaggedPointer())) { |
4933 return Representation::External(); | 4952 return Representation::External(); |
4934 } | 4953 } |
4935 | 4954 |
4936 DCHECK(!type->Is(Type::Untagged())); | 4955 DCHECK(!type->Is(Type::Untagged())); |
4937 return Representation::Tagged(); | 4956 return Representation::Tagged(); |
4938 } | 4957 } |
4939 | 4958 |
4940 } // namespace internal | 4959 } // namespace internal |
4941 } // namespace v8 | 4960 } // namespace v8 |
OLD | NEW |