| 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/code-factory.h" | 5 #include "src/code-factory.h" |
| 6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
| 7 #include "src/cpu-profiler.h" | 7 #include "src/cpu-profiler.h" |
| 8 #include "src/hydrogen-osr.h" | 8 #include "src/hydrogen-osr.h" |
| 9 #include "src/ic/ic.h" | 9 #include "src/ic/ic.h" |
| 10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.h" |
| (...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 Handle<String>class_name, | 2641 Handle<String>class_name, |
| 2642 Register input, | 2642 Register input, |
| 2643 Register temp, | 2643 Register temp, |
| 2644 Register temp2) { | 2644 Register temp2) { |
| 2645 DCHECK(!input.is(temp)); | 2645 DCHECK(!input.is(temp)); |
| 2646 DCHECK(!input.is(temp2)); | 2646 DCHECK(!input.is(temp2)); |
| 2647 DCHECK(!temp.is(temp2)); | 2647 DCHECK(!temp.is(temp2)); |
| 2648 | 2648 |
| 2649 __ JumpIfSmi(input, is_false); | 2649 __ JumpIfSmi(input, is_false); |
| 2650 | 2650 |
| 2651 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
| 2652 __ GetObjectType(input, temp, temp2); |
| 2653 __ Branch(is_false, lt, temp2, Operand(FIRST_JS_RECEIVER_TYPE)); |
| 2654 |
| 2655 // Objects with [[Call]] have class 'Function'. |
| 2656 __ lbu(temp2, FieldMemOperand(temp, Map::kBitFieldOffset)); |
| 2657 __ And(temp2, temp2, Operand(1 << Map::kIsCallable)); |
| 2651 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { | 2658 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { |
| 2652 // Assuming the following assertions, we can use the same compares to test | 2659 __ Branch(is_true, ne, temp2, Operand(zero_reg)); |
| 2653 // for both being a function type and being in the object type range. | |
| 2654 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | |
| 2655 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
| 2656 FIRST_SPEC_OBJECT_TYPE + 1); | |
| 2657 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
| 2658 LAST_SPEC_OBJECT_TYPE - 1); | |
| 2659 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | |
| 2660 | |
| 2661 __ GetObjectType(input, temp, temp2); | |
| 2662 __ Branch(is_false, lt, temp2, Operand(FIRST_SPEC_OBJECT_TYPE)); | |
| 2663 __ Branch(is_true, eq, temp2, Operand(FIRST_SPEC_OBJECT_TYPE)); | |
| 2664 __ Branch(is_true, eq, temp2, Operand(LAST_SPEC_OBJECT_TYPE)); | |
| 2665 } else { | 2660 } else { |
| 2666 // Faster code path to avoid two compares: subtract lower bound from the | 2661 __ Branch(is_false, ne, temp2, Operand(zero_reg)); |
| 2667 // actual type and do a signed compare with the width of the type range. | |
| 2668 __ GetObjectType(input, temp, temp2); | |
| 2669 __ Dsubu(temp2, temp2, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); | |
| 2670 __ Branch(is_false, gt, temp2, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE - | |
| 2671 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); | |
| 2672 } | 2662 } |
| 2673 | 2663 |
| 2674 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. | 2664 // Now we are in the FIRST-LAST_JS_RECEIVER_TYPE range. |
| 2675 // Check if the constructor in the map is a function. | 2665 // Check if the constructor in the map is a function. |
| 2676 Register instance_type = scratch1(); | 2666 Register instance_type = scratch1(); |
| 2677 DCHECK(!instance_type.is(temp)); | 2667 DCHECK(!instance_type.is(temp)); |
| 2678 __ GetMapConstructor(temp, temp, temp2, instance_type); | 2668 __ GetMapConstructor(temp, temp, temp2, instance_type); |
| 2679 | 2669 |
| 2680 // Objects with a non-function constructor have class 'Object'. | 2670 // Objects with a non-function constructor have class 'Object'. |
| 2681 if (String::Equals(class_name, isolate()->factory()->Object_string())) { | 2671 if (String::Equals(class_name, isolate()->factory()->Object_string())) { |
| 2682 __ Branch(is_true, ne, instance_type, Operand(JS_FUNCTION_TYPE)); | 2672 __ Branch(is_true, ne, instance_type, Operand(JS_FUNCTION_TYPE)); |
| 2683 } else { | 2673 } else { |
| 2684 __ Branch(is_false, ne, instance_type, Operand(JS_FUNCTION_TYPE)); | 2674 __ Branch(is_false, ne, instance_type, Operand(JS_FUNCTION_TYPE)); |
| (...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6116 __ Push(at, ToRegister(instr->function())); | 6106 __ Push(at, ToRegister(instr->function())); |
| 6117 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6107 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6118 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6108 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6119 } | 6109 } |
| 6120 | 6110 |
| 6121 | 6111 |
| 6122 #undef __ | 6112 #undef __ |
| 6123 | 6113 |
| 6124 } // namespace internal | 6114 } // namespace internal |
| 6125 } // namespace v8 | 6115 } // namespace v8 |
| OLD | NEW |