Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 1580233003: [turbofan] avoid xchg instruction on Intel (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 } 2039 }
2040 2040
2041 2041
2042 void CodeGenerator::AssembleSwap(InstructionOperand* source, 2042 void CodeGenerator::AssembleSwap(InstructionOperand* source,
2043 InstructionOperand* destination) { 2043 InstructionOperand* destination) {
2044 X64OperandConverter g(this, nullptr); 2044 X64OperandConverter g(this, nullptr);
2045 // Dispatch on the source and destination operand kinds. Not all 2045 // Dispatch on the source and destination operand kinds. Not all
2046 // combinations are possible. 2046 // combinations are possible.
2047 if (source->IsRegister() && destination->IsRegister()) { 2047 if (source->IsRegister() && destination->IsRegister()) {
2048 // Register-register. 2048 // Register-register.
2049 __ xchgq(g.ToRegister(source), g.ToRegister(destination)); 2049 Register src = g.ToRegister(source);
2050 Register dst = g.ToRegister(destination);
2051 __ movq(kScratchRegister, src);
2052 __ movq(src, dst);
2053 __ movq(dst, kScratchRegister);
2050 } else if (source->IsRegister() && destination->IsStackSlot()) { 2054 } else if (source->IsRegister() && destination->IsStackSlot()) {
2051 Register src = g.ToRegister(source); 2055 Register src = g.ToRegister(source);
2056 __ pushq(src);
2057 frame_access_state()->IncreaseSPDelta(1);
2052 Operand dst = g.ToOperand(destination); 2058 Operand dst = g.ToOperand(destination);
2053 __ xchgq(src, dst); 2059 __ movq(src, dst);
2060 frame_access_state()->IncreaseSPDelta(-1);
2061 dst = g.ToOperand(destination);
2062 __ popq(dst);
2054 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || 2063 } else if ((source->IsStackSlot() && destination->IsStackSlot()) ||
2055 (source->IsDoubleStackSlot() && 2064 (source->IsDoubleStackSlot() &&
2056 destination->IsDoubleStackSlot())) { 2065 destination->IsDoubleStackSlot())) {
2057 // Memory-memory. 2066 // Memory-memory.
2058 Register tmp = kScratchRegister; 2067 Register tmp = kScratchRegister;
2059 Operand src = g.ToOperand(source); 2068 Operand src = g.ToOperand(source);
2060 Operand dst = g.ToOperand(destination); 2069 Operand dst = g.ToOperand(destination);
2061 __ movq(tmp, dst); 2070 __ movq(tmp, dst);
2062 __ xchgq(tmp, src); 2071 __ pushq(src);
2063 __ movq(dst, tmp); 2072 frame_access_state()->IncreaseSPDelta(1);
2073 src = g.ToOperand(source);
2074 __ movq(src, tmp);
2075 frame_access_state()->IncreaseSPDelta(-1);
2076 dst = g.ToOperand(destination);
2077 __ popq(dst);
2064 } else if (source->IsDoubleRegister() && destination->IsDoubleRegister()) { 2078 } else if (source->IsDoubleRegister() && destination->IsDoubleRegister()) {
2065 // XMM register-register swap. We rely on having xmm0 2079 // XMM register-register swap. We rely on having xmm0
2066 // available as a fixed scratch register. 2080 // available as a fixed scratch register.
2067 XMMRegister src = g.ToDoubleRegister(source); 2081 XMMRegister src = g.ToDoubleRegister(source);
2068 XMMRegister dst = g.ToDoubleRegister(destination); 2082 XMMRegister dst = g.ToDoubleRegister(destination);
2069 __ Movapd(xmm0, src); 2083 __ Movapd(xmm0, src);
2070 __ Movapd(src, dst); 2084 __ Movapd(src, dst);
2071 __ Movapd(dst, xmm0); 2085 __ Movapd(dst, xmm0);
2072 } else if (source->IsDoubleRegister() && destination->IsDoubleStackSlot()) { 2086 } else if (source->IsDoubleRegister() && destination->IsDoubleStackSlot()) {
2073 // XMM register-memory swap. We rely on having xmm0 2087 // XMM register-memory swap. We rely on having xmm0
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 2121 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
2108 __ Nop(padding_size); 2122 __ Nop(padding_size);
2109 } 2123 }
2110 } 2124 }
2111 2125
2112 #undef __ 2126 #undef __
2113 2127
2114 } // namespace compiler 2128 } // namespace compiler
2115 } // namespace internal 2129 } // namespace internal
2116 } // namespace v8 2130 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698