[Vm-dev] VM Maker: VMMaker.oscog-eem.1360.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Jun 17 02:44:16 UTC 2015


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1360.mcz

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

Name: VMMaker.oscog-eem.1360
Author: eem
Time: 16 June 2015, 7:42:05.97 pm
UUID: 5c6c54b7-17d9-4a75-8da3-c908c8329fef
Ancestors: VMMaker.oscog-eem.1359

ARM Cogit:
Fix growing literals.  Can't use realloc cuz existing
refs must be updated to new literals.

Fix literalInstructionInRange: in C by making sure
that literalOpcodeIndex is signed.

Fix type errors and typos.

=============== Diff against VMMaker.oscog-eem.1359 ===============

Item was changed:
  ----- Method: CogOutOfLineLiteralsARMCompiler>>literalOpcodeIndex (in category 'generate machine code') -----
  literalOpcodeIndex
  	"Hack:  To know how far away a literal is from its referencing instruction we store
  	 its opcodeIndex, or -1, if as yet unassigned, in the second operand of the literal."
  	<inline: true>
  	self assert: opcode = Literal.
+ 	^(operands at: 2) asInteger!
- 	^operands at: 2!

Item was changed:
  ----- Method: OutOfLineLiteralsManager>>allocateLiteral: (in category 'compile abstract instructions') -----
  allocateLiteral: aLiteral
  	"Allocate a n unsharable Literal instruction for the literal and answer it."
  	<returnTypeC: #'AbstractInstruction *'>
  	<inline: true>
  	| litInst |
  	<var: 'litInst' type: #'AbstractInstruction *'>
  	nextLiteralIndex >= literalsSize ifTrue:
  		[self allocateLiterals: literalsSize + 8].
  	litInst := self literalInstructionAt: nextLiteralIndex.
  	litInst
  		opcode: Literal;
  		operand0: aLiteral;
  		setIsUnique;
  		setLiteralOpcodeIndex: -1. "means as-yet-unassigned; see literalInstructionInRange:"
  	nextLiteralIndex := nextLiteralIndex + 1.
+ 	"Record the opcodeIndex of the first dependent instruction (the first instruction that references an out-of-line literal)"
- 	"Record the opcodeIndex of the first dependent instructuon (the first instruction that references an out-of-line literal)"
  	firstOpcodeIndex > cogit getOpcodeIndex ifTrue:
  		[firstOpcodeIndex := cogit getOpcodeIndex - 1].
  	^litInst!

Item was changed:
  ----- Method: OutOfLineLiteralsManager>>allocateLiterals: (in category 'initialization') -----
  allocateLiterals: initialNumLiterals
  	<inline: true>
+ 	| newLiterals newInst existingInst |
+ 	<var: 'newInst' type: #'AbstractInstruction *'>
+ 	<var: 'existingInst' type: #'AbstractInstruction *'>
+ 	<var: 'newLiterals' type: #'AbstractInstruction *'>
  	initialNumLiterals > literalsSize ifTrue:
+ 		[newLiterals := self cCode:
+ 								[self c: initialNumLiterals alloc: (self sizeof: CogAbstractInstruction)]
+ 							inSmalltalk:
+ 								[CArrayAccessor on: ((1 to: initialNumLiterals) collect: [:i| CogCompilerClass for: cogit])].
+ 		 "Must copy across state (not using realloc, cuz...) and
+ 		  must also update existing instructions to refer to the new ones...
+ 		  It's either this or modify all generation routines to be able to retry
+ 		  with more literals after running out of literals."
+ 		 literals ifNotNil:
+ 			[0 to: nextLiteralIndex - 1 do:
+ 				[:i|
+ 				existingInst := self literalInstructionAt: i.
+ 				newInst := self addressOf: (newLiterals at: i).
+ 				newInst
+ 					opcode: Literal;
+ 					operand0: (existingInst operands at: 0);
+ 					setLiteralOpcodeIndex: existingInst literalOpcodeIndex.
+ 				self assert: existingInst dependent isNil.
+ 				existingInst dependent: newInst].
+ 			0 to: cogit getOpcodeIndex - 1 do:
+ 				[:i|
+ 				existingInst := cogit abstractInstructionAt: i.
+ 				(existingInst dependent notNil
+ 				 and: [existingInst dependent opcode = Literal]) ifTrue:
+ 					[existingInst dependent: existingInst dependent dependent]]].
+ 		 self cCode: [self free: literals] inSmalltalk: [].
+ 		 literals := newLiterals.
- 		[self cCode:
- 				[literals := self re: literals alloc: initialNumLiterals * (self sizeof: CogAbstractInstruction)]
- 			inSmalltalk:
- 				[| newLiterals |
- 				 newLiterals := Array new: initialNumLiterals.
- 				 literals ifNotNil:
- 					[:existingLiterals| newLiterals replaceFrom: 1 to: literalsSize with: existingLiterals object startingAt: 1].
- 				 literals := CArrayAccessor on: newLiterals].
  		 literalsSize := initialNumLiterals]!

Item was changed:
  ----- Method: OutOfLineLiteralsManager>>classRefInClosedPICAt: (in category 'garbage collection') -----
  classRefInClosedPICAt: mcpc
+ 	<inline: true>
  	^objectMemory longAt: mcpc - objectMemory bytesPerOop!

Item was changed:
  ----- Method: OutOfLineLiteralsManager>>locateLiteral: (in category 'compile abstract instructions') -----
  locateLiteral: aLiteral
  	"Search for a Literal instruction that is in-range and answer it.  Otherwise
  	 allocate a new Literal instruction for the literal and answer it."
  	<returnTypeC: #'AbstractInstruction *'>
  	<inline: false>
  	| litInst |
  	<var: 'litInst' type: #'AbstractInstruction *'>
  	0 to: nextLiteralIndex - 1 do:
  		[:i|
  		litInst := self literalInstructionAt: i.
  		((litInst operands at: 0) = aLiteral
  		 and: [litInst isSharable
  		 and: [self literalInstructionInRange: litInst]]) ifTrue:
  			[^litInst]].
  	nextLiteralIndex >= literalsSize ifTrue:
  		[self allocateLiterals: literalsSize + 8].
  	litInst := self literalInstructionAt: nextLiteralIndex.
  	litInst
  		opcode: Literal;
  		operand0: aLiteral;
  		setLiteralOpcodeIndex: -1. "means as-yet-unassigned; see literalInstructionInRange:"
  	nextLiteralIndex := nextLiteralIndex + 1.
+ 	"Record the opcodeIndex of the first dependent instruction (the first instruction that references an out-of-line literal)"
- 	"Record the opcodeIndex of the first dependent instructuon (the first instruction that references an out-of-line literal)"
  	firstOpcodeIndex > cogit getOpcodeIndex ifTrue:
  		[firstOpcodeIndex := cogit getOpcodeIndex - 1].
  	^litInst!

Item was changed:
  ----- Method: OutOfLineLiteralsManager>>objRefInClosedPICAt: (in category 'garbage collection') -----
  objRefInClosedPICAt: mcpc
+ 	<inline: true>
  	^objectMemory longAt: mcpc!



More information about the Vm-dev mailing list