Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clean blocks with dead context on debugger #15153

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Kernel-BytecodeEncoders/EncoderForSistaV1.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ EncoderForSistaV1 class >> isCreateBlockAt: pc in: method [

| byte |
byte := self nonExtensionBytecodeAt: pc in: method.
^ byte = 250
^ byte = 250 or: [
(method sourceNodeForPC: pc) in: [ :node | "Clean blocks are created as PushConstant"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falling back to the AST here is not that nice as it breaks the abstraction (the idea is that the bytecode level abstractions should be usable without the AST). But we could merge it for now and improve later, this is used only the the debugger which needs the AST anyway.

node isBlock and: [ node isClean ] ] ]
]

{ #category : 'block closure support' }
Expand Down
21 changes: 18 additions & 3 deletions src/Kernel/Context.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,21 @@ Context >> cut: aContext [
callee privSender: nil
]

{ #category : 'accessing' }
Context >> deadContextForClosure: closure [

| outerMethod |
outerMethod := closure literalAt: closure literals size + 1.

^ (self class
sender: self
receiver: nil
method: outerMethod
arguments: { })
pc: nil;
yourself
]

{ #category : 'printing' }
Context >> debugStack: stackSize on: aStream [
"print a condensed version of the stack up to stackSize on aStream"
Expand Down Expand Up @@ -925,9 +940,9 @@ Context >> home [

closureOrNil ifNil: [ ^ self ].
"this happens for clean blocks, we try to find the home on the stack"
^ closureOrNil outerContext
ifNil: [ self activeHome ]
ifNotNil: [:outer | outer home ]
^ closureOrNil outerContext
ifNil: [ self activeHome ifNil: [ self deadContextForClosure: self method ] ]
ifNotNil: [ :outer | outer home ]
]

{ #category : 'accessing' }
Expand Down
5 changes: 4 additions & 1 deletion src/OpalCompiler-Core/CompiledBlock.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ CompiledBlock >> sourceNode [

{ #category : '*OpalCompiler-Core' }
CompiledBlock >> sourceNodeForPC: aPC [

| blockNode |
blockNode := self outerCode sourceNodeForPC: self pcInOuter.
^blockNode sourceNodeForPC: aPC
"Bug in the cache? The mapping is returning Return node instead of Block"
MarcusDenker marked this conversation as resolved.
Show resolved Hide resolved
blockNode isReturn ifTrue: [ blockNode := blockNode value ].
^ blockNode sourceNodeForPC: aPC
]

{ #category : '*OpalCompiler-Core' }
Expand Down