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

Unified Diff: runtime/vm/simulator_dbc.cc

Issue 2962353003: Implement Dart VM option '--trace_sim_after' in DBC simulator (Closed)
Patch Set: 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
« runtime/vm/simulator_dbc.h ('K') | « 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..12423cac0a067e4c8b7dc35f2fc2728b161d80f9 100644
--- a/runtime/vm/simulator_dbc.cc
+++ b/runtime/vm/simulator_dbc.cc
@@ -529,7 +529,7 @@ void Simulator::InitOnce() {
}
-Simulator::Simulator() : stack_(NULL), fp_(NULL) {
+Simulator::Simulator() : stack_(NULL), fp_(NULL), icount_(0) {
// Setup simulator support first. Some of this information is needed to
// setup the architecture state.
// We allocate the stack here, the size is computed as the sum of
@@ -575,6 +575,24 @@ uword Simulator::StackTop() const {
}
+// 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");
+ }
+}
+
+
// Calls into the Dart runtime are based on this interface.
typedef void (*SimulatorRuntimeCall)(NativeArguments arguments);
@@ -984,12 +1002,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
+
// 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)
« runtime/vm/simulator_dbc.h ('K') | « runtime/vm/simulator_dbc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698