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-regexp-gen.h" | 5 #include "src/builtins/builtins-regexp-gen.h" |
6 #include "src/builtins/builtins-utils-gen.h" | 6 #include "src/builtins/builtins-utils-gen.h" |
7 #include "src/builtins/builtins.h" | 7 #include "src/builtins/builtins.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stub-assembler.h" | 9 #include "src/code-stub-assembler.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 | 1052 |
1053 BIND(&stub_call); | 1053 BIND(&stub_call); |
1054 Return(regexp_call()); | 1054 Return(regexp_call()); |
1055 | 1055 |
1056 BIND(&slow_lookup); | 1056 BIND(&slow_lookup); |
1057 } | 1057 } |
1058 | 1058 |
1059 GotoIf(IsNullOrUndefined(object), &out); | 1059 GotoIf(IsNullOrUndefined(object), &out); |
1060 | 1060 |
1061 // Fall back to a slow lookup of {object[symbol]}. | 1061 // Fall back to a slow lookup of {object[symbol]}. |
| 1062 // |
| 1063 // The spec uses GetMethod({object}, {symbol}), which has a few quirks: |
| 1064 // * null values are turned into undefined, and |
| 1065 // * an exception is thrown if the value is not undefined, null, or callable. |
| 1066 // We handle the former by jumping to {out} for null values as well, while |
| 1067 // the latter is already handled by the Call({maybe_func}) operation. |
1062 | 1068 |
1063 Node* const maybe_func = GetProperty(context, object, symbol); | 1069 Node* const maybe_func = GetProperty(context, object, symbol); |
1064 GotoIf(IsUndefined(maybe_func), &out); | 1070 GotoIf(IsUndefined(maybe_func), &out); |
| 1071 GotoIf(IsNull(maybe_func), &out); |
1065 | 1072 |
1066 // Attempt to call the function. | 1073 // Attempt to call the function. |
1067 | |
1068 Node* const result = generic_call(maybe_func); | 1074 Node* const result = generic_call(maybe_func); |
1069 Return(result); | 1075 Return(result); |
1070 | 1076 |
1071 BIND(&out); | 1077 BIND(&out); |
1072 } | 1078 } |
1073 | 1079 |
1074 compiler::Node* StringBuiltinsAssembler::IndexOfDollarChar(Node* const context, | 1080 compiler::Node* StringBuiltinsAssembler::IndexOfDollarChar(Node* const context, |
1075 Node* const string) { | 1081 Node* const string) { |
1076 CSA_ASSERT(this, IsString(string)); | 1082 CSA_ASSERT(this, IsString(string)); |
1077 | 1083 |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 1785 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
1780 HeapConstant(factory()->NewStringFromAsciiChecked( | 1786 HeapConstant(factory()->NewStringFromAsciiChecked( |
1781 "String Iterator.prototype.next", TENURED)), | 1787 "String Iterator.prototype.next", TENURED)), |
1782 iterator); | 1788 iterator); |
1783 Unreachable(); | 1789 Unreachable(); |
1784 } | 1790 } |
1785 } | 1791 } |
1786 | 1792 |
1787 } // namespace internal | 1793 } // namespace internal |
1788 } // namespace v8 | 1794 } // namespace v8 |
OLD | NEW |