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

Unified Diff: runtime/vm/intermediate_language_arm.cc

Issue 12629004: Implement native call stub on ARM and native call redirection in ARM simulator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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/flow_graph_compiler_arm.cc ('k') | runtime/vm/runtime_entry_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_arm.cc
===================================================================
--- runtime/vm/intermediate_language_arm.cc (revision 19698)
+++ runtime/vm/intermediate_language_arm.cc (working copy)
@@ -13,6 +13,7 @@
#include "vm/locations.h"
#include "vm/object_store.h"
#include "vm/parser.h"
+#include "vm/simulator.h"
#include "vm/stub_code.h"
#include "vm/symbols.h"
@@ -191,13 +192,46 @@
LocationSummary* NativeCallInstr::MakeLocationSummary() const {
- UNIMPLEMENTED();
- return NULL;
+ const intptr_t kNumInputs = 0;
+ const intptr_t kNumTemps = 3;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
+ locs->set_temp(0, Location::RegisterLocation(R1));
+ locs->set_temp(1, Location::RegisterLocation(R2));
+ locs->set_temp(2, Location::RegisterLocation(R5));
+ locs->set_out(Location::RegisterLocation(R0));
+ return locs;
}
void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ ASSERT(locs()->temp(0).reg() == R1);
+ ASSERT(locs()->temp(1).reg() == R2);
+ ASSERT(locs()->temp(2).reg() == R5);
+ Register result = locs()->out().reg();
+
+ // Push the result place holder initialized to NULL.
+ __ PushObject(Object::ZoneHandle());
+ // Pass a pointer to the first argument in R2.
+ if (!function().HasOptionalParameters()) {
+ __ AddImmediate(R2, FP, (2 + function().NumParameters()) * kWordSize);
+ } else {
+ __ AddImmediate(R2, FP, ParsedFunction::kFirstLocalSlotIndex * kWordSize);
+ }
+ // Compute the effective address. When running under the simulator,
+ // this is a redirection address that forces the simulator to call
+ // into the runtime system.
+ uword entry = reinterpret_cast<uword>(native_c_function());
+#if defined(USING_SIMULATOR)
+ entry = Simulator::RedirectExternalReference(entry, Simulator::kNativeCall);
+#endif
+ __ LoadImmediate(R5, entry);
+ __ LoadImmediate(R1, NativeArguments::ComputeArgcTag(function()));
+ compiler->GenerateCall(token_pos(),
+ &StubCode::CallNativeCFunctionLabel(),
+ PcDescriptors::kOther,
+ locs());
+ __ Pop(result);
}
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm.cc ('k') | runtime/vm/runtime_entry_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698