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

Side by Side Diff: src/arm/codegen-arm.cc

Issue 2808039: Simplify ToBoolean if we know we have a Smi. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } 741 }
742 742
743 743
744 // ECMA-262, section 9.2, page 30: ToBoolean(). Convert the given 744 // ECMA-262, section 9.2, page 30: ToBoolean(). Convert the given
745 // register to a boolean in the condition code register. The code 745 // register to a boolean in the condition code register. The code
746 // may jump to 'false_target' in case the register converts to 'false'. 746 // may jump to 'false_target' in case the register converts to 'false'.
747 void CodeGenerator::ToBoolean(JumpTarget* true_target, 747 void CodeGenerator::ToBoolean(JumpTarget* true_target,
748 JumpTarget* false_target) { 748 JumpTarget* false_target) {
749 // Note: The generated code snippet does not change stack variables. 749 // Note: The generated code snippet does not change stack variables.
750 // Only the condition code should be set. 750 // Only the condition code should be set.
751 bool known_smi = frame_->KnownSmiAt(0);
751 Register tos = frame_->PopToRegister(); 752 Register tos = frame_->PopToRegister();
752 753
753 // Fast case checks 754 // Fast case checks
754 755
755 // Check if the value is 'false'. 756 // Check if the value is 'false'.
756 __ LoadRoot(ip, Heap::kFalseValueRootIndex); 757 if (!known_smi) {
757 __ cmp(tos, ip); 758 __ LoadRoot(ip, Heap::kFalseValueRootIndex);
758 false_target->Branch(eq); 759 __ cmp(tos, ip);
760 false_target->Branch(eq);
759 761
760 // Check if the value is 'true'. 762 // Check if the value is 'true'.
761 __ LoadRoot(ip, Heap::kTrueValueRootIndex); 763 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
762 __ cmp(tos, ip); 764 __ cmp(tos, ip);
763 true_target->Branch(eq); 765 true_target->Branch(eq);
764 766
765 // Check if the value is 'undefined'. 767 // Check if the value is 'undefined'.
766 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 768 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
767 __ cmp(tos, ip); 769 __ cmp(tos, ip);
768 false_target->Branch(eq); 770 false_target->Branch(eq);
771 }
769 772
770 // Check if the value is a smi. 773 // Check if the value is a smi.
771 __ cmp(tos, Operand(Smi::FromInt(0))); 774 __ cmp(tos, Operand(Smi::FromInt(0)));
772 false_target->Branch(eq);
773 __ tst(tos, Operand(kSmiTagMask));
774 true_target->Branch(eq);
775 775
776 // Slow case: call the runtime. 776 if (!known_smi) {
777 frame_->EmitPush(tos); 777 false_target->Branch(eq);
778 frame_->CallRuntime(Runtime::kToBool, 1); 778 __ tst(tos, Operand(kSmiTagMask));
779 // Convert the result (r0) to a condition code. 779 true_target->Branch(eq);
780 __ LoadRoot(ip, Heap::kFalseValueRootIndex); 780
781 __ cmp(r0, ip); 781 // Slow case: call the runtime.
782 frame_->EmitPush(tos);
783 frame_->CallRuntime(Runtime::kToBool, 1);
784 // Convert the result (r0) to a condition code.
785 __ LoadRoot(ip, Heap::kFalseValueRootIndex);
786 __ cmp(r0, ip);
787 }
782 788
783 cc_reg_ = ne; 789 cc_reg_ = ne;
784 } 790 }
785 791
786 792
787 void CodeGenerator::GenericBinaryOperation(Token::Value op, 793 void CodeGenerator::GenericBinaryOperation(Token::Value op,
788 OverwriteMode overwrite_mode, 794 OverwriteMode overwrite_mode,
789 GenerateInlineSmi inline_smi, 795 GenerateInlineSmi inline_smi,
790 int constant_rhs) { 796 int constant_rhs) {
791 // top of virtual frame: y 797 // top of virtual frame: y
(...skipping 10374 matching lines...) Expand 10 before | Expand all | Expand 10 after
11166 __ bind(&string_add_runtime); 11172 __ bind(&string_add_runtime);
11167 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 11173 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
11168 } 11174 }
11169 11175
11170 11176
11171 #undef __ 11177 #undef __
11172 11178
11173 } } // namespace v8::internal 11179 } } // namespace v8::internal
11174 11180
11175 #endif // V8_TARGET_ARCH_ARM 11181 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698