Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename {Cons,New}Array into NewArray{Stack,Nil}Init #17370

Open
wants to merge 1 commit into
base: Pharo13
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Debugging-Core/SymbolicBytecodeBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ SymbolicBytecodeBuilder >> pushClosureTemps: numTemps [
self addBytecode: 'pushClosureTemps:' , numTemps printString
]

{ #category : 'instruction decoding' }
SymbolicBytecodeBuilder >> pushConsArrayWithElements: numElements [

self addBytecode: 'pop ', numElements printString, ' into (Array new: ', numElements printString, ')'
]

{ #category : 'instruction decoding' }
SymbolicBytecodeBuilder >> pushConstant: obj [
"Print the Push Constant, obj, on Top Of Stack bytecode."
Expand Down Expand Up @@ -237,6 +231,12 @@ SymbolicBytecodeBuilder >> pushNewArrayOfSize: numElements [
self addBytecode: 'push: (Array new: ', numElements printString, ')'
]

{ #category : 'instruction decoding' }
SymbolicBytecodeBuilder >> pushNewArrayStackInitWithElements: numElements [

self addBytecode: 'pop ', numElements printString, ' into (Array new: ', numElements printString, ')'
]

{ #category : 'instruction decoding' }
SymbolicBytecodeBuilder >> pushReceiver [
"Print the Push Active Context's Receiver on Top Of Stack bytecode."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ FBIRBytecodeDecompilerTest >> testPopTop [
]

{ #category : 'tests' }
FBIRBytecodeDecompilerTest >> testPushConsArray [
FBIRBytecodeDecompilerTest >> testPushNewArrayStackInit [
| ir1 ir2 method |
ir1 := IRBuilderTest new testPushConsArray.
ir1 := IRBuilderTest new testPushNewArrayStackInit.
method := ir1 compiledMethod.
ir2 := FBIRBytecodeDecompiler new decompile: method.
self deny: ir2 compiledMethod identicalTo: method.
Expand All @@ -270,9 +270,9 @@ FBIRBytecodeDecompilerTest >> testPushConsArray [
]

{ #category : 'tests' }
FBIRBytecodeDecompilerTest >> testPushConsArray2 [
FBIRBytecodeDecompilerTest >> testPushNewArrayStackInit2 [
| ir1 ir2 method |
ir1 := IRBuilderTest new testPushConsArray2.
ir1 := IRBuilderTest new testPushNewArrayStackInit2.
method := ir1 compiledMethod.
ir2 := FBIRBytecodeDecompiler new decompile: method.
self deny: ir2 compiledMethod identicalTo: method.
Expand Down
16 changes: 8 additions & 8 deletions src/Flashback-Decompiler/FBDDecompiler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,6 @@ FBDDecompiler >> pushCleanClosure: aCompiledBlock [
currentSequence := savedSequence
]

{ #category : 'data flow instructions' }
FBDDecompiler >> pushConsArrayWithElements: numElements [
| array |
array := Array new: numElements.
numElements to: 1 by: -1 do: [ :i | array at: i put: simulatedStack removeLast ].
simulatedStack addLast: (builder codeArray: array)
]

{ #category : 'data flow instructions' }
FBDDecompiler >> pushConstant: value [
value isEmbeddedBlock ifTrue: [ ^self pushCleanClosure: value compiledBlock ].
Expand Down Expand Up @@ -543,6 +535,14 @@ FBDDecompiler >> pushNewArrayOfSize: numElements [
simulatedStack addLast: tempVect
]

{ #category : 'data flow instructions' }
FBDDecompiler >> pushNewArrayStackInitWithElements: numElements [
| array |
array := Array new: numElements.
numElements to: 1 by: -1 do: [ :i | array at: i put: simulatedStack removeLast ].
simulatedStack addLast: (builder codeArray: array)
]

{ #category : 'data flow instructions' }
FBDDecompiler >> pushReceiver [
simulatedStack addLast: builder codeReceiver
Expand Down
10 changes: 5 additions & 5 deletions src/Flashback-Decompiler/FBIRBytecodeDecompiler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,6 @@ FBIRBytecodeDecompiler >> pushActiveContext [
irBuilder pushThisContext
]

{ #category : 'instruction decoding' }
FBIRBytecodeDecompiler >> pushConsArrayWithElements: numElements [
irBuilder pushConsArray: numElements
]

{ #category : 'instruction decoding' }
FBIRBytecodeDecompiler >> pushConstant: value [
irBuilder pushLiteral: value
Expand All @@ -234,6 +229,11 @@ FBIRBytecodeDecompiler >> pushNewArrayOfSize: size [
newTempVector := IRRemoteArray new size: size
]

{ #category : 'instruction decoding' }
FBIRBytecodeDecompiler >> pushNewArrayStackInitWithElements: numElements [
irBuilder pushNewArrayStackInit: numElements
]

{ #category : 'instruction decoding' }
FBIRBytecodeDecompiler >> pushReceiver [
irBuilder pushReceiver
Expand Down
14 changes: 7 additions & 7 deletions src/Kernel-BytecodeEncoders/BytecodeEncoder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ BytecodeEncoder >> sizePop [
^self sizeOpcodeSelector: #genPop withArguments: #()
]

{ #category : 'opcode sizing' }
BytecodeEncoder >> sizePushConsArray: numElements [
^self sizeOpcodeSelector: #genPushConsArray: withArguments: {numElements}
]

{ #category : 'opcode sizing' }
BytecodeEncoder >> sizePushInstVar: instVarIndex [
^self sizeOpcodeSelector: #genPushInstVar: withArguments: {instVarIndex}
Expand All @@ -176,8 +171,13 @@ BytecodeEncoder >> sizePushLiteralVar: literalIndex [
]

{ #category : 'opcode sizing' }
BytecodeEncoder >> sizePushNewArray: size [
^self sizeOpcodeSelector: #genPushNewArray: withArguments: {size}
BytecodeEncoder >> sizePushNewArrayNilInit: size [
^self sizeOpcodeSelector: #genPushNewArrayNilInit: withArguments: {size}
]

{ #category : 'opcode sizing' }
BytecodeEncoder >> sizePushNewArrayStackInit: numElements [
^self sizeOpcodeSelector: #genPushNewArrayStackInit: withArguments: {numElements}
]

{ #category : 'opcode sizing' }
Expand Down
24 changes: 12 additions & 12 deletions src/Kernel-BytecodeEncoders/EncoderForSistaV1.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1034,17 +1034,6 @@ EncoderForSistaV1 >> genPushCharacter: aCharacterOrCode [
nextPut: (code bitAnd: 255)
]

{ #category : 'bytecode generation' }
EncoderForSistaV1 >> genPushConsArray: size [
(size < 0 or: [size > 127]) ifTrue:
[^self outOfRangeError: 'size' index: size range: 0 to: 127].
"231 11100111 jkkkkkkk Push (Array new: kkkkkkk) (j = 0)
& Pop kkkkkkk elements into: (Array new: kkkkkkk) (j = 1)"
stream
nextPut: 231;
nextPut: size + 128
]

{ #category : 'extended bytecode generation' }
EncoderForSistaV1 >> genPushFullClosure: compiledBlockLiteralIndex numCopied: numCopied receiverOnStack: receiverOnStack outerContextNeeded: outerContextNeeded [
"* 249 11111001 xxxxxxxx siyyyyyy push Closure Compiled block literal index xxxxxxxx (+ Extend A * 256) numCopied yyyyyy receiverOnStack: s = 1 ignoreOuterContext: i = 1"
Expand Down Expand Up @@ -1155,7 +1144,7 @@ EncoderForSistaV1 >> genPushLiteralVar: literalIndex [
]

{ #category : 'bytecode generation' }
EncoderForSistaV1 >> genPushNewArray: size [
EncoderForSistaV1 >> genPushNewArrayNilInit: size [
(size < 0 or: [size > 127]) ifTrue:
[^self outOfRangeError: 'size' index: size range: 0 to: 127].
"231 11100111 jkkkkkkk Push (Array new: kkkkkkk) (j = 0)
Expand All @@ -1165,6 +1154,17 @@ EncoderForSistaV1 >> genPushNewArray: size [
nextPut: size
]

{ #category : 'bytecode generation' }
EncoderForSistaV1 >> genPushNewArrayStackInit: size [
(size < 0 or: [size > 127]) ifTrue:
[^self outOfRangeError: 'size' index: size range: 0 to: 127].
"231 11100111 jkkkkkkk Push (Array new: kkkkkkk) (j = 0)
& Pop kkkkkkk elements into: (Array new: kkkkkkk) (j = 1)"
stream
nextPut: 231;
nextPut: size + 128
]

{ #category : 'bytecode generation' }
EncoderForSistaV1 >> genPushReceiver [
"76 01001100 Push Receiver"
Expand Down
18 changes: 9 additions & 9 deletions src/Kernel-CodeModel/Context.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1515,15 +1515,6 @@ Context >> pushClosureTemps: numTemps [
numTemps timesRepeat: [ self push: nil ]
]

{ #category : 'instruction decoding' }
Context >> pushConsArrayWithElements: numElements [
| array |
array := Array new: numElements.
numElements to: 1 by: -1 do: [ :i |
array at: i put: self pop ].
self push: array
]

{ #category : 'instruction decoding' }
Context >> pushConstant: value [
"Simulate the action of bytecode that pushes the constant, value, on the
Expand Down Expand Up @@ -1559,6 +1550,15 @@ Context >> pushNewArrayOfSize: arraySize [
self push: (Array new: arraySize)
]

{ #category : 'instruction decoding' }
Context >> pushNewArrayStackInitWithElements: numElements [
| array |
array := Array new: numElements.
numElements to: 1 by: -1 do: [ :i |
array at: i put: self pop ].
self push: array
]

{ #category : 'instruction decoding' }
Context >> pushReceiver [
"Simulate the action of bytecode that pushes the active context's receiver
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel-CodeModel/InstructionStream.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ InstructionStream >> interpretNext2ByteSistaV1Instruction: bytecode for: client
bytecode = 231 ifTrue:
[^byte < 128
ifTrue: [client pushNewArrayOfSize: byte]
ifFalse: [client pushConsArrayWithElements: byte - 128]].
ifFalse: [client pushNewArrayStackInitWithElements: byte - 128]].
bytecode = 232 ifTrue:
[^client pushConstant: (extB bitShift: 8) + byte].
^client pushConstant: (Character value: (extB bitShift: 8) + byte)].
Expand Down
10 changes: 5 additions & 5 deletions src/Kernel/InstructionClient.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ InstructionClient >> pushClosureTemps: numTemps [
"push on stack nil numTemps times for the closure temps"
]

{ #category : 'instruction decoding' }
InstructionClient >> pushConsArrayWithElements: numElements [
"Push Cons Array of size numElements popping numElements items from the stack into the array bytecode."
]

{ #category : 'instruction decoding' }
InstructionClient >> pushConstant: value [
"Push Constant, value, on Top Of Stack bytecode."
Expand All @@ -173,6 +168,11 @@ InstructionClient >> pushNewArrayOfSize: numElements [
"Push New Array of size numElements bytecode."
]

{ #category : 'instruction decoding' }
InstructionClient >> pushNewArrayStackInitWithElements: numElements [
"Push new Array of size numElements and fill it by popping numElements items from the stack into the array bytecode."
]

{ #category : 'instruction decoding' }
InstructionClient >> pushReceiver [
"Push Active Context's Receiver on Top Of Stack bytecode."
Expand Down
16 changes: 8 additions & 8 deletions src/OpalCompiler-Core/IRBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,6 @@ IRBuilder >> properties: aDict [
ir properties: aDict
]

{ #category : 'instructions' }
IRBuilder >> pushConsArray: size [

self add: (IRInstruction pushConsArray: size)
]

{ #category : 'instructions' }
IRBuilder >> pushDup [

Expand Down Expand Up @@ -348,9 +342,15 @@ IRBuilder >> pushLiteralVariable: object [
]

{ #category : 'instructions' }
IRBuilder >> pushNewArray: size [
IRBuilder >> pushNewArrayNilInit: size [

self add: (IRInstruction pushNewArrayNilInit: size)
]

{ #category : 'instructions' }
IRBuilder >> pushNewArrayStackInit: size [

self add: (IRInstruction pushNewArray: size)
self add: (IRInstruction pushNewArrayStackInit: size)
]

{ #category : 'instructions' }
Expand Down
18 changes: 9 additions & 9 deletions src/OpalCompiler-Core/IRBytecodeGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,6 @@ IRBytecodeGenerator >> properties: propDict [
properties := propDict
]

{ #category : 'instructions' }
IRBytecodeGenerator >> pushConsArray: size [
stack push.
stack pop: size.
encoder genPushConsArray: size
]

{ #category : 'instructions' }
IRBytecodeGenerator >> pushDup [
stack push.
Expand Down Expand Up @@ -540,9 +533,16 @@ IRBytecodeGenerator >> pushLiteralVariable: object [
]

{ #category : 'instructions' }
IRBytecodeGenerator >> pushNewArray: size [
IRBytecodeGenerator >> pushNewArrayNilInit: size [
stack push.
encoder genPushNewArray: size
encoder genPushNewArrayNilInit: size
]

{ #category : 'instructions' }
IRBytecodeGenerator >> pushNewArrayStackInit: size [
stack push.
stack pop: size.
encoder genPushNewArrayStackInit: size
]

{ #category : 'instructions' }
Expand Down
20 changes: 10 additions & 10 deletions src/OpalCompiler-Core/IRInstruction.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ IRInstruction class >> popTop [
^ IRPop new
]

{ #category : 'instance creation' }
IRInstruction class >> pushConsArray: aSize [
^IRPushArray new
size: aSize;
cons: true;
yourself
]

{ #category : 'instance creation' }
IRInstruction class >> pushDup [

Expand Down Expand Up @@ -104,11 +96,19 @@ IRInstruction class >> pushLiteralVariable: object [
]

{ #category : 'instance creation' }
IRInstruction class >> pushNewArray: aSize [
IRInstruction class >> pushNewArrayNilInit: aSize [

^IRPushArray new
size: aSize;
cons: false;
initsFromStack: false;
yourself
]

{ #category : 'instance creation' }
IRInstruction class >> pushNewArrayStackInit: aSize [
^IRPushArray new
size: aSize;
initsFromStack: true;
yourself
]

Expand Down
6 changes: 3 additions & 3 deletions src/OpalCompiler-Core/IRPrinter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ IRPrinter >> visitPopIntoTemp: tmp [
{ #category : 'visiting' }
IRPrinter >> visitPushArray: array [

array cons
array initsFromStack
ifTrue: [
stream nextPutAll: 'pushConsArray: ' ]
stream nextPutAll: 'pushNewArrayStackInit: ' ]
ifFalse: [
stream nextPutAll: 'pushNewArray: ' ].
stream nextPutAll: 'pushNewArrayNilInit: ' ].
array size printOn: stream
]

Expand Down
20 changes: 10 additions & 10 deletions src/OpalCompiler-Core/IRPushArray.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
#superclass : 'IRInstruction',
#instVars : [
'size',
'cons'
'initsFromStack'
],
#category : 'OpalCompiler-Core-IR-Nodes',
#package : 'OpalCompiler-Core',
Expand All @@ -20,20 +20,20 @@ IRPushArray >> accept: aVisitor [
^ aVisitor visitPushArray: self
]

{ #category : 'accessing' }
IRPushArray >> cons [
^ cons
{ #category : 'initialization' }
IRPushArray >> initialize [
size := 0.
initsFromStack := false
]

{ #category : 'accessing' }
IRPushArray >> cons: aBool [
cons := aBool
IRPushArray >> initsFromStack [
^ initsFromStack
]

{ #category : 'initialization' }
IRPushArray >> initialize [
size := 0.
cons := false
{ #category : 'accessing' }
IRPushArray >> initsFromStack: aBool [
initsFromStack := aBool
]

{ #category : 'accessing' }
Expand Down
Loading