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" |
11 #include "src/compiler/osr.h" | 11 #include "src/compiler/osr.h" |
12 #include "src/x64/assembler-x64.h" | 12 #include "src/x64/assembler-x64.h" |
13 #include "src/x64/macro-assembler-x64.h" | 13 #include "src/x64/macro-assembler-x64.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
19 #define __ masm()-> | 19 #define __ masm()-> |
20 | 20 |
21 | |
22 #define kScratchDoubleReg xmm0 | |
23 | |
24 | |
25 // Adds X64 specific methods for decoding operands. | 21 // Adds X64 specific methods for decoding operands. |
26 class X64OperandConverter : public InstructionOperandConverter { | 22 class X64OperandConverter : public InstructionOperandConverter { |
27 public: | 23 public: |
28 X64OperandConverter(CodeGenerator* gen, Instruction* instr) | 24 X64OperandConverter(CodeGenerator* gen, Instruction* instr) |
29 : InstructionOperandConverter(gen, instr) {} | 25 : InstructionOperandConverter(gen, instr) {} |
30 | 26 |
31 Immediate InputImmediate(size_t index) { | 27 Immediate InputImmediate(size_t index) { |
32 return ToImmediate(instr_->InputAt(index)); | 28 return ToImmediate(instr_->InputAt(index)); |
33 } | 29 } |
34 | 30 |
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2220 Operand dst = g.ToOperand(destination); | 2216 Operand dst = g.ToOperand(destination); |
2221 __ Movsd(dst, src); | 2217 __ Movsd(dst, src); |
2222 } | 2218 } |
2223 } else if (source->IsFPStackSlot()) { | 2219 } else if (source->IsFPStackSlot()) { |
2224 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); | 2220 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); |
2225 Operand src = g.ToOperand(source); | 2221 Operand src = g.ToOperand(source); |
2226 if (destination->IsFPRegister()) { | 2222 if (destination->IsFPRegister()) { |
2227 XMMRegister dst = g.ToDoubleRegister(destination); | 2223 XMMRegister dst = g.ToDoubleRegister(destination); |
2228 __ Movsd(dst, src); | 2224 __ Movsd(dst, src); |
2229 } else { | 2225 } else { |
2230 // We rely on having xmm0 available as a fixed scratch register. | |
2231 Operand dst = g.ToOperand(destination); | 2226 Operand dst = g.ToOperand(destination); |
2232 __ Movsd(xmm0, src); | 2227 __ Movsd(kScratchDoubleReg, src); |
2233 __ Movsd(dst, xmm0); | 2228 __ Movsd(dst, kScratchDoubleReg); |
2234 } | 2229 } |
2235 } else { | 2230 } else { |
2236 UNREACHABLE(); | 2231 UNREACHABLE(); |
2237 } | 2232 } |
2238 } | 2233 } |
2239 | 2234 |
2240 | 2235 |
2241 void CodeGenerator::AssembleSwap(InstructionOperand* source, | 2236 void CodeGenerator::AssembleSwap(InstructionOperand* source, |
2242 InstructionOperand* destination) { | 2237 InstructionOperand* destination) { |
2243 X64OperandConverter g(this, nullptr); | 2238 X64OperandConverter g(this, nullptr); |
(...skipping 23 matching lines...) Expand all Loading... |
2267 Operand dst = g.ToOperand(destination); | 2262 Operand dst = g.ToOperand(destination); |
2268 __ movq(tmp, dst); | 2263 __ movq(tmp, dst); |
2269 __ pushq(src); | 2264 __ pushq(src); |
2270 frame_access_state()->IncreaseSPDelta(1); | 2265 frame_access_state()->IncreaseSPDelta(1); |
2271 src = g.ToOperand(source); | 2266 src = g.ToOperand(source); |
2272 __ movq(src, tmp); | 2267 __ movq(src, tmp); |
2273 frame_access_state()->IncreaseSPDelta(-1); | 2268 frame_access_state()->IncreaseSPDelta(-1); |
2274 dst = g.ToOperand(destination); | 2269 dst = g.ToOperand(destination); |
2275 __ popq(dst); | 2270 __ popq(dst); |
2276 } else if (source->IsFPRegister() && destination->IsFPRegister()) { | 2271 } else if (source->IsFPRegister() && destination->IsFPRegister()) { |
2277 // XMM register-register swap. We rely on having xmm0 | 2272 // XMM register-register swap. |
2278 // available as a fixed scratch register. | |
2279 XMMRegister src = g.ToDoubleRegister(source); | 2273 XMMRegister src = g.ToDoubleRegister(source); |
2280 XMMRegister dst = g.ToDoubleRegister(destination); | 2274 XMMRegister dst = g.ToDoubleRegister(destination); |
2281 __ Movapd(xmm0, src); | 2275 __ Movapd(kScratchDoubleReg, src); |
2282 __ Movapd(src, dst); | 2276 __ Movapd(src, dst); |
2283 __ Movapd(dst, xmm0); | 2277 __ Movapd(dst, kScratchDoubleReg); |
2284 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { | 2278 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { |
2285 // XMM register-memory swap. We rely on having xmm0 | 2279 // XMM register-memory swap. |
2286 // available as a fixed scratch register. | |
2287 XMMRegister src = g.ToDoubleRegister(source); | 2280 XMMRegister src = g.ToDoubleRegister(source); |
2288 Operand dst = g.ToOperand(destination); | 2281 Operand dst = g.ToOperand(destination); |
2289 __ Movsd(xmm0, src); | 2282 __ Movsd(kScratchDoubleReg, src); |
2290 __ Movsd(src, dst); | 2283 __ Movsd(src, dst); |
2291 __ Movsd(dst, xmm0); | 2284 __ Movsd(dst, kScratchDoubleReg); |
2292 } else { | 2285 } else { |
2293 // No other combinations are possible. | 2286 // No other combinations are possible. |
2294 UNREACHABLE(); | 2287 UNREACHABLE(); |
2295 } | 2288 } |
2296 } | 2289 } |
2297 | 2290 |
2298 | 2291 |
2299 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { | 2292 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { |
2300 for (size_t index = 0; index < target_count; ++index) { | 2293 for (size_t index = 0; index < target_count; ++index) { |
2301 __ dq(targets[index]); | 2294 __ dq(targets[index]); |
(...skipping 14 matching lines...) Expand all Loading... |
2316 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2309 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2317 __ Nop(padding_size); | 2310 __ Nop(padding_size); |
2318 } | 2311 } |
2319 } | 2312 } |
2320 | 2313 |
2321 #undef __ | 2314 #undef __ |
2322 | 2315 |
2323 } // namespace compiler | 2316 } // namespace compiler |
2324 } // namespace internal | 2317 } // namespace internal |
2325 } // namespace v8 | 2318 } // namespace v8 |
OLD | NEW |