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-utils-gen.h" | 5 #include "src/builtins/builtins-utils-gen.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 // Fast cases for internalized strings. | 198 // Fast cases for internalized strings. |
199 Node* number_string = LoadRoot(Heap::knumber_stringRootIndex); | 199 Node* number_string = LoadRoot(Heap::knumber_stringRootIndex); |
200 GotoIf(WordEqual(hint, number_string), &hint_is_number); | 200 GotoIf(WordEqual(hint, number_string), &hint_is_number); |
201 Node* default_string = LoadRoot(Heap::kdefault_stringRootIndex); | 201 Node* default_string = LoadRoot(Heap::kdefault_stringRootIndex); |
202 GotoIf(WordEqual(hint, default_string), &hint_is_string); | 202 GotoIf(WordEqual(hint, default_string), &hint_is_string); |
203 Node* string_string = LoadRoot(Heap::kstring_stringRootIndex); | 203 Node* string_string = LoadRoot(Heap::kstring_stringRootIndex); |
204 GotoIf(WordEqual(hint, string_string), &hint_is_string); | 204 GotoIf(WordEqual(hint, string_string), &hint_is_string); |
205 | 205 |
206 // Slow-case with actual string comparisons. | 206 // Slow-case with actual string comparisons. |
207 Callable string_equal = CodeFactory::StringEqual(isolate()); | |
208 GotoIf(TaggedIsSmi(hint), &hint_is_invalid); | 207 GotoIf(TaggedIsSmi(hint), &hint_is_invalid); |
209 GotoIfNot(IsString(hint), &hint_is_invalid); | 208 GotoIfNot(IsString(hint), &hint_is_invalid); |
210 GotoIf(WordEqual(CallStub(string_equal, context, hint, number_string), | 209 GotoIf(WordEqual( |
211 TrueConstant()), | 210 CallBuiltin(Builtins::kStringEqual, context, hint, number_string), |
| 211 TrueConstant()), |
212 &hint_is_number); | 212 &hint_is_number); |
213 GotoIf(WordEqual(CallStub(string_equal, context, hint, default_string), | 213 GotoIf(WordEqual( |
214 TrueConstant()), | 214 CallBuiltin(Builtins::kStringEqual, context, hint, default_string), |
| 215 TrueConstant()), |
215 &hint_is_string); | 216 &hint_is_string); |
216 GotoIf(WordEqual(CallStub(string_equal, context, hint, string_string), | 217 GotoIf(WordEqual( |
217 TrueConstant()), | 218 CallBuiltin(Builtins::kStringEqual, context, hint, string_string), |
| 219 TrueConstant()), |
218 &hint_is_string); | 220 &hint_is_string); |
219 Goto(&hint_is_invalid); | 221 Goto(&hint_is_invalid); |
220 | 222 |
221 // Use the OrdinaryToPrimitive builtin to convert to a Number. | 223 // Use the OrdinaryToPrimitive builtin to convert to a Number. |
222 BIND(&hint_is_number); | 224 BIND(&hint_is_number); |
223 { | 225 { |
224 Callable callable = CodeFactory::OrdinaryToPrimitive( | 226 Callable callable = CodeFactory::OrdinaryToPrimitive( |
225 isolate(), OrdinaryToPrimitiveHint::kNumber); | 227 isolate(), OrdinaryToPrimitiveHint::kNumber); |
226 Node* result = CallStub(callable, context, receiver); | 228 Node* result = CallStub(callable, context, receiver); |
227 Return(result); | 229 Return(result); |
(...skipping 21 matching lines...) Expand all Loading... |
249 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 251 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
250 HeapConstant(factory()->NewStringFromAsciiChecked( | 252 HeapConstant(factory()->NewStringFromAsciiChecked( |
251 "Date.prototype [ @@toPrimitive ]", TENURED)), | 253 "Date.prototype [ @@toPrimitive ]", TENURED)), |
252 receiver); | 254 receiver); |
253 Unreachable(); | 255 Unreachable(); |
254 } | 256 } |
255 } | 257 } |
256 | 258 |
257 } // namespace internal | 259 } // namespace internal |
258 } // namespace v8 | 260 } // namespace v8 |
OLD | NEW |