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

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

Issue 6665006: Reduce strength of ModI for power-of-2 divisor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: port to arm and x64 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-arm.cc ('k') | src/hydrogen-instructions.h » ('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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 789 }
790 } 790 }
791 791
792 792
793 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { 793 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) {
794 // Nothing to do. 794 // Nothing to do.
795 } 795 }
796 796
797 797
798 void LCodeGen::DoModI(LModI* instr) { 798 void LCodeGen::DoModI(LModI* instr) {
799 if (HMod::cast(instr->hydrogen())->HasPowerOf2Divisor()) {
Kevin Millikin (Chromium) 2011/03/14 14:35:07 The HMod::cast should not be necessary here (and j
800 Register dividend = ToRegister(instr->InputAt(0));
801
802 int32_t divisor =
803 HConstant::cast(
804 HMod::cast(instr->hydrogen())->right())->Integer32Value();
805
806 if (divisor < 0) divisor = -divisor;
807
808 Label positive_dividend, done;
809 __ tst(dividend, Operand(dividend));
810 __ b(pl, &positive_dividend);
811 __ rsb(dividend, dividend, Operand(0));
812 __ and_(dividend, dividend, Operand(divisor - 1));
813 __ rsb(dividend, dividend, Operand(0), SetCC);
814 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
815 __ b(ne, &done);
816 DeoptimizeIf(al, instr->environment());
817 }
818 __ bind(&positive_dividend);
819 __ and_(dividend, dividend, Operand(divisor - 1));
820 __ bind(&done);
821 return;
822 }
823
799 class DeferredModI: public LDeferredCode { 824 class DeferredModI: public LDeferredCode {
800 public: 825 public:
801 DeferredModI(LCodeGen* codegen, LModI* instr) 826 DeferredModI(LCodeGen* codegen, LModI* instr)
802 : LDeferredCode(codegen), instr_(instr) { } 827 : LDeferredCode(codegen), instr_(instr) { }
803 virtual void Generate() { 828 virtual void Generate() {
804 codegen()->DoDeferredBinaryOpStub(instr_, Token::MOD); 829 codegen()->DoDeferredBinaryOpStub(instr_, Token::MOD);
805 } 830 }
806 private: 831 private:
807 LModI* instr_; 832 LModI* instr_;
808 }; 833 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 __ b(lt, &done); 874 __ b(lt, &done);
850 // If not, reduce the left hand side by the right hand 875 // If not, reduce the left hand side by the right hand
851 // side and check again. 876 // side and check again.
852 if (i < kUnfolds - 1) __ sub(scratch, scratch, right); 877 if (i < kUnfolds - 1) __ sub(scratch, scratch, right);
853 } 878 }
854 879
855 // Check for power of two on the right hand side. 880 // Check for power of two on the right hand side.
856 __ JumpIfNotPowerOfTwoOrZero(right, scratch, &call_stub); 881 __ JumpIfNotPowerOfTwoOrZero(right, scratch, &call_stub);
857 // Perform modulo operation (scratch contains right - 1). 882 // Perform modulo operation (scratch contains right - 1).
858 __ and_(result, scratch, Operand(left)); 883 __ and_(result, scratch, Operand(left));
884 __ b(&done);
859 885
860 __ bind(&call_stub); 886 __ bind(&call_stub);
861 // Call the stub. The numbers in r0 and r1 have 887 // Call the stub. The numbers in r0 and r1 have
862 // to be tagged to Smis. If that is not possible, deoptimize. 888 // to be tagged to Smis. If that is not possible, deoptimize.
863 DeferredModI* deferred = new DeferredModI(this, instr); 889 DeferredModI* deferred = new DeferredModI(this, instr);
864 __ TrySmiTag(left, &deoptimize, scratch); 890 __ TrySmiTag(left, &deoptimize, scratch);
865 __ TrySmiTag(right, &deoptimize, scratch); 891 __ TrySmiTag(right, &deoptimize, scratch);
866 892
867 __ b(al, deferred->entry()); 893 __ b(al, deferred->entry());
868 __ bind(deferred->exit()); 894 __ bind(deferred->exit());
(...skipping 3008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 ASSERT(!environment->HasBeenRegistered()); 3903 ASSERT(!environment->HasBeenRegistered());
3878 RegisterEnvironmentForDeoptimization(environment); 3904 RegisterEnvironmentForDeoptimization(environment);
3879 ASSERT(osr_pc_offset_ == -1); 3905 ASSERT(osr_pc_offset_ == -1);
3880 osr_pc_offset_ = masm()->pc_offset(); 3906 osr_pc_offset_ = masm()->pc_offset();
3881 } 3907 }
3882 3908
3883 3909
3884 #undef __ 3910 #undef __
3885 3911
3886 } } // namespace v8::internal 3912 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698