Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2152.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2152 Author: eem Time: 14 March 2017, 10:49:41.882331 am UUID: aca4c515-7f36-407d-b0fa-5a641d583423 Ancestors: VMMaker.oscog-eem.2151 General: Add two new primitive error codes to address the callbacks-during-bitblt problem, PrimErrObjectMoved & PrimErrObjectNotPinned. Cogit: Fix the assert in allocateOpcodes:bytecodes:ifFail: by a) improving the sizeof: estimates for CogBytecodeFixup and CogAbstractInstruction and b upping the factor to multiply those sizes by. =============== Diff against VMMaker.oscog-eem.2151 =============== Item was changed: ----- Method: CogAbstractInstruction class>>byteSizeForSimulator: (in category 'simulation only') ----- byteSizeForSimulator: aVMClass "Answer an approximation of the byte size of an AbstractInstruction struct. + This is for estimating the alloca in allocateOpcodes:bytecodes:ifFail: + self allSubclasses collect: [:ea| {ea. ea byteSizeForSimulator: ea basicNew}]" - This is for estimating the alloca in allocateOpcodes:bytecodes:ifFail:" | ptrsize | + ptrsize := self == CogAbstractInstruction ifTrue: [BytesPerWord] ifFalse: [self wordSize]. + ^CogCompilerClass instSize + - 4 "cogit, objectMemory, bcpc, machineCode" + - 4 + 1 + "opcode machineCodeSize maxSize annotation are all bytes -> 1 long" * ptrsize - ptrsize := aVMClass sizeof: #'void *'. - ^CogCompilerClass instSize - 4 "cogit, objectMemory et al" * ptrsize + CogCompilerClass basicNew machineCodeBytes roundTo: ptrsize! Item was added: + ----- Method: CogSSBytecodeFixup class>>byteSizeForSimulator: (in category 'simulation only') ----- + byteSizeForSimulator: aVMClass + "Answer an approximation of the byte size of an AbstractInstruction struct. + This is for estimating the alloca in allocateOpcodes:bytecodes:ifFail: + self withAllSubclasses collect: [:ea| { ea byteSizeForSimulator: ea basicNew. ea typedef}]" + ^(LowcodeVM ifTrue: [self instSize - 1] ifFalse: [self instSize - 2]) * (aVMClass sizeof: #'void *')! Item was changed: ----- Method: Cogit>>allocateOpcodes:bytecodes:ifFail: (in category 'initialization') ----- allocateOpcodes: numberOfAbstractOpcodes bytecodes: numberOfBytecodes ifFail: failBlock "Allocate the various arrays needed to compile abstract instructions, failing if the size needed is considered too high. Notionally we only need as many fixups as there are bytecodes. But we reuse fixups to record pc-dependent instructions in generateInstructionsAt: and so need at least as many as there are abstract opcodes. This *must* be inlined since the arrays are alloca'ed (stack allocated) so that they are freed when compilation is done. N.B. We do one single alloca to save embarrassing C optimizers that generate incorrect code as both gcc and the intel compiler do on x86." <inline: true> | opcodeBytes fixupBytes allocBytes | numAbstractOpcodes := numberOfAbstractOpcodes. opcodeBytes := (self sizeof: CogAbstractInstruction) * numAbstractOpcodes. fixupBytes := (self sizeof: CogBytecodeFixup) * numAbstractOpcodes. allocBytes := opcodeBytes + fixupBytes. "Document the fact that the MaxStackAllocSize ensures that the number of abstract opcodes fits in a 16 bit integer (e.g. CogBytecodeFixup's instructionIndex)." + self assert: (self sizeof: CogAbstractInstruction) + (self sizeof: CogBytecodeFixup) * 49152 > MaxStackAllocSize. - self assert: (self sizeof: CogAbstractInstruction) + (self sizeof: CogBytecodeFixup) * 32768 > MaxStackAllocSize. allocBytes > MaxStackAllocSize ifTrue: [^failBlock value]. self cCode: [abstractOpcodes := self alloca: allocBytes. self b: abstractOpcodes zero: allocBytes. fixups := (abstractOpcodes asUnsignedInteger + opcodeBytes) asVoidPointer] inSmalltalk: [abstractOpcodes := CArrayAccessor on: ((1 to: numAbstractOpcodes) collect: [:ign| CogCompilerClass for: self]). fixups := CArrayAccessor on: ((1 to: numAbstractOpcodes) collect: [:ign| self bytecodeFixupClass for: self])]. self zeroOpcodeIndexForNewOpcodes. labelCounter := 0! Item was changed: SharedPool subclass: #VMBasicConstants instanceVariableNames: '' + classVariableNames: 'BaseHeaderSize BytecodeSetHasExtensions BytesPerOop BytesPerWord COGMTVM COGVM DisownVMLockOutFullGC DoAssertionChecks DoExpensiveAssertionChecks GCCheckPrimCall GCModeBecome GCModeFreeSpace GCModeFull GCModeImageSegment GCModeIncremental GCModeNewSpace IMMUTABILITY LowcodeVM MULTIPLEBYTECODESETS NewspeakVM PharoVM PrimErrBadArgument PrimErrBadIndex PrimErrBadMethod PrimErrBadNumArgs PrimErrBadReceiver PrimErrGenericFailure PrimErrInappropriate PrimErrLimitExceeded PrimErrNamedInternal PrimErrNoCMemory PrimErrNoMemory PrimErrNoModification PrimErrNotFound PrimErrObjectIsPinned PrimErrObjectMayMove PrimErrObjectMoved PrimErrObjectNotPinned PrimErrUnsupported PrimErrWritePastObject PrimNoErr SPURVM STACKVM SistaVM VMBIGENDIAN' - classVariableNames: 'BaseHeaderSize BytecodeSetHasExtensions BytesPerOop BytesPerWord COGMTVM COGVM DisownVMLockOutFullGC DoAssertionChecks DoExpensiveAssertionChecks GCCheckPrimCall GCModeBecome GCModeFreeSpace GCModeFull GCModeImageSegment GCModeIncremental GCModeNewSpace IMMUTABILITY LowcodeVM MULTIPLEBYTECODESETS NewspeakVM PharoVM PrimErrBadArgument PrimErrBadIndex PrimErrBadMethod PrimErrBadNumArgs PrimErrBadReceiver PrimErrGenericFailure PrimErrInappropriate PrimErrLimitExceeded PrimErrNamedInternal PrimErrNoCMemory PrimErrNoMemory PrimErrNoModification PrimErrNotFound PrimErrObjectIsPinned PrimErrObjectMayMove PrimErrUnsupported PrimErrWritePastObject PrimNoErr SPURVM STACKVM SistaVM VMBIGENDIAN' poolDictionaries: '' category: 'VMMaker-Interpreter'! !VMBasicConstants commentStamp: '<historical>' prior: 0! I am a shared pool for basic constants upon which the VM as a whole depends. self ensureClassPool. self classPool declare: #BytesPerWord from: VMSqueakV3ObjectRepresentationConstants classPool. self classPool declare: #BaseHeaderSize from: VMSqueakV3ObjectRepresentationConstants classPool (ObjectMemory classPool keys select: [:k| k beginsWith: 'Byte']) do: [:k| self classPool declare: k from: ObjectMemory classPool]! Item was changed: ----- Method: VMClass class>>initializePrimitiveErrorCodes (in category 'initialization') ----- initializePrimitiveErrorCodes "Define the VM's primitive error codes. N.B. these are replicated in platforms/Cross/vm/sqVirtualMachine.h." "VMClass initializePrimitiveErrorCodes" | pet | PrimErrTableIndex := 51. "Zero-relative" "See SmalltalkImage>>recreateSpecialObjectsArray for the table definition. If the table exists and is large enough the corresponding entry is returned as the primitive error, otherwise the error is answered numerically." pet := Smalltalk specialObjectsArray at: PrimErrTableIndex + 1 ifAbsent: [#()]. pet isArray ifFalse: [pet := #()]. PrimNoErr := 0. "for helper methods that need to answer success or an error code." PrimErrGenericFailure := pet indexOf: nil ifAbsent: 1. PrimErrBadReceiver := pet indexOf: #'bad receiver' ifAbsent: 2. PrimErrBadArgument := pet indexOf: #'bad argument' ifAbsent: 3. PrimErrBadIndex := pet indexOf: #'bad index' ifAbsent: 4. PrimErrBadNumArgs := pet indexOf: #'bad number of arguments' ifAbsent: 5. PrimErrInappropriate := pet indexOf: #'inappropriate operation' ifAbsent: 6. PrimErrUnsupported := pet indexOf: #'unsupported operation' ifAbsent: 7. PrimErrNoModification := pet indexOf: #'no modification' ifAbsent: 8. PrimErrNoMemory := pet indexOf: #'insufficient object memory' ifAbsent: 9. PrimErrNoCMemory := pet indexOf: #'insufficient C memory' ifAbsent: 10. PrimErrNotFound := pet indexOf: #'not found' ifAbsent: 11. PrimErrBadMethod := pet indexOf: #'bad method' ifAbsent: 12. PrimErrNamedInternal := pet indexOf: #'internal error in named primitive machinery' ifAbsent: 13. PrimErrObjectMayMove := pet indexOf: #'object may move' ifAbsent: 14. PrimErrLimitExceeded := pet indexOf: #'resource limit exceeded' ifAbsent: 15. PrimErrObjectIsPinned := pet indexOf: #'object is pinned' ifAbsent: 16. + PrimErrWritePastObject := pet indexOf: #'primitive write beyond end of object' ifAbsent: 17. + PrimErrObjectMoved := pet indexOf: #'object moved' ifAbsent: 18. + PrimErrObjectNotPinned := pet indexOf: #'object not pinned' ifAbsent: 19! - PrimErrWritePastObject := pet indexOf: #'primitive write beyond end of object' ifAbsent: 17! |
Free forum by Nabble | Edit this page |