| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 Bind(&return_x); | 248 Bind(&return_x); |
| 249 return var_x.value(); | 249 return var_x.value(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 Node* CodeStubAssembler::SmiFromWord32(Node* value) { | 252 Node* CodeStubAssembler::SmiFromWord32(Node* value) { |
| 253 value = ChangeInt32ToIntPtr(value); | 253 value = ChangeInt32ToIntPtr(value); |
| 254 return WordShl(value, SmiShiftBitsConstant()); | 254 return WordShl(value, SmiShiftBitsConstant()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 Node* CodeStubAssembler::SmiTag(Node* value) { | 257 Node* CodeStubAssembler::SmiTag(Node* value) { |
| 258 int32_t constant_value; |
| 259 if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) { |
| 260 return SmiConstant(Smi::FromInt(constant_value)); |
| 261 } |
| 258 return WordShl(value, SmiShiftBitsConstant()); | 262 return WordShl(value, SmiShiftBitsConstant()); |
| 259 } | 263 } |
| 260 | 264 |
| 261 Node* CodeStubAssembler::SmiUntag(Node* value) { | 265 Node* CodeStubAssembler::SmiUntag(Node* value) { |
| 262 return WordSar(value, SmiShiftBitsConstant()); | 266 return WordSar(value, SmiShiftBitsConstant()); |
| 263 } | 267 } |
| 264 | 268 |
| 265 Node* CodeStubAssembler::SmiToWord32(Node* value) { | 269 Node* CodeStubAssembler::SmiToWord32(Node* value) { |
| 266 Node* result = WordSar(value, SmiShiftBitsConstant()); | 270 Node* result = WordSar(value, SmiShiftBitsConstant()); |
| 267 if (Is64()) { | 271 if (Is64()) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 Node* total_size = IntPtrAdd(data_size, header_size); | 532 Node* total_size = IntPtrAdd(data_size, header_size); |
| 529 | 533 |
| 530 Node* result = Allocate(total_size, kNone); | 534 Node* result = Allocate(total_size, kNone); |
| 531 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kFixedArrayMapRootIndex)); | 535 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kFixedArrayMapRootIndex)); |
| 532 StoreObjectFieldNoWriteBarrier(result, FixedArray::kLengthOffset, | 536 StoreObjectFieldNoWriteBarrier(result, FixedArray::kLengthOffset, |
| 533 SmiTag(length)); | 537 SmiTag(length)); |
| 534 | 538 |
| 535 return result; | 539 return result; |
| 536 } | 540 } |
| 537 | 541 |
| 538 Node* CodeStubAssembler::LoadFixedArrayElementInt32Index( | 542 Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node, |
| 539 Node* object, Node* index, int additional_offset) { | 543 int additional_offset, |
| 540 Node* header_size = IntPtrConstant(additional_offset + | 544 ParameterMode parameter_mode) { |
| 541 FixedArray::kHeaderSize - kHeapObjectTag); | 545 int32_t header_size = |
| 542 index = ChangeInt32ToIntPtr(index); | 546 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
| 543 Node* scaled_index = WordShl(index, IntPtrConstant(kPointerSizeLog2)); | 547 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, |
| 544 Node* offset = IntPtrAdd(scaled_index, header_size); | 548 parameter_mode, header_size); |
| 545 return Load(MachineType::AnyTagged(), object, offset); | 549 return Load(MachineType::AnyTagged(), object, offset); |
| 546 } | 550 } |
| 547 | 551 |
| 548 Node* CodeStubAssembler::LoadMapInstanceSize(Node* map) { | 552 Node* CodeStubAssembler::LoadMapInstanceSize(Node* map) { |
| 549 return Load(MachineType::Uint8(), map, | 553 return Load(MachineType::Uint8(), map, |
| 550 IntPtrConstant(Map::kInstanceSizeOffset - kHeapObjectTag)); | 554 IntPtrConstant(Map::kInstanceSizeOffset - kHeapObjectTag)); |
| 551 } | 555 } |
| 552 | 556 |
| 553 Node* CodeStubAssembler::LoadFixedArrayElementSmiIndex(Node* object, | |
| 554 Node* smi_index, | |
| 555 int additional_offset) { | |
| 556 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize; | |
| 557 Node* header_size = IntPtrConstant(additional_offset + | |
| 558 FixedArray::kHeaderSize - kHeapObjectTag); | |
| 559 Node* scaled_index = | |
| 560 (kSmiShiftBits > kPointerSizeLog2) | |
| 561 ? WordSar(smi_index, IntPtrConstant(kSmiShiftBits - kPointerSizeLog2)) | |
| 562 : WordShl(smi_index, | |
| 563 IntPtrConstant(kPointerSizeLog2 - kSmiShiftBits)); | |
| 564 Node* offset = IntPtrAdd(scaled_index, header_size); | |
| 565 return Load(MachineType::AnyTagged(), object, offset); | |
| 566 } | |
| 567 | |
| 568 Node* CodeStubAssembler::LoadFixedArrayElementConstantIndex(Node* object, | |
| 569 int index) { | |
| 570 Node* offset = IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag + | |
| 571 index * kPointerSize); | |
| 572 return Load(MachineType::AnyTagged(), object, offset); | |
| 573 } | |
| 574 | |
| 575 Node* CodeStubAssembler::LoadNativeContext(Node* context) { | 557 Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
| 576 return LoadFixedArrayElementConstantIndex(context, | 558 return LoadFixedArrayElement(context, |
| 577 Context::NATIVE_CONTEXT_INDEX); | 559 Int32Constant(Context::NATIVE_CONTEXT_INDEX)); |
| 578 } | 560 } |
| 579 | 561 |
| 580 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, | 562 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
| 581 Node* native_context) { | 563 Node* native_context) { |
| 582 return LoadFixedArrayElementConstantIndex(native_context, | 564 return LoadFixedArrayElement(native_context, |
| 583 Context::ArrayMapIndex(kind)); | 565 Int32Constant(Context::ArrayMapIndex(kind))); |
| 584 } | 566 } |
| 585 | 567 |
| 586 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 568 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
| 587 return StoreNoWriteBarrier( | 569 return StoreNoWriteBarrier( |
| 588 MachineRepresentation::kFloat64, object, | 570 MachineRepresentation::kFloat64, object, |
| 589 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); | 571 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); |
| 590 } | 572 } |
| 591 | 573 |
| 592 Node* CodeStubAssembler::StoreObjectField( | 574 Node* CodeStubAssembler::StoreObjectField( |
| 593 Node* object, int offset, Node* value) { | 575 Node* object, int offset, Node* value) { |
| 594 return Store(MachineRepresentation::kTagged, object, | 576 return Store(MachineRepresentation::kTagged, object, |
| 595 IntPtrConstant(offset - kHeapObjectTag), value); | 577 IntPtrConstant(offset - kHeapObjectTag), value); |
| 596 } | 578 } |
| 597 | 579 |
| 598 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( | 580 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
| 599 Node* object, int offset, Node* value, MachineRepresentation rep) { | 581 Node* object, int offset, Node* value, MachineRepresentation rep) { |
| 600 return StoreNoWriteBarrier(rep, object, | 582 return StoreNoWriteBarrier(rep, object, |
| 601 IntPtrConstant(offset - kHeapObjectTag), value); | 583 IntPtrConstant(offset - kHeapObjectTag), value); |
| 602 } | 584 } |
| 603 | 585 |
| 604 Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) { | 586 Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) { |
| 605 return StoreNoWriteBarrier( | 587 return StoreNoWriteBarrier( |
| 606 MachineRepresentation::kTagged, object, | 588 MachineRepresentation::kTagged, object, |
| 607 IntPtrConstant(HeapNumber::kMapOffset - kHeapObjectTag), map); | 589 IntPtrConstant(HeapNumber::kMapOffset - kHeapObjectTag), map); |
| 608 } | 590 } |
| 609 | 591 |
| 610 Node* CodeStubAssembler::StoreFixedArrayElementNoWriteBarrier(Node* object, | 592 Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, |
| 611 Node* index, | 593 Node* value, |
| 612 Node* value) { | 594 WriteBarrierMode barrier_mode, |
| 613 index = ChangeInt32ToIntPtr(index); | 595 ParameterMode parameter_mode) { |
| 596 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || |
| 597 barrier_mode == UPDATE_WRITE_BARRIER); |
| 614 Node* offset = | 598 Node* offset = |
| 615 IntPtrAdd(WordShl(index, IntPtrConstant(kPointerSizeLog2)), | 599 ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, parameter_mode, |
| 616 IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag)); | 600 FixedArray::kHeaderSize - kHeapObjectTag); |
| 617 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset, | 601 MachineRepresentation rep = MachineRepresentation::kTagged; |
| 618 value); | 602 if (barrier_mode == SKIP_WRITE_BARRIER) { |
| 603 return StoreNoWriteBarrier(rep, object, offset, value); |
| 604 } else { |
| 605 return Store(rep, object, offset, value); |
| 606 } |
| 619 } | 607 } |
| 620 | 608 |
| 621 Node* CodeStubAssembler::StoreFixedArrayElementInt32Index(Node* object, | 609 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( |
| 622 Node* index, | 610 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { |
| 623 Node* value) { | |
| 624 index = ChangeInt32ToIntPtr(index); | |
| 625 Node* offset = | 611 Node* offset = |
| 626 IntPtrAdd(WordShl(index, IntPtrConstant(kPointerSizeLog2)), | 612 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, |
| 627 IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag)); | 613 FixedArray::kHeaderSize - kHeapObjectTag); |
| 628 return Store(MachineRepresentation::kTagged, object, offset, value); | 614 MachineRepresentation rep = MachineRepresentation::kFloat64; |
| 629 } | 615 return StoreNoWriteBarrier(rep, object, offset, value); |
| 630 | |
| 631 Node* CodeStubAssembler::StoreFixedDoubleArrayElementInt32Index(Node* object, | |
| 632 Node* index, | |
| 633 Node* value) { | |
| 634 index = ChangeInt32ToIntPtr(index); | |
| 635 Node* offset = | |
| 636 IntPtrAdd(WordShl(index, IntPtrConstant(kPointerSizeLog2)), | |
| 637 IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag)); | |
| 638 return StoreNoWriteBarrier(MachineRepresentation::kFloat64, object, offset, | |
| 639 value); | |
| 640 } | |
| 641 | |
| 642 Node* CodeStubAssembler::StoreFixedArrayElementInt32Index(Node* object, | |
| 643 int index, | |
| 644 Node* value) { | |
| 645 Node* offset = IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag + | |
| 646 index * kPointerSize); | |
| 647 return Store(MachineRepresentation::kTagged, object, offset, value); | |
| 648 } | |
| 649 | |
| 650 Node* CodeStubAssembler::StoreFixedArrayElementNoWriteBarrier(Node* object, | |
| 651 int index, | |
| 652 Node* value) { | |
| 653 Node* offset = IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag + | |
| 654 index * kPointerSize); | |
| 655 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset, | |
| 656 value); | |
| 657 } | |
| 658 | |
| 659 Node* CodeStubAssembler::StoreFixedDoubleArrayElementInt32Index(Node* object, | |
| 660 int index, | |
| 661 Node* value) { | |
| 662 Node* offset = IntPtrConstant(FixedDoubleArray::kHeaderSize - kHeapObjectTag + | |
| 663 index * kDoubleSize); | |
| 664 return StoreNoWriteBarrier(MachineRepresentation::kFloat64, object, offset, | |
| 665 value); | |
| 666 } | 616 } |
| 667 | 617 |
| 668 Node* CodeStubAssembler::AllocateHeapNumber() { | 618 Node* CodeStubAssembler::AllocateHeapNumber() { |
| 669 Node* result = Allocate(HeapNumber::kSize, kNone); | 619 Node* result = Allocate(HeapNumber::kSize, kNone); |
| 670 StoreMapNoWriteBarrier(result, HeapNumberMapConstant()); | 620 StoreMapNoWriteBarrier(result, HeapNumberMapConstant()); |
| 671 return result; | 621 return result; |
| 672 } | 622 } |
| 673 | 623 |
| 674 Node* CodeStubAssembler::AllocateHeapNumberWithValue(Node* value) { | 624 Node* CodeStubAssembler::AllocateHeapNumberWithValue(Node* value) { |
| 675 Node* result = AllocateHeapNumber(); | 625 Node* result = AllocateHeapNumber(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 691 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); | 641 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); |
| 692 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); | 642 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); |
| 693 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, | 643 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, |
| 694 SmiConstant(Smi::FromInt(length))); | 644 SmiConstant(Smi::FromInt(length))); |
| 695 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, | 645 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, |
| 696 IntPtrConstant(String::kEmptyHashField)); | 646 IntPtrConstant(String::kEmptyHashField)); |
| 697 return result; | 647 return result; |
| 698 } | 648 } |
| 699 | 649 |
| 700 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, | 650 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, |
| 701 int capacity, int length, | 651 Node* capacity_node, Node* length_node, |
| 702 compiler::Node* allocation_site) { | 652 compiler::Node* allocation_site, |
| 653 ParameterMode mode) { |
| 703 bool is_double = IsFastDoubleElementsKind(kind); | 654 bool is_double = IsFastDoubleElementsKind(kind); |
| 704 int element_size = is_double ? kDoubleSize : kPointerSize; | 655 int base_size = JSArray::kSize + FixedArray::kHeaderSize; |
| 705 int total_size = | |
| 706 JSArray::kSize + FixedArray::kHeaderSize + element_size * capacity; | |
| 707 int elements_offset = JSArray::kSize; | 656 int elements_offset = JSArray::kSize; |
| 708 | 657 |
| 709 if (allocation_site != nullptr) { | 658 if (allocation_site != nullptr) { |
| 710 total_size += AllocationMemento::kSize; | 659 base_size += AllocationMemento::kSize; |
| 711 elements_offset += AllocationMemento::kSize; | 660 elements_offset += AllocationMemento::kSize; |
| 712 } | 661 } |
| 713 | 662 |
| 663 int32_t capacity; |
| 664 bool constant_capacity = ToInt32Constant(capacity_node, capacity); |
| 665 Node* total_size = |
| 666 ElementOffsetFromIndex(capacity_node, kind, mode, base_size); |
| 667 |
| 714 // Allocate both array and elements object, and initialize the JSArray. | 668 // Allocate both array and elements object, and initialize the JSArray. |
| 715 Heap* heap = isolate()->heap(); | 669 Heap* heap = isolate()->heap(); |
| 716 Node* array = Allocate(total_size); | 670 Node* array = Allocate(total_size); |
| 717 StoreMapNoWriteBarrier(array, array_map); | 671 StoreMapNoWriteBarrier(array, array_map); |
| 718 Node* empty_properties = | 672 Node* empty_properties = |
| 719 HeapConstant(Handle<HeapObject>(heap->empty_fixed_array())); | 673 HeapConstant(Handle<HeapObject>(heap->empty_fixed_array())); |
| 720 StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset, | 674 StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset, |
| 721 empty_properties); | 675 empty_properties); |
| 722 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, | 676 StoreObjectFieldNoWriteBarrier( |
| 723 SmiConstant(Smi::FromInt(length))); | 677 array, JSArray::kLengthOffset, |
| 678 mode == SMI_PARAMETERS ? length_node : SmiTag(length_node)); |
| 724 | 679 |
| 725 if (allocation_site != nullptr) { | 680 if (allocation_site != nullptr) { |
| 726 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); | 681 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); |
| 727 } | 682 } |
| 728 | 683 |
| 729 // Setup elements object. | 684 // Setup elements object. |
| 730 Node* elements = InnerAllocate(array, elements_offset); | 685 Node* elements = InnerAllocate(array, elements_offset); |
| 731 StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements); | 686 StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements); |
| 732 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map() | 687 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map() |
| 733 : heap->fixed_array_map()); | 688 : heap->fixed_array_map()); |
| 734 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map)); | 689 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map)); |
| 735 StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, | 690 StoreObjectFieldNoWriteBarrier( |
| 736 SmiConstant(Smi::FromInt(capacity))); | 691 elements, FixedArray::kLengthOffset, |
| 692 mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node)); |
| 737 | 693 |
| 738 Node* double_hole = Float64Constant(bit_cast<double>(kHoleNanInt64)); | 694 Node* double_hole = Float64Constant(bit_cast<double>(kHoleNanInt64)); |
| 739 Node* hole = HeapConstant(Handle<HeapObject>(heap->the_hole_value())); | 695 Node* hole = HeapConstant(Handle<HeapObject>(heap->the_hole_value())); |
| 740 if (capacity <= kElementLoopUnrollThreshold) { | 696 if (constant_capacity && capacity <= kElementLoopUnrollThreshold) { |
| 741 for (int i = 0; i < capacity; ++i) { | 697 for (int i = 0; i < capacity; ++i) { |
| 742 if (is_double) { | 698 if (is_double) { |
| 743 StoreFixedDoubleArrayElementInt32Index(elements, i, double_hole); | 699 StoreFixedDoubleArrayElement(elements, Int32Constant(i), double_hole); |
| 744 } else { | 700 } else { |
| 745 StoreFixedArrayElementNoWriteBarrier(elements, i, hole); | 701 StoreFixedArrayElement(elements, Int32Constant(i), hole, |
| 702 SKIP_WRITE_BARRIER); |
| 746 } | 703 } |
| 747 } | 704 } |
| 748 } else { | 705 } else { |
| 749 // TODO(danno): Add a loop for initialization | 706 // TODO(danno): Add a loop for initialization |
| 750 UNIMPLEMENTED(); | 707 UNIMPLEMENTED(); |
| 751 } | 708 } |
| 752 | 709 |
| 753 return array; | 710 return array; |
| 754 } | 711 } |
| 755 | 712 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 &if_codeisonebyte, &if_codeistwobyte); | 1193 &if_codeisonebyte, &if_codeistwobyte); |
| 1237 Bind(&if_codeisonebyte); | 1194 Bind(&if_codeisonebyte); |
| 1238 { | 1195 { |
| 1239 // Load the isolate wide single character string cache. | 1196 // Load the isolate wide single character string cache. |
| 1240 Node* cache = LoadRoot(Heap::kSingleCharacterStringCacheRootIndex); | 1197 Node* cache = LoadRoot(Heap::kSingleCharacterStringCacheRootIndex); |
| 1241 | 1198 |
| 1242 // Check if we have an entry for the {code} in the single character string | 1199 // Check if we have an entry for the {code} in the single character string |
| 1243 // cache already. | 1200 // cache already. |
| 1244 Label if_entryisundefined(this, Label::kDeferred), | 1201 Label if_entryisundefined(this, Label::kDeferred), |
| 1245 if_entryisnotundefined(this); | 1202 if_entryisnotundefined(this); |
| 1246 Node* entry = LoadFixedArrayElementInt32Index(cache, code); | 1203 Node* entry = LoadFixedArrayElement(cache, code); |
| 1247 Branch(WordEqual(entry, UndefinedConstant()), &if_entryisundefined, | 1204 Branch(WordEqual(entry, UndefinedConstant()), &if_entryisundefined, |
| 1248 &if_entryisnotundefined); | 1205 &if_entryisnotundefined); |
| 1249 | 1206 |
| 1250 Bind(&if_entryisundefined); | 1207 Bind(&if_entryisundefined); |
| 1251 { | 1208 { |
| 1252 // Allocate a new SeqOneByteString for {code} and store it in the {cache}. | 1209 // Allocate a new SeqOneByteString for {code} and store it in the {cache}. |
| 1253 Node* result = AllocateSeqOneByteString(1); | 1210 Node* result = AllocateSeqOneByteString(1); |
| 1254 StoreNoWriteBarrier( | 1211 StoreNoWriteBarrier( |
| 1255 MachineRepresentation::kWord8, result, | 1212 MachineRepresentation::kWord8, result, |
| 1256 IntPtrConstant(SeqOneByteString::kHeaderSize - kHeapObjectTag), code); | 1213 IntPtrConstant(SeqOneByteString::kHeaderSize - kHeapObjectTag), code); |
| 1257 StoreFixedArrayElementInt32Index(cache, code, result); | 1214 StoreFixedArrayElement(cache, code, result); |
| 1258 var_result.Bind(result); | 1215 var_result.Bind(result); |
| 1259 Goto(&if_done); | 1216 Goto(&if_done); |
| 1260 } | 1217 } |
| 1261 | 1218 |
| 1262 Bind(&if_entryisnotundefined); | 1219 Bind(&if_entryisnotundefined); |
| 1263 { | 1220 { |
| 1264 // Return the entry from the {cache}. | 1221 // Return the entry from the {cache}. |
| 1265 var_result.Bind(entry); | 1222 var_result.Bind(entry); |
| 1266 Goto(&if_done); | 1223 Goto(&if_done); |
| 1267 } | 1224 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 Bind(&loop); | 1331 Bind(&loop); |
| 1375 { | 1332 { |
| 1376 Node* index = var_descriptor.value(); | 1333 Node* index = var_descriptor.value(); |
| 1377 Node* offset = Int32Constant(DescriptorArray::ToKeyIndex(0)); | 1334 Node* offset = Int32Constant(DescriptorArray::ToKeyIndex(0)); |
| 1378 Node* factor = Int32Constant(DescriptorArray::kDescriptorSize); | 1335 Node* factor = Int32Constant(DescriptorArray::kDescriptorSize); |
| 1379 Label if_notdone(this); | 1336 Label if_notdone(this); |
| 1380 Branch(Word32Equal(index, nof), if_not_found, &if_notdone); | 1337 Branch(Word32Equal(index, nof), if_not_found, &if_notdone); |
| 1381 Bind(&if_notdone); | 1338 Bind(&if_notdone); |
| 1382 { | 1339 { |
| 1383 Node* array_index = Int32Add(offset, Int32Mul(index, factor)); | 1340 Node* array_index = Int32Add(offset, Int32Mul(index, factor)); |
| 1384 Node* current = LoadFixedArrayElementInt32Index(descriptors, array_index); | 1341 Node* current = LoadFixedArrayElement(descriptors, array_index); |
| 1385 Label if_unequal(this); | 1342 Label if_unequal(this); |
| 1386 Branch(WordEqual(current, name), if_found, &if_unequal); | 1343 Branch(WordEqual(current, name), if_found, &if_unequal); |
| 1387 Bind(&if_unequal); | 1344 Bind(&if_unequal); |
| 1388 | 1345 |
| 1389 var_descriptor.Bind(Int32Add(index, Int32Constant(1))); | 1346 var_descriptor.Bind(Int32Add(index, Int32Constant(1))); |
| 1390 Goto(&loop); | 1347 Goto(&loop); |
| 1391 } | 1348 } |
| 1392 } | 1349 } |
| 1393 } | 1350 } |
| 1394 | 1351 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1415 Bind(&if_isobjectorsmi); | 1372 Bind(&if_isobjectorsmi); |
| 1416 { | 1373 { |
| 1417 Node* elements = LoadElements(object); | 1374 Node* elements = LoadElements(object); |
| 1418 Node* length = LoadFixedArrayBaseLength(elements); | 1375 Node* length = LoadFixedArrayBaseLength(elements); |
| 1419 | 1376 |
| 1420 Label if_iskeyinrange(this); | 1377 Label if_iskeyinrange(this); |
| 1421 Branch(Int32LessThan(index, SmiToWord32(length)), &if_iskeyinrange, | 1378 Branch(Int32LessThan(index, SmiToWord32(length)), &if_iskeyinrange, |
| 1422 if_not_found); | 1379 if_not_found); |
| 1423 | 1380 |
| 1424 Bind(&if_iskeyinrange); | 1381 Bind(&if_iskeyinrange); |
| 1425 Node* element = LoadFixedArrayElementInt32Index(elements, index); | 1382 Node* element = LoadFixedArrayElement(elements, index); |
| 1426 Node* the_hole = LoadRoot(Heap::kTheHoleValueRootIndex); | 1383 Node* the_hole = LoadRoot(Heap::kTheHoleValueRootIndex); |
| 1427 Branch(WordEqual(element, the_hole), if_not_found, if_found); | 1384 Branch(WordEqual(element, the_hole), if_not_found, if_found); |
| 1428 } | 1385 } |
| 1429 } | 1386 } |
| 1430 | 1387 |
| 1431 Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable, | 1388 Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable, |
| 1432 Node* object) { | 1389 Node* object) { |
| 1433 Variable var_result(this, MachineRepresentation::kTagged); | 1390 Variable var_result(this, MachineRepresentation::kTagged); |
| 1434 Label return_false(this), return_true(this), | 1391 Label return_false(this), return_true(this), |
| 1435 return_runtime(this, Label::kDeferred), return_result(this); | 1392 return_runtime(this, Label::kDeferred), return_result(this); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 // Fallback to the runtime implementation. | 1514 // Fallback to the runtime implementation. |
| 1558 var_result.Bind( | 1515 var_result.Bind( |
| 1559 CallRuntime(Runtime::kOrdinaryHasInstance, context, callable, object)); | 1516 CallRuntime(Runtime::kOrdinaryHasInstance, context, callable, object)); |
| 1560 } | 1517 } |
| 1561 Goto(&return_result); | 1518 Goto(&return_result); |
| 1562 | 1519 |
| 1563 Bind(&return_result); | 1520 Bind(&return_result); |
| 1564 return var_result.value(); | 1521 return var_result.value(); |
| 1565 } | 1522 } |
| 1566 | 1523 |
| 1524 compiler::Node* CodeStubAssembler::ElementOffsetFromIndex(Node* index_node, |
| 1525 ElementsKind kind, |
| 1526 ParameterMode mode, |
| 1527 int base_size) { |
| 1528 bool is_double = IsFastDoubleElementsKind(kind); |
| 1529 int element_size_shift = is_double ? kDoubleSizeLog2 : kPointerSizeLog2; |
| 1530 int element_size = 1 << element_size_shift; |
| 1531 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize; |
| 1532 int32_t index = 0; |
| 1533 bool constant_index = false; |
| 1534 if (mode == SMI_PARAMETERS) { |
| 1535 element_size_shift -= kSmiShiftBits; |
| 1536 intptr_t temp = 0; |
| 1537 constant_index = ToIntPtrConstant(index_node, temp); |
| 1538 index = temp >> kSmiShiftBits; |
| 1539 } else { |
| 1540 constant_index = ToInt32Constant(index_node, index); |
| 1541 } |
| 1542 if (constant_index) { |
| 1543 return IntPtrConstant(base_size + element_size * index); |
| 1544 } |
| 1545 if (base_size == 0) { |
| 1546 return (element_size_shift >= 0) |
| 1547 ? WordShl(index_node, IntPtrConstant(element_size_shift)) |
| 1548 : WordShr(index_node, IntPtrConstant(-element_size_shift)); |
| 1549 } |
| 1550 return IntPtrAdd( |
| 1551 Int32Constant(base_size), |
| 1552 (element_size_shift >= 0) |
| 1553 ? WordShl(index_node, IntPtrConstant(element_size_shift)) |
| 1554 : WordShr(index_node, IntPtrConstant(-element_size_shift))); |
| 1555 } |
| 1556 |
| 1567 } // namespace internal | 1557 } // namespace internal |
| 1568 } // namespace v8 | 1558 } // namespace v8 |
| OLD | NEW |