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

Side by Side Diff: src/ia32/lithium-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/ia32/full-codegen-ia32.cc ('k') | src/x64/full-codegen-x64.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 3684 matching lines...) Expand 10 before | Expand all | Expand 10 after
3695 EmitBranch(true_block, false_block, final_branch_condition); 3695 EmitBranch(true_block, false_block, final_branch_condition);
3696 } 3696 }
3697 3697
3698 3698
3699 Condition LCodeGen::EmitTypeofIs(Label* true_label, 3699 Condition LCodeGen::EmitTypeofIs(Label* true_label,
3700 Label* false_label, 3700 Label* false_label,
3701 Register input, 3701 Register input,
3702 Handle<String> type_name) { 3702 Handle<String> type_name) {
3703 Condition final_branch_condition = no_condition; 3703 Condition final_branch_condition = no_condition;
3704 if (type_name->Equals(Heap::number_symbol())) { 3704 if (type_name->Equals(Heap::number_symbol())) {
3705 __ test(input, Immediate(kSmiTagMask)); 3705 __ JumpIfSmi(input, true_label);
3706 __ j(zero, true_label);
3707 __ cmp(FieldOperand(input, HeapObject::kMapOffset), 3706 __ cmp(FieldOperand(input, HeapObject::kMapOffset),
3708 Factory::heap_number_map()); 3707 Factory::heap_number_map());
3709 final_branch_condition = equal; 3708 final_branch_condition = equal;
3710 3709
3711 } else if (type_name->Equals(Heap::string_symbol())) { 3710 } else if (type_name->Equals(Heap::string_symbol())) {
3712 __ test(input, Immediate(kSmiTagMask)); 3711 __ JumpIfSmi(input, false_label);
3713 __ j(zero, false_label); 3712 __ CmpObjectType(input, FIRST_NONSTRING_TYPE, input);
3714 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); 3713 __ j(above_equal, false_label);
3715 __ test_b(FieldOperand(input, Map::kBitFieldOffset), 3714 __ test_b(FieldOperand(input, Map::kBitFieldOffset),
3716 1 << Map::kIsUndetectable); 3715 1 << Map::kIsUndetectable);
3717 __ j(not_zero, false_label); 3716 final_branch_condition = zero;
3718 __ CmpInstanceType(input, FIRST_NONSTRING_TYPE);
3719 final_branch_condition = below;
3720 3717
3721 } else if (type_name->Equals(Heap::boolean_symbol())) { 3718 } else if (type_name->Equals(Heap::boolean_symbol())) {
3722 __ cmp(input, Factory::true_value()); 3719 __ cmp(input, Factory::true_value());
3723 __ j(equal, true_label); 3720 __ j(equal, true_label);
3724 __ cmp(input, Factory::false_value()); 3721 __ cmp(input, Factory::false_value());
3725 final_branch_condition = equal; 3722 final_branch_condition = equal;
3726 3723
3727 } else if (type_name->Equals(Heap::undefined_symbol())) { 3724 } else if (type_name->Equals(Heap::undefined_symbol())) {
3728 __ cmp(input, Factory::undefined_value()); 3725 __ cmp(input, Factory::undefined_value());
3729 __ j(equal, true_label); 3726 __ j(equal, true_label);
3730 __ test(input, Immediate(kSmiTagMask)); 3727 __ JumpIfSmi(input, false_label);
3731 __ j(zero, false_label);
3732 // Check for undetectable objects => true. 3728 // Check for undetectable objects => true.
3733 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); 3729 __ mov(input, FieldOperand(input, HeapObject::kMapOffset));
3734 __ test_b(FieldOperand(input, Map::kBitFieldOffset), 3730 __ test_b(FieldOperand(input, Map::kBitFieldOffset),
3735 1 << Map::kIsUndetectable); 3731 1 << Map::kIsUndetectable);
3736 final_branch_condition = not_zero; 3732 final_branch_condition = not_zero;
3737 3733
3738 } else if (type_name->Equals(Heap::function_symbol())) { 3734 } else if (type_name->Equals(Heap::function_symbol())) {
3739 __ test(input, Immediate(kSmiTagMask)); 3735 __ JumpIfSmi(input, false_label);
3740 __ j(zero, false_label);
3741 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); 3736 __ CmpObjectType(input, JS_FUNCTION_TYPE, input);
3742 __ j(equal, true_label); 3737 __ j(equal, true_label);
3743 // Regular expressions => 'function' (they are callable). 3738 // Regular expressions => 'function' (they are callable).
3744 __ CmpInstanceType(input, JS_REGEXP_TYPE); 3739 __ CmpInstanceType(input, JS_REGEXP_TYPE);
3745 final_branch_condition = equal; 3740 final_branch_condition = equal;
3746 3741
3747 } else if (type_name->Equals(Heap::object_symbol())) { 3742 } else if (type_name->Equals(Heap::object_symbol())) {
3748 __ test(input, Immediate(kSmiTagMask)); 3743 __ JumpIfSmi(input, false_label);
3749 __ j(zero, false_label);
3750 __ cmp(input, Factory::null_value()); 3744 __ cmp(input, Factory::null_value());
3751 __ j(equal, true_label); 3745 __ j(equal, true_label);
3752 // Regular expressions => 'function', not 'object'. 3746 // Regular expressions => 'function', not 'object'.
3753 __ CmpObjectType(input, JS_REGEXP_TYPE, input); 3747 __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, input);
3754 __ j(equal, false_label); 3748 __ j(below, false_label);
3749 __ CmpInstanceType(input, FIRST_FUNCTION_CLASS_TYPE);
3750 __ j(above_equal, false_label);
3755 // Check for undetectable objects => false. 3751 // Check for undetectable objects => false.
3756 __ test_b(FieldOperand(input, Map::kBitFieldOffset), 3752 __ test_b(FieldOperand(input, Map::kBitFieldOffset),
3757 1 << Map::kIsUndetectable); 3753 1 << Map::kIsUndetectable);
3758 __ j(not_zero, false_label); 3754 final_branch_condition = zero;
3759 // Check for JS objects => true.
3760 __ CmpInstanceType(input, FIRST_JS_OBJECT_TYPE);
3761 __ j(below, false_label);
3762 __ CmpInstanceType(input, LAST_JS_OBJECT_TYPE);
3763 final_branch_condition = below_equal;
3764 3755
3765 } else { 3756 } else {
3766 final_branch_condition = not_equal; 3757 final_branch_condition = not_equal;
3767 __ jmp(false_label); 3758 __ jmp(false_label);
3768 // A dead branch instruction will be generated after this point. 3759 // A dead branch instruction will be generated after this point.
3769 } 3760 }
3770 3761
3771 return final_branch_condition; 3762 return final_branch_condition;
3772 } 3763 }
3773 3764
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
3885 ASSERT(osr_pc_offset_ == -1); 3876 ASSERT(osr_pc_offset_ == -1);
3886 osr_pc_offset_ = masm()->pc_offset(); 3877 osr_pc_offset_ = masm()->pc_offset();
3887 } 3878 }
3888 3879
3889 3880
3890 #undef __ 3881 #undef __
3891 3882
3892 } } // namespace v8::internal 3883 } } // namespace v8::internal
3893 3884
3894 #endif // V8_TARGET_ARCH_IA32 3885 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698