OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 } | 2265 } |
2266 | 2266 |
2267 | 2267 |
2268 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { | 2268 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { |
2269 X87Register left = ToX87Register(instr->left()); | 2269 X87Register left = ToX87Register(instr->left()); |
2270 X87Register right = ToX87Register(instr->right()); | 2270 X87Register right = ToX87Register(instr->right()); |
2271 X87Register result = ToX87Register(instr->result()); | 2271 X87Register result = ToX87Register(instr->result()); |
2272 if (instr->op() != Token::MOD) { | 2272 if (instr->op() != Token::MOD) { |
2273 X87PrepareBinaryOp(left, right, result); | 2273 X87PrepareBinaryOp(left, right, result); |
2274 } | 2274 } |
| 2275 // Set the precision control to double-precision. |
| 2276 __ X87SetFPUCW(0x027F); |
2275 switch (instr->op()) { | 2277 switch (instr->op()) { |
2276 case Token::ADD: | 2278 case Token::ADD: |
2277 __ fadd_i(1); | 2279 __ fadd_i(1); |
2278 break; | 2280 break; |
2279 case Token::SUB: | 2281 case Token::SUB: |
2280 __ fsub_i(1); | 2282 __ fsub_i(1); |
2281 break; | 2283 break; |
2282 case Token::MUL: | 2284 case Token::MUL: |
2283 __ fmul_i(1); | 2285 __ fmul_i(1); |
2284 break; | 2286 break; |
(...skipping 14 matching lines...) Expand all Loading... |
2299 | 2301 |
2300 // Return value is in st(0) on ia32. | 2302 // Return value is in st(0) on ia32. |
2301 X87CommitWrite(result); | 2303 X87CommitWrite(result); |
2302 break; | 2304 break; |
2303 } | 2305 } |
2304 default: | 2306 default: |
2305 UNREACHABLE(); | 2307 UNREACHABLE(); |
2306 break; | 2308 break; |
2307 } | 2309 } |
2308 | 2310 |
2309 // Only always explicitly storing to memory to force the round-down for double | 2311 __ X87SetFPUCW(0x037F); |
2310 // arithmetic. | |
2311 __ lea(esp, Operand(esp, -kDoubleSize)); | |
2312 __ fstp_d(Operand(esp, 0)); | |
2313 __ fld_d(Operand(esp, 0)); | |
2314 __ lea(esp, Operand(esp, kDoubleSize)); | |
2315 } | 2312 } |
2316 | 2313 |
2317 | 2314 |
2318 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { | 2315 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { |
2319 DCHECK(ToRegister(instr->context()).is(esi)); | 2316 DCHECK(ToRegister(instr->context()).is(esi)); |
2320 DCHECK(ToRegister(instr->left()).is(edx)); | 2317 DCHECK(ToRegister(instr->left()).is(edx)); |
2321 DCHECK(ToRegister(instr->right()).is(eax)); | 2318 DCHECK(ToRegister(instr->right()).is(eax)); |
2322 DCHECK(ToRegister(instr->result()).is(eax)); | 2319 DCHECK(ToRegister(instr->result()).is(eax)); |
2323 | 2320 |
2324 Handle<Code> code = | 2321 Handle<Code> code = |
(...skipping 3974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6299 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6296 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6300 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6297 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6301 } | 6298 } |
6302 | 6299 |
6303 | 6300 |
6304 #undef __ | 6301 #undef __ |
6305 | 6302 |
6306 } } // namespace v8::internal | 6303 } } // namespace v8::internal |
6307 | 6304 |
6308 #endif // V8_TARGET_ARCH_X87 | 6305 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |