OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/crankshaft/x64/lithium-codegen-x64.h" | 7 #include "src/crankshaft/x64/lithium-codegen-x64.h" |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 Handle<String> class_name, | 2491 Handle<String> class_name, |
2492 Register input, | 2492 Register input, |
2493 Register temp, | 2493 Register temp, |
2494 Register temp2) { | 2494 Register temp2) { |
2495 DCHECK(!input.is(temp)); | 2495 DCHECK(!input.is(temp)); |
2496 DCHECK(!input.is(temp2)); | 2496 DCHECK(!input.is(temp2)); |
2497 DCHECK(!temp.is(temp2)); | 2497 DCHECK(!temp.is(temp2)); |
2498 | 2498 |
2499 __ JumpIfSmi(input, is_false); | 2499 __ JumpIfSmi(input, is_false); |
2500 | 2500 |
| 2501 __ CmpObjectType(input, JS_FUNCTION_TYPE, temp); |
2501 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { | 2502 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { |
2502 // Assuming the following assertions, we can use the same compares to test | |
2503 // for both being a function type and being in the object type range. | |
2504 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | |
2505 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
2506 LAST_JS_RECEIVER_TYPE - 1); | |
2507 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); | |
2508 __ CmpObjectType(input, FIRST_JS_RECEIVER_TYPE, temp); | |
2509 __ j(below, is_false); | |
2510 __ CmpInstanceType(temp, LAST_JS_RECEIVER_TYPE); | |
2511 __ j(equal, is_true); | 2503 __ j(equal, is_true); |
2512 } else { | 2504 } else { |
2513 // Faster code path to avoid two compares: subtract lower bound from the | 2505 __ j(equal, is_false); |
2514 // actual type and do a signed compare with the width of the type range. | |
2515 __ movp(temp, FieldOperand(input, HeapObject::kMapOffset)); | |
2516 __ movzxbl(temp2, FieldOperand(temp, Map::kInstanceTypeOffset)); | |
2517 __ subp(temp2, Immediate(FIRST_JS_RECEIVER_TYPE)); | |
2518 __ cmpp(temp2, Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE - | |
2519 FIRST_JS_RECEIVER_TYPE)); | |
2520 __ j(above, is_false); | |
2521 } | 2506 } |
2522 | 2507 |
2523 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. | |
2524 // Check if the constructor in the map is a function. | 2508 // Check if the constructor in the map is a function. |
2525 __ GetMapConstructor(temp, temp, kScratchRegister); | 2509 __ GetMapConstructor(temp, temp, kScratchRegister); |
2526 | 2510 |
2527 // Objects with a non-function constructor have class 'Object'. | 2511 // Objects with a non-function constructor have class 'Object'. |
2528 __ CmpInstanceType(kScratchRegister, JS_FUNCTION_TYPE); | 2512 __ CmpInstanceType(kScratchRegister, JS_FUNCTION_TYPE); |
2529 if (String::Equals(class_name, isolate()->factory()->Object_string())) { | 2513 if (String::Equals(class_name, isolate()->factory()->Object_string())) { |
2530 __ j(not_equal, is_true); | 2514 __ j(not_equal, is_true); |
2531 } else { | 2515 } else { |
2532 __ j(not_equal, is_false); | 2516 __ j(not_equal, is_false); |
2533 } | 2517 } |
(...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5715 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5699 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5716 } | 5700 } |
5717 | 5701 |
5718 | 5702 |
5719 #undef __ | 5703 #undef __ |
5720 | 5704 |
5721 } // namespace internal | 5705 } // namespace internal |
5722 } // namespace v8 | 5706 } // namespace v8 |
5723 | 5707 |
5724 #endif // V8_TARGET_ARCH_X64 | 5708 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |