-
Notifications
You must be signed in to change notification settings - Fork 64
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specialize primitive at #647
base: pharo-12
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments with ideas
jump1 := cogit JumpNonZero: 0. | ||
cogit MoveR: Arg0Reg R: TempReg. | ||
cogit ArithmeticShiftRightCq: 3 R: TempReg. | ||
cogit MoveM64: 0 r: ReceiverResultReg R: ClassReg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see why you're looking at customisation, this could be checked statically
cogit AndCq: 255 R: SendNumArgsReg. | ||
cogit CmpCq: 255 R: SendNumArgsReg. | ||
jump3 := cogit JumpZero: 0. | ||
jump4 := cogit Jump: 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern could be simplified if we do a better way to sort basic blocks
cogit MoveR: ReceiverResultReg R: SendNumArgsReg. | ||
cogit AddR: SendNumArgsReg R: TempReg. | ||
cogit AddCq: -1 R: TempReg. | ||
cogit MoveMb: 8 r: TempReg R: SendNumArgsReg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be also simplifiable
cogit AddR: SendNumArgsReg R: TempReg. | ||
cogit AddCq: -1 R: TempReg. | ||
cogit MoveMb: 8 r: TempReg R: SendNumArgsReg. | ||
cogit AndCq: 255 R: SendNumArgsReg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could avoid this instruction if the backend automatically zero extends the reads only when required...
jump4 := cogit JumpLess: 0. | ||
cogit CmpR: ClassReg R: TempReg. | ||
jump3 := cogit JumpGreater: 0. | ||
cogit SubCq: 1 R: TempReg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An interesting not here is that we know we cannot fail anymore. So here we should be able to use the Receiver register and override it as soon as it is not used anymore.
This
cogit SubCq: 1 R: TempReg.
cogit LogicalShiftLeftCq: 3 R: TempReg.
cogit MoveR: ReceiverResultReg R: ClassReg.
cogit AddR: ClassReg R: TempReg.
cogit MoveM64: 8 r: TempReg R: ClassReg.
cogit MoveR: ClassReg R: ReceiverResultReg.
could eventually be compiled as
cogit SubCq: 1 R: TempReg.
cogit LogicalShiftLeftCq: 3 R: TempReg.
cogit AddR: ReceiverResultReg. R: TempReg.
cogit MoveM64: 8 r: TempReg R: ReceiverResultReg.
cogit TstCq: 7 R: ReceiverResultReg. | ||
jump1 := cogit JumpNonZero: 0. | ||
cogit MoveR: Arg0Reg R: TempReg. | ||
cogit ArithmeticShiftRightCq: 3 R: TempReg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not validating that the argument is an integer!
| jump3 jump1 currentBlock jump4 jump2 | | ||
cogit TstCq: 7 R: ReceiverResultReg. | ||
jump1 := cogit JumpNonZero: 0. | ||
cogit MoveR: Arg0Reg R: TempReg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, there is no validation on the argument!
<accessorDepth: 0> | ||
<numberOfArguments: 1> | ||
self commonAtWith: [ :array :index | | ||
self stPointerArray: array at: index ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the conciseness :)
We can even refactor the original one to look like this.
I agree |
Made in a dojo with many people :)
Adding two specialised versions of
primitiveAt
.primitiveAtByteArray
for bytearraysprimitiveAtPointerArray
for normal arraysThis PR is related to #638, but needs more work (I left some comments).
We should merge both together.