Chromium Code Reviews| 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 4491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4502 assembler->Parameter( | 4502 assembler->Parameter( |
| 4503 ArrayNoArgumentConstructorDescriptor::kFunctionIndex), | 4503 ArrayNoArgumentConstructorDescriptor::kFunctionIndex), |
| 4504 JSFunction::kPrototypeOrInitialMapOffset); | 4504 JSFunction::kPrototypeOrInitialMapOffset); |
| 4505 Node* array = assembler->AllocateJSArray( | 4505 Node* array = assembler->AllocateJSArray( |
| 4506 elements_kind(), array_map, | 4506 elements_kind(), array_map, |
| 4507 assembler->IntPtrConstant(JSArray::kPreallocatedArrayElements), | 4507 assembler->IntPtrConstant(JSArray::kPreallocatedArrayElements), |
| 4508 assembler->IntPtrConstant(0), nullptr); | 4508 assembler->IntPtrConstant(0), nullptr); |
| 4509 assembler->Return(array); | 4509 assembler->Return(array); |
| 4510 } | 4510 } |
| 4511 | 4511 |
| 4512 namespace { | |
| 4513 | |
| 4514 static void SingleArgumentConstructorCommon( | |
|
Benedikt Meurer
2016/05/24 04:36:21
Nit: static is unnecessary within anonymous namesp
danno
2016/05/24 07:39:32
Done.
| |
| 4515 CodeStubAssembler* assembler, ElementsKind elements_kind, | |
| 4516 compiler::Node* array_map, compiler::Node* allocation_site, | |
| 4517 Runtime::FunctionId runtime_fallback, AllocationSiteMode mode) { | |
| 4518 typedef compiler::Node Node; | |
| 4519 typedef CodeStubAssembler::Label Label; | |
| 4520 | |
| 4521 CodeStubAssembler::Label ok(assembler); | |
|
Benedikt Meurer
2016/05/24 04:36:21
You don't need CodeStubAssembler:: since you typed
danno
2016/05/24 07:39:32
Done.
| |
| 4522 CodeStubAssembler::Label smi_size(assembler); | |
| 4523 CodeStubAssembler::Label small_smi_size(assembler); | |
| 4524 CodeStubAssembler::Label call_runtime(assembler, Label::kDeferred); | |
| 4525 | |
| 4526 Node* size = assembler->Parameter( | |
| 4527 ArraySingleArgumentConstructorDescriptor::kArraySizeSmiParameterIndex); | |
| 4528 assembler->Branch(assembler->WordIsSmi(size), &smi_size, &call_runtime); | |
| 4529 | |
| 4530 assembler->Bind(&smi_size); | |
| 4531 int element_size = | |
| 4532 IsFastDoubleElementsKind(elements_kind) ? kDoubleSize : kPointerSize; | |
| 4533 int max_fast_elements = | |
| 4534 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize - | |
| 4535 JSArray::kSize - AllocationMemento::kSize) / | |
| 4536 element_size; | |
| 4537 assembler->Branch( | |
| 4538 assembler->SmiAboveOrEqual( | |
| 4539 size, assembler->SmiConstant(Smi::FromInt(max_fast_elements))), | |
| 4540 &call_runtime, &small_smi_size); | |
| 4541 | |
| 4542 assembler->Bind(&small_smi_size); | |
| 4543 { | |
| 4544 Node* array = assembler->AllocateJSArray( | |
| 4545 elements_kind, array_map, size, size, | |
| 4546 mode == DONT_TRACK_ALLOCATION_SITE ? nullptr : allocation_site, | |
| 4547 CodeStubAssembler::SMI_PARAMETERS); | |
| 4548 assembler->Return(array); | |
| 4549 } | |
| 4550 | |
| 4551 assembler->Bind(&call_runtime); | |
| 4552 { | |
| 4553 Node* context = assembler->Parameter( | |
| 4554 ArraySingleArgumentConstructorDescriptor::kContextIndex); | |
| 4555 Node* constructor = assembler->Parameter( | |
| 4556 ArraySingleArgumentConstructorDescriptor::kFunctionIndex); | |
| 4557 Node* argument_count = assembler->Parameter( | |
| 4558 ArraySingleArgumentConstructorDescriptor::kArgumentsCountIndex); | |
| 4559 Node* argument_base_offset = assembler->IntPtrAdd( | |
| 4560 assembler->IntPtrConstant(CommonFrameConstants::kFixedFrameSizeAboveFp - | |
| 4561 kPointerSize), | |
| 4562 assembler->Word32Shl(argument_count, | |
| 4563 assembler->IntPtrConstant(kPointerSizeLog2))); | |
| 4564 Node* argument_base = assembler->IntPtrAdd(assembler->LoadFramePointer(), | |
| 4565 argument_base_offset); | |
| 4566 Node* array = assembler->CallRuntime( | |
| 4567 runtime_fallback, context, constructor, argument_base, | |
| 4568 assembler->SmiTag(argument_count), allocation_site); | |
| 4569 assembler->Return(array); | |
| 4570 } | |
| 4571 } | |
| 4572 } // namespace | |
| 4573 | |
| 4574 void ArraySingleArgumentConstructorStub::GenerateAssembly( | |
| 4575 CodeStubAssembler* assembler) const { | |
| 4576 typedef compiler::Node Node; | |
| 4577 Node* function = assembler->Parameter( | |
| 4578 ArraySingleArgumentConstructorDescriptor::kFunctionIndex); | |
| 4579 Node* native_context = | |
| 4580 assembler->LoadObjectField(function, JSFunction::kContextOffset); | |
| 4581 Node* array_map = | |
| 4582 assembler->LoadJSArrayElementsMap(elements_kind(), native_context); | |
| 4583 AllocationSiteMode mode = override_mode() == DISABLE_ALLOCATION_SITES | |
| 4584 ? DONT_TRACK_ALLOCATION_SITE | |
| 4585 : AllocationSite::GetMode(elements_kind()); | |
| 4586 Node* allocation_site = assembler->Parameter( | |
| 4587 ArrayNoArgumentConstructorDescriptor::kAllocationSiteIndex); | |
| 4588 SingleArgumentConstructorCommon( | |
| 4589 assembler, elements_kind(), array_map, allocation_site, | |
| 4590 Runtime::kArraySingleArgumentConstructor, mode); | |
| 4591 } | |
| 4592 | |
| 4593 void InternalArraySingleArgumentConstructorStub::GenerateAssembly( | |
| 4594 CodeStubAssembler* assembler) const { | |
| 4595 typedef compiler::Node Node; | |
| 4596 Node* function = assembler->Parameter( | |
| 4597 ArraySingleArgumentConstructorDescriptor::kFunctionIndex); | |
| 4598 Node* array_map = assembler->LoadObjectField( | |
| 4599 function, JSFunction::kPrototypeOrInitialMapOffset); | |
| 4600 SingleArgumentConstructorCommon( | |
| 4601 assembler, elements_kind(), array_map, assembler->UndefinedConstant(), | |
| 4602 Runtime::kArraySingleArgumentConstructor, DONT_TRACK_ALLOCATION_SITE); | |
| 4603 } | |
| 4604 | |
| 4512 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) | 4605 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) |
| 4513 : PlatformCodeStub(isolate) { | 4606 : PlatformCodeStub(isolate) { |
| 4514 minor_key_ = ArgumentCountBits::encode(ANY); | 4607 minor_key_ = ArgumentCountBits::encode(ANY); |
| 4515 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 4608 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 4516 } | 4609 } |
| 4517 | 4610 |
| 4518 | 4611 |
| 4519 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, | 4612 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, |
| 4520 int argument_count) | 4613 int argument_count) |
| 4521 : PlatformCodeStub(isolate) { | 4614 : PlatformCodeStub(isolate) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 4550 if (type->Is(Type::UntaggedPointer())) { | 4643 if (type->Is(Type::UntaggedPointer())) { |
| 4551 return Representation::External(); | 4644 return Representation::External(); |
| 4552 } | 4645 } |
| 4553 | 4646 |
| 4554 DCHECK(!type->Is(Type::Untagged())); | 4647 DCHECK(!type->Is(Type::Untagged())); |
| 4555 return Representation::Tagged(); | 4648 return Representation::Tagged(); |
| 4556 } | 4649 } |
| 4557 | 4650 |
| 4558 } // namespace internal | 4651 } // namespace internal |
| 4559 } // namespace v8 | 4652 } // namespace v8 |
| OLD | NEW |