| 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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
| 6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // representation of the {hint}. | 53 // representation of the {hint}. |
| 54 Callable callable = CodeFactory::Call(assembler->isolate()); | 54 Callable callable = CodeFactory::Call(assembler->isolate()); |
| 55 Node* hint_string = assembler->HeapConstant( | 55 Node* hint_string = assembler->HeapConstant( |
| 56 assembler->factory()->ToPrimitiveHintString(hint)); | 56 assembler->factory()->ToPrimitiveHintString(hint)); |
| 57 Node* result = assembler->CallJS(callable, context, exotic_to_prim, input, | 57 Node* result = assembler->CallJS(callable, context, exotic_to_prim, input, |
| 58 hint_string); | 58 hint_string); |
| 59 | 59 |
| 60 // Verify that the {result} is actually a primitive. | 60 // Verify that the {result} is actually a primitive. |
| 61 Label if_resultisprimitive(assembler), | 61 Label if_resultisprimitive(assembler), |
| 62 if_resultisnotprimitive(assembler, Label::kDeferred); | 62 if_resultisnotprimitive(assembler, Label::kDeferred); |
| 63 assembler->GotoIf(assembler->WordIsSmi(result), &if_resultisprimitive); | 63 assembler->GotoIf(assembler->TaggedIsSmi(result), &if_resultisprimitive); |
| 64 Node* result_instance_type = assembler->LoadInstanceType(result); | 64 Node* result_instance_type = assembler->LoadInstanceType(result); |
| 65 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE); | 65 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE); |
| 66 assembler->Branch(assembler->Int32LessThanOrEqual( | 66 assembler->Branch(assembler->Int32LessThanOrEqual( |
| 67 result_instance_type, | 67 result_instance_type, |
| 68 assembler->Int32Constant(LAST_PRIMITIVE_TYPE)), | 68 assembler->Int32Constant(LAST_PRIMITIVE_TYPE)), |
| 69 &if_resultisprimitive, &if_resultisnotprimitive); | 69 &if_resultisprimitive, &if_resultisnotprimitive); |
| 70 | 70 |
| 71 assembler->Bind(&if_resultisprimitive); | 71 assembler->Bind(&if_resultisprimitive); |
| 72 { | 72 { |
| 73 // Just return the {result}. | 73 // Just return the {result}. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 typedef CodeStubAssembler::Label Label; | 155 typedef CodeStubAssembler::Label Label; |
| 156 typedef compiler::Node Node; | 156 typedef compiler::Node Node; |
| 157 typedef TypeConversionDescriptor Descriptor; | 157 typedef TypeConversionDescriptor Descriptor; |
| 158 | 158 |
| 159 Node* input = assembler->Parameter(Descriptor::kArgument); | 159 Node* input = assembler->Parameter(Descriptor::kArgument); |
| 160 Node* context = assembler->Parameter(Descriptor::kContext); | 160 Node* context = assembler->Parameter(Descriptor::kContext); |
| 161 | 161 |
| 162 Label is_number(assembler); | 162 Label is_number(assembler); |
| 163 Label runtime(assembler); | 163 Label runtime(assembler); |
| 164 | 164 |
| 165 assembler->GotoIf(assembler->WordIsSmi(input), &is_number); | 165 assembler->GotoIf(assembler->TaggedIsSmi(input), &is_number); |
| 166 | 166 |
| 167 Node* input_map = assembler->LoadMap(input); | 167 Node* input_map = assembler->LoadMap(input); |
| 168 Node* input_instance_type = assembler->LoadMapInstanceType(input_map); | 168 Node* input_instance_type = assembler->LoadMapInstanceType(input_map); |
| 169 | 169 |
| 170 Label not_string(assembler); | 170 Label not_string(assembler); |
| 171 assembler->GotoUnless(assembler->IsStringInstanceType(input_instance_type), | 171 assembler->GotoUnless(assembler->IsStringInstanceType(input_instance_type), |
| 172 ¬_string); | 172 ¬_string); |
| 173 assembler->Return(input); | 173 assembler->Return(input); |
| 174 | 174 |
| 175 Label not_heap_number(assembler); | 175 Label not_heap_number(assembler); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 245 } |
| 246 for (Handle<String> name : method_names) { | 246 for (Handle<String> name : method_names) { |
| 247 // Lookup the {name} on the {input}. | 247 // Lookup the {name} on the {input}. |
| 248 Callable callable = CodeFactory::GetProperty(assembler->isolate()); | 248 Callable callable = CodeFactory::GetProperty(assembler->isolate()); |
| 249 Node* name_string = assembler->HeapConstant(name); | 249 Node* name_string = assembler->HeapConstant(name); |
| 250 Node* method = assembler->CallStub(callable, context, input, name_string); | 250 Node* method = assembler->CallStub(callable, context, input, name_string); |
| 251 | 251 |
| 252 // Check if the {method} is callable. | 252 // Check if the {method} is callable. |
| 253 Label if_methodiscallable(assembler), | 253 Label if_methodiscallable(assembler), |
| 254 if_methodisnotcallable(assembler, Label::kDeferred); | 254 if_methodisnotcallable(assembler, Label::kDeferred); |
| 255 assembler->GotoIf(assembler->WordIsSmi(method), &if_methodisnotcallable); | 255 assembler->GotoIf(assembler->TaggedIsSmi(method), &if_methodisnotcallable); |
| 256 Node* method_map = assembler->LoadMap(method); | 256 Node* method_map = assembler->LoadMap(method); |
| 257 Node* method_bit_field = assembler->LoadMapBitField(method_map); | 257 Node* method_bit_field = assembler->LoadMapBitField(method_map); |
| 258 assembler->Branch( | 258 assembler->Branch( |
| 259 assembler->Word32Equal( | 259 assembler->Word32Equal( |
| 260 assembler->Word32And(method_bit_field, assembler->Int32Constant( | 260 assembler->Word32And(method_bit_field, assembler->Int32Constant( |
| 261 1 << Map::kIsCallable)), | 261 1 << Map::kIsCallable)), |
| 262 assembler->Int32Constant(0)), | 262 assembler->Int32Constant(0)), |
| 263 &if_methodisnotcallable, &if_methodiscallable); | 263 &if_methodisnotcallable, &if_methodiscallable); |
| 264 | 264 |
| 265 assembler->Bind(&if_methodiscallable); | 265 assembler->Bind(&if_methodiscallable); |
| 266 { | 266 { |
| 267 // Call the {method} on the {input}. | 267 // Call the {method} on the {input}. |
| 268 Callable callable = CodeFactory::Call(assembler->isolate()); | 268 Callable callable = CodeFactory::Call(assembler->isolate()); |
| 269 Node* result = assembler->CallJS(callable, context, method, input); | 269 Node* result = assembler->CallJS(callable, context, method, input); |
| 270 var_result.Bind(result); | 270 var_result.Bind(result); |
| 271 | 271 |
| 272 // Return the {result} if it is a primitive. | 272 // Return the {result} if it is a primitive. |
| 273 assembler->GotoIf(assembler->WordIsSmi(result), &return_result); | 273 assembler->GotoIf(assembler->TaggedIsSmi(result), &return_result); |
| 274 Node* result_instance_type = assembler->LoadInstanceType(result); | 274 Node* result_instance_type = assembler->LoadInstanceType(result); |
| 275 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE); | 275 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE); |
| 276 assembler->GotoIf(assembler->Int32LessThanOrEqual( | 276 assembler->GotoIf(assembler->Int32LessThanOrEqual( |
| 277 result_instance_type, | 277 result_instance_type, |
| 278 assembler->Int32Constant(LAST_PRIMITIVE_TYPE)), | 278 assembler->Int32Constant(LAST_PRIMITIVE_TYPE)), |
| 279 &return_result); | 279 &return_result); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Just continue with the next {name} if the {method} is not callable. | 282 // Just continue with the next {name} if the {method} is not callable. |
| 283 assembler->Goto(&if_methodisnotcallable); | 283 assembler->Goto(&if_methodisnotcallable); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return_two53minus1(assembler, Label::kDeferred), | 338 return_two53minus1(assembler, Label::kDeferred), |
| 339 return_zero(assembler, Label::kDeferred); | 339 return_zero(assembler, Label::kDeferred); |
| 340 | 340 |
| 341 // Load the current {len} value. | 341 // Load the current {len} value. |
| 342 Node* len = var_len.value(); | 342 Node* len = var_len.value(); |
| 343 | 343 |
| 344 // Check if {len} is a positive Smi. | 344 // Check if {len} is a positive Smi. |
| 345 assembler->GotoIf(assembler->WordIsPositiveSmi(len), &return_len); | 345 assembler->GotoIf(assembler->WordIsPositiveSmi(len), &return_len); |
| 346 | 346 |
| 347 // Check if {len} is a (negative) Smi. | 347 // Check if {len} is a (negative) Smi. |
| 348 assembler->GotoIf(assembler->WordIsSmi(len), &return_zero); | 348 assembler->GotoIf(assembler->TaggedIsSmi(len), &return_zero); |
| 349 | 349 |
| 350 // Check if {len} is a HeapNumber. | 350 // Check if {len} is a HeapNumber. |
| 351 Label if_lenisheapnumber(assembler), | 351 Label if_lenisheapnumber(assembler), |
| 352 if_lenisnotheapnumber(assembler, Label::kDeferred); | 352 if_lenisnotheapnumber(assembler, Label::kDeferred); |
| 353 assembler->Branch(assembler->IsHeapNumberMap(assembler->LoadMap(len)), | 353 assembler->Branch(assembler->IsHeapNumberMap(assembler->LoadMap(len)), |
| 354 &if_lenisheapnumber, &if_lenisnotheapnumber); | 354 &if_lenisheapnumber, &if_lenisnotheapnumber); |
| 355 | 355 |
| 356 assembler->Bind(&if_lenisheapnumber); | 356 assembler->Bind(&if_lenisheapnumber); |
| 357 { | 357 { |
| 358 // Load the floating-point value of {len}. | 358 // Load the floating-point value of {len}. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 Label if_number(assembler, Label::kDeferred), if_notsmi(assembler), | 413 Label if_number(assembler, Label::kDeferred), if_notsmi(assembler), |
| 414 if_jsreceiver(assembler), if_noconstructor(assembler, Label::kDeferred), | 414 if_jsreceiver(assembler), if_noconstructor(assembler, Label::kDeferred), |
| 415 if_wrapjsvalue(assembler); | 415 if_wrapjsvalue(assembler); |
| 416 | 416 |
| 417 Node* object = assembler->Parameter(Descriptor::kArgument); | 417 Node* object = assembler->Parameter(Descriptor::kArgument); |
| 418 Node* context = assembler->Parameter(Descriptor::kContext); | 418 Node* context = assembler->Parameter(Descriptor::kContext); |
| 419 | 419 |
| 420 Variable constructor_function_index_var(assembler, | 420 Variable constructor_function_index_var(assembler, |
| 421 MachineType::PointerRepresentation()); | 421 MachineType::PointerRepresentation()); |
| 422 | 422 |
| 423 assembler->Branch(assembler->WordIsSmi(object), &if_number, &if_notsmi); | 423 assembler->Branch(assembler->TaggedIsSmi(object), &if_number, &if_notsmi); |
| 424 | 424 |
| 425 assembler->Bind(&if_notsmi); | 425 assembler->Bind(&if_notsmi); |
| 426 Node* map = assembler->LoadMap(object); | 426 Node* map = assembler->LoadMap(object); |
| 427 | 427 |
| 428 assembler->GotoIf(assembler->IsHeapNumberMap(map), &if_number); | 428 assembler->GotoIf(assembler->IsHeapNumberMap(map), &if_number); |
| 429 | 429 |
| 430 Node* instance_type = assembler->LoadMapInstanceType(map); | 430 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 431 assembler->GotoIf(assembler->IsJSReceiverInstanceType(instance_type), | 431 assembler->GotoIf(assembler->IsJSReceiverInstanceType(instance_type), |
| 432 &if_jsreceiver); | 432 &if_jsreceiver); |
| 433 | 433 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 typedef TypeofDescriptor Descriptor; | 477 typedef TypeofDescriptor Descriptor; |
| 478 | 478 |
| 479 Node* object = assembler->Parameter(Descriptor::kObject); | 479 Node* object = assembler->Parameter(Descriptor::kObject); |
| 480 Node* context = assembler->Parameter(Descriptor::kContext); | 480 Node* context = assembler->Parameter(Descriptor::kContext); |
| 481 | 481 |
| 482 assembler->Return(assembler->Typeof(object, context)); | 482 assembler->Return(assembler->Typeof(object, context)); |
| 483 } | 483 } |
| 484 | 484 |
| 485 } // namespace internal | 485 } // namespace internal |
| 486 } // namespace v8 | 486 } // namespace v8 |
| OLD | NEW |