Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 6606005: Simplify test for typeof x == 'Object' on all platforms. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3918 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 UnaryOperation* left_unary = left->AsUnaryOperation(); 3929 UnaryOperation* left_unary = left->AsUnaryOperation();
3930 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; 3930 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
3931 Handle<String> check = Handle<String>::cast(right_literal_value); 3931 Handle<String> check = Handle<String>::cast(right_literal_value);
3932 3932
3933 { AccumulatorValueContext context(this); 3933 { AccumulatorValueContext context(this);
3934 VisitForTypeofValue(left_unary->expression()); 3934 VisitForTypeofValue(left_unary->expression());
3935 } 3935 }
3936 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 3936 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
3937 3937
3938 if (check->Equals(Heap::number_symbol())) { 3938 if (check->Equals(Heap::number_symbol())) {
3939 __ test(eax, Immediate(kSmiTagMask)); 3939 __ JumpIfSmi(eax, if_true);
3940 __ j(zero, if_true);
3941 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), 3940 __ cmp(FieldOperand(eax, HeapObject::kMapOffset),
3942 Factory::heap_number_map()); 3941 Factory::heap_number_map());
3943 Split(equal, if_true, if_false, fall_through); 3942 Split(equal, if_true, if_false, fall_through);
3944 } else if (check->Equals(Heap::string_symbol())) { 3943 } else if (check->Equals(Heap::string_symbol())) {
3945 __ test(eax, Immediate(kSmiTagMask)); 3944 __ JumpIfSmi(eax, if_false);
3946 __ j(zero, if_false); 3945 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx);
3946 __ j(above_equal, if_false);
3947 // Check for undetectable objects => false. 3947 // Check for undetectable objects => false.
3948 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); 3948 __ test_b(FieldOperand(edx, Map::kBitFieldOffset),
3949 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); 3949 1 << Map::kIsUndetectable);
3950 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); 3950 Split(zero, if_true, if_false, fall_through);
3951 __ j(not_zero, if_false);
3952 __ CmpInstanceType(edx, FIRST_NONSTRING_TYPE);
3953 Split(below, if_true, if_false, fall_through);
3954 } else if (check->Equals(Heap::boolean_symbol())) { 3951 } else if (check->Equals(Heap::boolean_symbol())) {
3955 __ cmp(eax, Factory::true_value()); 3952 __ cmp(eax, Factory::true_value());
3956 __ j(equal, if_true); 3953 __ j(equal, if_true);
3957 __ cmp(eax, Factory::false_value()); 3954 __ cmp(eax, Factory::false_value());
3958 Split(equal, if_true, if_false, fall_through); 3955 Split(equal, if_true, if_false, fall_through);
3959 } else if (check->Equals(Heap::undefined_symbol())) { 3956 } else if (check->Equals(Heap::undefined_symbol())) {
3960 __ cmp(eax, Factory::undefined_value()); 3957 __ cmp(eax, Factory::undefined_value());
3961 __ j(equal, if_true); 3958 __ j(equal, if_true);
3962 __ test(eax, Immediate(kSmiTagMask)); 3959 __ JumpIfSmi(eax, if_false);
3963 __ j(zero, if_false);
3964 // Check for undetectable objects => true. 3960 // Check for undetectable objects => true.
3965 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); 3961 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset));
3966 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); 3962 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset));
3967 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); 3963 __ test(ecx, Immediate(1 << Map::kIsUndetectable));
3968 Split(not_zero, if_true, if_false, fall_through); 3964 Split(not_zero, if_true, if_false, fall_through);
3969 } else if (check->Equals(Heap::function_symbol())) { 3965 } else if (check->Equals(Heap::function_symbol())) {
3970 __ test(eax, Immediate(kSmiTagMask)); 3966 __ JumpIfSmi(eax, if_false);
3971 __ j(zero, if_false); 3967 __ CmpObjectType(eax, FIRST_FUNCTION_CLASS_TYPE, edx);
3972 __ CmpObjectType(eax, JS_FUNCTION_TYPE, edx); 3968 Split(above_equal, if_true, if_false, fall_through);
3973 __ j(equal, if_true);
3974 // Regular expressions => 'function' (they are callable).
3975 __ CmpInstanceType(edx, JS_REGEXP_TYPE);
3976 Split(equal, if_true, if_false, fall_through);
3977 } else if (check->Equals(Heap::object_symbol())) { 3969 } else if (check->Equals(Heap::object_symbol())) {
3978 __ test(eax, Immediate(kSmiTagMask)); 3970 __ JumpIfSmi(eax, if_false);
3979 __ j(zero, if_false);
3980 __ cmp(eax, Factory::null_value()); 3971 __ cmp(eax, Factory::null_value());
3981 __ j(equal, if_true); 3972 __ j(equal, if_true);
3982 // Regular expressions => 'function', not 'object'. 3973 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, edx);
3983 __ CmpObjectType(eax, JS_REGEXP_TYPE, edx); 3974 __ j(below, if_false);
3984 __ j(equal, if_false); 3975 __ CmpInstanceType(edx, FIRST_FUNCTION_CLASS_TYPE);
3976 __ j(above_equal, if_false);
3985 // Check for undetectable objects => false. 3977 // Check for undetectable objects => false.
3986 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); 3978 __ test_b(FieldOperand(edx, Map::kBitFieldOffset),
3987 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); 3979 1 << Map::kIsUndetectable);
3988 __ j(not_zero, if_false); 3980 Split(zero, if_true, if_false, fall_through);
3989 // Check for JS objects => true.
3990 __ movzx_b(ecx, FieldOperand(edx, Map::kInstanceTypeOffset));
3991 __ cmp(ecx, FIRST_JS_OBJECT_TYPE);
3992 __ j(less, if_false);
3993 __ cmp(ecx, LAST_JS_OBJECT_TYPE);
3994 Split(less_equal, if_true, if_false, fall_through);
3995 } else { 3981 } else {
3996 if (if_false != fall_through) __ jmp(if_false); 3982 if (if_false != fall_through) __ jmp(if_false);
3997 } 3983 }
3998 3984
3999 return true; 3985 return true;
4000 } 3986 }
4001 3987
4002 3988
4003 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { 3989 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
4004 Comment cmnt(masm_, "[ CompareOperation"); 3990 Comment cmnt(masm_, "[ CompareOperation");
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
4269 // And return. 4255 // And return.
4270 __ ret(0); 4256 __ ret(0);
4271 } 4257 }
4272 4258
4273 4259
4274 #undef __ 4260 #undef __
4275 4261
4276 } } // namespace v8::internal 4262 } } // namespace v8::internal
4277 4263
4278 #endif // V8_TARGET_ARCH_IA32 4264 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698