* src/vm/jit/trace.cpp: Method tracer can now trace builtin functions as well.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Sun, 2 Aug 2009 12:13:17 +0000 (14:13 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Sun, 2 Aug 2009 12:13:17 +0000 (14:13 +0200)
* src/vm/jit/codegen-common.cpp: Some minor adaption to allow above change.
* src/vm/options.c (opt_TraceBuiltinCalls): Added new tracer option.
* src/vm/options.h (opt_TraceBuiltinCalls): Likewise.

src/vm/jit/codegen-common.cpp
src/vm/jit/trace.cpp
src/vm/options.c
src/vm/options.h

index d6334aeb2216e228b074ba1fa88dab8139e0bab3..a6f80b60f3213e2653570fbfdae64fefd24965fa 100644 (file)
@@ -803,7 +803,7 @@ java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv)
        /* print the call-trace if necesarry */
        /* BEFORE: filling the local reference table */
 
-       if (opt_TraceJavaCalls)
+       if (opt_TraceJavaCalls || opt_TraceBuiltinCalls)
                trace_java_call_enter(m, arg_regs, arg_stack);
 # endif
 #endif
@@ -933,7 +933,7 @@ java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv)
        /* print the call-trace if necesarry */
        /* AFTER: unwrapping the return value */
 
-       if (opt_TraceJavaCalls)
+       if (opt_TraceJavaCalls || opt_TraceBuiltinCalls)
                trace_java_call_exit(m, ret_regs);
 # endif
 #endif
index f6dd77abae0d6f6d036637b0940cdd7beefb8adc..d515db09c5750a683cc6d7fd7867e3f18308c1a5 100644 (file)
@@ -203,17 +203,22 @@ void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack)
        s4          i;
        s4          pos;
 
-       /* We don't trace builtin functions here because the argument
-          passing happens via the native ABI and does not fit these
-          functions. */
-
-       if (method_is_builtin(m))
-               return;
+       /* We can only trace "slow" builtin functions (those with a stub)
+        * here, because the argument passing of "fast" ones happens via
+        * the native ABI and does not fit these functions. */
 
+       if (method_is_builtin(m)) {
+               if (!opt_TraceBuiltinCalls)
+                       return;
+       }
+       else {
+               if (!opt_TraceJavaCalls)
+                       return;
 #if defined(ENABLE_DEBUG_FILTER)
-       if (!show_filters_test_verbosecall_enter(m))
-               return;
+               if (!show_filters_test_verbosecall_enter(m))
+                       return;
 #endif
+       }
 
 #if defined(ENABLE_VMLOG)
        vmlog_cacao_enter_method(m);
@@ -334,17 +339,22 @@ void trace_java_call_exit(methodinfo *m, uint64_t *return_regs)
        s4          pos;
        imm_union   val;
 
-       /* We don't trace builtin functions here because the argument
-          passing happens via the native ABI and does not fit these
-          functions. */
-
-       if (method_is_builtin(m))
-               return;
+       /* We can only trace "slow" builtin functions (those with a stub)
+        * here, because the argument passing of "fast" ones happens via
+        * the native ABI and does not fit these functions. */
 
+       if (method_is_builtin(m)) {
+               if (!opt_TraceBuiltinCalls)
+                       return;
+       }
+       else {
+               if (!opt_TraceJavaCalls)
+                       return;
 #if defined(ENABLE_DEBUG_FILTER)
-       if (!show_filters_test_verbosecall_exit(m))
-               return;
+               if (!show_filters_test_verbosecall_exit(m))
+                       return;
 #endif
+       }
 
 #if defined(ENABLE_VMLOG)
        vmlog_cacao_leave_method(m);
index 861713a62018b4ff02397563cd66be7d5fe9f815..dc73d2ff1997600c9a78aa2381820dd2788b7b30 100644 (file)
@@ -198,6 +198,7 @@ int      opt_RegallocSpillAll             = 0;
 #if defined(ENABLE_REPLACEMENT)
 int      opt_TestReplacement              = 0;
 #endif
+int      opt_TraceBuiltinCalls            = 0;
 int      opt_TraceCompilerCalls           = 0;
 int      opt_TraceExceptions              = 0;
 int      opt_TraceHPI                     = 0;
@@ -262,6 +263,7 @@ enum {
        OPT_ProfileMemoryUsageGNUPlot,
        OPT_RegallocSpillAll,
        OPT_TestReplacement,
+       OPT_TraceBuiltinCalls,
        OPT_TraceCompilerCalls,
        OPT_TraceExceptions,
        OPT_TraceHPI,
@@ -333,6 +335,7 @@ option_t options_XX[] = {
 #if defined(ENABLE_REPLACEMENT)
        { "TestReplacement",              OPT_TestReplacement,              OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" },
 #endif
+       { "TraceBuiltinCalls",            OPT_TraceBuiltinCalls,            OPT_TYPE_BOOLEAN, "trace calls to VM builtin functions" },
        { "TraceCompilerCalls",           OPT_TraceCompilerCalls,           OPT_TYPE_BOOLEAN, "trace JIT compiler calls" },
        { "TraceExceptions",              OPT_TraceExceptions,              OPT_TYPE_BOOLEAN, "trace Exception throwing" },
        { "TraceHPI",                     OPT_TraceHPI,                     OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" },
@@ -791,6 +794,10 @@ void options_xx(JavaVMInitArgs *vm_args)
                        break;
 #endif
 
+               case OPT_TraceBuiltinCalls:
+                       opt_TraceBuiltinCalls = enable;
+                       break;
+
                case OPT_TraceCompilerCalls:
                        opt_TraceCompilerCalls = enable;
                        break;
index 1c653351e8c7cf650371099384409dee36c81348..9a232a0246c54060e1784cb4e49baa6dc38a9620 100644 (file)
@@ -220,6 +220,7 @@ extern int      opt_RegallocSpillAll;
 #if defined(ENABLE_REPLACEMENT)
 extern int      opt_TestReplacement;
 #endif
+extern int      opt_TraceBuiltinCalls;
 extern int      opt_TraceCompilerCalls;
 extern int      opt_TraceExceptions;
 extern int      opt_TraceHPI;