Skip to content

Commit

Permalink
Don't convert traceFnCall args to a PersistentVector
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmonettas committed Jan 30, 2024
1 parent 9d86fc3 commit 3e9022d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Instructions here apply to ClojureStorm >= `1.11.1-19` and `1.12.0-alpha4_14`
```clojure
(clojure.storm.Tracer/setTraceFnsCallbacks
{:trace-fn-call-fn (fn [_ fn-ns fn-name fn-args-vec form-id]
(prn "fn-call " fn-ns fn-name fn-args-vec form-id))
(prn "fn-call " fn-ns fn-name (into [] fn-args-vec) form-id))
:trace-fn-return-fn (fn [_ ret coord form-id]
(prn "fn-return" ret coord form-id))
:trace-fn-unwind-fn (fn [_ throwable coord form-id]
Expand Down
9 changes: 2 additions & 7 deletions src/jvm/clojure/storm/Emitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,13 @@ public static Label emitFnPrologue(GeneratorAdapter gen, ObjExpr objx, String mu
String fnName = name.getName();
String fnNs = name.getNamespace();

// push all the args array on the stack and then
// create a immutable vector
// TODO: is there a benefit on creating a PersistentVector here?
// Since this array isn't going to be mutated anyway, so we will be paying
// the perf cost for no reason
// push all the args array on the stack and then
gen.loadArgArray();
gen.invokeStatic(Type.getType(clojure.lang.PersistentVector.class), Method.getMethod("clojure.lang.PersistentVector create(Object[])"));

gen.push(fnNs); // push the function namespace
gen.push(fnName); // push the function name
gen.push((int)formId); // push the form-id
gen.invokeStatic(TRACER_CLASS_TYPE, Method.getMethod("void traceFnCall(clojure.lang.IPersistentVector, String, String, int)")); // trace the function call
gen.invokeStatic(TRACER_CLASS_TYPE, Method.getMethod("void traceFnCall(Object[], String, String, int)")); // trace the function call

// emit binds for all function's arguments
emitBindTraces(gen, objx, arglocals, PersistentVector.EMPTY);
Expand Down
2 changes: 1 addition & 1 deletion src/jvm/clojure/storm/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void handleThreadException(Thread thread, Throwable ex) {
handleExceptionFn.invoke(thread, ex);
}

static public void traceFnCall(IPersistentVector fnArgs, String fnNs, String fnName, int formId) {
static public void traceFnCall(Object[] fnArgs, String fnNs, String fnName, int formId) {
if (traceFnCallFn != null)
traceFnCallFn.invoke(null, fnNs, fnName, fnArgs, formId);
}
Expand Down

0 comments on commit 3e9022d

Please sign in to comment.