[squeak-dev] The Trunk: Kernel-nice.746.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Mar 10 18:53:52 UTC 2013


Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.746.mcz

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

Name: Kernel-nice.746
Author: nice
Time: 10 March 2013, 7:52:48.738 pm
UUID: 0f9d411b-68a9-49eb-b37a-1bc4fb8fa36d
Ancestors: Kernel-bf.744

Fix ClassBuilder which previously failed to flush the cache of old CompiledMethod when the class changes of format.
This failure to invoke primitive 116 can lead to COG VM crash (a cogit jitted method is not unlinked).
This does not affect old interpreter which clear the caches thru primitive 119.
It is essential that the newClass points to identity-preserved CompiledMethods of oldClass methodDictionary before recompiling so that primitive 116 be correctly invoked, particularly we must not clear methodDictionary with a MethodDictionary new..

=============== Diff against Kernel-bf.744 ===============

Item was changed:
  ----- Method: ClassBuilder>>newSubclassOf:type:instanceVariables:from: (in category 'class definition') -----
  newSubclassOf: newSuper type: type instanceVariables: instVars from: oldClass
  	"Create a new subclass of the given superclass with the given specification."
  	| newFormat newClass |
  	"Compute the format of the new class"
  	newFormat := 
  		self computeFormat: type 
  			instSize: instVars size 
  			forSuper: newSuper 
  			ccIndex: (oldClass ifNil:[0] ifNotNil:[oldClass indexIfCompact]).
  
  	newFormat == nil ifTrue:[^nil].
  
  	(oldClass == nil or:[oldClass isMeta not]) 
  		ifTrue:[newClass := self privateNewSubclassOf: newSuper from: oldClass]
  		ifFalse:[newClass := oldClass clone].
  
  	newClass 
  		superclass: newSuper
+ 		methodDictionary: (oldClass ifNil: [MethodDictionary new] ifNotNil: [oldClass methodDict copy])
- 		methodDictionary: MethodDictionary new
  		format: newFormat;
  		setInstVarNames: instVars.
  
  	oldClass ifNotNil:[
  		newClass organization: oldClass organization.
  		"Recompile the new class"
  		oldClass hasMethods 
  			ifTrue:[newClass compileAllFrom: oldClass].
  
  		oldClass hasTraitComposition ifTrue: [
  			newClass setTraitComposition: oldClass traitComposition copyTraitExpression ].
  		oldClass class hasTraitComposition ifTrue: [
  			newClass class setTraitComposition: oldClass class traitComposition copyTraitExpression ].
  		
  		self recordClass: oldClass replacedBy: newClass.
  	].
  
  	(oldClass == nil or:[oldClass isObsolete not]) 
  		ifTrue:[newSuper addSubclass: newClass]
  		ifFalse:[newSuper addObsoleteSubclass: newClass].
  
  	^newClass!

Item was changed:
  ----- Method: ClassBuilder>>privateNewSubclassOf:from: (in category 'private') -----
  privateNewSubclassOf: newSuper from: oldClass
  	"Create a new meta and non-meta subclass of newSuper using oldClass as template"
  	"WARNING: This method does not preserve the superclass/subclass invariant!!"
  	| newSuperMeta oldMeta newMeta |
  	oldClass ifNil:[^self privateNewSubclassOf: newSuper].
  	newSuperMeta := newSuper ifNil:[Class] ifNotNil:[newSuper class].
  	oldMeta := oldClass class.
  	newMeta := oldMeta clone.
  	newMeta 
  		superclass: newSuperMeta
+ 		methodDictionary: oldMeta methodDict copy
- 		methodDictionary: MethodDictionary new
  		format: (self computeFormat: oldMeta typeOfClass 
  					instSize: oldMeta instVarNames size 
  					forSuper: newSuperMeta
  					ccIndex: 0);
  		setInstVarNames: oldMeta instVarNames;
  		organization: oldMeta organization.
  	"Recompile the meta class"
  	oldMeta hasMethods 
  		ifTrue:[newMeta compileAllFrom: oldMeta].
  	"Record the meta class change"
  	self recordClass: oldMeta replacedBy: newMeta.
  	"And create a new instance"
  	^newMeta adoptInstance: oldClass from: oldMeta!



More information about the Squeak-dev mailing list