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

Unified Diff: src/ia32/code-stubs-ia32.cc

Issue 10706002: Implements a new API to set a function entry hook for profiling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Sketch ARM code stub. 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
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index afa3e1c568bdfadbe9e3feb88d51b2efaa56118a..302062500c0d3f5168193d2084f897bb4ef27b2f 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -7474,6 +7474,46 @@ void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) {
__ ret(0);
}
+
+void ProfileEntryHookStub::Generate(MacroAssembler* masm) {
+ // Grab the cycle counter immediately.
+ __ db(0x0F); // rdtsc();
danno 2012/07/10 09:37:13 Any reason to not add this to assembler-ia32.h?
Sigurður Ásgeirsson 2012/07/11 14:50:34 This is already in the assembler, but under a cond
+ __ db(0x31);
+
+ // Ecx is the only volatile register we must save.
+ __ push(ecx);
+
+ // Push the cycle time arg.
+ __ push(edx);
+ __ push(eax);
+
+ // Calculate and push the original stack pointer.
+ __ lea(eax, Operand(esp, 0xC));
danno 2012/07/10 09:37:13 Constants? (maybe from frame-ia32.h, also applies
Sigurður Ásgeirsson 2012/07/11 14:50:34 Done.
+ __ push(eax);
+
+ // Calculate and push the function address.
+ __ mov(eax, Operand(eax, 0));
+ __ sub(eax, Immediate(5));
danno 2012/07/10 09:37:13 constant?
Sigurður Ásgeirsson 2012/07/11 14:50:34 Done.
+ __ push(eax);
+
+ // Call the entry hook.
+ int32_t hook_location =
+ reinterpret_cast<int32_t>(V8::GetFunctionEntryHookLocation());
+ __ call(Operand(hook_location, RelocInfo::NONE));
+ __ add(esp, Immediate(0x10));
+
+ // Restore ecx.
+ __ pop(ecx);
+ __ ret(0);
+}
+
+
+void ProfileEntryHookStub::GenerateAheadOfTime() {
+ ProfileEntryHookStub stub;
+ Handle<Code> code = stub.GetCode();
+ code->set_is_pregenerated(true);
+}
+
#undef __
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698