| 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
| 9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 2340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2351 } | 2351 } |
| 2352 } | 2352 } |
| 2353 } else if (source->IsFPRegister()) { | 2353 } else if (source->IsFPRegister()) { |
| 2354 XMMRegister src = g.ToDoubleRegister(source); | 2354 XMMRegister src = g.ToDoubleRegister(source); |
| 2355 if (destination->IsFPRegister()) { | 2355 if (destination->IsFPRegister()) { |
| 2356 XMMRegister dst = g.ToDoubleRegister(destination); | 2356 XMMRegister dst = g.ToDoubleRegister(destination); |
| 2357 __ Movapd(dst, src); | 2357 __ Movapd(dst, src); |
| 2358 } else { | 2358 } else { |
| 2359 DCHECK(destination->IsFPStackSlot()); | 2359 DCHECK(destination->IsFPStackSlot()); |
| 2360 Operand dst = g.ToOperand(destination); | 2360 Operand dst = g.ToOperand(destination); |
| 2361 __ Movsd(dst, src); | 2361 MachineRepresentation rep = |
| 2362 LocationOperand::cast(source)->representation(); |
| 2363 if (rep != MachineRepresentation::kSimd128) { |
| 2364 __ Movsd(dst, src); |
| 2365 } else { |
| 2366 __ Movups(dst, src); |
| 2367 } |
| 2362 } | 2368 } |
| 2363 } else if (source->IsFPStackSlot()) { | 2369 } else if (source->IsFPStackSlot()) { |
| 2364 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); | 2370 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); |
| 2365 Operand src = g.ToOperand(source); | 2371 Operand src = g.ToOperand(source); |
| 2372 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
| 2366 if (destination->IsFPRegister()) { | 2373 if (destination->IsFPRegister()) { |
| 2367 XMMRegister dst = g.ToDoubleRegister(destination); | 2374 XMMRegister dst = g.ToDoubleRegister(destination); |
| 2368 __ Movsd(dst, src); | 2375 if (rep != MachineRepresentation::kSimd128) { |
| 2376 __ Movsd(dst, src); |
| 2377 } else { |
| 2378 __ Movups(dst, src); |
| 2379 } |
| 2369 } else { | 2380 } else { |
| 2370 Operand dst = g.ToOperand(destination); | 2381 Operand dst = g.ToOperand(destination); |
| 2371 __ Movsd(kScratchDoubleReg, src); | 2382 if (rep != MachineRepresentation::kSimd128) { |
| 2372 __ Movsd(dst, kScratchDoubleReg); | 2383 __ Movsd(kScratchDoubleReg, src); |
| 2384 __ Movsd(dst, kScratchDoubleReg); |
| 2385 } else { |
| 2386 __ Movups(kScratchDoubleReg, src); |
| 2387 __ Movups(dst, kScratchDoubleReg); |
| 2388 } |
| 2373 } | 2389 } |
| 2374 } else { | 2390 } else { |
| 2375 UNREACHABLE(); | 2391 UNREACHABLE(); |
| 2376 } | 2392 } |
| 2377 } | 2393 } |
| 2378 | 2394 |
| 2379 | 2395 |
| 2380 void CodeGenerator::AssembleSwap(InstructionOperand* source, | 2396 void CodeGenerator::AssembleSwap(InstructionOperand* source, |
| 2381 InstructionOperand* destination) { | 2397 InstructionOperand* destination) { |
| 2382 X64OperandConverter g(this, nullptr); | 2398 X64OperandConverter g(this, nullptr); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2394 __ pushq(src); | 2410 __ pushq(src); |
| 2395 frame_access_state()->IncreaseSPDelta(1); | 2411 frame_access_state()->IncreaseSPDelta(1); |
| 2396 Operand dst = g.ToOperand(destination); | 2412 Operand dst = g.ToOperand(destination); |
| 2397 __ movq(src, dst); | 2413 __ movq(src, dst); |
| 2398 frame_access_state()->IncreaseSPDelta(-1); | 2414 frame_access_state()->IncreaseSPDelta(-1); |
| 2399 dst = g.ToOperand(destination); | 2415 dst = g.ToOperand(destination); |
| 2400 __ popq(dst); | 2416 __ popq(dst); |
| 2401 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || | 2417 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || |
| 2402 (source->IsFPStackSlot() && destination->IsFPStackSlot())) { | 2418 (source->IsFPStackSlot() && destination->IsFPStackSlot())) { |
| 2403 // Memory-memory. | 2419 // Memory-memory. |
| 2404 Register tmp = kScratchRegister; | |
| 2405 Operand src = g.ToOperand(source); | 2420 Operand src = g.ToOperand(source); |
| 2406 Operand dst = g.ToOperand(destination); | 2421 Operand dst = g.ToOperand(destination); |
| 2407 __ movq(tmp, dst); | 2422 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
| 2408 __ pushq(src); | 2423 if (rep != MachineRepresentation::kSimd128) { |
| 2409 frame_access_state()->IncreaseSPDelta(1); | 2424 Register tmp = kScratchRegister; |
| 2410 src = g.ToOperand(source); | 2425 __ movq(tmp, dst); |
| 2411 __ movq(src, tmp); | 2426 __ pushq(src); |
| 2412 frame_access_state()->IncreaseSPDelta(-1); | 2427 frame_access_state()->IncreaseSPDelta(1); |
| 2413 dst = g.ToOperand(destination); | 2428 src = g.ToOperand(source); |
| 2414 __ popq(dst); | 2429 __ movq(src, tmp); |
| 2430 frame_access_state()->IncreaseSPDelta(-1); |
| 2431 dst = g.ToOperand(destination); |
| 2432 __ popq(dst); |
| 2433 } else { |
| 2434 // Use the XOR trick to swap without a temporary. |
| 2435 __ Movups(kScratchDoubleReg, src); |
| 2436 __ Xorps(kScratchDoubleReg, dst); // scratch contains src ^ dst. |
| 2437 __ Movups(src, kScratchDoubleReg); |
| 2438 __ Xorps(kScratchDoubleReg, dst); // scratch contains src. |
| 2439 __ Movups(dst, kScratchDoubleReg); |
| 2440 __ Xorps(kScratchDoubleReg, src); // scratch contains dst. |
| 2441 __ Movups(src, kScratchDoubleReg); |
| 2442 } |
| 2415 } else if (source->IsFPRegister() && destination->IsFPRegister()) { | 2443 } else if (source->IsFPRegister() && destination->IsFPRegister()) { |
| 2416 // XMM register-register swap. | 2444 // XMM register-register swap. |
| 2417 XMMRegister src = g.ToDoubleRegister(source); | 2445 XMMRegister src = g.ToDoubleRegister(source); |
| 2418 XMMRegister dst = g.ToDoubleRegister(destination); | 2446 XMMRegister dst = g.ToDoubleRegister(destination); |
| 2419 __ Movapd(kScratchDoubleReg, src); | 2447 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
| 2420 __ Movapd(src, dst); | 2448 if (rep != MachineRepresentation::kSimd128) { |
| 2421 __ Movapd(dst, kScratchDoubleReg); | 2449 __ Movapd(kScratchDoubleReg, src); |
| 2450 __ Movapd(src, dst); |
| 2451 __ Movapd(dst, kScratchDoubleReg); |
| 2452 } else { |
| 2453 __ Movups(kScratchDoubleReg, src); |
| 2454 __ Movups(src, dst); |
| 2455 __ Movups(dst, kScratchDoubleReg); |
| 2456 } |
| 2422 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { | 2457 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { |
| 2423 // XMM register-memory swap. | 2458 // XMM register-memory swap. |
| 2424 XMMRegister src = g.ToDoubleRegister(source); | 2459 XMMRegister src = g.ToDoubleRegister(source); |
| 2425 Operand dst = g.ToOperand(destination); | 2460 Operand dst = g.ToOperand(destination); |
| 2426 __ Movsd(kScratchDoubleReg, src); | 2461 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
| 2427 __ Movsd(src, dst); | 2462 if (rep != MachineRepresentation::kSimd128) { |
| 2428 __ Movsd(dst, kScratchDoubleReg); | 2463 __ Movsd(kScratchDoubleReg, src); |
| 2464 __ Movsd(src, dst); |
| 2465 __ Movsd(dst, kScratchDoubleReg); |
| 2466 } else { |
| 2467 __ Movups(kScratchDoubleReg, src); |
| 2468 __ Movups(src, dst); |
| 2469 __ Movups(dst, kScratchDoubleReg); |
| 2470 } |
| 2429 } else { | 2471 } else { |
| 2430 // No other combinations are possible. | 2472 // No other combinations are possible. |
| 2431 UNREACHABLE(); | 2473 UNREACHABLE(); |
| 2432 } | 2474 } |
| 2433 } | 2475 } |
| 2434 | 2476 |
| 2435 | 2477 |
| 2436 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { | 2478 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { |
| 2437 for (size_t index = 0; index < target_count; ++index) { | 2479 for (size_t index = 0; index < target_count; ++index) { |
| 2438 __ dq(targets[index]); | 2480 __ dq(targets[index]); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2453 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2495 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 2454 __ Nop(padding_size); | 2496 __ Nop(padding_size); |
| 2455 } | 2497 } |
| 2456 } | 2498 } |
| 2457 | 2499 |
| 2458 #undef __ | 2500 #undef __ |
| 2459 | 2501 |
| 2460 } // namespace compiler | 2502 } // namespace compiler |
| 2461 } // namespace internal | 2503 } // namespace internal |
| 2462 } // namespace v8 | 2504 } // namespace v8 |
| OLD | NEW |