The Trunk: Compiler-mt.406.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compiler-mt.406.mcz

commits-2
Marcel Taeumel uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-mt.406.mcz

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

Name: Compiler-mt.406
Author: mt
Time: 24 July 2019, 5:10:22.611145 pm
UUID: 6d65ea45-4488-471b-a9cf-b4a16cac35f3
Ancestors: Compiler-mt.405

Minor performance improvement for has-literal checks. Thanks to Levente for the ideas!

Still not sure about putting true/false/nil-checks to the top. Also not sure the complex return blocks for symbol/character/integer.

=============== Diff against Compiler-mt.405 ===============

Item was changed:
  ----- Method: BytecodeEncoder class>>canBeSpecialLiteral: (in category 'testing') -----
  canBeSpecialLiteral: aLiteral
+ "This check can be used to prevent unnecessary use of #scanBlockOrNilForLiteral:. For performance, this method summarizes specializations from all known bytecode encoders. It is not meant to be refined per bytecode encoder."
- "This check can be used to prevent unnecessary use of #scanBlockOrNilForLiteral:. For performance, this method summarizes specializations from all known bytecode encoders. It is not meant to be refined per encoder."
 
+ aLiteral isSymbol ifTrue: [^ Smalltalk specialSelectors identityIncludes: aLiteral].
+ aLiteral isCharacter ifTrue: [^ aLiteral asInteger <= 65535].
+ aLiteral isInteger ifTrue: [^ aLiteral between: -32768 and: 32767].
+
+ aLiteral == true ifTrue: [^ true].
+ aLiteral == false ifTrue: [^ true].
+ aLiteral == nil ifTrue: [^ true].
+
+ ^ false!
- ^ ((((((aLiteral isSymbol and: [Smalltalk specialSelectors includes: aLiteral])
- or: [aLiteral isInteger and: [aLiteral between: -32768 and: 32767]])
- or: [aLiteral isCharacter and: [aLiteral asInteger <= 65535]])
- or: [aLiteral == true])
- or: [aLiteral == false])
- or: [aLiteral == nil])!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Compiler-mt.406.mcz

Levente Uzonyi
Hi Marcel,

On Wed, 24 Jul 2019, [hidden email] wrote:

> Marcel Taeumel uploaded a new version of Compiler to project The Trunk:
> http://source.squeak.org/trunk/Compiler-mt.406.mcz
>
> ==================== Summary ====================
>
> Name: Compiler-mt.406
> Author: mt
> Time: 24 July 2019, 5:10:22.611145 pm
> UUID: 6d65ea45-4488-471b-a9cf-b4a16cac35f3
> Ancestors: Compiler-mt.405
>
> Minor performance improvement for has-literal checks. Thanks to Levente for the ideas!
>
> Still not sure about putting true/false/nil-checks to the top. Also not sure the complex return blocks for symbol/character/integer.

The code is fine as-is. I doubt it needed optimization in the first place.
I would even consider turning the branches of true, false, nil and ^false
back into a single boolean expression, but I don't think it's worth to
spend more time and SqueakSource resources on this.

Performance-wise, this version is pretty good. The ugly and weird JIT hack
to use ifTrue:ifFalse: with explicit returns could boost it a bit. E.g.:

  aLiteral isSymbol ifTrue: [
  (Smalltalk specialSelectors identityIncludes: aLiteral) ifTrue: [ ^true ].
  ^false ]
instead of

  aLiteral isSymbol ifTrue: [^ Smalltalk specialSelectors identityIncludes: aLiteral].


Levente

>
> =============== Diff against Compiler-mt.405 ===============
>
> Item was changed:
>  ----- Method: BytecodeEncoder class>>canBeSpecialLiteral: (in category 'testing') -----
>  canBeSpecialLiteral: aLiteral
> + "This check can be used to prevent unnecessary use of #scanBlockOrNilForLiteral:. For performance, this method summarizes specializations from all known bytecode encoders. It is not meant to be refined per bytecode encoder."
> - "This check can be used to prevent unnecessary use of #scanBlockOrNilForLiteral:. For performance, this method summarizes specializations from all known bytecode encoders. It is not meant to be refined per encoder."
>
> + aLiteral isSymbol ifTrue: [^ Smalltalk specialSelectors identityIncludes: aLiteral].
> + aLiteral isCharacter ifTrue: [^ aLiteral asInteger <= 65535].
> + aLiteral isInteger ifTrue: [^ aLiteral between: -32768 and: 32767].
> +
> + aLiteral == true ifTrue: [^ true].
> + aLiteral == false ifTrue: [^ true].
> + aLiteral == nil ifTrue: [^ true].
> +
> + ^ false!
> - ^ ((((((aLiteral isSymbol and: [Smalltalk specialSelectors includes: aLiteral])
> - or: [aLiteral isInteger and: [aLiteral between: -32768 and: 32767]])
> - or: [aLiteral isCharacter and: [aLiteral asInteger <= 65535]])
> - or: [aLiteral == true])
> - or: [aLiteral == false])
> - or: [aLiteral == nil])!