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

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

Issue 10534116: Implement kDoubleToDouble and kIntegerToDouble on ia32 and x64. (Closed) Base URL: https://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') | no next file » | 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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 __ movq(result, RAX); 1398 __ movq(result, RAX);
1399 __ popq(temp); 1399 __ popq(temp);
1400 __ movsd(XMM0, FieldAddress(temp, Double::value_offset())); 1400 __ movsd(XMM0, FieldAddress(temp, Double::value_offset()));
1401 __ DoubleNegate(XMM0); 1401 __ DoubleNegate(XMM0);
1402 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 1402 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1403 } else { 1403 } else {
1404 UNREACHABLE(); 1404 UNREACHABLE();
1405 } 1405 }
1406 } 1406 }
1407 1407
1408
1409 LocationSummary* ToDoubleComp::MakeLocationSummary() const {
1410 const intptr_t kNumInputs = 1;
1411 const intptr_t kNumTemps = 0;
1412 if (from() == kDouble) {
1413 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps);
1414 locs->set_in(0, Location::RequiresRegister());
1415 locs->set_out(Location::SameAsFirstInput());
1416 return locs;
1417 } else {
1418 ASSERT(from() == kSmi);
1419 return LocationSummary::Make(kNumInputs, Location::RegisterLocation(RAX));
1420 }
1421 }
1422
1423
1424 void ToDoubleComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1425 Register value = locs()->in(0).reg();
1426 Register result = locs()->out().reg();
1427
1428 const DeoptReasonId deopt_reason = (from() == kDouble) ?
1429 kDeoptDoubleToDouble : kDeoptIntegerToDouble;
1430 Label* deopt = compiler->AddDeoptStub(instance_call()->cid(),
1431 instance_call()->token_index(),
1432 instance_call()->try_index(),
1433 deopt_reason,
1434 value,
1435 kNoRegister);
1436
1437 if (from() == kDouble) {
1438 __ testq(value, Immediate(kSmiTagMask));
1439 __ j(ZERO, deopt); // Deoptimize if Smi.
1440 __ CompareClassId(value, kDouble);
1441 __ j(NOT_EQUAL, deopt); // Deoptimize if not Double.
1442 ASSERT(value == result);
1443 return;
1444 }
1445
1446 ASSERT(from() == kSmi);
1447
1448 // TODO(vegorov): allocate a single ZoneHandle in FlowGraphCompiler for
1449 // double class.
1450 const Class& double_class =
1451 Class::ZoneHandle(Isolate::Current()->object_store()->double_class());
1452
1453 const Code& stub =
1454 Code::Handle(StubCode::GetAllocationStubForClass(double_class));
1455
1456 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint());
1457
1458 // TODO(vegorov): allocate box in the driver loop to avoid pushing and poping.
1459 __ pushq(value);
1460 compiler->GenerateCall(instance_call()->token_index(),
1461 instance_call()->try_index(),
1462 &label,
1463 PcDescriptors::kOther);
1464 ASSERT(result == RAX);
1465 __ popq(value);
1466
1467 __ testq(value, Immediate(kSmiTagMask));
1468 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi.
1469 __ SmiUntag(value);
1470 __ cvtsi2sd(XMM0, value);
1471 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1472 }
1473
1474
1408 } // namespace dart 1475 } // namespace dart
1409 1476
1410 #undef __ 1477 #undef __
1411 1478
1412 #endif // defined TARGET_ARCH_X64 1479 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698