OLD | NEW |
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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1032 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1033 Label ok; | 1033 Label ok; |
1034 __ tst(left, Operand(left)); | 1034 __ tst(left, Operand(left)); |
1035 __ b(ne, &ok); | 1035 __ b(ne, &ok); |
1036 __ tst(right, Operand(right)); | 1036 __ tst(right, Operand(right)); |
1037 __ b(pl, &ok); | 1037 __ b(pl, &ok); |
1038 __ b(al, &deoptimize); | 1038 __ b(al, &deoptimize); |
1039 __ bind(&ok); | 1039 __ bind(&ok); |
1040 } | 1040 } |
1041 | 1041 |
| 1042 // Try a few common cases before using the generic stub. |
| 1043 Label call_stub; |
| 1044 const int kUnfolds = 3; |
| 1045 // Skip if either side is negative. |
| 1046 __ cmp(left, Operand(0)); |
| 1047 __ cmp(right, Operand(0), NegateCondition(mi)); |
| 1048 __ b(mi, &call_stub); |
| 1049 // If the right hand side is smaller than the (nonnegative) |
| 1050 // left hand side, it is the result. Else try a few subtractions |
| 1051 // of the left hand side. |
| 1052 __ mov(scratch, left); |
| 1053 for (int i = 0; i < kUnfolds; i++) { |
| 1054 // Check if the left hand side is less or equal than the |
| 1055 // the right hand side. |
| 1056 __ cmp(scratch, right); |
| 1057 __ mov(result, scratch, LeaveCC, lt); |
| 1058 __ b(lt, &done); |
| 1059 // If not, reduce the left hand side by the right hand |
| 1060 // side and check again. |
| 1061 if (i < kUnfolds - 1) __ sub(scratch, scratch, right); |
| 1062 } |
| 1063 |
| 1064 // Check for power of two on the right hand side. |
| 1065 __ sub(scratch, right, Operand(1), SetCC); |
| 1066 __ b(mi, &call_stub); |
| 1067 __ tst(scratch, right); |
| 1068 __ b(ne, &call_stub); |
| 1069 // Perform modulo operation. |
| 1070 __ and_(result, scratch, Operand(left)); |
| 1071 |
| 1072 __ bind(&call_stub); |
1042 // Call the generic stub. The numbers in r0 and r1 have | 1073 // Call the generic stub. The numbers in r0 and r1 have |
1043 // to be tagged to Smis. If that is not possible, deoptimize. | 1074 // to be tagged to Smis. If that is not possible, deoptimize. |
1044 DeferredModI* deferred = new DeferredModI(this, instr); | 1075 DeferredModI* deferred = new DeferredModI(this, instr); |
1045 __ TrySmiTag(left, &deoptimize, scratch); | 1076 __ TrySmiTag(left, &deoptimize, scratch); |
1046 __ TrySmiTag(right, &deoptimize, scratch); | 1077 __ TrySmiTag(right, &deoptimize, scratch); |
1047 | 1078 |
1048 __ b(al, deferred->entry()); | 1079 __ b(al, deferred->entry()); |
1049 __ bind(deferred->exit()); | 1080 __ bind(deferred->exit()); |
1050 | 1081 |
1051 // If the result in r0 is a Smi, untag it, else deoptimize. | 1082 // If the result in r0 is a Smi, untag it, else deoptimize. |
1052 __ BranchOnNotSmi(result, &deoptimize); | 1083 __ BranchOnNotSmi(result, &deoptimize); |
1053 __ mov(result, Operand(result, ASR, 1)); | 1084 __ SmiUntag(result); |
1054 | 1085 |
1055 __ b(al, &done); | 1086 __ b(al, &done); |
1056 __ bind(&deoptimize); | 1087 __ bind(&deoptimize); |
1057 DeoptimizeIf(al, instr->environment()); | 1088 DeoptimizeIf(al, instr->environment()); |
1058 __ bind(&done); | 1089 __ bind(&done); |
1059 } | 1090 } |
1060 | 1091 |
1061 | 1092 |
1062 void LCodeGen::DoDivI(LDivI* instr) { | 1093 void LCodeGen::DoDivI(LDivI* instr) { |
1063 class DeferredDivI: public LDeferredCode { | 1094 class DeferredDivI: public LDeferredCode { |
(...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3364 | 3395 |
3365 | 3396 |
3366 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 3397 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
3367 Abort("DoOsrEntry unimplemented."); | 3398 Abort("DoOsrEntry unimplemented."); |
3368 } | 3399 } |
3369 | 3400 |
3370 | 3401 |
3371 #undef __ | 3402 #undef __ |
3372 | 3403 |
3373 } } // namespace v8::internal | 3404 } } // namespace v8::internal |
OLD | NEW |