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 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
| 9 #include "src/base/bits.h" |
9 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
10 #include "src/hydrogen-osr.h" | 11 #include "src/hydrogen-osr.h" |
11 #include "src/x64/lithium-codegen-x64.h" | 12 #include "src/x64/lithium-codegen-x64.h" |
12 | 13 |
13 namespace v8 { | 14 namespace v8 { |
14 namespace internal { | 15 namespace internal { |
15 | 16 |
16 | 17 |
17 // When invoking builtins, we need to record the safepoint in the middle of | 18 // When invoking builtins, we need to record the safepoint in the middle of |
18 // the invoke instruction sequence generated by the macro assembler. | 19 // the invoke instruction sequence generated by the macro assembler. |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 __ sarl(remainder, Immediate(31)); | 1267 __ sarl(remainder, Immediate(31)); |
1267 __ addl(result, remainder); | 1268 __ addl(result, remainder); |
1268 __ bind(&done); | 1269 __ bind(&done); |
1269 } | 1270 } |
1270 | 1271 |
1271 | 1272 |
1272 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { | 1273 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { |
1273 Register dividend = ToRegister(instr->dividend()); | 1274 Register dividend = ToRegister(instr->dividend()); |
1274 int32_t divisor = instr->divisor(); | 1275 int32_t divisor = instr->divisor(); |
1275 Register result = ToRegister(instr->result()); | 1276 Register result = ToRegister(instr->result()); |
1276 DCHECK(divisor == kMinInt || IsPowerOf2(Abs(divisor))); | 1277 DCHECK(divisor == kMinInt || base::bits::IsPowerOfTwo32(Abs(divisor))); |
1277 DCHECK(!result.is(dividend)); | 1278 DCHECK(!result.is(dividend)); |
1278 | 1279 |
1279 // Check for (0 / -x) that will produce negative zero. | 1280 // Check for (0 / -x) that will produce negative zero. |
1280 HDiv* hdiv = instr->hydrogen(); | 1281 HDiv* hdiv = instr->hydrogen(); |
1281 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1282 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { |
1282 __ testl(dividend, dividend); | 1283 __ testl(dividend, dividend); |
1283 DeoptimizeIf(zero, instr->environment()); | 1284 DeoptimizeIf(zero, instr->environment()); |
1284 } | 1285 } |
1285 // Check for (kMinInt / -1). | 1286 // Check for (kMinInt / -1). |
1286 if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) { | 1287 if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) { |
(...skipping 3801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5088 __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), | 5089 __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), |
5089 Immediate(static_cast<int8_t>(last))); | 5090 Immediate(static_cast<int8_t>(last))); |
5090 DeoptimizeIf(above, instr->environment()); | 5091 DeoptimizeIf(above, instr->environment()); |
5091 } | 5092 } |
5092 } | 5093 } |
5093 } else { | 5094 } else { |
5094 uint8_t mask; | 5095 uint8_t mask; |
5095 uint8_t tag; | 5096 uint8_t tag; |
5096 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag); | 5097 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag); |
5097 | 5098 |
5098 if (IsPowerOf2(mask)) { | 5099 if (base::bits::IsPowerOfTwo32(mask)) { |
5099 DCHECK(tag == 0 || IsPowerOf2(tag)); | 5100 DCHECK(tag == 0 || base::bits::IsPowerOfTwo32(tag)); |
5100 __ testb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), | 5101 __ testb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), |
5101 Immediate(mask)); | 5102 Immediate(mask)); |
5102 DeoptimizeIf(tag == 0 ? not_zero : zero, instr->environment()); | 5103 DeoptimizeIf(tag == 0 ? not_zero : zero, instr->environment()); |
5103 } else { | 5104 } else { |
5104 __ movzxbl(kScratchRegister, | 5105 __ movzxbl(kScratchRegister, |
5105 FieldOperand(kScratchRegister, Map::kInstanceTypeOffset)); | 5106 FieldOperand(kScratchRegister, Map::kInstanceTypeOffset)); |
5106 __ andb(kScratchRegister, Immediate(mask)); | 5107 __ andb(kScratchRegister, Immediate(mask)); |
5107 __ cmpb(kScratchRegister, Immediate(tag)); | 5108 __ cmpb(kScratchRegister, Immediate(tag)); |
5108 DeoptimizeIf(not_equal, instr->environment()); | 5109 DeoptimizeIf(not_equal, instr->environment()); |
5109 } | 5110 } |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5850 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5851 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5851 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5852 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5852 } | 5853 } |
5853 | 5854 |
5854 | 5855 |
5855 #undef __ | 5856 #undef __ |
5856 | 5857 |
5857 } } // namespace v8::internal | 5858 } } // namespace v8::internal |
5858 | 5859 |
5859 #endif // V8_TARGET_ARCH_X64 | 5860 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |