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

Unified Diff: runtime/vm/code_patcher_ia32.cc

Issue 1294113004: VM: Link native calls lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 years, 4 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/code_patcher_arm64.cc ('k') | runtime/vm/code_patcher_mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_patcher_ia32.cc
diff --git a/runtime/vm/code_patcher_ia32.cc b/runtime/vm/code_patcher_ia32.cc
index 08c7caf03b2ac44ea8bf3d027643369ed5393084..95d64e08e59c73a8175017f3b67af494df5627e5 100644
--- a/runtime/vm/code_patcher_ia32.cc
+++ b/runtime/vm/code_patcher_ia32.cc
@@ -44,6 +44,8 @@ class UnoptimizedCall : public ValueObject {
void set_target(uword target) const {
uword* target_addr = reinterpret_cast<uword*>(call_address() + 1);
uword offset = target - return_address();
+ WritableInstructionsScope writable(reinterpret_cast<uword>(target_addr),
+ sizeof(offset));
*target_addr = offset;
CPU::FlushICache(call_address(), kInstructionSize);
}
@@ -64,11 +66,33 @@ class UnoptimizedCall : public ValueObject {
return start_ + 1 * kInstructionSize;
}
+ protected:
uword start_;
+
+ private:
DISALLOW_IMPLICIT_CONSTRUCTORS(UnoptimizedCall);
};
+class NativeCall : public UnoptimizedCall {
+ public:
+ explicit NativeCall(uword return_address) : UnoptimizedCall(return_address) {
+ }
+
+ NativeFunction native_function() const {
+ return *reinterpret_cast<NativeFunction*>(start_ + 1);
+ }
+
+ void set_native_function(NativeFunction func) const {
+ WritableInstructionsScope writable(start_ + 1, sizeof(func));
+ *reinterpret_cast<NativeFunction*>(start_ + 1) = func;
+ }
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(NativeCall);
+};
+
+
class InstanceCall : public UnoptimizedCall {
public:
explicit InstanceCall(uword return_address)
@@ -210,6 +234,28 @@ RawFunction* CodePatcher::GetUnoptimizedStaticCallAt(
}
+void CodePatcher::PatchNativeCallAt(uword return_address,
+ const Code& code,
+ NativeFunction target,
+ const Code& trampoline) {
+ ASSERT(code.ContainsInstructionAt(return_address));
+ NativeCall call(return_address);
+ call.set_target(trampoline.EntryPoint());
+ call.set_native_function(target);
+}
+
+
+uword CodePatcher::GetNativeCallAt(uword return_address,
+ const Code& code,
+ NativeFunction* target) {
+ ASSERT(code.ContainsInstructionAt(return_address));
+ NativeCall call(return_address);
+ *target = call.native_function();
+ return call.target();
+}
+
+
+
intptr_t CodePatcher::InstanceCallSizeInBytes() {
return InstanceCall::kNumInstructions * InstanceCall::kInstructionSize;
}
« no previous file with comments | « runtime/vm/code_patcher_arm64.cc ('k') | runtime/vm/code_patcher_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698