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 Return(EmptyStringConstant()); | 659 { |
| 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 } |
660 | 666 |
661 BIND(&if_positioninbounds); | 667 BIND(&if_positioninbounds); |
662 } | 668 } |
663 | 669 |
664 // Load the character code at the {position} from the {receiver}. | 670 // Load the character code at the {position} from the {receiver}. |
665 Node* code = StringCharCodeAt(receiver, position); | 671 Node* code = StringCharCodeAt(receiver, position); |
666 | 672 |
667 // And return the single character string with only that {code}. | 673 // And return the single character string with only that {code}. |
668 Node* result = StringFromCharCode(code); | 674 Node* result = StringFromCharCode(code); |
669 Return(result); | 675 Return(result); |
(...skipping 18 matching lines...) Expand all Loading... |
688 | 694 |
689 // Determine the actual length of the {receiver} String. | 695 // Determine the actual length of the {receiver} String. |
690 Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset); | 696 Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset); |
691 | 697 |
692 // Return NaN if the Smi {position} is outside the bounds of the {receiver}. | 698 // Return NaN if the Smi {position} is outside the bounds of the {receiver}. |
693 Label if_positioninbounds(this); | 699 Label if_positioninbounds(this); |
694 Branch(SmiAboveOrEqual(position, receiver_length), &return_nan, | 700 Branch(SmiAboveOrEqual(position, receiver_length), &return_nan, |
695 &if_positioninbounds); | 701 &if_positioninbounds); |
696 | 702 |
697 BIND(&return_nan); | 703 BIND(&return_nan); |
698 Return(NaNConstant()); | 704 { |
| 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 } |
699 | 711 |
700 BIND(&if_positioninbounds); | 712 BIND(&if_positioninbounds); |
701 } | 713 } |
702 | 714 |
703 // Load the character at the {position} from the {receiver}. | 715 // Load the character at the {position} from the {receiver}. |
704 Node* value = StringCharCodeAt(receiver, position); | 716 Node* value = StringCharCodeAt(receiver, position); |
705 Node* result = SmiFromWord32(value); | 717 Node* result = SmiFromWord32(value); |
706 Return(result); | 718 Return(result); |
707 } | 719 } |
708 | 720 |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 1833 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
1822 HeapConstant(factory()->NewStringFromAsciiChecked( | 1834 HeapConstant(factory()->NewStringFromAsciiChecked( |
1823 "String Iterator.prototype.next", TENURED)), | 1835 "String Iterator.prototype.next", TENURED)), |
1824 iterator); | 1836 iterator); |
1825 Unreachable(); | 1837 Unreachable(); |
1826 } | 1838 } |
1827 } | 1839 } |
1828 | 1840 |
1829 } // namespace internal | 1841 } // namespace internal |
1830 } // namespace v8 | 1842 } // namespace v8 |
OLD | NEW |