| 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 3935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3946 UnaryOperation* left_unary = left->AsUnaryOperation(); | 3946 UnaryOperation* left_unary = left->AsUnaryOperation(); |
| 3947 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; | 3947 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; |
| 3948 Handle<String> check = Handle<String>::cast(right_literal_value); | 3948 Handle<String> check = Handle<String>::cast(right_literal_value); |
| 3949 | 3949 |
| 3950 { AccumulatorValueContext context(this); | 3950 { AccumulatorValueContext context(this); |
| 3951 VisitForTypeofValue(left_unary->expression()); | 3951 VisitForTypeofValue(left_unary->expression()); |
| 3952 } | 3952 } |
| 3953 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 3953 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 3954 | 3954 |
| 3955 if (check->Equals(isolate()->heap()->number_symbol())) { | 3955 if (check->Equals(isolate()->heap()->number_symbol())) { |
| 3956 __ test(eax, Immediate(kSmiTagMask)); | 3956 __ JumpIfSmi(eax, if_true); |
| 3957 __ j(zero, if_true); | |
| 3958 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), | 3957 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), |
| 3959 isolate()->factory()->heap_number_map()); | 3958 isolate()->factory()->heap_number_map()); |
| 3960 Split(equal, if_true, if_false, fall_through); | 3959 Split(equal, if_true, if_false, fall_through); |
| 3961 } else if (check->Equals(isolate()->heap()->string_symbol())) { | 3960 } else if (check->Equals(isolate()->heap()->string_symbol())) { |
| 3962 __ test(eax, Immediate(kSmiTagMask)); | 3961 __ JumpIfSmi(eax, if_false); |
| 3963 __ j(zero, if_false); | 3962 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx); |
| 3963 __ j(above_equal, if_false); |
| 3964 // Check for undetectable objects => false. | 3964 // Check for undetectable objects => false. |
| 3965 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); | 3965 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), |
| 3966 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); | 3966 1 << Map::kIsUndetectable); |
| 3967 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); | 3967 Split(zero, if_true, if_false, fall_through); |
| 3968 __ j(not_zero, if_false); | |
| 3969 __ CmpInstanceType(edx, FIRST_NONSTRING_TYPE); | |
| 3970 Split(below, if_true, if_false, fall_through); | |
| 3971 } else if (check->Equals(isolate()->heap()->boolean_symbol())) { | 3968 } else if (check->Equals(isolate()->heap()->boolean_symbol())) { |
| 3972 __ cmp(eax, isolate()->factory()->true_value()); | 3969 __ cmp(eax, isolate()->factory()->true_value()); |
| 3973 __ j(equal, if_true); | 3970 __ j(equal, if_true); |
| 3974 __ cmp(eax, isolate()->factory()->false_value()); | 3971 __ cmp(eax, isolate()->factory()->false_value()); |
| 3975 Split(equal, if_true, if_false, fall_through); | 3972 Split(equal, if_true, if_false, fall_through); |
| 3976 } else if (check->Equals(isolate()->heap()->undefined_symbol())) { | 3973 } else if (check->Equals(isolate()->heap()->undefined_symbol())) { |
| 3977 __ cmp(eax, isolate()->factory()->undefined_value()); | 3974 __ cmp(eax, isolate()->factory()->undefined_value()); |
| 3978 __ j(equal, if_true); | 3975 __ j(equal, if_true); |
| 3979 __ test(eax, Immediate(kSmiTagMask)); | 3976 __ JumpIfSmi(eax, if_false); |
| 3980 __ j(zero, if_false); | |
| 3981 // Check for undetectable objects => true. | 3977 // Check for undetectable objects => true. |
| 3982 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); | 3978 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 3983 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); | 3979 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); |
| 3984 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); | 3980 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); |
| 3985 Split(not_zero, if_true, if_false, fall_through); | 3981 Split(not_zero, if_true, if_false, fall_through); |
| 3986 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 3982 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
| 3987 __ test(eax, Immediate(kSmiTagMask)); | 3983 __ JumpIfSmi(eax, if_false); |
| 3988 __ j(zero, if_false); | 3984 __ CmpObjectType(eax, FIRST_FUNCTION_CLASS_TYPE, edx); |
| 3989 __ CmpObjectType(eax, JS_FUNCTION_TYPE, edx); | 3985 Split(above_equal, if_true, if_false, fall_through); |
| 3990 __ j(equal, if_true); | |
| 3991 // Regular expressions => 'function' (they are callable). | |
| 3992 __ CmpInstanceType(edx, JS_REGEXP_TYPE); | |
| 3993 Split(equal, if_true, if_false, fall_through); | |
| 3994 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 3986 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
| 3995 __ test(eax, Immediate(kSmiTagMask)); | 3987 __ JumpIfSmi(eax, if_false); |
| 3996 __ j(zero, if_false); | |
| 3997 __ cmp(eax, isolate()->factory()->null_value()); | 3988 __ cmp(eax, isolate()->factory()->null_value()); |
| 3998 __ j(equal, if_true); | 3989 __ j(equal, if_true); |
| 3999 // Regular expressions => 'function', not 'object'. | 3990 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, edx); |
| 4000 __ CmpObjectType(eax, JS_REGEXP_TYPE, edx); | 3991 __ j(below, if_false); |
| 4001 __ j(equal, if_false); | 3992 __ CmpInstanceType(edx, FIRST_FUNCTION_CLASS_TYPE); |
| 3993 __ j(above_equal, if_false); |
| 4002 // Check for undetectable objects => false. | 3994 // Check for undetectable objects => false. |
| 4003 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); | 3995 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), |
| 4004 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); | 3996 1 << Map::kIsUndetectable); |
| 4005 __ j(not_zero, if_false); | 3997 Split(zero, if_true, if_false, fall_through); |
| 4006 // Check for JS objects => true. | |
| 4007 __ movzx_b(ecx, FieldOperand(edx, Map::kInstanceTypeOffset)); | |
| 4008 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | |
| 4009 __ j(less, if_false); | |
| 4010 __ cmp(ecx, LAST_JS_OBJECT_TYPE); | |
| 4011 Split(less_equal, if_true, if_false, fall_through); | |
| 4012 } else { | 3998 } else { |
| 4013 if (if_false != fall_through) __ jmp(if_false); | 3999 if (if_false != fall_through) __ jmp(if_false); |
| 4014 } | 4000 } |
| 4015 | 4001 |
| 4016 return true; | 4002 return true; |
| 4017 } | 4003 } |
| 4018 | 4004 |
| 4019 | 4005 |
| 4020 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 4006 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 4021 Comment cmnt(masm_, "[ CompareOperation"); | 4007 Comment cmnt(masm_, "[ CompareOperation"); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4286 // And return. | 4272 // And return. |
| 4287 __ ret(0); | 4273 __ ret(0); |
| 4288 } | 4274 } |
| 4289 | 4275 |
| 4290 | 4276 |
| 4291 #undef __ | 4277 #undef __ |
| 4292 | 4278 |
| 4293 } } // namespace v8::internal | 4279 } } // namespace v8::internal |
| 4294 | 4280 |
| 4295 #endif // V8_TARGET_ARCH_IA32 | 4281 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |