[Vm-dev] VM Maker: BytecodeSets.spur-cb.51.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Apr 15 17:22:50 UTC 2016


ClementBera uploaded a new version of BytecodeSets to project VM Maker:
http://source.squeak.org/VMMaker/BytecodeSets.spur-cb.51.mcz

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

Name: BytecodeSets.spur-cb.51
Author: cb
Time: 15 April 2016, 10:22:41.309154 am
UUID: bbb34112-2fe4-474c-bd20-2193f5a8f458
Ancestors: BytecodeSets.spur-cb.50

Improved examples for full block closures.

=============== Diff against BytecodeSets.spur-cb.50 ===============

Item was changed:
  BlockClosure variableSubclass: #FullBlockClosure
  	instanceVariableNames: 'receiver'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'BytecodeSets-SistaV1'!
  
+ !FullBlockClosure commentStamp: 'cb 4/15/2016 10:20' prior: 0!
- !FullBlockClosure commentStamp: 'cb 4/10/2016 10:05' prior: 0!
  A FullBlockClosure is a closure that can be indepdendent of any outerContext if desired.  It has its own method (currently reusing the startpc inst var) and its own receiver.  outerContext can be either a MethodContext/Context or nil.
  
  Instance Variables
  	receiver:		<Object>
  
  Here's an example (a chunk designed to be typed into the spurreader image with this class filed in, e.g. in the simulator), circa early 2016 for creating the recursive nfib example (|nfib|nfib:=nil.nfib:=[:n|n<=1ifTrue:[1]ifFalse:[(nfib value:n-1)+(nfib value:n-2)+1]].(1to:12)collect:nfib) using FullBlockClosure:
  
+ (| method closure |
- | method closure |
  method := (AssemblerMethod new
  	methodClass: Object;
  	selector: #nfib:;
  	numArgs: 1;
  	numTemps: 2;
  	literal: #ifTrue:ifFalse:;
  	pushTemporaryVariable: 0;
  	pushSpecialConstant: 1;
  	send: #<= super: false numArgs: 1;
  	jump: 'L1' if: false;
  	pushSpecialConstant: 1;
  	jump: 'L2';
  	label: 'L1';
  	pushRemoteTemp: 0 inVectorAt: 1;
  	pushTemporaryVariable: 0;
  	pushSpecialConstant: 1;
  	send: #- super: false numArgs: 1;
  	send: #value: super: false numArgs: 1;
  	pushRemoteTemp: 0 inVectorAt: 1;
  	pushTemporaryVariable: 0;
  	pushSpecialConstant: 2;
  	send: #- super: false numArgs: 1;
  	send: #value: super: false numArgs: 1;
  	send: #+ super: false numArgs: 1;
  	pushSpecialConstant: 1;
  	send: #+ super: false numArgs: 1;
  	label: 'L2';
  	blockReturnTop;
  	yourself) assemble.
  closure := FullBlockClosure new: 1.
  closure
  	outerContext: nil;
  	compiledBlock: method;
  	numArgs: 1;
  	receiver: nil.
  closure at: 1 put: (Array with: closure).
+ (1 to: 12) collect: closure!!)
- (1 to: 12) collect: closure!!
  
  Here is a second example:
+ (| methodBlock outerMethod closure |
- | methodBlock outerMethod |
  methodBlock := (AssemblerMethod new
  	methodClass: Object;
  	selector: #inblock2;
- 	numArgs: 0;
  	numTemps: 1;
+ 	pushTemporaryVariable: 0;
- 	popIntoTemporaryVariable: 0;
  	blockReturnTop;
  	yourself) assemble.
  outerMethod := (AssemblerMethod new
  	encoder: EncoderForSistaV1 new;
  	methodClass: Object;
  	selector: #foo;
- 	numTemps: 0;
- 	trailerData: #[0];
- 	literal: #with:;
- 	binding: #Array;
- 	literal: 10;
  	literal: methodBlock;
  	pushSpecialConstant: 1;
+ 	pushFullClosure: 0 numCopied: 1;
- 	pushFullClosure: 3 numCopied: 1;
- 	send: #value super: false numArgs: 0;
  	methodReturnTop;
  	yourself) assemble.
+ closure := #rcvr withArgs: #() executeMethod: outerMethod.
+ {closure at: 1 . closure receiver . closure value} !!)!
- self assert: (nil withArgs: #() executeMethod: outerMethod) = 1.!

Item was added:
+ ----- Method: InstructionPrinter>>pushFullClosure:numCopied: (in category '*BytecodeSets-instruction decoding') -----
+ pushFullClosure: cb numCopied: num
+ 	self print: 'pushFullClosure: ' , cb selector , ' numCopied: ' , num!



More information about the Vm-dev mailing list