Skip to content

CogVMSimulator >> onObjectMemory:cogit:options: #962

@kumom

Description

@kumom

I am looking at the method onObjectMemory:cogit:options: and this implementation does not look right to me.

onObjectMemory: anObjectMemory cogit: aCogit options: optionsDictionaryOrArray
	| simulatorClass |
	^self == CogVMSimulator
		ifTrue:
			[simulatorClass := SmalltalkImage current endianness == #big
				ifTrue: [self notYetImplemented]
				ifFalse: [CogVMSimulatorLSB].
			simulatorClass
				initializeWithOptions: optionsDictionaryOrArray
				objectMemoryClass: (anObjectMemory ifNotNil: [anObjectMemory class]).
			 simulatorClass
				onObjectMemory: (anObjectMemory ifNil:
										[self objectMemoryClass simulatorClass new])
				cogit: aCogit
				options: optionsDictionaryOrArray]
		ifFalse:
			[| sim |
			sim := self basicNew.
			sim objectMemory: anObjectMemory.
			sim cogit: aCogit.
			sim initialize.
			sim]
  1. Should it be self class == CogVMSimulator instead of self == CogVMSimulator? Currently, it seems that only ifFalse branch will be evaluated.
  2. The only subclass of CogVMSimulator is CogVMSimulatorLSB at the moment. Why don't we implement the same method in CogVMSimulatorLSB and avoid this class check?
  3. Why don't we use similar logic in the ifFalse branch?
  4. I checked all the senders of this method (and senders of these senders, etc.) and it seems that anObjectMemory is always nil. Is it expected?
  5. By sending onObjectMemory:cogit:options: to simulatorClass, aren't we just calling this same method again (and hence potentially causing infinite recursion, if we actually evaluate the ifTrue branch)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions