VM Maker: VMMaker.oscog-eem.2855.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMaker.oscog-eem.2855.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2855.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.2855
Author: eem
Time: 26 October 2020, 10:49:35.24822 pm
UUID: 0228f9ca-5807-4e90-a7b5-e1fe14caddb7
Ancestors: VMMaker.oscog-eem.2854

Add oopAt:[put:] support to Alien, needed for callbacks that exchange Smalltalk objects.  We need to discuss the security/safety implications, but the basic facility is essential for object-to-object interconnects such as JNI, and indeed Qwaq's PyBridge Python interconnect.

=============== Diff against VMMaker.oscog-eem.2854 ===============

Item was removed:
- ----- Method: IA32ABIPlugin>>isAlien: (in category 'private-support') -----
- isAlien: anOop
- <export: true>
- ^interpreterProxy
- includesBehavior: (interpreterProxy fetchClassOf: anOop)
- ThatOf: interpreterProxy classAlien!

Item was added:
+ ----- Method: IA32ABIPlugin>>primOopAt (in category 'primitives-accessing') -----
+ primOopAt
+ "Fetch an oop from 32 or 64 bits starting at the given byte offset (little endian)."
+ "THIS IS A HUGE SECURITY HOLE, BUT FULL CALLBACKS DEMAND IT"
+ "<Alien> oopAt: index <Integer> ^<Object>
+ <primitive: 'oopAtPut' error: errorCode module: 'IA32ABI'>"
+ | byteOffset rcvr startAddr addr |
+ <export: true>
+
+ byteOffset := (interpreterProxy stackPositiveMachineIntegerValue: 0) - 1.
+ rcvr := interpreterProxy stackObjectValue: 1.
+ interpreterProxy failed ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ (self index: byteOffset length: BytesPerOop inRange: rcvr) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadIndex].
+ (interpreterProxy isOopImmutable: rcvr) ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrNoModification].
+ (startAddr := self startOfData: rcvr) = 0 ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadReceiver].
+ addr := self cCoerce: startAddr + byteOffset to: #'sqInt *'.
+ "WE SHOULD DO VALIDATION HERE!!  FOR NOW WE PUNT, BUT THIS REALLY DOES REQUIRE A GOOD ANSWER!!!!"
+ ^interpreterProxy methodReturnValue: (addr at: 0)!

Item was added:
+ ----- Method: IA32ABIPlugin>>primOopAtPut (in category 'primitives-accessing') -----
+ primOopAtPut
+ "Store an oop into 32 or 64 bits starting at the given byte offset (little endian)."
+ "THIS IS A HUGE SECURITY HOLE, BUT FULL CALLBACKS DEMAND IT"
+ "<Alien> oopAt: index <Integer> put: value <Object> ^<Object>
+ <primitive: 'oopAtPut' error: errorCode module: 'IA32ABI'>"
+ | byteOffset rcvr startAddr addr oop |
+ <export: true>
+
+ oop := interpreterProxy stackValue: 0.
+ byteOffset := (interpreterProxy stackPositiveMachineIntegerValue: 1) - 1.
+ rcvr := interpreterProxy stackObjectValue: 2.
+ interpreterProxy failed ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ (self index: byteOffset length: BytesPerOop inRange: rcvr) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadIndex].
+ (interpreterProxy isOopImmutable: rcvr) ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrNoModification].
+ (startAddr := self startOfData: rcvr) = 0 ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadReceiver].
+ addr := self cCoerce: startAddr + byteOffset to: #'sqInt *'.
+ addr at: 0 put: oop.
+ ^interpreterProxy methodReturnValue: oop!

Item was removed:
- ----- Method: ThreadedFFIPlugin>>isAlien: (in category 'primitive support') -----
- isAlien: anOop
- ^interpreterProxy
- includesBehavior: (interpreterProxy fetchClassOf: anOop)
- ThatOf: interpreterProxy classAlien!