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 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 Operand dst = g.ToOperand(destination); | 2014 Operand dst = g.ToOperand(destination); |
2015 __ movq(tmp, src); | 2015 __ movq(tmp, src); |
2016 __ movq(dst, tmp); | 2016 __ movq(dst, tmp); |
2017 } | 2017 } |
2018 } else if (source->IsConstant()) { | 2018 } else if (source->IsConstant()) { |
2019 ConstantOperand* constant_source = ConstantOperand::cast(source); | 2019 ConstantOperand* constant_source = ConstantOperand::cast(source); |
2020 Constant src = g.ToConstant(constant_source); | 2020 Constant src = g.ToConstant(constant_source); |
2021 if (destination->IsRegister() || destination->IsStackSlot()) { | 2021 if (destination->IsRegister() || destination->IsStackSlot()) { |
2022 Register dst = destination->IsRegister() ? g.ToRegister(destination) | 2022 Register dst = destination->IsRegister() ? g.ToRegister(destination) |
2023 : kScratchRegister; | 2023 : kScratchRegister; |
2024 switch (src.type()) { | 2024 if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE) { |
2025 case Constant::kInt32: | 2025 if (src.type() == Constant::kInt32) { |
2026 // TODO(dcarney): don't need scratch in this case. | 2026 __ Set(dst, src.ToInt32(), src.rmode()); |
2027 __ Set(dst, src.ToInt32()); | 2027 } else if (src.type() == Constant::kInt64) { |
2028 break; | 2028 __ Set(dst, src.ToInt64(), src.rmode()); |
2029 case Constant::kInt64: | 2029 } |
2030 __ Set(dst, src.ToInt64()); | 2030 } else { |
2031 break; | 2031 switch (src.type()) { |
2032 case Constant::kFloat32: | 2032 case Constant::kInt32: |
2033 __ Move(dst, | 2033 // TODO(dcarney): don't need scratch in this case. |
2034 isolate()->factory()->NewNumber(src.ToFloat32(), TENURED)); | 2034 __ Set(dst, src.ToInt32()); |
2035 break; | 2035 break; |
2036 case Constant::kFloat64: | 2036 case Constant::kInt64: |
2037 __ Move(dst, | 2037 __ Set(dst, src.ToInt64()); |
2038 isolate()->factory()->NewNumber(src.ToFloat64(), TENURED)); | 2038 break; |
2039 break; | 2039 case Constant::kFloat32: |
2040 case Constant::kExternalReference: | 2040 __ Move(dst, |
2041 __ Move(dst, src.ToExternalReference()); | 2041 isolate()->factory()->NewNumber(src.ToFloat32(), TENURED)); |
2042 break; | 2042 break; |
2043 case Constant::kHeapObject: { | 2043 case Constant::kFloat64: |
2044 Handle<HeapObject> src_object = src.ToHeapObject(); | 2044 __ Move(dst, |
2045 Heap::RootListIndex index; | 2045 isolate()->factory()->NewNumber(src.ToFloat64(), TENURED)); |
2046 int offset; | 2046 break; |
2047 if (IsMaterializableFromFrame(src_object, &offset)) { | 2047 case Constant::kExternalReference: |
2048 __ movp(dst, Operand(rbp, offset)); | 2048 __ Move(dst, src.ToExternalReference()); |
2049 } else if (IsMaterializableFromRoot(src_object, &index)) { | 2049 break; |
2050 __ LoadRoot(dst, index); | 2050 case Constant::kHeapObject: { |
2051 } else { | 2051 Handle<HeapObject> src_object = src.ToHeapObject(); |
2052 __ Move(dst, src_object); | 2052 Heap::RootListIndex index; |
| 2053 int offset; |
| 2054 if (IsMaterializableFromFrame(src_object, &offset)) { |
| 2055 __ movp(dst, Operand(rbp, offset)); |
| 2056 } else if (IsMaterializableFromRoot(src_object, &index)) { |
| 2057 __ LoadRoot(dst, index); |
| 2058 } else { |
| 2059 __ Move(dst, src_object); |
| 2060 } |
| 2061 break; |
2053 } | 2062 } |
2054 break; | 2063 case Constant::kRpoNumber: |
| 2064 UNREACHABLE(); // TODO(dcarney): load of labels on x64. |
| 2065 break; |
2055 } | 2066 } |
2056 case Constant::kRpoNumber: | |
2057 UNREACHABLE(); // TODO(dcarney): load of labels on x64. | |
2058 break; | |
2059 } | 2067 } |
2060 if (destination->IsStackSlot()) { | 2068 if (destination->IsStackSlot()) { |
2061 __ movq(g.ToOperand(destination), kScratchRegister); | 2069 __ movq(g.ToOperand(destination), kScratchRegister); |
2062 } | 2070 } |
2063 } else if (src.type() == Constant::kFloat32) { | 2071 } else if (src.type() == Constant::kFloat32) { |
2064 // TODO(turbofan): Can we do better here? | 2072 // TODO(turbofan): Can we do better here? |
2065 uint32_t src_const = bit_cast<uint32_t>(src.ToFloat32()); | 2073 uint32_t src_const = bit_cast<uint32_t>(src.ToFloat32()); |
2066 if (destination->IsDoubleRegister()) { | 2074 if (destination->IsDoubleRegister()) { |
2067 __ Move(g.ToDoubleRegister(destination), src_const); | 2075 __ Move(g.ToDoubleRegister(destination), src_const); |
2068 } else { | 2076 } else { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2199 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2192 __ Nop(padding_size); | 2200 __ Nop(padding_size); |
2193 } | 2201 } |
2194 } | 2202 } |
2195 | 2203 |
2196 #undef __ | 2204 #undef __ |
2197 | 2205 |
2198 } // namespace compiler | 2206 } // namespace compiler |
2199 } // namespace internal | 2207 } // namespace internal |
2200 } // namespace v8 | 2208 } // namespace v8 |
OLD | NEW |