| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 case Token::kBIT_NOT: | 2009 case Token::kBIT_NOT: |
| 2010 __ notq(value); | 2010 __ notq(value); |
| 2011 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. | 2011 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. |
| 2012 break; | 2012 break; |
| 2013 default: | 2013 default: |
| 2014 UNREACHABLE(); | 2014 UNREACHABLE(); |
| 2015 } | 2015 } |
| 2016 } | 2016 } |
| 2017 | 2017 |
| 2018 | 2018 |
| 2019 LocationSummary* NumberNegateInstr::MakeLocationSummary() const { | |
| 2020 const intptr_t kNumInputs = 1; | |
| 2021 const intptr_t kNumTemps = 1; // Needed for doubles. | |
| 2022 LocationSummary* summary = | |
| 2023 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
| 2024 summary->set_in(0, Location::RegisterLocation(RAX)); | |
| 2025 summary->set_out(Location::RegisterLocation(RAX)); | |
| 2026 summary->set_temp(0, Location::RegisterLocation(RCX)); | |
| 2027 return summary; | |
| 2028 } | |
| 2029 | |
| 2030 | |
| 2031 void NumberNegateInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 2032 const ICData& ic_data = *instance_call()->ic_data(); | |
| 2033 ASSERT(!ic_data.IsNull()); | |
| 2034 ASSERT(ic_data.num_args_tested() == 1); | |
| 2035 | |
| 2036 // TODO(srdjan): Implement for more checks. | |
| 2037 ASSERT(ic_data.NumberOfChecks() == 1); | |
| 2038 intptr_t test_class_id; | |
| 2039 Function& target = Function::Handle(); | |
| 2040 ic_data.GetOneClassCheckAt(0, &test_class_id, &target); | |
| 2041 | |
| 2042 Register value = locs()->in(0).reg(); | |
| 2043 Register result = locs()->out().reg(); | |
| 2044 ASSERT(value == result); | |
| 2045 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | |
| 2046 kDeoptUnaryOp); | |
| 2047 if (test_class_id == kDoubleCid) { | |
| 2048 Register temp = locs()->temp(0).reg(); | |
| 2049 __ testq(value, Immediate(kSmiTagMask)); | |
| 2050 __ j(ZERO, deopt); // Smi. | |
| 2051 __ CompareClassId(value, kDoubleCid); | |
| 2052 __ j(NOT_EQUAL, deopt); | |
| 2053 // Allocate result object. | |
| 2054 const Class& double_class = compiler->double_class(); | |
| 2055 const Code& stub = | |
| 2056 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); | |
| 2057 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); | |
| 2058 __ pushq(value); | |
| 2059 compiler->GenerateCall(instance_call()->token_pos(), | |
| 2060 &label, | |
| 2061 PcDescriptors::kOther, | |
| 2062 instance_call()->locs()); | |
| 2063 // Result is in RAX. | |
| 2064 ASSERT(result != temp); | |
| 2065 __ movq(result, RAX); | |
| 2066 __ popq(temp); | |
| 2067 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); | |
| 2068 __ DoubleNegate(XMM0); | |
| 2069 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | |
| 2070 } else { | |
| 2071 UNREACHABLE(); | |
| 2072 } | |
| 2073 ASSERT(ResultCid() == kDoubleCid); | |
| 2074 } | |
| 2075 | |
| 2076 | |
| 2077 LocationSummary* DoubleToDoubleInstr::MakeLocationSummary() const { | 2019 LocationSummary* DoubleToDoubleInstr::MakeLocationSummary() const { |
| 2078 const intptr_t kNumInputs = 1; | 2020 const intptr_t kNumInputs = 1; |
| 2079 const intptr_t kNumTemps = 0; | 2021 const intptr_t kNumTemps = 0; |
| 2080 LocationSummary* locs = | 2022 LocationSummary* locs = |
| 2081 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2023 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2082 locs->set_in(0, Location::RequiresRegister()); | 2024 locs->set_in(0, Location::RequiresRegister()); |
| 2083 locs->set_out(Location::SameAsFirstInput()); | 2025 locs->set_out(Location::SameAsFirstInput()); |
| 2084 return locs; | 2026 return locs; |
| 2085 } | 2027 } |
| 2086 | 2028 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 __ j(ABOVE_EQUAL, deopt); | 2248 __ j(ABOVE_EQUAL, deopt); |
| 2307 } | 2249 } |
| 2308 } | 2250 } |
| 2309 | 2251 |
| 2310 | 2252 |
| 2311 } // namespace dart | 2253 } // namespace dart |
| 2312 | 2254 |
| 2313 #undef __ | 2255 #undef __ |
| 2314 | 2256 |
| 2315 #endif // defined TARGET_ARCH_X64 | 2257 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |