| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // We should never return here. | 212 // We should never return here. |
| 213 __ int3(); | 213 __ int3(); |
| 214 __ Bind(&done); | 214 __ Bind(&done); |
| 215 } | 215 } |
| 216 | 216 |
| 217 | 217 |
| 218 void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 218 void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 219 Register obj = locs()->in(0).reg(); | 219 Register obj = locs()->in(0).reg(); |
| 220 Register result = locs()->out().reg(); | 220 Register result = locs()->out().reg(); |
| 221 | 221 |
| 222 if (!is_eliminated()) { | 222 EmitAssertBoolean(obj, token_pos(), deopt_id(), locs(), compiler); |
| 223 EmitAssertBoolean(obj, token_pos(), deopt_id(), locs(), compiler); | |
| 224 } | |
| 225 ASSERT(obj == result); | 223 ASSERT(obj == result); |
| 226 } | 224 } |
| 227 | 225 |
| 228 | 226 |
| 229 LocationSummary* ArgumentDefinitionTestInstr::MakeLocationSummary() const { | 227 LocationSummary* ArgumentDefinitionTestInstr::MakeLocationSummary() const { |
| 230 const intptr_t kNumInputs = 1; | 228 const intptr_t kNumInputs = 1; |
| 231 const intptr_t kNumTemps = 0; | 229 const intptr_t kNumTemps = 0; |
| 232 LocationSummary* locs = | 230 LocationSummary* locs = |
| 233 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 231 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 234 locs->set_in(0, Location::RegisterLocation(RAX)); | 232 locs->set_in(0, Location::RegisterLocation(RAX)); |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 Register result = locs()->out().reg(); | 952 Register result = locs()->out().reg(); |
| 955 __ movq(result, | 953 __ movq(result, |
| 956 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress()))); | 954 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress()))); |
| 957 __ movq(result, Address(result, | 955 __ movq(result, Address(result, |
| 958 char_code, | 956 char_code, |
| 959 TIMES_HALF_WORD_SIZE, // Char code is a smi. | 957 TIMES_HALF_WORD_SIZE, // Char code is a smi. |
| 960 Symbols::kNullCharCodeSymbolOffset * kWordSize)); | 958 Symbols::kNullCharCodeSymbolOffset * kWordSize)); |
| 961 } | 959 } |
| 962 | 960 |
| 963 | 961 |
| 964 intptr_t LoadIndexedInstr::ResultCid() const { | 962 CompileType* LoadIndexedInstr::ComputeInitialType() const { |
| 965 switch (class_id_) { | 963 switch (class_id_) { |
| 966 case kArrayCid: | 964 case kArrayCid: |
| 967 case kImmutableArrayCid: | 965 case kImmutableArrayCid: |
| 968 return kDynamicCid; | 966 return CompileType::Dynamic(); |
| 967 |
| 969 case kFloat32ArrayCid : | 968 case kFloat32ArrayCid : |
| 970 case kFloat64ArrayCid : | 969 case kFloat64ArrayCid : |
| 971 return kDoubleCid; | 970 return CompileType::FromCid(kDoubleCid); |
| 971 |
| 972 case kInt8ArrayCid: | 972 case kInt8ArrayCid: |
| 973 case kUint8ArrayCid: | 973 case kUint8ArrayCid: |
| 974 case kUint8ClampedArrayCid: | 974 case kUint8ClampedArrayCid: |
| 975 case kExternalUint8ArrayCid: | 975 case kExternalUint8ArrayCid: |
| 976 case kExternalUint8ClampedArrayCid: | 976 case kExternalUint8ClampedArrayCid: |
| 977 case kInt16ArrayCid: | 977 case kInt16ArrayCid: |
| 978 case kUint16ArrayCid: | 978 case kUint16ArrayCid: |
| 979 case kOneByteStringCid: | 979 case kOneByteStringCid: |
| 980 case kTwoByteStringCid: | 980 case kTwoByteStringCid: |
| 981 case kInt32ArrayCid: | 981 case kInt32ArrayCid: |
| 982 case kUint32ArrayCid: | 982 case kUint32ArrayCid: |
| 983 return kSmiCid; | 983 return CompileType::FromCid(kSmiCid); |
| 984 |
| 984 default: | 985 default: |
| 985 UNIMPLEMENTED(); | 986 UNIMPLEMENTED(); |
| 986 return kSmiCid; | 987 return NULL; |
| 987 } | 988 } |
| 988 } | 989 } |
| 989 | 990 |
| 990 | 991 |
| 991 Representation LoadIndexedInstr::representation() const { | 992 Representation LoadIndexedInstr::representation() const { |
| 992 switch (class_id_) { | 993 switch (class_id_) { |
| 993 case kArrayCid: | 994 case kArrayCid: |
| 994 case kImmutableArrayCid: | 995 case kImmutableArrayCid: |
| 995 case kInt8ArrayCid: | 996 case kInt8ArrayCid: |
| 996 case kUint8ArrayCid: | 997 case kUint8ArrayCid: |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 break; | 2121 break; |
| 2121 } | 2122 } |
| 2122 default: | 2123 default: |
| 2123 UNREACHABLE(); | 2124 UNREACHABLE(); |
| 2124 break; | 2125 break; |
| 2125 } | 2126 } |
| 2126 } | 2127 } |
| 2127 | 2128 |
| 2128 | 2129 |
| 2129 LocationSummary* CheckEitherNonSmiInstr::MakeLocationSummary() const { | 2130 LocationSummary* CheckEitherNonSmiInstr::MakeLocationSummary() const { |
| 2130 ASSERT((left()->ResultCid() != kDoubleCid) && | 2131 ASSERT((left()->Type()->ToCid() != kDoubleCid) && |
| 2131 (right()->ResultCid() != kDoubleCid)); | 2132 (right()->Type()->ToCid() != kDoubleCid)); |
| 2132 const intptr_t kNumInputs = 2; | 2133 const intptr_t kNumInputs = 2; |
| 2133 const intptr_t kNumTemps = 1; | 2134 const intptr_t kNumTemps = 1; |
| 2134 LocationSummary* summary = | 2135 LocationSummary* summary = |
| 2135 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2136 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2136 summary->set_in(0, Location::RequiresRegister()); | 2137 summary->set_in(0, Location::RequiresRegister()); |
| 2137 summary->set_in(1, Location::RequiresRegister()); | 2138 summary->set_in(1, Location::RequiresRegister()); |
| 2138 summary->set_temp(0, Location::RequiresRegister()); | 2139 summary->set_temp(0, Location::RequiresRegister()); |
| 2139 return summary; | 2140 return summary; |
| 2140 } | 2141 } |
| 2141 | 2142 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 LocationSummary* summary = | 2219 LocationSummary* summary = |
| 2219 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2220 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2220 summary->set_in(0, Location::RequiresRegister()); | 2221 summary->set_in(0, Location::RequiresRegister()); |
| 2221 if (CanDeoptimize()) summary->set_temp(0, Location::RequiresRegister()); | 2222 if (CanDeoptimize()) summary->set_temp(0, Location::RequiresRegister()); |
| 2222 summary->set_out(Location::RequiresFpuRegister()); | 2223 summary->set_out(Location::RequiresFpuRegister()); |
| 2223 return summary; | 2224 return summary; |
| 2224 } | 2225 } |
| 2225 | 2226 |
| 2226 | 2227 |
| 2227 void UnboxDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2228 void UnboxDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2228 const intptr_t value_cid = value()->ResultCid(); | 2229 const intptr_t value_cid = value()->Type()->ToCid(); |
| 2229 const Register value = locs()->in(0).reg(); | 2230 const Register value = locs()->in(0).reg(); |
| 2230 const XmmRegister result = locs()->out().fpu_reg(); | 2231 const XmmRegister result = locs()->out().fpu_reg(); |
| 2231 | 2232 |
| 2232 if (value_cid == kDoubleCid) { | 2233 if (value_cid == kDoubleCid) { |
| 2233 __ movsd(result, FieldAddress(value, Double::value_offset())); | 2234 __ movsd(result, FieldAddress(value, Double::value_offset())); |
| 2234 } else if (value_cid == kSmiCid) { | 2235 } else if (value_cid == kSmiCid) { |
| 2235 __ SmiUntag(value); // Untag input before conversion. | 2236 __ SmiUntag(value); // Untag input before conversion. |
| 2236 __ cvtsi2sd(result, value); | 2237 __ cvtsi2sd(result, value); |
| 2237 __ SmiTag(value); // Restore input register. | 2238 __ SmiTag(value); // Restore input register. |
| 2238 } else { | 2239 } else { |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2620 const intptr_t kNumInputs = 1; | 2621 const intptr_t kNumInputs = 1; |
| 2621 const intptr_t kNumTemps = 0; | 2622 const intptr_t kNumTemps = 0; |
| 2622 LocationSummary* summary = | 2623 LocationSummary* summary = |
| 2623 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2624 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2624 summary->set_in(0, Location::RequiresRegister()); | 2625 summary->set_in(0, Location::RequiresRegister()); |
| 2625 return summary; | 2626 return summary; |
| 2626 } | 2627 } |
| 2627 | 2628 |
| 2628 | 2629 |
| 2629 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2630 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2630 // TODO(srdjan): Check if we can remove this by reordering CSE and LICM. | |
| 2631 if (value()->ResultCid() == kSmiCid) return; | |
| 2632 Register value = locs()->in(0).reg(); | 2631 Register value = locs()->in(0).reg(); |
| 2633 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2632 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2634 kDeoptCheckSmi); | 2633 kDeoptCheckSmi); |
| 2635 __ testq(value, Immediate(kSmiTagMask)); | 2634 __ testq(value, Immediate(kSmiTagMask)); |
| 2636 __ j(NOT_ZERO, deopt); | 2635 __ j(NOT_ZERO, deopt); |
| 2637 } | 2636 } |
| 2638 | 2637 |
| 2639 | 2638 |
| 2640 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { | 2639 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { |
| 2641 const intptr_t kNumInputs = 2; | 2640 const intptr_t kNumInputs = 2; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3046 PcDescriptors::kOther, | 3045 PcDescriptors::kOther, |
| 3047 locs()); | 3046 locs()); |
| 3048 __ Drop(2); // Discard type arguments and receiver. | 3047 __ Drop(2); // Discard type arguments and receiver. |
| 3049 } | 3048 } |
| 3050 | 3049 |
| 3051 } // namespace dart | 3050 } // namespace dart |
| 3052 | 3051 |
| 3053 #undef __ | 3052 #undef __ |
| 3054 | 3053 |
| 3055 #endif // defined TARGET_ARCH_X64 | 3054 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |