| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 Operand OutputOperand() { return ToOperand(instr_->Output()); } | 35 Operand OutputOperand() { return ToOperand(instr_->Output()); } |
| 36 | 36 |
| 37 Immediate ToImmediate(InstructionOperand* operand) { | 37 Immediate ToImmediate(InstructionOperand* operand) { |
| 38 Constant constant = ToConstant(operand); | 38 Constant constant = ToConstant(operand); |
| 39 if (constant.type() == Constant::kFloat64) { | 39 if (constant.type() == Constant::kFloat64) { |
| 40 DCHECK_EQ(0, bit_cast<int64_t>(constant.ToFloat64())); | 40 DCHECK_EQ(0, bit_cast<int64_t>(constant.ToFloat64())); |
| 41 return Immediate(0); | 41 return Immediate(0); |
| 42 } | 42 } |
| 43 if (constant.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || | 43 if (constant.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || |
| 44 constant.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE) { | 44 constant.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE || |
| 45 constant.rmode() == RelocInfo::WASM_GLOBAL_REFERENCE) { |
| 45 return Immediate(constant.ToInt32(), constant.rmode()); | 46 return Immediate(constant.ToInt32(), constant.rmode()); |
| 46 } | 47 } |
| 47 return Immediate(constant.ToInt32()); | 48 return Immediate(constant.ToInt32()); |
| 48 } | 49 } |
| 49 | 50 |
| 50 Operand ToOperand(InstructionOperand* op, int extra = 0) { | 51 Operand ToOperand(InstructionOperand* op, int extra = 0) { |
| 51 DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); | 52 DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); |
| 52 return SlotToOperand(AllocatedOperand::cast(op)->index(), extra); | 53 return SlotToOperand(AllocatedOperand::cast(op)->index(), extra); |
| 53 } | 54 } |
| 54 | 55 |
| (...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 __ movq(dst, tmp); | 2158 __ movq(dst, tmp); |
| 2158 } | 2159 } |
| 2159 } else if (source->IsConstant()) { | 2160 } else if (source->IsConstant()) { |
| 2160 ConstantOperand* constant_source = ConstantOperand::cast(source); | 2161 ConstantOperand* constant_source = ConstantOperand::cast(source); |
| 2161 Constant src = g.ToConstant(constant_source); | 2162 Constant src = g.ToConstant(constant_source); |
| 2162 if (destination->IsRegister() || destination->IsStackSlot()) { | 2163 if (destination->IsRegister() || destination->IsStackSlot()) { |
| 2163 Register dst = destination->IsRegister() ? g.ToRegister(destination) | 2164 Register dst = destination->IsRegister() ? g.ToRegister(destination) |
| 2164 : kScratchRegister; | 2165 : kScratchRegister; |
| 2165 switch (src.type()) { | 2166 switch (src.type()) { |
| 2166 case Constant::kInt32: { | 2167 case Constant::kInt32: { |
| 2167 if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE) { | 2168 if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || |
| 2169 src.rmode() == RelocInfo::WASM_GLOBAL_REFERENCE) { |
| 2168 __ movq(dst, src.ToInt64(), src.rmode()); | 2170 __ movq(dst, src.ToInt64(), src.rmode()); |
| 2169 } else { | 2171 } else { |
| 2170 // TODO(dcarney): don't need scratch in this case. | 2172 // TODO(dcarney): don't need scratch in this case. |
| 2171 int32_t value = src.ToInt32(); | 2173 int32_t value = src.ToInt32(); |
| 2172 if (value == 0) { | 2174 if (value == 0) { |
| 2173 __ xorl(dst, dst); | 2175 __ xorl(dst, dst); |
| 2174 } else { | 2176 } else { |
| 2175 __ movl(dst, Immediate(value)); | 2177 __ movl(dst, Immediate(value)); |
| 2176 } | 2178 } |
| 2177 } | 2179 } |
| 2178 break; | 2180 break; |
| 2179 } | 2181 } |
| 2180 case Constant::kInt64: | 2182 case Constant::kInt64: |
| 2181 if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE) { | 2183 if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || |
| 2184 src.rmode() == RelocInfo::WASM_GLOBAL_REFERENCE) { |
| 2182 __ movq(dst, src.ToInt64(), src.rmode()); | 2185 __ movq(dst, src.ToInt64(), src.rmode()); |
| 2183 } else { | 2186 } else { |
| 2184 DCHECK(src.rmode() != RelocInfo::WASM_MEMORY_SIZE_REFERENCE); | 2187 DCHECK(src.rmode() != RelocInfo::WASM_MEMORY_SIZE_REFERENCE); |
| 2185 __ Set(dst, src.ToInt64()); | 2188 __ Set(dst, src.ToInt64()); |
| 2186 } | 2189 } |
| 2187 break; | 2190 break; |
| 2188 case Constant::kFloat32: | 2191 case Constant::kFloat32: |
| 2189 __ Move(dst, | 2192 __ Move(dst, |
| 2190 isolate()->factory()->NewNumber(src.ToFloat32(), TENURED)); | 2193 isolate()->factory()->NewNumber(src.ToFloat32(), TENURED)); |
| 2191 break; | 2194 break; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2340 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2343 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 2341 __ Nop(padding_size); | 2344 __ Nop(padding_size); |
| 2342 } | 2345 } |
| 2343 } | 2346 } |
| 2344 | 2347 |
| 2345 #undef __ | 2348 #undef __ |
| 2346 | 2349 |
| 2347 } // namespace compiler | 2350 } // namespace compiler |
| 2348 } // namespace internal | 2351 } // namespace internal |
| 2349 } // namespace v8 | 2352 } // namespace v8 |
| OLD | NEW |