OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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/builtins/builtins-string-gen.h" | 5 #include "src/builtins/builtins-string-gen.h" |
6 | 6 |
7 #include "src/builtins/builtins-regexp-gen.h" | 7 #include "src/builtins/builtins-regexp-gen.h" |
8 #include "src/builtins/builtins-utils-gen.h" | 8 #include "src/builtins/builtins-utils-gen.h" |
9 #include "src/builtins/builtins.h" | 9 #include "src/builtins/builtins.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 649 |
650 // Determine the actual length of the {receiver} String. | 650 // Determine the actual length of the {receiver} String. |
651 Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset); | 651 Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset); |
652 | 652 |
653 // Return "" if the Smi {position} is outside the bounds of the {receiver}. | 653 // Return "" if the Smi {position} is outside the bounds of the {receiver}. |
654 Label if_positioninbounds(this); | 654 Label if_positioninbounds(this); |
655 Branch(SmiAboveOrEqual(position, receiver_length), &return_emptystring, | 655 Branch(SmiAboveOrEqual(position, receiver_length), &return_emptystring, |
656 &if_positioninbounds); | 656 &if_positioninbounds); |
657 | 657 |
658 BIND(&return_emptystring); | 658 BIND(&return_emptystring); |
659 { | 659 Return(EmptyStringConstant()); |
660 // Invalidate the "String Bounds Check" protector. | |
661 Node* invalid = SmiConstant(Isolate::kProtectorInvalid); | |
662 Node* cell = LoadRoot(Heap::kStringBoundsCheckProtectorRootIndex); | |
663 StoreObjectFieldNoWriteBarrier(cell, Cell::kValueOffset, invalid); | |
664 Return(EmptyStringConstant()); | |
665 } | |
666 | 660 |
667 BIND(&if_positioninbounds); | 661 BIND(&if_positioninbounds); |
668 } | 662 } |
669 | 663 |
670 // Load the character code at the {position} from the {receiver}. | 664 // Load the character code at the {position} from the {receiver}. |
671 Node* code = StringCharCodeAt(receiver, position); | 665 Node* code = StringCharCodeAt(receiver, position); |
672 | 666 |
673 // And return the single character string with only that {code}. | 667 // And return the single character string with only that {code}. |
674 Node* result = StringFromCharCode(code); | 668 Node* result = StringFromCharCode(code); |
675 Return(result); | 669 Return(result); |
(...skipping 18 matching lines...) Expand all Loading... |
694 | 688 |
695 // Determine the actual length of the {receiver} String. | 689 // Determine the actual length of the {receiver} String. |
696 Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset); | 690 Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset); |
697 | 691 |
698 // Return NaN if the Smi {position} is outside the bounds of the {receiver}. | 692 // Return NaN if the Smi {position} is outside the bounds of the {receiver}. |
699 Label if_positioninbounds(this); | 693 Label if_positioninbounds(this); |
700 Branch(SmiAboveOrEqual(position, receiver_length), &return_nan, | 694 Branch(SmiAboveOrEqual(position, receiver_length), &return_nan, |
701 &if_positioninbounds); | 695 &if_positioninbounds); |
702 | 696 |
703 BIND(&return_nan); | 697 BIND(&return_nan); |
704 { | 698 Return(NaNConstant()); |
705 // Invalidate the "String Bounds Check" protector. | |
706 Node* invalid = SmiConstant(Isolate::kProtectorInvalid); | |
707 Node* cell = LoadRoot(Heap::kStringBoundsCheckProtectorRootIndex); | |
708 StoreObjectFieldNoWriteBarrier(cell, Cell::kValueOffset, invalid); | |
709 Return(NaNConstant()); | |
710 } | |
711 | 699 |
712 BIND(&if_positioninbounds); | 700 BIND(&if_positioninbounds); |
713 } | 701 } |
714 | 702 |
715 // Load the character at the {position} from the {receiver}. | 703 // Load the character at the {position} from the {receiver}. |
716 Node* value = StringCharCodeAt(receiver, position); | 704 Node* value = StringCharCodeAt(receiver, position); |
717 Node* result = SmiFromWord32(value); | 705 Node* result = SmiFromWord32(value); |
718 Return(result); | 706 Return(result); |
719 } | 707 } |
720 | 708 |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 1821 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
1834 HeapConstant(factory()->NewStringFromAsciiChecked( | 1822 HeapConstant(factory()->NewStringFromAsciiChecked( |
1835 "String Iterator.prototype.next", TENURED)), | 1823 "String Iterator.prototype.next", TENURED)), |
1836 iterator); | 1824 iterator); |
1837 Unreachable(); | 1825 Unreachable(); |
1838 } | 1826 } |
1839 } | 1827 } |
1840 | 1828 |
1841 } // namespace internal | 1829 } // namespace internal |
1842 } // namespace v8 | 1830 } // namespace v8 |
OLD | NEW |