<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Clément,<br></div><div><br>On Jan 6, 2016, at 7:28 AM, Clément Bera <<a href="mailto:bera.clement@gmail.com">bera.clement@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><span></span></div></blockquote><blockquote type="cite"><div><div dir="ltr">Ok.<div><br></div><div>According to my attempts, Stack and Cog Simulators are working fine (both Spur and SqueakV3). However the VM compiled to C crashes while trying to assign a block into an instance variable.</div><div><br></div><div>So something is still wrong. <br></div></div></div></blockquote><div><br></div><span style="background-color: rgba(255, 255, 255, 0);">Is the crash with immutability enabled or disabled? One thing I can think of trying is to</span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">a) revert the package to pre immutability, simulate a REPL image until it prompts for input and copy the contents of the code zone to a byte array</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">b) revert the package back to immutability, with IMMUTABILITY disabled, simulate to the same point and look for differences in the code zone</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br>_,,,^..^,,,_ (phone)</span><div><br><blockquote type="cite"><div><div class="gmail_extra"><br><div class="gmail_quote">2016-01-06 14:46 GMT+01:00 <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-cb.1617.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-cb.1617.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-cb.1617<br>
Author: cb<br>
Time: 6 January 2016, 2:46:27.798 pm<br>
UUID: 81fe5b89-69de-45b8-9b65-f2f4a8bd187d<br>
Ancestors: VMMaker.oscog-rmacnak.1616<br>
<br>
As Eliot ntoed, I made a dumb mistake breking instance variable stores in the interpreter.<br>
<br>
This commit fixes the mistake. In addition, storing into an immutable object in a primitive now signals a no modification error instead of inappropriate error.<br>
<br>
I checked and the StackVMSimulator is working fine after this commit. Unfortunately, the CogVMSimulator does not work in my machine, likely due to other bugs. I am going to check that it works and that compilation to C works right now.<br>
<br>
=============== Diff against VMMaker.oscog-rmacnak.1616 ===============<br>
<br>
Item was changed:<br>
----- Method: CoInterpreterPrimitives>>primitiveObjectAtPut (in category 'object access primitives') -----<br>
primitiveObjectAtPut<br>
"Store a literal into a CompiledMethod at the given index. Defined for CompiledMethods only."<br>
| thisReceiver rawHeader realHeader index newValue |<br>
newValue := self stackValue: 0.<br>
index := self stackValue: 1.<br>
(objectMemory isNonIntegerObject: index) ifTrue:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br>
index := objectMemory integerValueOf: index.<br>
thisReceiver := self stackValue: 2.<br>
self cppIf: IMMUTABILITY<br>
+ ifTrue: [ (objectMemory isImmutable: thisReceiver) ifTrue: [ ^self primitiveFailFor: PrimErrNoModification ] ].<br>
- ifTrue: [ (objectMemory isImmutable: thisReceiver) ifTrue: [ ^self primitiveFailFor: PrimErrInappropriate ] ].<br>
rawHeader := self rawHeaderOf: thisReceiver.<br>
realHeader := (self isCogMethodReference: rawHeader)<br>
ifTrue: [(self cCoerceSimple: rawHeader to: #'CogMethod *') methodHeader]<br>
ifFalse: [rawHeader].<br>
(index > 0<br>
and: [index <= ((objectMemory literalCountOfMethodHeader: realHeader) + LiteralStart)]) ifFalse:<br>
[^self primitiveFailFor: PrimErrBadIndex].<br>
index = 1<br>
ifTrue:<br>
[((objectMemory isNonIntegerObject: newValue)<br>
or: [(objectMemory literalCountOfMethodHeader: newValue) ~= (objectMemory literalCountOfMethodHeader: realHeader)]) ifTrue:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br>
(self isCogMethodReference: rawHeader)<br>
ifTrue: [(self cCoerceSimple: rawHeader to: #'CogMethod *') methodHeader: newValue]<br>
ifFalse: [objectMemory storePointerUnchecked: 0 ofObject: thisReceiver withValue: newValue]]<br>
ifFalse:<br>
[objectMemory storePointer: index - 1 ofObject: thisReceiver withValue: newValue].<br>
self pop: 3 thenPush: newValue!<br>
<br>
Item was changed:<br>
----- Method: InterpreterPrimitives>>primitiveFloatAtPut (in category 'indexing primitives') -----<br>
primitiveFloatAtPut<br>
"Provide platform-independent access to 32-bit words comprising<br>
a Float. Map index 1 onto the most significant word and index 2<br>
onto the least significant word."<br>
| rcvr index oopToStore valueToStore |<br>
<var: #valueToStore type: #usqInt><br>
oopToStore := self stackTop.<br>
valueToStore := self positive32BitValueOf: oopToStore.<br>
self successful ifFalse:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br>
rcvr := self stackValue: 2.<br>
index := self stackValue: 1.<br>
(objectMemory isImmediateFloat: rcvr) ifTrue:<br>
[^self primitiveFailFor: PrimErrBadReceiver].<br>
self cppIf: IMMUTABILITY<br>
+ ifTrue: [ (objectMemory isImmutable: rcvr) ifTrue: [^self primitiveFailFor: PrimErrNoModification] ].<br>
- ifTrue: [ (objectMemory isImmutable: rcvr) ifTrue: [^self primitiveFailFor: PrimErrBadReceiver] ].<br>
index = ConstOne ifTrue:<br>
[objectMemory storeLong32: (VMBIGENDIAN ifTrue: [0] ifFalse: [1])<br>
ofObject: rcvr<br>
withValue: valueToStore.<br>
^self pop: 3 thenPush: oopToStore].<br>
index = ConstTwo ifTrue:<br>
[objectMemory storeLong32: (VMBIGENDIAN ifTrue: [1] ifFalse: [0])<br>
ofObject: rcvr<br>
withValue: valueToStore.<br>
^self pop: 3 thenPush: oopToStore].<br>
self primitiveFailFor: ((objectMemory isIntegerObject: index)<br>
ifTrue: [PrimErrBadIndex]<br>
ifFalse: [PrimErrBadArgument])!<br>
<br>
Item was changed:<br>
----- Method: InterpreterPrimitives>>primitiveIntegerAtPut (in category 'sound primitives') -----<br>
primitiveIntegerAtPut<br>
"Return the 32bit signed integer contents of a words receiver"<br>
| index rcvr sz addr value valueOop |<br>
<var: 'value' type: 'int'><br>
valueOop := self stackValue: 0.<br>
index := self stackIntegerValue: 1.<br>
value := self signed32BitValueOf: valueOop.<br>
self successful ifFalse:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br>
rcvr := self stackValue: 2.<br>
(objectMemory isWords: rcvr) ifFalse:<br>
[^self primitiveFailFor: PrimErrInappropriate].<br>
self cppIf: IMMUTABILITY "isWords: ensure non immediate"<br>
+ ifTrue: [ (objectMemory isImmutable: rcvr) ifTrue: [ ^self primitiveFailFor: PrimErrNoModification ] ].<br>
- ifTrue: [ (objectMemory isImmutable: rcvr) ifTrue: [ ^self primitiveFailFor: PrimErrInappropriate ] ].<br>
sz := objectMemory lengthOf: rcvr. "number of fields"<br>
(index >= 1 and: [index <= sz]) ifFalse:<br>
[^self primitiveFailFor: PrimErrBadIndex].<br>
"4 = 32 bits / 8"<br>
addr := rcvr + objectMemory baseHeaderSize + (index - 1 * 4). "for zero indexing"<br>
value := objectMemory intAt: addr put: value.<br>
self pop: 3 thenPush: valueOop "pop all; return value"<br>
!<br>
<br>
Item was changed:<br>
----- Method: InterpreterPrimitives>>primitiveObjectAtPut (in category 'object access primitives') -----<br>
primitiveObjectAtPut<br>
"Store a literal into a CompiledMethod at the given index. Defined for CompiledMethods only."<br>
| thisReceiver index newValue |<br>
newValue := self stackValue: 0.<br>
index := self stackValue: 1.<br>
((objectMemory isNonIntegerObject: index)<br>
or: [index = ConstOne and: [(objectMemory isNonIntegerObject: newValue)]]) ifTrue:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br>
index := objectMemory integerValueOf: index.<br>
thisReceiver := self stackValue: 2.<br>
self cppIf: IMMUTABILITY<br>
+ ifTrue: [ (objectMemory isImmutable: thisReceiver) ifTrue: [ ^self primitiveFailFor: PrimErrNoModification ] ].<br>
- ifTrue: [ (objectMemory isImmutable: thisReceiver) ifTrue: [ ^self primitiveFailFor: PrimErrInappropriate ] ].<br>
(index > 0 and: [index <= ((objectMemory literalCountOf: thisReceiver) + LiteralStart)]) ifFalse:<br>
[^self primitiveFailFor: PrimErrBadIndex].<br>
objectMemory storePointer: index - 1 ofObject: thisReceiver withValue: newValue.<br>
self pop: 3 thenPush: newValue!<br>
<br>
Item was changed:<br>
----- Method: InterpreterPrimitives>>primitiveShortAtPut (in category 'sound primitives') -----<br>
primitiveShortAtPut<br>
"Treat the receiver, which can be indexible by either bytes or words, as an array<br>
of signed 16-bit values. Set the contents of the given index to the given value.<br>
Note that the index specifies the i-th 16-bit entry, not the i-th byte or word."<br>
<br>
| index rcvr value |<br>
value := self stackTop.<br>
index := self stackValue: 1.<br>
((objectMemory isIntegerObject: value)<br>
and: [(objectMemory isIntegerObject: index)<br>
and: [value := objectMemory integerValueOf: value.<br>
(value >= -32768) and: [value <= 32767]]]) ifFalse:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br>
rcvr := self stackValue: 2.<br>
(objectMemory isWordsOrBytes: rcvr) ifFalse:<br>
[^self primitiveFailFor: PrimErrInappropriate].<br>
self cppIf: IMMUTABILITY "isWordsOrBytes ensure non immediate"<br>
+ ifTrue: [ (objectMemory isImmutable: rcvr) ifTrue: [ ^self primitiveFailFor: PrimErrNoModification ] ].<br>
- ifTrue: [ (objectMemory isImmutable: rcvr) ifTrue: [ ^self primitiveFailFor: PrimErrInappropriate ] ].<br>
index := objectMemory integerValueOf: index.<br>
(index >= 1 and: [index <= (objectMemory num16BitUnitsOf: rcvr)]) ifFalse:<br>
[^self primitiveFailFor: PrimErrBadIndex].<br>
objectMemory storeShort16: index - 1 ofObject: rcvr withValue: value.<br>
self pop: 3 thenPush: (objectMemory integerObjectOf: value)!<br>
<br>
Item was changed:<br>
----- Method: SpurMemoryManager>>isOopValidBecome: (in category 'become implementation') -----<br>
isOopValidBecome: oop<br>
"Answers 0 if the oop can be become.<br>
Answers an error code in the other case"<br>
(self isImmediate: oop) ifTrue: [^PrimErrInappropriate].<br>
(self isPinned: oop) ifTrue: [^PrimErrObjectIsPinned].<br>
self<br>
cppIf: IMMUTABILITY<br>
+ ifTrue: [ (self isImmutable: oop) ifTrue: [^PrimErrNoModification] ].<br>
- ifTrue: [ (self isImmutable: oop) ifTrue: [^PrimErrInappropriate] ].<br>
^ 0!<br>
<br>
Item was changed:<br>
----- Method: StackInterpreter>>extendedStoreAndPopBytecode (in category 'stack bytecodes') -----<br>
extendedStoreAndPopBytecode<br>
<inline: true><br>
self extendedStoreBytecodePop: true<br>
+ "may not be reached (immutable receiver)"!<br>
- !<br>
<br>
Item was changed:<br>
----- Method: StackInterpreter>>extendedStoreBytecode (in category 'stack bytecodes') -----<br>
extendedStoreBytecode<br>
<inline: true><br>
+ self extendedStoreBytecodePop: false<br>
+ "may not be reached (immutable receiver)"!<br>
- self extendedStoreBytecodePop: false!<br>
<br>
Item was changed:<br>
----- Method: StackInterpreter>>storeAndPopReceiverVariableBytecode (in category 'stack bytecodes') -----<br>
storeAndPopReceiverVariableBytecode<br>
"Note: This code uses<br>
storePointerUnchecked:ofObject:withValue: and does the<br>
store check explicitely in order to help the translator<br>
produce better code."<br>
| rcvr top |<br>
rcvr := self receiver.<br>
top := self internalStackTop.<br>
self internalPop: 1.<br>
+ self<br>
+ cCode: "Slang will inline currentBytecode to a constant so this will work in C"<br>
+ [self fetchNextBytecode.<br>
+ objectMemory<br>
+ storePointerImmutabilityCheck: (currentBytecode bitAnd: 7)<br>
+ ofObject: rcvr<br>
+ withValue: top]<br>
+ inSmalltalk: "But in Smalltalk we must use the currentBytecode's value, not the next.<br>
+ We cant use the following code when generating C code as slang<br>
+ won't inline currentBytecode correctly due to the extra temp."<br>
+ [ | instVarIndex |<br>
+ instVarIndex := currentBytecode bitAnd: 7.<br>
+ self fetchNextBytecode.<br>
+ objectMemory<br>
+ storePointerImmutabilityCheck: instVarIndex<br>
+ ofObject: rcvr<br>
+ withValue: top]!<br>
- self fetchNextBytecode.<br>
- objectMemory storePointerImmutabilityCheck: (currentBytecode bitAnd: 7) ofObject: rcvr withValue: top.!<br>
<br>
Item was changed:<br>
----- Method: StackInterpreterPrimitives>>primitiveInstVarAtPut (in category 'object access primitives') -----<br>
primitiveInstVarAtPut<br>
| newValue index rcvr hdr fmt totalLength fixedFields |<br>
newValue := self stackTop.<br>
index := self stackValue: 1.<br>
rcvr := self stackValue: 2.<br>
((objectMemory isNonIntegerObject: index)<br>
or: [argumentCount > 2 "e.g. object:instVarAt:put:"<br>
and: [objectMemory isOopForwarded: rcvr]]) ifTrue:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br>
+ (objectMemory isImmediate: rcvr) ifTrue: [ ^ self primitiveFailFor: PrimErrInappropriate].<br>
+ self<br>
+ cppIf: IMMUTABILITY<br>
+ ifTrue: [ (objectMemory isImmutable: rcvr) ifTrue: [ ^ self primitiveFailFor: PrimErrNoModification] ].<br>
- self cppIf: IMMUTABILITY<br>
- ifTrue: [ (objectMemory isOopImmutable: rcvr) ifTrue: [^self primitiveFailFor: PrimErrInappropriate] ]<br>
- ifFalse: [ (objectMemory isImmediate: rcvr) ifTrue: [^self primitiveFailFor: PrimErrInappropriate] ].<br>
index := objectMemory integerValueOf: index.<br>
hdr := objectMemory baseHeader: rcvr.<br>
fmt := objectMemory formatOfHeader: hdr.<br>
totalLength := objectMemory lengthOf: rcvr baseHeader: hdr format: fmt.<br>
fixedFields := objectMemory fixedFieldsOf: rcvr format: fmt length: totalLength.<br>
(index >= 1 and: [index <= fixedFields]) ifFalse:<br>
[^self primitiveFailFor: PrimErrBadIndex].<br>
(fmt = objectMemory indexablePointersFormat<br>
and: [objectMemory isContextHeader: hdr])<br>
ifTrue: [self externalInstVar: index - 1 ofContext: rcvr put: newValue]<br>
ifFalse: [self subscript: rcvr with: index storing: newValue format: fmt].<br>
self pop: argumentCount + 1 thenPush: newValue!<br>
<br>
</blockquote></div><br></div>
</div></blockquote></div></div></body></html>