Chromium Code Reviews| 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 "lib/error.h" | 8 #include "lib/error.h" |
| 9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1186 Register right = locs()->in(1).reg(); | 1186 Register right = locs()->in(1).reg(); |
| 1187 __ pushq(left); | 1187 __ pushq(left); |
| 1188 __ pushq(right); | 1188 __ pushq(right); |
| 1189 InstanceCallComp* instance_call_comp = instance_call(); | 1189 InstanceCallComp* instance_call_comp = instance_call(); |
| 1190 instance_call_comp->EmitNativeCode(compiler); | 1190 instance_call_comp->EmitNativeCode(compiler); |
| 1191 if (locs()->out().reg() != RAX) { | 1191 if (locs()->out().reg() != RAX) { |
| 1192 __ movq(locs()->out().reg(), RAX); | 1192 __ movq(locs()->out().reg(), RAX); |
| 1193 } | 1193 } |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 | |
| 1197 LocationSummary* UnaryOpComp::MakeLocationSummary() const { | |
| 1198 const intptr_t kNumInputs = 1; | |
| 1199 const intptr_t kNumTemps = 1; // Needed for doubles. | |
| 1200 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps); | |
| 1201 summary->set_in(0, Location::RequiresRegister()); | |
| 1202 summary->set_out(Location::SameAsFirstInput()); | |
| 1203 summary->set_temp(0, Location::RequiresRegister()); | |
| 1204 return summary; | |
| 1205 } | |
| 1206 | |
| 1207 | |
| 1208 void UnaryOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 1209 const ICData& ic_data = *instance_call()->ic_data(); | |
| 1210 ASSERT(!ic_data.IsNull()); | |
| 1211 ASSERT(ic_data.num_args_tested() == 1); | |
| 1212 // TODO(srdjan): Implement for more checks. | |
| 1213 ASSERT(ic_data.NumberOfChecks() == 1); | |
| 1214 Class& test_class = Class::Handle(); | |
| 1215 Function& target = Function::Handle(); | |
| 1216 ic_data.GetOneClassCheckAt(0, &test_class, &target); | |
| 1217 | |
| 1218 Register value = locs()->in(0).reg(); | |
| 1219 Register result = locs()->out().reg(); | |
| 1220 ASSERT(value == result); | |
| 1221 Label* deopt = compiler->AddDeoptStub(instance_call()->cid(), | |
| 1222 instance_call()->token_index(), | |
| 1223 instance_call()->try_index(), | |
| 1224 kDeoptSmiBinaryOp, | |
| 1225 value, | |
| 1226 kNoRegister); | |
| 1227 if (test_class.index() == kSmi) { | |
| 1228 __ testq(value, Immediate(kSmiTagMask)); | |
| 1229 __ j(NOT_ZERO, deopt); | |
| 1230 switch (op_kind()) { | |
| 1231 case Token::kNEGATE: | |
| 1232 __ negq(value); | |
| 1233 __ j(OVERFLOW, deopt); | |
| 1234 break; | |
| 1235 case Token::kBIT_NOT: | |
| 1236 __ notq(value); | |
| 1237 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. | |
| 1238 break; | |
| 1239 default: | |
| 1240 UNREACHABLE(); | |
| 1241 } | |
| 1242 return; | |
| 1243 } | |
| 1244 if (test_class.index() == kDouble) { | |
|
Florian Schneider
2012/05/31 09:22:54
Maybe it would make sense to split UnaryOp into tw
srdjan
2012/05/31 20:02:44
UnaryOpComp -> UnarySmiOpComp and adding NumberNe
| |
| 1245 if (op_kind() == Token::kBIT_NOT) { | |
| 1246 __ jmp(deopt); | |
| 1247 return; | |
| 1248 } | |
| 1249 Register temp = locs()->temp(0).reg(); | |
| 1250 __ testq(value, Immediate(kSmiTagMask)); | |
| 1251 __ j(ZERO, deopt); // Smi. | |
| 1252 __ CompareClassId(value, kDouble); | |
| 1253 __ j(NOT_EQUAL, deopt); | |
| 1254 ASSERT(op_kind() == Token::kNEGATE); | |
| 1255 // Allocate result object. | |
| 1256 const Class& double_class = | |
| 1257 Class::ZoneHandle(Isolate::Current()->object_store()->double_class()); | |
| 1258 const Code& stub = | |
| 1259 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); | |
| 1260 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); | |
| 1261 __ pushq(value); | |
| 1262 compiler->GenerateCall(instance_call()->token_index(), | |
| 1263 instance_call()->try_index(), | |
| 1264 &label, | |
| 1265 PcDescriptors::kOther); | |
| 1266 // Result is in EAX. | |
| 1267 __ movq(result, RAX); | |
| 1268 __ popq(temp); | |
| 1269 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); | |
| 1270 __ DoubleNegate(XMM0); | |
| 1271 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); | |
| 1272 } | |
| 1273 } | |
| 1274 | |
| 1196 } // namespace dart | 1275 } // namespace dart |
| 1197 | 1276 |
| 1198 #undef __ | 1277 #undef __ |
| 1199 | 1278 |
| 1200 #endif // defined TARGET_ARCH_X64 | 1279 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |