OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1652 __ cmp(input, isolate()->factory()->null_value()); | 1652 __ cmp(input, isolate()->factory()->null_value()); |
1653 __ j(equal, is_object); | 1653 __ j(equal, is_object); |
1654 | 1654 |
1655 __ mov(temp1, FieldOperand(input, HeapObject::kMapOffset)); | 1655 __ mov(temp1, FieldOperand(input, HeapObject::kMapOffset)); |
1656 // Undetectable objects behave like undefined. | 1656 // Undetectable objects behave like undefined. |
1657 __ movzx_b(temp2, FieldOperand(temp1, Map::kBitFieldOffset)); | 1657 __ movzx_b(temp2, FieldOperand(temp1, Map::kBitFieldOffset)); |
1658 __ test(temp2, Immediate(1 << Map::kIsUndetectable)); | 1658 __ test(temp2, Immediate(1 << Map::kIsUndetectable)); |
1659 __ j(not_zero, is_not_object); | 1659 __ j(not_zero, is_not_object); |
1660 | 1660 |
1661 __ movzx_b(temp2, FieldOperand(temp1, Map::kInstanceTypeOffset)); | 1661 __ movzx_b(temp2, FieldOperand(temp1, Map::kInstanceTypeOffset)); |
1662 __ cmp(temp2, FIRST_JS_OBJECT_TYPE); | 1662 __ cmp(temp2, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE); |
1663 __ j(below, is_not_object); | 1663 __ j(below, is_not_object); |
1664 __ cmp(temp2, LAST_JS_OBJECT_TYPE); | 1664 __ cmp(temp2, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
1665 return below_equal; | 1665 return below_equal; |
1666 } | 1666 } |
1667 | 1667 |
1668 | 1668 |
1669 void LCodeGen::DoIsObject(LIsObject* instr) { | 1669 void LCodeGen::DoIsObject(LIsObject* instr) { |
1670 Register reg = ToRegister(instr->InputAt(0)); | 1670 Register reg = ToRegister(instr->InputAt(0)); |
1671 Register result = ToRegister(instr->result()); | 1671 Register result = ToRegister(instr->result()); |
1672 Register temp = ToRegister(instr->TempAt(0)); | 1672 Register temp = ToRegister(instr->TempAt(0)); |
1673 Label is_false, is_true, done; | 1673 Label is_false, is_true, done; |
1674 | 1674 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1867 void LCodeGen::EmitClassOfTest(Label* is_true, | 1867 void LCodeGen::EmitClassOfTest(Label* is_true, |
1868 Label* is_false, | 1868 Label* is_false, |
1869 Handle<String>class_name, | 1869 Handle<String>class_name, |
1870 Register input, | 1870 Register input, |
1871 Register temp, | 1871 Register temp, |
1872 Register temp2) { | 1872 Register temp2) { |
1873 ASSERT(!input.is(temp)); | 1873 ASSERT(!input.is(temp)); |
1874 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. | 1874 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. |
1875 __ test(input, Immediate(kSmiTagMask)); | 1875 __ test(input, Immediate(kSmiTagMask)); |
1876 __ j(zero, is_false); | 1876 __ j(zero, is_false); |
1877 __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, temp); | 1877 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
1878 __ j(below, is_false); | 1878 __ j(below, is_false); |
1879 | 1879 |
1880 // Map is now in temp. | 1880 // Map is now in temp. |
1881 // Functions have class 'Function'. | 1881 // Functions have class 'Function'. |
1882 __ CmpInstanceType(temp, JS_FUNCTION_TYPE); | 1882 __ CmpInstanceType(temp, FIRST_CALLABLE_SPEC_OBJECT_TYPE); |
1883 if (class_name->IsEqualTo(CStrVector("Function"))) { | 1883 if (class_name->IsEqualTo(CStrVector("Function"))) { |
1884 __ j(equal, is_true); | 1884 __ j(greater_equal, is_true); |
Kevin Millikin (Chromium)
2011/05/30 16:32:29
This needs to be above_equal (also just below).
rossberg
2011/05/31 14:50:24
Done.
| |
1885 } else { | 1885 } else { |
1886 __ j(equal, is_false); | 1886 __ j(greater_equal, is_false); |
1887 } | 1887 } |
1888 | 1888 |
1889 // Check if the constructor in the map is a function. | 1889 // Check if the constructor in the map is a function. |
1890 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); | 1890 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); |
1891 | 1891 |
1892 // As long as JS_FUNCTION_TYPE is the last instance type and it is | 1892 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and |
1893 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for | 1893 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after |
1894 // LAST_JS_OBJECT_TYPE. | 1894 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. |
1895 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 1895 ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); |
1896 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); | 1896 ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == |
1897 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); | |
1897 | 1898 |
1898 // Objects with a non-function constructor have class 'Object'. | 1899 // Objects with a non-function constructor have class 'Object'. |
1899 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); | 1900 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); |
1900 if (class_name->IsEqualTo(CStrVector("Object"))) { | 1901 if (class_name->IsEqualTo(CStrVector("Object"))) { |
1901 __ j(not_equal, is_true); | 1902 __ j(not_equal, is_true); |
1902 } else { | 1903 } else { |
1903 __ j(not_equal, is_false); | 1904 __ j(not_equal, is_false); |
1904 } | 1905 } |
1905 | 1906 |
1906 // temp now contains the constructor function. Grab the | 1907 // temp now contains the constructor function. Grab the |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2591 // as a receiver. | 2592 // as a receiver. |
2592 Label global_object, receiver_ok; | 2593 Label global_object, receiver_ok; |
2593 __ cmp(receiver, factory()->null_value()); | 2594 __ cmp(receiver, factory()->null_value()); |
2594 __ j(equal, &global_object, Label::kNear); | 2595 __ j(equal, &global_object, Label::kNear); |
2595 __ cmp(receiver, factory()->undefined_value()); | 2596 __ cmp(receiver, factory()->undefined_value()); |
2596 __ j(equal, &global_object, Label::kNear); | 2597 __ j(equal, &global_object, Label::kNear); |
2597 | 2598 |
2598 // The receiver should be a JS object. | 2599 // The receiver should be a JS object. |
2599 __ test(receiver, Immediate(kSmiTagMask)); | 2600 __ test(receiver, Immediate(kSmiTagMask)); |
2600 DeoptimizeIf(equal, instr->environment()); | 2601 DeoptimizeIf(equal, instr->environment()); |
2601 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, scratch); | 2602 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, scratch); |
2602 DeoptimizeIf(below, instr->environment()); | 2603 DeoptimizeIf(below, instr->environment()); |
2603 __ jmp(&receiver_ok, Label::kNear); | 2604 __ jmp(&receiver_ok, Label::kNear); |
2604 | 2605 |
2605 __ bind(&global_object); | 2606 __ bind(&global_object); |
2606 // TODO(kmillikin): We have a hydrogen value for the global object. See | 2607 // TODO(kmillikin): We have a hydrogen value for the global object. See |
2607 // if it's better to use it than to explicitly fetch it from the context | 2608 // if it's better to use it than to explicitly fetch it from the context |
2608 // here. | 2609 // here. |
2609 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2610 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2610 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); | 2611 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); |
2611 __ bind(&receiver_ok); | 2612 __ bind(&receiver_ok); |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4251 __ cmp(input, factory()->undefined_value()); | 4252 __ cmp(input, factory()->undefined_value()); |
4252 __ j(equal, true_label); | 4253 __ j(equal, true_label); |
4253 __ JumpIfSmi(input, false_label); | 4254 __ JumpIfSmi(input, false_label); |
4254 // Check for undetectable objects => true. | 4255 // Check for undetectable objects => true. |
4255 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); | 4256 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); |
4256 __ test_b(FieldOperand(input, Map::kBitFieldOffset), | 4257 __ test_b(FieldOperand(input, Map::kBitFieldOffset), |
4257 1 << Map::kIsUndetectable); | 4258 1 << Map::kIsUndetectable); |
4258 final_branch_condition = not_zero; | 4259 final_branch_condition = not_zero; |
4259 | 4260 |
4260 } else if (type_name->Equals(heap()->function_symbol())) { | 4261 } else if (type_name->Equals(heap()->function_symbol())) { |
4262 ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | |
4261 __ JumpIfSmi(input, false_label); | 4263 __ JumpIfSmi(input, false_label); |
4262 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); | 4264 __ CmpObjectType(input, FIRST_CALLABLE_SPEC_OBJECT_TYPE, input); |
4263 __ j(equal, true_label); | 4265 final_branch_condition = above_equal; |
4264 // Regular expressions => 'function' (they are callable). | |
4265 __ CmpInstanceType(input, JS_REGEXP_TYPE); | |
4266 final_branch_condition = equal; | |
4267 | 4266 |
4268 } else if (type_name->Equals(heap()->object_symbol())) { | 4267 } else if (type_name->Equals(heap()->object_symbol())) { |
4269 __ JumpIfSmi(input, false_label); | 4268 __ JumpIfSmi(input, false_label); |
4270 __ cmp(input, factory()->null_value()); | 4269 __ cmp(input, factory()->null_value()); |
4271 __ j(equal, true_label); | 4270 __ j(equal, true_label); |
4272 // Regular expressions => 'function', not 'object'. | 4271 // Regular expressions => 'function', not 'object'. |
4273 __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, input); | 4272 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); |
4274 __ j(below, false_label); | 4273 __ j(below, false_label); |
4275 __ CmpInstanceType(input, FIRST_FUNCTION_CLASS_TYPE); | 4274 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
4276 __ j(above_equal, false_label); | 4275 __ j(above, false_label); |
4277 // Check for undetectable objects => false. | 4276 // Check for undetectable objects => false. |
4278 __ test_b(FieldOperand(input, Map::kBitFieldOffset), | 4277 __ test_b(FieldOperand(input, Map::kBitFieldOffset), |
4279 1 << Map::kIsUndetectable); | 4278 1 << Map::kIsUndetectable); |
4280 final_branch_condition = zero; | 4279 final_branch_condition = zero; |
4281 | 4280 |
4282 } else { | 4281 } else { |
4283 final_branch_condition = not_equal; | 4282 final_branch_condition = not_equal; |
4284 __ jmp(false_label); | 4283 __ jmp(false_label); |
4285 // A dead branch instruction will be generated after this point. | 4284 // A dead branch instruction will be generated after this point. |
4286 } | 4285 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4430 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 4429 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
4431 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4430 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4432 } | 4431 } |
4433 | 4432 |
4434 | 4433 |
4435 #undef __ | 4434 #undef __ |
4436 | 4435 |
4437 } } // namespace v8::internal | 4436 } } // namespace v8::internal |
4438 | 4437 |
4439 #endif // V8_TARGET_ARCH_IA32 | 4438 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |