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

Unified Diff: runtime/vm/code_patcher_ia32.cc

Issue 11783066: Optimize function at its entry instead of at exit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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.cc ('k') | runtime/vm/code_patcher_x64.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
===================================================================
--- runtime/vm/code_patcher_ia32.cc (revision 16874)
+++ runtime/vm/code_patcher_ia32.cc (working copy)
@@ -160,69 +160,15 @@
}
-static void SwapCode(intptr_t num_bytes, char* a, char* b) {
- for (intptr_t i = 0; i < num_bytes; i++) {
- char tmp = *a;
- *a = *b;
- *b = tmp;
- a++;
- b++;
- }
-}
-
-// The patch code buffer contains the jmp code which will be inserted at
-// entry point.
-void CodePatcher::PatchEntry(const Code& code) {
- JumpPattern jmp_entry(code.EntryPoint());
- ASSERT(!jmp_entry.IsValid());
- const uword patch_buffer = code.GetPatchCodePc();
- ASSERT(patch_buffer != 0);
- JumpPattern jmp_patch(patch_buffer);
- ASSERT(jmp_patch.IsValid());
- const uword jump_target = jmp_patch.TargetAddress();
- SwapCode(jmp_patch.pattern_length_in_bytes(),
- reinterpret_cast<char*>(code.EntryPoint()),
- reinterpret_cast<char*>(patch_buffer));
- jmp_entry.SetTargetAddress(jump_target);
+void CodePatcher::InsertCallAt(uword start, uword target) {
+ *reinterpret_cast<uint8_t*>(start) = 0xE8;
+ CallPattern call(start);
+ call.SetTargetAddress(target);
+ CPU::FlushICache(start, CallPattern::InstructionLength());
}
-// The entry point is a jmp instruction, the patch code buffer contains
-// original code, the entry point contains the jump instruction.
-void CodePatcher::RestoreEntry(const Code& code) {
- JumpPattern jmp_entry(code.EntryPoint());
- ASSERT(jmp_entry.IsValid());
- const uword jump_target = jmp_entry.TargetAddress();
- const uword patch_buffer = code.GetPatchCodePc();
- ASSERT(patch_buffer != 0);
- // 'patch_buffer' contains original entry code.
- JumpPattern jmp_patch(patch_buffer);
- ASSERT(!jmp_patch.IsValid());
- SwapCode(jmp_patch.pattern_length_in_bytes(),
- reinterpret_cast<char*>(code.EntryPoint()),
- reinterpret_cast<char*>(patch_buffer));
- ASSERT(jmp_patch.IsValid());
- jmp_patch.SetTargetAddress(jump_target);
-}
-
-
-bool CodePatcher::CodeIsPatchable(const Code& code) {
- JumpPattern jmp_entry(code.EntryPoint());
- if (code.Size() < (jmp_entry.pattern_length_in_bytes() * 2)) {
- return false;
- }
- uword limit = code.EntryPoint() + jmp_entry.pattern_length_in_bytes();
- for (intptr_t i = 0; i < code.pointer_offsets_length(); i++) {
- const uword addr = code.GetPointerOffsetAt(i) + code.EntryPoint();
- if (addr < limit) {
- return false;
- }
- }
- return true;
-}
-
-
bool CodePatcher::IsDartCall(uword return_address) {
return DartCallPattern::IsValid(return_address);
}
@@ -246,15 +192,6 @@
return DartCallPattern::kNumInstructions * DartCallPattern::kInstructionSize;
}
-
-void CodePatcher::InsertCallAt(uword start, uword target) {
- *reinterpret_cast<uint8_t*>(start) = 0xE8;
- CallPattern call(start);
- call.SetTargetAddress(target);
- CPU::FlushICache(start, CallPattern::InstructionLength());
-}
-
-
} // namespace dart
#endif // defined TARGET_ARCH_IA32
« no previous file with comments | « runtime/vm/code_patcher.cc ('k') | runtime/vm/code_patcher_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698