OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arm64/lithium-codegen-arm64.h" | 7 #include "src/arm64/lithium-codegen-arm64.h" |
8 #include "src/arm64/lithium-gap-resolver-arm64.h" | 8 #include "src/arm64/lithium-gap-resolver-arm64.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/stub-cache.h" | 10 #include "src/stub-cache.h" |
(...skipping 3915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3926 __ Mov(result, Operand(dividend, ASR, shift)); | 3926 __ Mov(result, Operand(dividend, ASR, shift)); |
3927 return; | 3927 return; |
3928 } | 3928 } |
3929 | 3929 |
3930 // If the divisor is negative, we have to negate and handle edge cases. | 3930 // If the divisor is negative, we have to negate and handle edge cases. |
3931 __ Negs(result, dividend); | 3931 __ Negs(result, dividend); |
3932 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3932 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3933 DeoptimizeIf(eq, instr->environment()); | 3933 DeoptimizeIf(eq, instr->environment()); |
3934 } | 3934 } |
3935 | 3935 |
| 3936 // Dividing by -1 is basically negation, unless we overflow. |
| 3937 if (divisor == -1) { |
| 3938 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
| 3939 DeoptimizeIf(vs, instr->environment()); |
| 3940 } |
| 3941 return; |
| 3942 } |
| 3943 |
3936 // If the negation could not overflow, simply shifting is OK. | 3944 // If the negation could not overflow, simply shifting is OK. |
3937 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { | 3945 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
3938 __ Mov(result, Operand(dividend, ASR, shift)); | 3946 __ Mov(result, Operand(dividend, ASR, shift)); |
3939 return; | 3947 return; |
3940 } | 3948 } |
3941 | 3949 |
3942 // Dividing by -1 is basically negation, unless we overflow. | 3950 __ Asr(result, result, shift); |
3943 if (divisor == -1) { | |
3944 DeoptimizeIf(vs, instr->environment()); | |
3945 return; | |
3946 } | |
3947 | |
3948 __ Asr(result, dividend, shift); | |
3949 __ Csel(result, result, kMinInt / divisor, vc); | 3951 __ Csel(result, result, kMinInt / divisor, vc); |
3950 } | 3952 } |
3951 | 3953 |
3952 | 3954 |
3953 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { | 3955 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { |
3954 Register dividend = ToRegister32(instr->dividend()); | 3956 Register dividend = ToRegister32(instr->dividend()); |
3955 int32_t divisor = instr->divisor(); | 3957 int32_t divisor = instr->divisor(); |
3956 Register result = ToRegister32(instr->result()); | 3958 Register result = ToRegister32(instr->result()); |
3957 ASSERT(!AreAliased(dividend, result)); | 3959 ASSERT(!AreAliased(dividend, result)); |
3958 | 3960 |
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6050 Handle<ScopeInfo> scope_info = instr->scope_info(); | 6052 Handle<ScopeInfo> scope_info = instr->scope_info(); |
6051 __ Push(scope_info); | 6053 __ Push(scope_info); |
6052 __ Push(ToRegister(instr->function())); | 6054 __ Push(ToRegister(instr->function())); |
6053 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); | 6055 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); |
6054 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6056 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6055 } | 6057 } |
6056 | 6058 |
6057 | 6059 |
6058 | 6060 |
6059 } } // namespace v8::internal | 6061 } } // namespace v8::internal |
OLD | NEW |