Hi everybody,
I'm forwarding an email I sent to Eliot as he suggested. It is about changes I'm doing to the VM to get type information dynamically. Thanks Eliot! Hernan. ---------- Forwarded message --------- From: Hernan Wilkinson <[hidden email]> Date: Thu, Oct 4, 2018 at 7:09 AM Subject: Re: Help for a crazy idea I have To: Eliot Miranda <[hidden email]> Hi Eliot! thank you for your answer. I look at Slots as you suggested. They could work but, at least as far I could see and play with them, they would not work for all the cases I have in mind, for example I could not use slots to keep the type of temporary variables, parameters or methods return, etc. If I'm mistaken please let me know. So, I continued with my idea and changed ClassDescription adding a new inst. var. called "instanceVariablesTypes", that points to an array of arrays. Each position of the first one points to the types of the inst. var. whose index correspond the position. Very simple and it works fine. Performance impact is very low. At the end of the email is the code I wrote at the VM in case you want to see it. Now I'm working on the temporary variables types using AdditionalMethodState. But the main reason I'm writing to you again is because I found a rare behavior and an error when running the simulator with the Cuis image. I'm using the StackInterpreter. The problems are are: 1) The simulator running a Cuis image does more scavengings than running the simulator with a Squeak image, even thought the Cuis image size is 9 mb and the Squeak one is 50 mb. (I know the image size has nothing to do with the young space size). So, is there a way to configure the young space size or a way to see why it triggers so many scavengings? 2) When I added the inst. var "instanceVariableTypes" to ClassDescription, some pointer ends up invalid. Doing the same with Squeak works fine. When adding that inst var in an Cuis image using the simulator, an assertion stops the simulator execution. There is another detail, this does not happen with 32 bit Cuis images/vm, only with 64 bit Cuis images. Do you know what could be happening? (I'm attaching the simulator's stack report just is case you have time to look at it, but it is very simple to reproduce). 3) What is the difference between "<primitive: 105 error: ec>" and just "<primitive: 105>" ? I had to replace in Cuis all the first one with the second one because the simulator did not work with methods using the first one (example: Array>>replaceFrom: start to: stop with: replacement startingAt: repStart) Anyway, it is very interesting what I'm achieving with just only keeping the types for inst. vars. I could significantly improve auto complete in the class browser for example, do some type checking, etc. I'll keep you posted with the changes I'm making. If you could help me with the 3 problems I mentioned above it would be great :-) Cheers! Hernan ----------------- Here is the code I changed in the VM: storeAndPopReceiverVariableBytecode | rcvr top instVarIndex | rcvr := self receiver. top := self internalStackTop. instVarIndex := currentBytecode bitAnd: 7. self internalPop: 1. objectMemory storePointerImmutabilityCheck: instVarIndex ofObject: rcvr withValue: top. self fetchNextBytecode. self keepInstanceVariableTypeInformationFor: top in: rcvr at: instVarIndex. "<--- added this" extendedStoreBytecodePop: popBoolean | descriptor variableType variableIndex value rcvr | <inline: true> descriptor := self fetchByte. variableType := descriptor >> 6 bitAnd: 3. variableIndex := descriptor bitAnd: 63. value := self internalStackTop. popBoolean ifTrue: [ self internalPop: 1 ]. variableType = 0 ifTrue: [rcvr := self receiver. objectMemory storePointerImmutabilityCheck: variableIndex ofObject: rcvr withValue: value. self keepInstanceVariableTypeInformationFor: value in: rcvr at: variableIndex. "<--- added this" ^ self fetchNextBytecode]. variableType = 1 ifTrue: [ self fetchNextBytecode. ^self temporary: variableIndex in: localFP put: value]. variableType = 3 ifTrue: [self storeLiteralVariable: variableIndex withValue: value. ^ self fetchNextBytecode]. self error: 'illegal store' keepInstanceVariableTypeInformationFor: anAssignedObject in: rcvr at: instVarIndex | assignedObjectClass assignedObjectClassTag instVarTypes rcvrClass rcvrClassTag types | "(objectMemory isForwarded: rcvr) ifTrue: [ self halt ]." rcvrClassTag := objectMemory fetchClassTagOf: rcvr. self deny: (objectMemory isForwardedClassTag: rcvrClassTag). rcvrClass := objectMemory classForClassTag: rcvrClassTag. self deny: rcvrClass isNil. "(objectMemory isForwarded: top) ifTrue: [ self halt ]." assignedObjectClassTag := objectMemory fetchClassTagOf: anAssignedObject. self deny: (objectMemory isForwardedClassTag: assignedObjectClassTag). assignedObjectClass := objectMemory classForClassTag: assignedObjectClassTag. self deny: assignedObjectClass isNil. instVarTypes := objectMemory followObjField: 5 ofObject: rcvrClass. "TODO: use constant instead of 5" instVarTypes = objectMemory nilObject ifTrue: [ ^self ]. types := objectMemory followObjField: instVarIndex ofObject: instVarTypes. 0 to: 9 do: [ :index | | typeAtIndex | "TODO: use array size and not 9. Check for types == nil" typeAtIndex := objectMemory followObjField: index ofObject: types. typeAtIndex == assignedObjectClass ifTrue: [ ^self ]. typeAtIndex == objectMemory nilObject ifTrue: [ ^objectMemory storePointer: index ofObject: types withValue: assignedObjectClass ]]. "self halt: 'out of space for types" On Wed, Sep 19, 2018 at 1:48 PM Eliot Miranda <[hidden email]> wrote:
Hernán Wilkinson Agile Software Development, Teaching & Coaching Phone: +54-011-4893-2057 Twitter: @HernanWilkinson site: http://www.10Pines.com Address: Alem 896, Floor 6, Buenos Aires, Argentina Hernán Wilkinson Agile Software Development, Teaching & Coaching Phone: +54-011-4893-2057 Twitter: @HernanWilkinson site: http://www.10Pines.com Address: Alem 896, Floor 6, Buenos Aires, Argentina AddingInstVarToClassDescriptionError.txt (83K) Download Attachment |
Free forum by Nabble | Edit this page |