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

Unified Diff: runtime/vm/simulator_dbc.cc

Issue 2962353003: Implement Dart VM option '--trace_sim_after' in DBC simulator (Closed)
Patch Set: fixes for review comments Created 3 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/simulator_dbc.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/simulator_dbc.cc
diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc
index afb5487f7b648781c6d84937682f9aff3616295b..028a3e0a40ca1753d6f007900e32547e2296c3f8 100644
--- a/runtime/vm/simulator_dbc.cc
+++ b/runtime/vm/simulator_dbc.cc
@@ -542,6 +542,8 @@ Simulator::Simulator() : stack_(NULL), fp_(NULL) {
sizeof(uintptr_t)];
last_setjmp_buffer_ = NULL;
top_exit_frame_info_ = 0;
+
+ NOT_IN_PRODUCT(icount_ = 0;)
}
@@ -574,6 +576,24 @@ uword Simulator::StackTop() const {
(OSThread::GetSpecifiedStackSize() + OSThread::kStackSizeBuffer);
}
zra 2017/06/30 22:08:42 Two newlines between functions in source files.
alexmarkov 2017/06/30 23:02:00 Done.
+#if !defined(PRODUCT)
+// Returns true if tracing of executed instructions is enabled.
+DART_FORCE_INLINE bool Simulator::IsTracingExecution() const {
+ return icount_ > FLAG_trace_sim_after;
+}
+
+
+// Prints bytecode instruction at given pc for instruction tracing.
+DART_NOINLINE void Simulator::TraceInstruction(uint32_t* pc) const {
+ THR_Print("%" Pu64 " ", icount_);
+ if (FLAG_support_disassembler) {
+ Disassembler::Disassemble(reinterpret_cast<uword>(pc),
+ reinterpret_cast<uword>(pc + 1));
+ } else {
+ THR_Print("Disassembler not supported in this mode.\n");
+ }
+}
+#endif // !defined(PRODUCT)
zra 2017/06/30 22:08:41 ditto
alexmarkov 2017/06/30 23:02:00 Done.
// Calls into the Dart runtime are based on this interface.
typedef void (*SimulatorRuntimeCall)(NativeArguments arguments);
@@ -984,12 +1004,24 @@ static DART_NOINLINE bool InvokeNativeAutoScopeWrapper(Thread* thread,
// Note: all macro helpers are intended to be used only inside Simulator::Call.
+// Counts and prints executed bytecode instructions (in a non-PRODUCT mode).
+#if !defined(PRODUCT)
+#define TRACE_INSTRUCTION \
+ icount_++; \
+ if (IsTracingExecution()) { \
+ TraceInstruction(pc - 1); \
+ }
+#else
+#define TRACE_INSTRUCTION
+#endif // !defined(PRODUCT)
+
// Decode opcode and A part of the given value and dispatch to the
// corresponding bytecode handler.
#define DISPATCH_OP(val) \
do { \
op = (val); \
rA = ((op >> 8) & 0xFF); \
+ TRACE_INSTRUCTION \
goto* dispatch[op & 0xFF]; \
} while (0)
« no previous file with comments | « runtime/vm/simulator_dbc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698