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

Side by Side Diff: src/arm/full-codegen-arm.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 | « no previous file | src/arm/lithium-codegen-arm.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 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 UnaryOperation* left_unary = left->AsUnaryOperation(); 3970 UnaryOperation* left_unary = left->AsUnaryOperation();
3971 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; 3971 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
3972 Handle<String> check = Handle<String>::cast(right_literal_value); 3972 Handle<String> check = Handle<String>::cast(right_literal_value);
3973 3973
3974 { AccumulatorValueContext context(this); 3974 { AccumulatorValueContext context(this);
3975 VisitForTypeofValue(left_unary->expression()); 3975 VisitForTypeofValue(left_unary->expression());
3976 } 3976 }
3977 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 3977 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
3978 3978
3979 if (check->Equals(Heap::number_symbol())) { 3979 if (check->Equals(Heap::number_symbol())) {
3980 __ tst(r0, Operand(kSmiTagMask)); 3980 __ JumpIfSmi(r0, if_true);
3981 __ b(eq, if_true);
3982 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); 3981 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset));
3983 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); 3982 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
3984 __ cmp(r0, ip); 3983 __ cmp(r0, ip);
3985 Split(eq, if_true, if_false, fall_through); 3984 Split(eq, if_true, if_false, fall_through);
3986 } else if (check->Equals(Heap::string_symbol())) { 3985 } else if (check->Equals(Heap::string_symbol())) {
3987 __ tst(r0, Operand(kSmiTagMask)); 3986 __ JumpIfSmi(r0, if_false);
3988 __ b(eq, if_false);
3989 // Check for undetectable objects => false. 3987 // Check for undetectable objects => false.
3990 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); 3988 __ CompareObjectType(r0, r0, r1, FIRST_NONSTRING_TYPE);
3989 __ b(ge, if_false);
3991 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); 3990 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset));
3992 __ and_(r1, r1, Operand(1 << Map::kIsUndetectable)); 3991 __ tst(r1, Operand(1 << Map::kIsUndetectable));
3993 __ cmp(r1, Operand(1 << Map::kIsUndetectable)); 3992 Split(eq, if_true, if_false, fall_through);
3994 __ b(eq, if_false);
3995 __ ldrb(r1, FieldMemOperand(r0, Map::kInstanceTypeOffset));
3996 __ cmp(r1, Operand(FIRST_NONSTRING_TYPE));
3997 Split(lt, if_true, if_false, fall_through);
3998 } else if (check->Equals(Heap::boolean_symbol())) { 3993 } else if (check->Equals(Heap::boolean_symbol())) {
3999 __ LoadRoot(ip, Heap::kTrueValueRootIndex); 3994 __ CompareRoot(r0, Heap::kTrueValueRootIndex);
4000 __ cmp(r0, ip);
4001 __ b(eq, if_true); 3995 __ b(eq, if_true);
4002 __ LoadRoot(ip, Heap::kFalseValueRootIndex); 3996 __ CompareRoot(r0, Heap::kFalseValueRootIndex);
4003 __ cmp(r0, ip);
4004 Split(eq, if_true, if_false, fall_through); 3997 Split(eq, if_true, if_false, fall_through);
4005 } else if (check->Equals(Heap::undefined_symbol())) { 3998 } else if (check->Equals(Heap::undefined_symbol())) {
4006 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 3999 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex);
4007 __ cmp(r0, ip);
4008 __ b(eq, if_true); 4000 __ b(eq, if_true);
4009 __ tst(r0, Operand(kSmiTagMask)); 4001 __ JumpIfSmi(r0, if_false);
4010 __ b(eq, if_false);
4011 // Check for undetectable objects => true. 4002 // Check for undetectable objects => true.
4012 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); 4003 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset));
4013 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); 4004 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset));
4014 __ and_(r1, r1, Operand(1 << Map::kIsUndetectable)); 4005 __ tst(r1, Operand(1 << Map::kIsUndetectable));
4015 __ cmp(r1, Operand(1 << Map::kIsUndetectable)); 4006 Split(ne, if_true, if_false, fall_through);
4007
4008 } else if (check->Equals(Heap::function_symbol())) {
4009 __ JumpIfSmi(r0, if_false);
4010 __ CompareObjectType(r0, r1, r0, FIRST_FUNCTION_CLASS_TYPE);
4011 Split(ge, if_true, if_false, fall_through);
4012
4013 } else if (check->Equals(Heap::object_symbol())) {
4014 __ JumpIfSmi(r0, if_false);
4015 __ CompareRoot(r0, Heap::kNullValueRootIndex);
4016 __ b(eq, if_true);
4017 // Check for JS objects => true.
4018 __ CompareObjectType(r0, r0, r1, FIRST_JS_OBJECT_TYPE);
4019 __ b(lo, if_false);
4020 __ CompareInstanceType(r0, r1, FIRST_FUNCTION_CLASS_TYPE);
4021 __ b(hs, if_false);
4022 // Check for undetectable objects => false.
4023 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset));
4024 __ tst(r1, Operand(1 << Map::kIsUndetectable));
4016 Split(eq, if_true, if_false, fall_through); 4025 Split(eq, if_true, if_false, fall_through);
4017 } else if (check->Equals(Heap::function_symbol())) {
4018 __ tst(r0, Operand(kSmiTagMask));
4019 __ b(eq, if_false);
4020 __ CompareObjectType(r0, r1, r0, JS_FUNCTION_TYPE);
4021 __ b(eq, if_true);
4022 // Regular expressions => 'function' (they are callable).
4023 __ CompareInstanceType(r1, r0, JS_REGEXP_TYPE);
4024 Split(eq, if_true, if_false, fall_through);
4025 } else if (check->Equals(Heap::object_symbol())) {
4026 __ tst(r0, Operand(kSmiTagMask));
4027 __ b(eq, if_false);
4028 __ LoadRoot(ip, Heap::kNullValueRootIndex);
4029 __ cmp(r0, ip);
4030 __ b(eq, if_true);
4031 // Regular expressions => 'function', not 'object'.
4032 __ CompareObjectType(r0, r1, r0, JS_REGEXP_TYPE);
4033 __ b(eq, if_false);
4034 // Check for undetectable objects => false.
4035 __ ldrb(r0, FieldMemOperand(r1, Map::kBitFieldOffset));
4036 __ and_(r0, r0, Operand(1 << Map::kIsUndetectable));
4037 __ cmp(r0, Operand(1 << Map::kIsUndetectable));
4038 __ b(eq, if_false);
4039 // Check for JS objects => true.
4040 __ ldrb(r0, FieldMemOperand(r1, Map::kInstanceTypeOffset));
4041 __ cmp(r0, Operand(FIRST_JS_OBJECT_TYPE));
4042 __ b(lt, if_false);
4043 __ cmp(r0, Operand(LAST_JS_OBJECT_TYPE));
4044 Split(le, if_true, if_false, fall_through);
4045 } else { 4026 } else {
4046 if (if_false != fall_through) __ jmp(if_false); 4027 if (if_false != fall_through) __ jmp(if_false);
4047 } 4028 }
4048 4029
4049 return true; 4030 return true;
4050 } 4031 }
4051 4032
4052 4033
4053 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { 4034 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
4054 Comment cmnt(masm_, "[ CompareOperation"); 4035 Comment cmnt(masm_, "[ CompareOperation");
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4296 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. 4277 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
4297 __ add(pc, r1, Operand(masm_->CodeObject())); 4278 __ add(pc, r1, Operand(masm_->CodeObject()));
4298 } 4279 }
4299 4280
4300 4281
4301 #undef __ 4282 #undef __
4302 4283
4303 } } // namespace v8::internal 4284 } } // namespace v8::internal
4304 4285
4305 #endif // V8_TARGET_ARCH_ARM 4286 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698