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

Side by Side Diff: src/arm/lithium-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 | « src/arm/full-codegen-arm.cc ('k') | src/ia32/full-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 3654 matching lines...) Expand 10 before | Expand all | Expand 10 after
3665 } 3665 }
3666 3666
3667 3667
3668 Condition LCodeGen::EmitTypeofIs(Label* true_label, 3668 Condition LCodeGen::EmitTypeofIs(Label* true_label,
3669 Label* false_label, 3669 Label* false_label,
3670 Register input, 3670 Register input,
3671 Handle<String> type_name) { 3671 Handle<String> type_name) {
3672 Condition final_branch_condition = kNoCondition; 3672 Condition final_branch_condition = kNoCondition;
3673 Register scratch = scratch0(); 3673 Register scratch = scratch0();
3674 if (type_name->Equals(Heap::number_symbol())) { 3674 if (type_name->Equals(Heap::number_symbol())) {
3675 __ tst(input, Operand(kSmiTagMask)); 3675 __ JumpIfSmi(input, true_label);
3676 __ b(eq, true_label);
3677 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset)); 3676 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset));
3678 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); 3677 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
3679 __ cmp(input, Operand(ip)); 3678 __ cmp(input, Operand(ip));
3680 final_branch_condition = eq; 3679 final_branch_condition = eq;
3681 3680
3682 } else if (type_name->Equals(Heap::string_symbol())) { 3681 } else if (type_name->Equals(Heap::string_symbol())) {
3683 __ tst(input, Operand(kSmiTagMask)); 3682 __ JumpIfSmi(input, false_label);
3684 __ b(eq, false_label); 3683 __ CompareObjectType(input, input, scratch, FIRST_NONSTRING_TYPE);
3685 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset)); 3684 __ b(ge, false_label);
3686 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset)); 3685 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset));
3687 __ tst(ip, Operand(1 << Map::kIsUndetectable)); 3686 __ tst(ip, Operand(1 << Map::kIsUndetectable));
3688 __ b(ne, false_label); 3687 final_branch_condition = eq;
3689 __ CompareInstanceType(input, scratch, FIRST_NONSTRING_TYPE);
3690 final_branch_condition = lo;
3691 3688
3692 } else if (type_name->Equals(Heap::boolean_symbol())) { 3689 } else if (type_name->Equals(Heap::boolean_symbol())) {
3693 __ LoadRoot(ip, Heap::kTrueValueRootIndex); 3690 __ CompareRoot(input, Heap::kTrueValueRootIndex);
3694 __ cmp(input, ip);
3695 __ b(eq, true_label); 3691 __ b(eq, true_label);
3696 __ LoadRoot(ip, Heap::kFalseValueRootIndex); 3692 __ CompareRoot(input, Heap::kFalseValueRootIndex);
3697 __ cmp(input, ip);
3698 final_branch_condition = eq; 3693 final_branch_condition = eq;
3699 3694
3700 } else if (type_name->Equals(Heap::undefined_symbol())) { 3695 } else if (type_name->Equals(Heap::undefined_symbol())) {
3701 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 3696 __ CompareRoot(input, Heap::kUndefinedValueRootIndex);
3702 __ cmp(input, ip);
3703 __ b(eq, true_label); 3697 __ b(eq, true_label);
3704 __ tst(input, Operand(kSmiTagMask)); 3698 __ JumpIfSmi(input, false_label);
3705 __ b(eq, false_label);
3706 // Check for undetectable objects => true. 3699 // Check for undetectable objects => true.
3707 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset)); 3700 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset));
3708 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset)); 3701 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset));
3709 __ tst(ip, Operand(1 << Map::kIsUndetectable)); 3702 __ tst(ip, Operand(1 << Map::kIsUndetectable));
3710 final_branch_condition = ne; 3703 final_branch_condition = ne;
3711 3704
3712 } else if (type_name->Equals(Heap::function_symbol())) { 3705 } else if (type_name->Equals(Heap::function_symbol())) {
3713 __ tst(input, Operand(kSmiTagMask)); 3706 __ JumpIfSmi(input, false_label);
3714 __ b(eq, false_label); 3707 __ CompareObjectType(input, input, scratch, FIRST_FUNCTION_CLASS_TYPE);
3715 __ CompareObjectType(input, input, scratch, JS_FUNCTION_TYPE); 3708 final_branch_condition = ge;
3716 __ b(eq, true_label);
3717 // Regular expressions => 'function' (they are callable).
3718 __ CompareInstanceType(input, scratch, JS_REGEXP_TYPE);
3719 final_branch_condition = eq;
3720 3709
3721 } else if (type_name->Equals(Heap::object_symbol())) { 3710 } else if (type_name->Equals(Heap::object_symbol())) {
3722 __ tst(input, Operand(kSmiTagMask)); 3711 __ JumpIfSmi(input, false_label);
3723 __ b(eq, false_label); 3712 __ CompareRoot(input, Heap::kNullValueRootIndex);
3724 __ LoadRoot(ip, Heap::kNullValueRootIndex);
3725 __ cmp(input, ip);
3726 __ b(eq, true_label); 3713 __ b(eq, true_label);
3727 // Regular expressions => 'function', not 'object'. 3714 __ CompareObjectType(input, input, scratch, FIRST_JS_OBJECT_TYPE);
3728 __ CompareObjectType(input, input, scratch, JS_REGEXP_TYPE); 3715 __ b(lo, false_label);
3729 __ b(eq, false_label); 3716 __ CompareInstanceType(input, scratch, FIRST_FUNCTION_CLASS_TYPE);
3717 __ b(hs, false_label);
3730 // Check for undetectable objects => false. 3718 // Check for undetectable objects => false.
3731 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset)); 3719 __ ldrb(ip, FieldMemOperand(input, Map::kBitFieldOffset));
3732 __ tst(ip, Operand(1 << Map::kIsUndetectable)); 3720 __ tst(ip, Operand(1 << Map::kIsUndetectable));
3733 __ b(ne, false_label); 3721 final_branch_condition = eq;
3734 // Check for JS objects => true.
3735 __ CompareInstanceType(input, scratch, FIRST_JS_OBJECT_TYPE);
3736 __ b(lo, false_label);
3737 __ CompareInstanceType(input, scratch, LAST_JS_OBJECT_TYPE);
3738 final_branch_condition = ls;
3739 3722
3740 } else { 3723 } else {
3741 final_branch_condition = ne; 3724 final_branch_condition = ne;
3742 __ b(false_label); 3725 __ b(false_label);
3743 // A dead branch instruction will be generated after this point. 3726 // A dead branch instruction will be generated after this point.
3744 } 3727 }
3745 3728
3746 return final_branch_condition; 3729 return final_branch_condition;
3747 } 3730 }
3748 3731
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3850 ASSERT(!environment->HasBeenRegistered()); 3833 ASSERT(!environment->HasBeenRegistered());
3851 RegisterEnvironmentForDeoptimization(environment); 3834 RegisterEnvironmentForDeoptimization(environment);
3852 ASSERT(osr_pc_offset_ == -1); 3835 ASSERT(osr_pc_offset_ == -1);
3853 osr_pc_offset_ = masm()->pc_offset(); 3836 osr_pc_offset_ = masm()->pc_offset();
3854 } 3837 }
3855 3838
3856 3839
3857 #undef __ 3840 #undef __
3858 3841
3859 } } // namespace v8::internal 3842 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698