Skip to content

Commit 82c8361

Browse files
committed
Fix let/loop bindings not being traced inside reify
1 parent 2628683 commit 82c8361

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,38 @@
33
## master (unreleased)
44

55
### New Features
6+
7+
### Changes
8+
9+
### Bugs fixed
10+
11+
## 1.12.0-4 (19-02-2025)
12+
13+
### New Features
14+
15+
### Changes
16+
17+
### Bugs fixed
18+
19+
- Fix let/loop bindings not being traced inside reify
20+
21+
## 1.12.0-3 (28-01-2025)
22+
23+
### New Features
24+
25+
### Changes
26+
27+
- Bring back instrumentation to the compile path to support decompiling for debugging
28+
29+
### Bugs fixed
30+
31+
## 1.12.0-2 (27-11-2024)
32+
33+
### New Features
34+
35+
### Changes
36+
37+
### Bugs fixed
638

739
- Trace most statements also
840

src/jvm/clojure/storm/Emitter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ public static void emitBindTrace(GeneratorAdapter gen, ObjExpr objx, BindingInit
369369
String symName = Compiler.demunge(bi.binding().name);
370370
Integer bIdx = bi.binding().idx;
371371

372-
if (objx instanceof FnExpr &&
373-
!skipInstrumentation(((FnExpr)objx).name()) &&
374-
coord != null &&
375-
!(symName.equals("-") || symName.contains("--"))) {
372+
if (((objx instanceof FnExpr && !skipInstrumentation(((FnExpr)objx).name())) || (objx instanceof NewInstanceExpr && !skipInstrumentation(((NewInstanceExpr)objx).name()))) &&
373+
coord != null &&
374+
(!(symName.equals("-") || symName.contains("--"))))
375+
{
376376

377377
Type valType = null;
378378
Class primc = Compiler.maybePrimitiveType(bi.init());
@@ -393,7 +393,8 @@ public static void emitBindTrace(GeneratorAdapter gen, ObjExpr objx, BindingInit
393393
public static void emitBindTraces(GeneratorAdapter gen, ObjExpr objx, IPersistentVector localBindings,
394394
IPersistentVector coord) {
395395

396-
if (bindInstrumentationEnable && objx instanceof FnExpr && !skipInstrumentation(((FnExpr) objx).name())) {
396+
if (bindInstrumentationEnable &&
397+
((objx instanceof FnExpr && !skipInstrumentation(((FnExpr) objx).name())) || (objx instanceof NewInstanceExpr && !skipInstrumentation(((NewInstanceExpr) objx).name())))) {
397398

398399
for (int i = 0; i < localBindings.count(); i++) {
399400

test/clojure/test_clojure/storm_bodies.clj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@
106106
[:fn-return 15 ""]]
107107
(u/capture)) "captured traces should match.")))
108108

109+
(deftest reified-let-test
110+
(let [r (b/reified-let)]
111+
(is (= 30 r) "function return should be right.")
112+
(is (= [[:fn-call "clojure.test-clojure.storm-test-code.bodies" "reified-let" [] 1131527981]
113+
[:fn-call "clojure.test-clojure.storm-test-code.bodies" "doit" [] 1131527981]
114+
[:bind "a" 10 "3,1,2,2"]
115+
[:bind "b" 20 "3,1,2,2"]
116+
[:expr-exec 10 "3,1,2,2,2,1"]
117+
[:expr-exec 20 "3,1,2,2,2,2"]
118+
[:expr-exec 30 "3,1,2,2,2"]
119+
[:expr-exec 30 "3,1,2,2"]
120+
[:fn-return 30 "3,1,2,0"]
121+
[:expr-exec 30 "3"]
122+
[:fn-return 30 ""]]
123+
(u/capture)) "captured traces should match.")))
124+
109125
(deftest case-test
110126
(let [r (b/casey :first)]
111127
(is (= 42 r) "function return should be right.")

test/clojure/test_clojure/storm_test_code/bodies.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434
z)]
3535
c))
3636

37+
(defprotocol PP
38+
(doit [_]))
39+
40+
(defn reified-let []
41+
(doit
42+
(reify PP
43+
(doit [_]
44+
(let [a 10
45+
b 20]
46+
(+ a b))))))
47+
3748
(defn casey [x]
3849
(case x
3950
:first (+ 40 2)

test/clojure/test_clojure/storm_types.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@
6464
(is (= [[:fn-call "clojure.test-clojure.storm-test-code.types" "area" [rect] 50784036]
6565
[:bind "r" rect ""]
6666
[:expr-exec rect "3,2,1,1"]
67+
[:bind "gclass" "clojure.test_clojure.storm_test_code.types.Rectangle" ""]
6768
[:expr-exec 2 "3,2,1"]
6869
[:expr-exec rect "3,2,2,1"]
70+
[:bind "gclass" "clojure.test_clojure.storm_test_code.types.Rectangle" ""]
6971
[:expr-exec 4 "3,2,2"]
7072
[:expr-exec 8 "3,2"]
7173
[:fn-return 8 ""]]

0 commit comments

Comments
 (0)