OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 Label* is_false, | 2514 Label* is_false, |
2515 Handle<String>class_name, | 2515 Handle<String>class_name, |
2516 Register input, | 2516 Register input, |
2517 Register temp, | 2517 Register temp, |
2518 Register temp2) { | 2518 Register temp2) { |
2519 DCHECK(!input.is(temp)); | 2519 DCHECK(!input.is(temp)); |
2520 DCHECK(!input.is(temp2)); | 2520 DCHECK(!input.is(temp2)); |
2521 DCHECK(!temp.is(temp2)); | 2521 DCHECK(!temp.is(temp2)); |
2522 __ JumpIfSmi(input, is_false); | 2522 __ JumpIfSmi(input, is_false); |
2523 | 2523 |
2524 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); | |
2525 __ CmpObjectType(input, FIRST_JS_RECEIVER_TYPE, temp); | |
2526 __ j(below, is_false); | |
2527 | |
2528 // Objects with [[Call]] have class 'Function'. | |
2529 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), 1 << Map::kIsCallable); | |
2530 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { | 2524 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { |
2531 __ j(not_zero, is_true); | 2525 // Assuming the following assertions, we can use the same compares to test |
| 2526 // for both being a function type and being in the object type range. |
| 2527 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 2528 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 2529 FIRST_SPEC_OBJECT_TYPE + 1); |
| 2530 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 2531 LAST_SPEC_OBJECT_TYPE - 1); |
| 2532 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 2533 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
| 2534 __ j(below, is_false); |
| 2535 __ j(equal, is_true); |
| 2536 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); |
| 2537 __ j(equal, is_true); |
2532 } else { | 2538 } else { |
2533 __ j(not_zero, is_false); | 2539 // Faster code path to avoid two compares: subtract lower bound from the |
| 2540 // actual type and do a signed compare with the width of the type range. |
| 2541 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); |
| 2542 __ movzx_b(temp2, FieldOperand(temp, Map::kInstanceTypeOffset)); |
| 2543 __ sub(Operand(temp2), Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 2544 __ cmp(Operand(temp2), Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE - |
| 2545 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 2546 __ j(above, is_false); |
2534 } | 2547 } |
2535 | 2548 |
2536 // Now we are in the FIRST-LAST_JS_RECEIVER_TYPE range. | 2549 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. |
2537 // Check if the constructor in the map is a function. | 2550 // Check if the constructor in the map is a function. |
2538 __ GetMapConstructor(temp, temp, temp2); | 2551 __ GetMapConstructor(temp, temp, temp2); |
2539 // Objects with a non-function constructor have class 'Object'. | 2552 // Objects with a non-function constructor have class 'Object'. |
2540 __ CmpInstanceType(temp2, JS_FUNCTION_TYPE); | 2553 __ CmpInstanceType(temp2, JS_FUNCTION_TYPE); |
2541 if (String::Equals(class_name, isolate()->factory()->Object_string())) { | 2554 if (String::Equals(class_name, isolate()->factory()->Object_string())) { |
2542 __ j(not_equal, is_true); | 2555 __ j(not_equal, is_true); |
2543 } else { | 2556 } else { |
2544 __ j(not_equal, is_false); | 2557 __ j(not_equal, is_false); |
2545 } | 2558 } |
2546 | 2559 |
(...skipping 3194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5741 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5754 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5742 } | 5755 } |
5743 | 5756 |
5744 | 5757 |
5745 #undef __ | 5758 #undef __ |
5746 | 5759 |
5747 } // namespace internal | 5760 } // namespace internal |
5748 } // namespace v8 | 5761 } // namespace v8 |
5749 | 5762 |
5750 #endif // V8_TARGET_ARCH_IA32 | 5763 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |