| 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 2971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2982 __ notq(value); | 2982 __ notq(value); |
| 2983 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. | 2983 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. |
| 2984 break; | 2984 break; |
| 2985 default: | 2985 default: |
| 2986 UNREACHABLE(); | 2986 UNREACHABLE(); |
| 2987 } | 2987 } |
| 2988 } | 2988 } |
| 2989 | 2989 |
| 2990 | 2990 |
| 2991 LocationSummary* SmiToDoubleInstr::MakeLocationSummary() const { | 2991 LocationSummary* SmiToDoubleInstr::MakeLocationSummary() const { |
| 2992 return MakeCallSummary(); // Calls a stub to allocate result. | 2992 const intptr_t kNumInputs = 1; |
| 2993 const intptr_t kNumTemps = 0; |
| 2994 LocationSummary* result = |
| 2995 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2996 result->set_in(0, Location::WritableRegister()); |
| 2997 result->set_out(Location::RequiresFpuRegister()); |
| 2998 return result; |
| 2993 } | 2999 } |
| 2994 | 3000 |
| 2995 | 3001 |
| 2996 void SmiToDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3002 void SmiToDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2997 Register result = locs()->out().reg(); | 3003 Register value = locs()->in(0).reg(); |
| 2998 | 3004 FpuRegister result = locs()->out().fpu_reg(); |
| 2999 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | |
| 3000 kDeoptIntegerToDouble); | |
| 3001 | |
| 3002 const Class& double_class = compiler->double_class(); | |
| 3003 const Code& stub = | |
| 3004 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); | |
| 3005 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); | |
| 3006 | |
| 3007 // TODO(fschneider): Inline new-space allocation and move the call into | |
| 3008 // deferred code. | |
| 3009 compiler->GenerateCall(instance_call()->token_pos(), | |
| 3010 &label, | |
| 3011 PcDescriptors::kOther, | |
| 3012 locs()); | |
| 3013 ASSERT(result == RAX); | |
| 3014 Register value = RBX; | |
| 3015 // Preserve argument on the stack until after the deoptimization point. | |
| 3016 __ movq(value, Address(RSP, 0)); | |
| 3017 | |
| 3018 __ testq(value, Immediate(kSmiTagMask)); | |
| 3019 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. | |
| 3020 __ SmiUntag(value); | 3005 __ SmiUntag(value); |
| 3021 __ cvtsi2sd(XMM0, value); | 3006 __ cvtsi2sd(result, value); |
| 3022 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | |
| 3023 __ Drop(1); | |
| 3024 } | 3007 } |
| 3025 | 3008 |
| 3026 | 3009 |
| 3027 LocationSummary* DoubleToIntegerInstr::MakeLocationSummary() const { | 3010 LocationSummary* DoubleToIntegerInstr::MakeLocationSummary() const { |
| 3028 const intptr_t kNumInputs = 1; | 3011 const intptr_t kNumInputs = 1; |
| 3029 const intptr_t kNumTemps = 1; | 3012 const intptr_t kNumTemps = 1; |
| 3030 LocationSummary* result = | 3013 LocationSummary* result = |
| 3031 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 3014 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 3032 result->set_in(0, Location::RegisterLocation(RCX)); | 3015 result->set_in(0, Location::RegisterLocation(RCX)); |
| 3033 result->set_out(Location::RegisterLocation(RAX)); | 3016 result->set_out(Location::RegisterLocation(RAX)); |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3689 PcDescriptors::kOther, | 3672 PcDescriptors::kOther, |
| 3690 locs()); | 3673 locs()); |
| 3691 __ Drop(2); // Discard type arguments and receiver. | 3674 __ Drop(2); // Discard type arguments and receiver. |
| 3692 } | 3675 } |
| 3693 | 3676 |
| 3694 } // namespace dart | 3677 } // namespace dart |
| 3695 | 3678 |
| 3696 #undef __ | 3679 #undef __ |
| 3697 | 3680 |
| 3698 #endif // defined TARGET_ARCH_X64 | 3681 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |