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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 8675)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -1600,6 +1600,54 @@
}
+LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const {
+ return MakeCallSummary();
+}
+
+
+void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
+ ASSERT(instance_call()->VerifyComputation());
+ ASSERT(class_ids().length() == targets().length());
+ ASSERT(class_ids().length() > 0);
+ Label* deopt = compiler->AddDeoptStub(instance_call()->cid(),
+ instance_call()->token_index(),
+ instance_call()->try_index(),
+ kDeoptPolymorphicInstanceCallTestFail);
+ Label handle_smi;
+ Label* is_smi_label = class_ids()[0] == kSmi ? &handle_smi : deopt;
+ // Load receiver into RAX.
+ __ movq(RAX,
+ Address(RSP, (instance_call()->ArgumentCount() - 1) * kWordSize));
+ __ testq(RAX, Immediate(kSmiTagMask));
+ __ j(ZERO, is_smi_label);
+ Label done;
+ __ LoadClassId(RDI, RAX);
+ for (intptr_t i = 0; i < class_ids().length(); i++) {
+ Label next_test;
+ __ cmpq(RDI, Immediate(class_ids()[i]));
+ __ j(NOT_EQUAL, &next_test);
+ compiler->GenerateStaticCall(instance_call()->cid(),
+ instance_call()->token_index(),
+ instance_call()->try_index(),
+ *targets()[i],
+ instance_call()->ArgumentCount(),
+ instance_call()->argument_names());
+ __ jmp(&done);
+ __ Bind(&next_test);
+ }
+ __ jmp(deopt);
+ if (is_smi_label == &handle_smi) {
+ __ Bind(&handle_smi);
+ compiler->GenerateStaticCall(instance_call()->cid(),
+ instance_call()->token_index(),
+ instance_call()->try_index(),
+ *targets()[0],
+ instance_call()->ArgumentCount(),
+ instance_call()->argument_names());
+ }
+ __ Bind(&done);
+}
+
} // namespace dart
#undef __
« 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