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

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

Issue 10539145: Implement polymorphic instance calls. (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
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 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 __ popq(value); 1593 __ popq(value);
1594 1594
1595 __ testq(value, Immediate(kSmiTagMask)); 1595 __ testq(value, Immediate(kSmiTagMask));
1596 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. 1596 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi.
1597 __ SmiUntag(value); 1597 __ SmiUntag(value);
1598 __ cvtsi2sd(XMM0, value); 1598 __ cvtsi2sd(XMM0, value);
1599 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 1599 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1600 } 1600 }
1601 1601
1602 1602
1603 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const {
1604 return MakeCallSummary();
1605 }
1606
1607
1608 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1609 ASSERT(instance_call()->VerifyComputation());
1610 ASSERT(class_ids().length() == targets().length());
1611 ASSERT(class_ids().length() > 0);
1612 Label* deopt = compiler->AddDeoptStub(instance_call()->cid(),
1613 instance_call()->token_index(),
1614 instance_call()->try_index(),
1615 kDeoptPolymorphicInstanceCallTestFail);
1616 Label handle_smi;
1617 Label* is_smi_label = class_ids()[0] == kSmi ? &handle_smi : deopt;
1618 __ movq(RAX,
1619 Address(RSP, (instance_call()->ArgumentCount() - 1) * kWordSize));
1620 __ testq(RAX, Immediate(kSmiTagMask));
1621 __ j(ZERO, is_smi_label); // Smi -> deopt.
1622 Label done;
1623 __ LoadClassId(RDI, RAX);
1624 for (intptr_t i = 0; i < class_ids().length(); i++) {
1625 Label next_test;
1626 __ cmpq(RDI, Immediate(class_ids()[i]));
1627 __ j(NOT_EQUAL, &next_test);
1628 compiler->GenerateStaticCall(instance_call()->cid(),
1629 instance_call()->token_index(),
1630 instance_call()->try_index(),
1631 *targets()[i],
1632 instance_call()->ArgumentCount(),
1633 instance_call()->argument_names());
1634 __ jmp(&done);
1635 __ Bind(&next_test);
1636 }
1637 __ jmp(deopt);
1638 if (is_smi_label == &handle_smi) {
1639 __ Bind(&handle_smi);
1640 compiler->GenerateStaticCall(instance_call()->cid(),
1641 instance_call()->token_index(),
1642 instance_call()->try_index(),
1643 *targets()[0],
1644 instance_call()->ArgumentCount(),
1645 instance_call()->argument_names());
1646 }
1647 __ Bind(&done);
1648 }
1649
1603 } // namespace dart 1650 } // namespace dart
1604 1651
1605 #undef __ 1652 #undef __
1606 1653
1607 #endif // defined TARGET_ARCH_X64 1654 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698