Skip to content

Commit

Permalink
Remove handleException system which isn't needed after unwind trace
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmonettas committed Feb 1, 2024
1 parent eeb3791 commit 4d25aec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 42 deletions.
10 changes: 1 addition & 9 deletions src/clj/clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7058,15 +7058,7 @@ fails, attempts to require sym's namespace and retries."
{:added "1.1"
:static true}
[f]
(let [f (binding-conveyor-fn
(fn [& args]
(try
(apply f args)
(catch Throwable t
(clojure.storm.Tracer/handleThreadException
(Thread/currentThread)
t)
(throw t)))))
(let [f (binding-conveyor-fn f)
fut (.submit clojure.lang.Agent/soloExecutor ^Callable f)]
(reify
clojure.lang.IDeref
Expand Down
3 changes: 1 addition & 2 deletions src/clj/clojure/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ by default when a new command-line REPL is started."} repl-requires
(print value)
(catch Throwable e
(throw (ex-info nil {:clojure.error/phase :print-eval-result} e)))))))
(catch Throwable e
(clojure.storm.Tracer/handleThreadException (Thread/currentThread) e)
(catch Throwable e
(caught e)
(set! *e e))))]
(with-bindings
Expand Down
3 changes: 1 addition & 2 deletions src/jvm/clojure/lang/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ static void doRun(Action action){
}
catch(Throwable e)
{
Tracer.handleThreadException(Thread.currentThread(), e);
error = e;
error = e;
}

if(error == null)
Expand Down
2 changes: 1 addition & 1 deletion src/jvm/clojure/lang/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7358,7 +7358,7 @@ public static Object eval(Object form) {
if (ce instanceof CompilerException)
{
Throwable cause = ce.getCause();
if(cause != null && (cause.getMessage().equals("Method code too large!")))
if(cause != null && cause.getMessage() !=null && cause.getMessage().equals("Method code too large!"))
{
System.out.println("Method too large, re-evaluating without storm instrumentation.");
Var.pushThreadBindings(RT.map(Emitter.INSTRUMENTATION_ENABLE, false));
Expand Down
32 changes: 4 additions & 28 deletions src/jvm/clojure/storm/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,19 @@ public class Tracer {
private static IFn traceFnUnwindFn = null;
private static IFn traceExprFn = null;
private static IFn traceBindFn = null;
private static IFn handleExceptionFn = null;


// TODO: this are depracated, remove when it is safe
private static Keyword TRACE_FN_CALL_FN_KEY = Keyword.intern(null, "trace-fn-call-fn-key");
private static Keyword TRACE_FN_RETURN_FN_KEY = Keyword.intern(null, "trace-fn-return-fn-key");
private static Keyword TRACE_EXPR_FN_KEY = Keyword.intern(null, "trace-expr-fn-key");
private static Keyword TRACE_BIND_FN_KEY = Keyword.intern(null, "trace-bind-fn-key");
private static Keyword HANDLE_EXCEPTION_FN_KEY = Keyword.intern(null, "handle-exception-fn-key");


private static Keyword TRACE_FN_CALL_FN = Keyword.intern(null, "trace-fn-call-fn");
private static Keyword TRACE_FN_RETURN_FN = Keyword.intern(null, "trace-fn-return-fn");
private static Keyword TRACE_FN_UNWIND_FN = Keyword.intern(null, "trace-fn-unwind-fn");
private static Keyword TRACE_EXPR_FN = Keyword.intern(null, "trace-expr-fn");
private static Keyword TRACE_BIND_FN = Keyword.intern(null, "trace-bind-fn");
private static Keyword HANDLE_EXCEPTION_FN = Keyword.intern(null, "handle-exception-fn");

static
{
// For all new threads created
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
handleThreadException(t, e);
});

}

public static void handleThreadException(Thread thread, Throwable ex) {
if (handleExceptionFn != null)
handleExceptionFn.invoke(thread, ex);
}


static public void traceFnCall(Object[] fnArgs, String fnNs, String fnName, int formId) {
if (traceFnCallFn != null)
traceFnCallFn.invoke(null, fnNs, fnName, fnArgs, formId);
Expand Down Expand Up @@ -103,10 +86,7 @@ public static void setTraceFnsCallbacks(IPersistentMap callbacks) {

if (callbacks.valAt(TRACE_BIND_FN_KEY) != null)
traceBindFn = (IFn) callbacks.valAt(TRACE_BIND_FN_KEY);

if (callbacks.valAt(HANDLE_EXCEPTION_FN_KEY) != null)
handleExceptionFn = (IFn) callbacks.valAt(HANDLE_EXCEPTION_FN_KEY);


// New keys

if (callbacks.valAt(TRACE_FN_CALL_FN) != null)
Expand All @@ -123,10 +103,6 @@ public static void setTraceFnsCallbacks(IPersistentMap callbacks) {

if (callbacks.valAt(TRACE_BIND_FN) != null)
traceBindFn = (IFn) callbacks.valAt(TRACE_BIND_FN);

if (callbacks.valAt(HANDLE_EXCEPTION_FN) != null)
handleExceptionFn = (IFn) callbacks.valAt(HANDLE_EXCEPTION_FN);


}

Expand Down

0 comments on commit 4d25aec

Please sign in to comment.