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

druidExitPoint does not work for meta-compilation of bytecodes #157

Open
PalumboN opened this issue Aug 22, 2024 · 0 comments · May be fixed by #161
Open

druidExitPoint does not work for meta-compilation of bytecodes #157

PalumboN opened this issue Aug 22, 2024 · 0 comments · May be fixed by #161
Labels
bug Something isn't working bytecode

Comments

@PalumboN
Copy link
Contributor

I found that the definition for pushNewArrayBytecode generated by Druid does not manage a border case well.

This bytecode need to instantiate an array, so there is a check using the objectMemory getScavengeThreshold to check if the new object fits in the new space:
https://github.com/pharo-project/pharo-vm/blob/eaa8ca205aa46fe79bd87dae2cb75244f67e743e/smalltalksrc/VMMaker/DruidJIT.class.st#L12691-L12695

The problem is that, after the comparison, there is a jump to the end of the bytecode in case of "not enough space".

This happen because the check in the interpreter uses druidExitPoint instrinsic.

	freeStart + numBytes > scavengeThreshold ifTrue: [
		self druidExitPoint.
		needGCFlag ifFalse: [self scheduleScavenge].
		self validateRoomInEdenOrDie: numBytes ].

But that intrinsic is implemented to work only with primitives:

DRMetaCompilerIRGenerator >> interpretDruidExitPointWith: aRBMethodNode [
| failure primitiveReturn returnState |
failure := self currentBasicBlock copy: 1.
self currentPrimitiveFailureCode: failure.
returnState := executionState copy.
primitiveReturn := returnState baseFrame.
primitiveReturn push: DRNullValue new. "Return something"
"Record that this execution stack did a method return
We will merge this one with other returned states when this method finishes"
primitiveReturn addDeferredReturnState: {
returnState.
(self addFrameReturn: primitiveReturn) }
]

That is why it is jumping at the end of the definition (for primitives, it is the way to "fail" and execute the fallback).

We need to merge druidExitPoint (for primitives) with druidForceIntepretation (for bytecodes).

@PalumboN PalumboN added bug Something isn't working bytecode labels Aug 22, 2024
@PalumboN PalumboN linked a pull request Dec 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bytecode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant