| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 8 | 8 |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 2518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2529 Label* is_false, | 2529 Label* is_false, |
| 2530 Handle<String>class_name, | 2530 Handle<String>class_name, |
| 2531 Register input, | 2531 Register input, |
| 2532 Register temp, | 2532 Register temp, |
| 2533 Register temp2) { | 2533 Register temp2) { |
| 2534 DCHECK(!input.is(temp)); | 2534 DCHECK(!input.is(temp)); |
| 2535 DCHECK(!input.is(temp2)); | 2535 DCHECK(!input.is(temp2)); |
| 2536 DCHECK(!temp.is(temp2)); | 2536 DCHECK(!temp.is(temp2)); |
| 2537 __ JumpIfSmi(input, is_false); | 2537 __ JumpIfSmi(input, is_false); |
| 2538 | 2538 |
| 2539 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Function"))) { | 2539 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { |
| 2540 // Assuming the following assertions, we can use the same compares to test | 2540 // Assuming the following assertions, we can use the same compares to test |
| 2541 // for both being a function type and being in the object type range. | 2541 // for both being a function type and being in the object type range. |
| 2542 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | 2542 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 2543 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == | 2543 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 2544 FIRST_SPEC_OBJECT_TYPE + 1); | 2544 FIRST_SPEC_OBJECT_TYPE + 1); |
| 2545 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | 2545 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 2546 LAST_SPEC_OBJECT_TYPE - 1); | 2546 LAST_SPEC_OBJECT_TYPE - 1); |
| 2547 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | 2547 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 2548 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); | 2548 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
| 2549 __ j(below, is_false); | 2549 __ j(below, is_false); |
| 2550 __ j(equal, is_true); | 2550 __ j(equal, is_true); |
| 2551 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); | 2551 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); |
| 2552 __ j(equal, is_true); | 2552 __ j(equal, is_true); |
| 2553 } else { | 2553 } else { |
| 2554 // Faster code path to avoid two compares: subtract lower bound from the | 2554 // Faster code path to avoid two compares: subtract lower bound from the |
| 2555 // actual type and do a signed compare with the width of the type range. | 2555 // actual type and do a signed compare with the width of the type range. |
| 2556 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); | 2556 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); |
| 2557 __ movzx_b(temp2, FieldOperand(temp, Map::kInstanceTypeOffset)); | 2557 __ movzx_b(temp2, FieldOperand(temp, Map::kInstanceTypeOffset)); |
| 2558 __ sub(Operand(temp2), Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 2558 __ sub(Operand(temp2), Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 2559 __ cmp(Operand(temp2), Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE - | 2559 __ cmp(Operand(temp2), Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE - |
| 2560 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 2560 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 2561 __ j(above, is_false); | 2561 __ j(above, is_false); |
| 2562 } | 2562 } |
| 2563 | 2563 |
| 2564 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. | 2564 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. |
| 2565 // Check if the constructor in the map is a function. | 2565 // Check if the constructor in the map is a function. |
| 2566 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); | 2566 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); |
| 2567 // Objects with a non-function constructor have class 'Object'. | 2567 // Objects with a non-function constructor have class 'Object'. |
| 2568 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); | 2568 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); |
| 2569 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Object"))) { | 2569 if (String::Equals(class_name, isolate()->factory()->Object_string())) { |
| 2570 __ j(not_equal, is_true); | 2570 __ j(not_equal, is_true); |
| 2571 } else { | 2571 } else { |
| 2572 __ j(not_equal, is_false); | 2572 __ j(not_equal, is_false); |
| 2573 } | 2573 } |
| 2574 | 2574 |
| 2575 // temp now contains the constructor function. Grab the | 2575 // temp now contains the constructor function. Grab the |
| 2576 // instance class name from there. | 2576 // instance class name from there. |
| 2577 __ mov(temp, FieldOperand(temp, JSFunction::kSharedFunctionInfoOffset)); | 2577 __ mov(temp, FieldOperand(temp, JSFunction::kSharedFunctionInfoOffset)); |
| 2578 __ mov(temp, FieldOperand(temp, | 2578 __ mov(temp, FieldOperand(temp, |
| 2579 SharedFunctionInfo::kInstanceClassNameOffset)); | 2579 SharedFunctionInfo::kInstanceClassNameOffset)); |
| (...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5675 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5675 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 5676 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5676 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5677 } | 5677 } |
| 5678 | 5678 |
| 5679 | 5679 |
| 5680 #undef __ | 5680 #undef __ |
| 5681 | 5681 |
| 5682 } } // namespace v8::internal | 5682 } } // namespace v8::internal |
| 5683 | 5683 |
| 5684 #endif // V8_TARGET_ARCH_IA32 | 5684 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |