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

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
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/opt_code_generator_ia32.cc » ('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 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 // Load receiver into RAX.
1619 __ movq(RAX,
1620 Address(RSP, (instance_call()->ArgumentCount() - 1) * kWordSize));
1621 __ testq(RAX, Immediate(kSmiTagMask));
1622 __ j(ZERO, is_smi_label);
1623 Label done;
1624 __ LoadClassId(RDI, RAX);
1625 for (intptr_t i = 0; i < class_ids().length(); i++) {
1626 Label next_test;
1627 __ cmpq(RDI, Immediate(class_ids()[i]));
1628 __ j(NOT_EQUAL, &next_test);
1629 compiler->GenerateStaticCall(instance_call()->cid(),
1630 instance_call()->token_index(),
1631 instance_call()->try_index(),
1632 *targets()[i],
1633 instance_call()->ArgumentCount(),
1634 instance_call()->argument_names());
1635 __ jmp(&done);
1636 __ Bind(&next_test);
1637 }
1638 __ jmp(deopt);
1639 if (is_smi_label == &handle_smi) {
1640 __ Bind(&handle_smi);
1641 compiler->GenerateStaticCall(instance_call()->cid(),
1642 instance_call()->token_index(),
1643 instance_call()->try_index(),
1644 *targets()[0],
1645 instance_call()->ArgumentCount(),
1646 instance_call()->argument_names());
1647 }
1648 __ Bind(&done);
1649 }
1650
1603 } // namespace dart 1651 } // namespace dart
1604 1652
1605 #undef __ 1653 #undef __
1606 1654
1607 #endif // defined TARGET_ARCH_X64 1655 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/opt_code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698