[Vm-dev] VM Maker: VMMaker.oscog-nice.1713.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Mar 5 02:17:34 UTC 2016


Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.1713.mcz

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

Name: VMMaker.oscog-nice.1713
Author: nice
Time: 5 March 2016, 3:15:22.817 am
UUID: ac270981-d3ba-4c42-a2b1-3a83693776be
Ancestors: VMMaker.oscog-nice.1712

The size of [unsigned] long long was not infered...

VM fool proofing:

Fix a missing guard in SmartSyntaxPlugin like explained at
http://forum.world.st/VM-safety-missing-failing-guards-in-SmartSyntaxPlugin-td4816518.html

Fix two missing guards in VM profiling primitives: one should not use the result of stackObjectValue: before checking for success, otherwise a null pointer exception will occur in case of failure.

=============== Diff against VMMaker.oscog-nice.1712 ===============

Item was changed:
  ----- Method: CCodeGenerator>>sizeOfIntegralCType: (in category 'inlining') -----
  sizeOfIntegralCType: anIntegralCType "<String>"
  	"N.B. Only works for values for which isIntegralCType: answers true."
  	| prunedCType index |
  	(anIntegralCType beginsWith: 'register ') ifTrue:
  		[^self sizeOfIntegralCType: (anIntegralCType allButFirst: 9)].
  	prunedCType := (anIntegralCType beginsWith: 'unsigned ')
  						ifTrue: [(anIntegralCType allButFirst: 9) withBlanksTrimmed]
  						ifFalse: [(anIntegralCType beginsWith: 'signed ')
  									ifTrue: [(anIntegralCType allButFirst: 7) withBlanksTrimmed]
  									ifFalse: [anIntegralCType]].
  	^prunedCType asString caseOf: {
  		['sqLong']	->	[8].
  		['usqLong']	->	[8].
+ 		['long long']	->	[8].
  		['sqInt']		->	[BytesPerWord].
  		['usqInt']	->	[BytesPerWord].
  		['int']		->	[4].
  		['short']		->	[2].
  		['short int']	->	[2].
  		['char']		->	[1].
  		['long']		->	[BytesPerWord].
  		['size_t']		->	[BytesPerWord].
  		['pid_t']		->	[BytesPerWord].
  	}
  	otherwise:
  		[((anIntegralCType beginsWith: 'unsigned') "e.g. 'unsigned  : 8'"
  		  and: [(anIntegralCType includesAnyOf: '[*]') not
  		  and: [(index := anIntegralCType indexOf: $:) > 0]])
  			ifTrue: [(Integer readFrom: (anIntegralCType copyFrom: index + 1 to: anIntegralCType size) withBlanksTrimmed readStream) + 7 // 8]
  			ifFalse: [self error: 'unrecognized integral type']]!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveVMProfileInfoInto (in category 'process primitives') -----
  primitiveVMProfileInfoInto
  	"Primitive. Answer whether the profiler is running or not.
  	 If the argument is an Array of suitable size fill it with the following information:
  		1. the addresses of the first element of the VM histogram (the first address in the executable)
  		2. the address following the last element (the last address in the executable, excluding dynamically linked libraries)
  		3. the size of the VM histogram in bins (each bin is a 4 byte unsigned long)
  		4. the size of the VM histogram in bins (each bin is a 4 byte unsigned long)"
  	| info running exeStart exeLimit vmBins easBins |
  	<var: #exeStart type: #'char *'>
  	<var: #exeLimit type: #'char *'>
  	<var: #vmBins type: #long>
  	<var: #easBins type: #long>
  	self success: argumentCount = 1.
  	self successful ifTrue:
+ 		[info := self stackObjectValue: 0].
+ 	self successful ifTrue:
+ 		[info ~= objectMemory nilObject ifTrue:
- 		[info := self stackObjectValue: 0.
- 		 info ~= objectMemory nilObject ifTrue:
  			[self assertClassOf: info is: (objectMemory splObj: ClassArray).
  			 self success: (objectMemory numSlotsOf: info) >= 4]].
  	self successful ifFalse:
  		[^nil].
  	
  	self cCode: 'ioProfileStatus(&running,&exeStart,&exeLimit,0,&vmBins,0,&easBins)'
  		inSmalltalk: [running := exeStart := exeLimit := vmBins := easBins := 0].
  	info ~= objectMemory nilObject ifTrue:
  		[objectMemory storePointerUnchecked: 0
  			ofObject: info
  			withValue: (objectMemory integerObjectOf: (self oopForPointer: exeStart)).
  		objectMemory storePointerUnchecked: 1
  			ofObject: info
  			withValue: (objectMemory integerObjectOf: (self oopForPointer: exeLimit)).
  		objectMemory storePointerUnchecked: 2
  			ofObject: info
  			withValue: (objectMemory integerObjectOf: vmBins).
  		objectMemory storePointerUnchecked: 3
  			ofObject: info
  			withValue: (objectMemory integerObjectOf: easBins)].
  	self pop: 2 thenPushBool: running!

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveVMProfileSamplesInto (in category 'process primitives') -----
  primitiveVMProfileSamplesInto
  	"Primitive.
  	 0 args: Answer whether the VM Profiler is running or not.
  	 1 arg:	Copy the sample data into the supplied argument, which must be a Bitmap
  			of suitable size. Answer the number of samples copied into the buffer."
  	| sampleBuffer sampleBufferAddress running bufferSize numSamples |
  	<var: #bufferSize type: #long>
  	<var: #sampleBufferAddress type: #'unsigned long *'>
  	self cCode: 'ioNewProfileStatus(&running,&bufferSize)'
  		inSmalltalk: [running := false. bufferSize := 0].
  	argumentCount = 0 ifTrue:
  		[^self pop: 1 thenPushBool: running].
  	self success: argumentCount = 1.
  	self successful ifTrue:
+ 		[sampleBuffer := self stackObjectValue: 0].
+ 	self successful ifTrue:
+ 		[self assertClassOf: sampleBuffer is: (objectMemory splObj: ClassBitmap).
- 		[sampleBuffer := self stackObjectValue: 0.
- 		 self assertClassOf: sampleBuffer is: (objectMemory splObj: ClassBitmap).
  		 self success: (objectMemory numSlotsOf: sampleBuffer) >= bufferSize].
  	self successful ifFalse:
  		[^nil].
  	sampleBufferAddress := objectMemory firstFixedField: sampleBuffer.
  	numSamples := self cCode: 'ioNewProfileSamplesInto(sampleBufferAddress)'
  						inSmalltalk: [sampleBufferAddress := sampleBufferAddress].
  	self pop: argumentCount + 1 thenPushInteger: numSamples!

Item was changed:
  ----- Method: SmartSyntaxPluginTMethod>>fixUpReturnOneStmt:on: (in category 'transforming') -----
  fixUpReturnOneStmt: stmt on: sStream
  
  	stmt isReturn ifFalse: [^sStream nextPut: stmt].
  	(stmt expression isSend
  	 and: [#('primitiveFail' 'primitiveFailFor:') includes: stmt expression selector]) ifTrue: 
  		["failure return"
  		 sStream nextPut: stmt expression.
  		 sStream nextPut: self nullReturnExpr.
  		 ^nil].
  	(stmt expression isVariable and: ['nil' = stmt expression name]) ifTrue: 
  		["^ nil -- this is never right unless automatically generated"
  		 sStream nextPut: stmt.
  		 ^nil].
  	(stmt expression isVariable and: ['self' = stmt expression name]) ifTrue: 
  		["^ self"
  		 self generateFailureGuardOn: sStream.
  		 fullArgs isEmpty ifFalse:[ sStream nextPut: (self popExpr: fullArgs size)].
  		 sStream nextPut: self nullReturnExpr.
  		 ^nil].
  	(stmt expression isVariable | stmt expression isConstant | suppressingFailureGuards) ifTrue:
  		["^ variable or ^ constant or ^ expr without guardchecking"
  		 self generateFailureGuardOn: sStream.
  		 sStream nextPut: (self pop: fullArgs size + 1 thenReturnExpr: stmt expression).
  		 sStream nextPut: self nullReturnExpr.
  		 ^nil].
  	"^ expr with guardchecking"
+ 	self generateFailureGuardOn: sStream.
  	sStream nextPut: (self assign: (self oopVariable: '_return_value') expression: stmt expression).
  	self generateFailureGuardOn: sStream.
  	sStream nextPut: (self pop: fullArgs size + 1 thenReturnExpr: (self oopVariable: '_return_value')).
  	sStream nextPut: self nullReturnExpr
  !



More information about the Vm-dev mailing list