Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 10440099: Adding unary op optimizations. missing assembly operations/ (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/token.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 Register right = locs()->in(1).reg(); 1293 Register right = locs()->in(1).reg();
1294 __ pushq(left); 1294 __ pushq(left);
1295 __ pushq(right); 1295 __ pushq(right);
1296 InstanceCallComp* instance_call_comp = instance_call(); 1296 InstanceCallComp* instance_call_comp = instance_call();
1297 instance_call_comp->EmitNativeCode(compiler); 1297 instance_call_comp->EmitNativeCode(compiler);
1298 if (locs()->out().reg() != RAX) { 1298 if (locs()->out().reg() != RAX) {
1299 __ movq(locs()->out().reg(), RAX); 1299 __ movq(locs()->out().reg(), RAX);
1300 } 1300 }
1301 } 1301 }
1302 1302
1303
1304 LocationSummary* UnarySmiOpComp::MakeLocationSummary() const {
1305 const intptr_t kNumInputs = 1;
1306 const intptr_t kNumTemps = 0;
1307 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps);
1308 summary->set_in(0, Location::RequiresRegister());
1309 summary->set_out(Location::SameAsFirstInput());
1310 return summary;
1311 }
1312
1313
1314 void UnarySmiOpComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1315 const ICData& ic_data = *instance_call()->ic_data();
1316 ASSERT(!ic_data.IsNull());
1317 ASSERT(ic_data.num_args_tested() == 1);
1318 // TODO(srdjan): Implement for more checks.
1319 ASSERT(ic_data.NumberOfChecks() == 1);
1320 Class& test_class = Class::Handle();
1321 Function& target = Function::Handle();
1322 ic_data.GetOneClassCheckAt(0, &test_class, &target);
1323
1324 Register value = locs()->in(0).reg();
1325 Register result = locs()->out().reg();
1326 ASSERT(value == result);
1327 Label* deopt = compiler->AddDeoptStub(instance_call()->cid(),
1328 instance_call()->token_index(),
1329 instance_call()->try_index(),
1330 kDeoptSmiBinaryOp,
1331 value,
1332 kNoRegister);
1333 if (test_class.id() == kSmi) {
1334 __ testq(value, Immediate(kSmiTagMask));
1335 __ j(NOT_ZERO, deopt);
1336 switch (op_kind()) {
1337 case Token::kNEGATE:
1338 __ negq(value);
1339 __ j(OVERFLOW, deopt);
1340 break;
1341 case Token::kBIT_NOT:
1342 __ notq(value);
1343 __ andq(value, Immediate(~kSmiTagMask)); // Remove inverted smi-tag.
1344 break;
1345 default:
1346 UNREACHABLE();
1347 }
1348 } else {
1349 UNREACHABLE();
1350 }
1351 }
1352
1353
1354 LocationSummary* NumberNegateComp::MakeLocationSummary() const {
1355 const intptr_t kNumInputs = 1;
1356 const intptr_t kNumTemps = 1; // Needed for doubles.
1357 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps);
1358 summary->set_in(0, Location::RequiresRegister());
1359 summary->set_out(Location::SameAsFirstInput());
1360 summary->set_temp(0, Location::RequiresRegister());
1361 return summary;
1362 }
1363
1364
1365 void NumberNegateComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1366 const ICData& ic_data = *instance_call()->ic_data();
1367 ASSERT(!ic_data.IsNull());
1368 ASSERT(ic_data.num_args_tested() == 1);
1369
1370 // TODO(srdjan): Implement for more checks.
1371 ASSERT(ic_data.NumberOfChecks() == 1);
1372 Class& test_class = Class::Handle();
1373 Function& target = Function::Handle();
1374 ic_data.GetOneClassCheckAt(0, &test_class, &target);
1375
1376 Register value = locs()->in(0).reg();
1377 Register result = locs()->out().reg();
1378 ASSERT(value == result);
1379 Label* deopt = compiler->AddDeoptStub(instance_call()->cid(),
1380 instance_call()->token_index(),
1381 instance_call()->try_index(),
1382 kDeoptSmiBinaryOp,
1383 value,
1384 kNoRegister);
1385 if (test_class.id() == kDouble) {
1386 Register temp = locs()->temp(0).reg();
1387 __ testq(value, Immediate(kSmiTagMask));
1388 __ j(ZERO, deopt); // Smi.
1389 __ CompareClassId(value, kDouble);
1390 __ j(NOT_EQUAL, deopt);
1391 // Allocate result object.
1392 const Class& double_class =
1393 Class::ZoneHandle(Isolate::Current()->object_store()->double_class());
1394 const Code& stub =
1395 Code::Handle(StubCode::GetAllocationStubForClass(double_class));
1396 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint());
1397 __ pushq(value);
1398 compiler->GenerateCall(instance_call()->token_index(),
1399 instance_call()->try_index(),
1400 &label,
1401 PcDescriptors::kOther);
1402 // Result is in EAX.
1403 __ movq(result, RAX);
1404 __ popq(temp);
1405 __ movsd(XMM0, FieldAddress(temp, Double::value_offset()));
1406 __ DoubleNegate(XMM0);
1407 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1408 } else {
1409 UNREACHABLE();
1410 }
1411 }
1412
1303 } // namespace dart 1413 } // namespace dart
1304 1414
1305 #undef __ 1415 #undef __
1306 1416
1307 #endif // defined TARGET_ARCH_X64 1417 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698