hpi-swa / trufflesqueak

A Squeak/Smalltalk VM and Polyglot Programming Environment for the GraalVM.
MIT License
286 stars 14 forks source link

Revise #new primitives #140

Open fniephaus opened 3 years ago

fniephaus commented 3 years ago

Both, SqueakObjectNewNode and the PrimNewNodes cache the receiverClass in some cases:

https://github.com/hpi-swa/trufflesqueak/blob/a0f1de39da15d304958b89b326b8dad177344e44/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/accessing/SqueakObjectNewNode.java#L74-L87

https://github.com/hpi-swa/trufflesqueak/blob/a0f1de39da15d304958b89b326b8dad177344e44/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/primitives/impl/StoragePrimitives.java#L182-L253

It may make sense to revise this to avoid cache duplication.

smarr commented 3 years ago

If you don't mind the hacky bits, this is how TruffleSOM integrates your #basicNew into a dispatch chain: https://github.com/SOM-st/TruffleSOM/pull/56/commits/d2f04f3bf3de79fb13176d6566cf331577a4f8bc

Specifically this for the standard dispatch, similar for super:

https://github.com/SOM-st/TruffleSOM/pull/56/commits/d2f04f3bf3de79fb13176d6566cf331577a4f8bc#diff-e6ba7b4ffc50689737a20f2121025ae11325e28b29cdf1c21f395c58d2522cc1R53-R69