Skip to content

Commit 033a2e4

Browse files
don't "re-get" some scopes if they don't change across frames
1 parent 84d5ba6 commit 033a2e4

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

luceedebug/src/main/java/luceedebug/coreinject/DebugManager.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import luceedebug.IDebugManager;
3535
import luceedebug.coreinject.frame.DebugFrame;
3636
import luceedebug.coreinject.frame.Frame;
37+
import luceedebug.coreinject.frame.Frame.FrameContext;
3738

3839
public class DebugManager implements IDebugManager {
3940

@@ -699,7 +700,17 @@ private DebugFrame maybe_pushCfFrame_worker(PageContext pageContext, String sour
699700

700701
final int depth = stack.size(); // first frame is frame 0, and prior to pushing the first frame the stack is length 0; next frame is frame 1, and prior to pushing it the stack is of length 1, ...
701702

702-
final DebugFrame frame = DebugFrame.makeFrame(sourceFilePath, depth, valTracker, pageContext);
703+
FrameContext maybeBaseFrame = stack.size() == 0
704+
? null
705+
: stack.get(0) instanceof Frame ? ((Frame)stack.get(0)).getFrameContext() : null;
706+
707+
final DebugFrame frame = DebugFrame.makeFrame(
708+
sourceFilePath,
709+
depth,
710+
valTracker,
711+
pageContext,
712+
maybeBaseFrame
713+
);
703714

704715
stack.add(frame);
705716

luceedebug/src/main/java/luceedebug/coreinject/frame/DebugFrame.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import lucee.runtime.PageContext;
44
import luceedebug.IDebugFrame;
55
import luceedebug.coreinject.ValTracker;
6+
import luceedebug.coreinject.frame.Frame.FrameContext;
67

78
/**
89
* Should be a sealed class, subtypes are:
@@ -19,14 +20,14 @@ public abstract class DebugFrame implements IDebugFrame {
1920
// and if so, we just return some dummy frame which is guranteed to NOT schedule more work.
2021
static private ThreadLocal<Boolean> isPushingFrame = ThreadLocal.withInitial(() -> false);
2122

22-
static public DebugFrame makeFrame(String sourceFilePath, int depth, ValTracker valTracker, PageContext pageContext) {
23+
static public DebugFrame makeFrame(String sourceFilePath, int depth, ValTracker valTracker, PageContext pageContext, FrameContext root) {
2324
if (isPushingFrame.get()) {
2425
return DummyFrame.get();
2526
}
2627
else {
2728
try {
2829
isPushingFrame.set(true);
29-
return new Frame(sourceFilePath, depth, valTracker, pageContext);
30+
return new Frame(sourceFilePath, depth, valTracker, pageContext, root);
3031
}
3132
finally {
3233
isPushingFrame.set(false);

luceedebug/src/main/java/luceedebug/coreinject/frame/Frame.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ public static class FrameContext {
109109
// expensive exceptions on literally every frame, e.g. if a scope is disabled by the engine and trying to touch it
110110
// throws an ExpressionException.
111111
//
112-
private FrameContext(PageContext pageContext) {
112+
private FrameContext(PageContext pageContext, FrameContext root) {
113113
this.pageContext = pageContext;
114-
this.application = getScopelikeOrNull(() -> pageContext.applicationScope());
114+
this.application = root != null ? root.application : getScopelikeOrNull(() -> pageContext.applicationScope());
115115
this.arguments = getScopelikeOrNull(() -> pageContext.argumentsScope());
116-
this.form = getScopelikeOrNull(() -> pageContext.formScope());
116+
this.form = root != null ? root.form : getScopelikeOrNull(() -> pageContext.formScope());
117117
this.local = getScopelikeOrNull(() -> pageContext.localScope());
118-
this.request = getScopelikeOrNull(() -> pageContext.requestScope());
119-
this.session = getScopelikeOrNull(() -> pageContext.getApplicationContext().isSetSessionManagement() ? pageContext.sessionScope() : null);
120-
this.server = getScopelikeOrNull(() -> pageContext.serverScope());
121-
this.url = getScopelikeOrNull(() -> pageContext.urlScope());
118+
this.request = root != null ? root.request : getScopelikeOrNull(() -> pageContext.requestScope());
119+
this.session = root != null ? root.session : getScopelikeOrNull(() -> pageContext.getApplicationContext().isSetSessionManagement() ? pageContext.sessionScope() : null);
120+
this.server = root != null ? root.server : getScopelikeOrNull(() -> pageContext.serverScope());
121+
this.url = root != null ? root.url : getScopelikeOrNull(() -> pageContext.urlScope());
122122
this.variables = getScopelikeOrNull(() -> pageContext.variablesScope());
123123
this.this_ = getScopelikeOrNull(() -> {
124124
// there is also `PageContextImpl.thisGet()` but it can create a `this` property on the variables scope, which seems like
@@ -222,12 +222,12 @@ public <T> T doWorkInThisFrame(Supplier<T> f) {
222222
}
223223
}
224224

225-
Frame(String sourceFilePath, int depth, ValTracker valTracker, PageContext pageContext) {
226-
this(sourceFilePath, depth, valTracker, pageContext, Frame.tryGetFrameName(pageContext));
225+
Frame(String sourceFilePath, int depth, ValTracker valTracker, PageContext pageContext, FrameContext root) {
226+
this(sourceFilePath, depth, valTracker, pageContext, Frame.tryGetFrameName(pageContext), root);
227227
}
228228

229-
private Frame(String sourceFilePath, int depth, ValTracker valTracker, PageContext pageContext, String name) {
230-
this.frameContext_ = new FrameContext(pageContext);
229+
private Frame(String sourceFilePath, int depth, ValTracker valTracker, PageContext pageContext, String name, FrameContext root) {
230+
this.frameContext_ = new FrameContext(pageContext, root);
231231
this.sourceFilePath = Objects.requireNonNull(sourceFilePath);
232232
this.valTracker = Objects.requireNonNull(valTracker);
233233
this.id = nextId.incrementAndGet();

0 commit comments

Comments
 (0)