OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 Node* offset = IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag + | 549 Node* offset = IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag + |
550 index * kPointerSize); | 550 index * kPointerSize); |
551 return Load(MachineType::AnyTagged(), object, offset); | 551 return Load(MachineType::AnyTagged(), object, offset); |
552 } | 552 } |
553 | 553 |
554 Node* CodeStubAssembler::LoadNativeContext(Node* context) { | 554 Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
555 return LoadFixedArrayElementConstantIndex(context, | 555 return LoadFixedArrayElementConstantIndex(context, |
556 Context::NATIVE_CONTEXT_INDEX); | 556 Context::NATIVE_CONTEXT_INDEX); |
557 } | 557 } |
558 | 558 |
| 559 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
| 560 Node* native_context) { |
| 561 return LoadFixedArrayElementConstantIndex(native_context, |
| 562 Context::ArrayMapIndex(kind)); |
| 563 } |
| 564 |
559 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 565 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
560 return StoreNoWriteBarrier( | 566 return StoreNoWriteBarrier( |
561 MachineRepresentation::kFloat64, object, | 567 MachineRepresentation::kFloat64, object, |
562 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); | 568 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); |
563 } | 569 } |
564 | 570 |
565 Node* CodeStubAssembler::StoreObjectField( | 571 Node* CodeStubAssembler::StoreObjectField( |
566 Node* object, int offset, Node* value) { | 572 Node* object, int offset, Node* value) { |
567 return Store(MachineRepresentation::kTagged, object, | 573 return Store(MachineRepresentation::kTagged, object, |
568 IntPtrConstant(offset - kHeapObjectTag), value); | 574 IntPtrConstant(offset - kHeapObjectTag), value); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) { | 669 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) { |
664 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); | 670 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); |
665 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); | 671 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); |
666 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, | 672 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, |
667 SmiConstant(Smi::FromInt(length))); | 673 SmiConstant(Smi::FromInt(length))); |
668 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, | 674 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, |
669 IntPtrConstant(String::kEmptyHashField)); | 675 IntPtrConstant(String::kEmptyHashField)); |
670 return result; | 676 return result; |
671 } | 677 } |
672 | 678 |
673 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, | 679 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, |
674 Node* native_context, int capacity, | 680 int capacity, int length, |
675 int length, | |
676 compiler::Node* allocation_site) { | 681 compiler::Node* allocation_site) { |
677 bool is_double = IsFastDoubleElementsKind(kind); | 682 bool is_double = IsFastDoubleElementsKind(kind); |
678 int element_size = is_double ? kDoubleSize : kPointerSize; | 683 int element_size = is_double ? kDoubleSize : kPointerSize; |
679 int total_size = | 684 int total_size = |
680 JSArray::kSize + FixedArray::kHeaderSize + element_size * capacity; | 685 JSArray::kSize + FixedArray::kHeaderSize + element_size * capacity; |
681 int elements_offset = JSArray::kSize; | 686 int elements_offset = JSArray::kSize; |
682 | 687 |
683 if (allocation_site != nullptr) { | 688 if (allocation_site != nullptr) { |
684 total_size += AllocationMemento::kSize; | 689 total_size += AllocationMemento::kSize; |
685 elements_offset += AllocationMemento::kSize; | 690 elements_offset += AllocationMemento::kSize; |
686 } | 691 } |
687 | 692 |
688 // Allocate both array and elements object, and initialize the JSArray. | 693 // Allocate both array and elements object, and initialize the JSArray. |
689 Heap* heap = isolate()->heap(); | 694 Heap* heap = isolate()->heap(); |
690 Node* array = Allocate(total_size); | 695 Node* array = Allocate(total_size); |
691 Node* array_map = LoadFixedArrayElementConstantIndex( | |
692 native_context, Context::ArrayMapIndex(kind)); | |
693 StoreMapNoWriteBarrier(array, array_map); | 696 StoreMapNoWriteBarrier(array, array_map); |
694 Node* empty_properties = | 697 Node* empty_properties = |
695 HeapConstant(Handle<HeapObject>(heap->empty_fixed_array())); | 698 HeapConstant(Handle<HeapObject>(heap->empty_fixed_array())); |
696 StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset, | 699 StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset, |
697 empty_properties); | 700 empty_properties); |
698 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, | 701 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, |
699 SmiConstant(Smi::FromInt(length))); | 702 SmiConstant(Smi::FromInt(length))); |
700 | 703 |
701 if (allocation_site != nullptr) { | 704 if (allocation_site != nullptr) { |
702 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); | 705 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 } | 1262 } |
1260 | 1263 |
1261 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, | 1264 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, |
1262 uint32_t mask) { | 1265 uint32_t mask) { |
1263 return Word32Shr(Word32And(word32, Int32Constant(mask)), | 1266 return Word32Shr(Word32And(word32, Int32Constant(mask)), |
1264 Int32Constant(shift)); | 1267 Int32Constant(shift)); |
1265 } | 1268 } |
1266 | 1269 |
1267 } // namespace internal | 1270 } // namespace internal |
1268 } // namespace v8 | 1271 } // namespace v8 |
OLD | NEW |