[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squeak-vm-dev
Subject:    [Vm-dev] Strange but when I try to implement a bytecode
From:       Mathieu Suen <mathk.sue () gmail ! com>
Date:       2007-08-19 13:12:14
Message-ID: ED121211-717D-4E22-9F41-3756EB961488 () gmail ! com
[Download RAW message or body]

 
Hi,

I have been trying to implement a bytecode to create the closure  
environment needed for the NewCompiler. My first implementation looks  
like this:

createEnvironment

	| closSize |
	self fetchNextBytecode.
	closSize := currentBytecode.
	self fetchNextBytecode.
	"The following may cause GC!"
	self success: (self sufficientSpaceToInstantiate:  (self splObj:  
ClosureEnvObject) indexableSize: closSize).
	successFlag ifTrue: [
		self storePointer: 4
			ofObject: activeContext
			withValue:(self instantiateClass: (self splObj: ClosureEnvObject)  
indexableSize: closSize)]


This bytecode was suppose to replace the following bytecodes:

113 <20> pushConstant: ClosureEnvironment
114 <76> pushConstant: 4
115 <CD> send: new:
116 <89> pushThisContext:
117 <21> pushConstant: 5
118 <F2> send: privStoreIn:instVar:
119 <87> pop

into :

37 <7E 04> new closure: 4


But it keeps not working when a GC occurs (either in the markAnTrace  
phase or in the sweep phase).

Then I change my implementation to:

createEnvironment

	| closSize |
	self fetchNextBytecode.
	closSize := currentBytecode.
	self fetchNextBytecode.
	self push: (self splObj: ClosureEnvObject).
	self push: (self integerObjectOf: closSize).
	self primitiveNewWithArg.
	.
	successFlag ifTrue: [
		self storePointer: 4
			ofObject: activeContext
			withValue: self popStack]

And it works I can explain why. Could you?


	Mth



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic