Quantcast

VM Maker: VMMaker.oscog-eem.2063.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

VM Maker: VMMaker.oscog-eem.2063.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2063.mcz

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

Name: VMMaker.oscog-eem.2063
Author: eem
Time: 31 December 2016, 2:37:08.922183 pm
UUID: 034eff8c-70b0-4106-b87e-a02a6a9aa506
Ancestors: VMMaker.oscog-eem.2062

SmartSyntaxPlugin Slang:

Avoid generating unreachable code when failing.  Avoid an unnecessary test for failed if returning an expression which can't fail.  Nuke an unused method.

=============== Diff against VMMaker.oscog-eem.2062 ===============

Item was removed:
- ----- Method: SmartSyntaxPluginTMethod>>checkSuccessExpr (in category 'private') -----
- checkSuccessExpr
- "Return the parse tree for an expression that aborts the primitive if the successFlag is not true."
-
- | expr |
- expr := 'interpreterProxy failed ifTrue: [^nil]'.
- ^ self statementsFor: expr varName: ''
- !

Item was changed:
  ----- Method: SmartSyntaxPluginTMethod>>fixUpReturnOneStmt:on: (in category 'transforming') -----
  fixUpReturnOneStmt: stmt on: sStream
 
  stmt isReturn ifFalse: [^sStream nextPut: stmt].
  (stmt expression isSend
  and: [#('primitiveFail' 'primitiveFailFor:') includes: stmt expression selector]) ifTrue:
  ["failure return"
  sStream nextPut: stmt expression.
  sStream nextPut: self nullReturnExpr.
  ^nil].
  (stmt expression isVariable and: ['nil' = stmt expression name]) ifTrue:
  ["^ nil -- this is never right unless automatically generated"
  sStream nextPut: stmt.
  ^nil].
  (stmt expression isVariable and: ['self' = stmt expression name]) ifTrue:
  ["^ self"
  self generateFailureGuardOn: sStream.
  fullArgs isEmpty ifFalse:[ sStream nextPut: (self popExpr: fullArgs size)].
  sStream nextPut: self nullReturnExpr.
  ^nil].
  (stmt expression isVariable | stmt expression isConstant | suppressingFailureGuards) ifTrue:
  ["^ variable or ^ constant or ^ expr without guardchecking"
  self generateFailureGuardOn: sStream.
  sStream nextPut: (self pop: fullArgs size + 1 thenReturnExpr: stmt expression).
  sStream nextPut: self nullReturnExpr.
  ^nil].
+ "^ expr with necessary guard checking"
- "^ expr with guardchecking"
  self generateFailureGuardOn: sStream.
+ (self resultExpressionAlwaysFails: stmt expression)
+ ifTrue:
+ [sStream nextPut: stmt expression]
+ ifFalse:
+ [sStream nextPut: (self assign: (self oopVariable: '_return_value') expression: stmt expression).
+ (self resultExpressionCanFail: stmt expression) ifTrue:
+ [self generateFailureGuardOn: sStream].
+ sStream nextPut: (self pop: fullArgs size + 1 thenReturnExpr: (self oopVariable: '_return_value'))].
+ sStream nextPut: self nullReturnExpr!
- sStream nextPut: (self assign: (self oopVariable: '_return_value') expression: stmt expression).
- self generateFailureGuardOn: sStream.
- sStream nextPut: (self pop: fullArgs size + 1 thenReturnExpr: (self oopVariable: '_return_value')).
- sStream nextPut: self nullReturnExpr
- !

Item was removed:
- ----- Method: SmartSyntaxPluginTMethod>>oldReplaceSizeMessages (in category 'private') -----
- oldReplaceSizeMessages
- "Replace sends of the message 'size' with calls to sizeOfSTArrayFromCPrimitive."
-
- | argExpr |
- parseTree nodesDo: [:n |
- (n isSend and: [n selector = #size]) ifTrue: [
- argExpr := TSendNode new
- setSelector: #+
- receiver: n receiver
- arguments: (Array with: (TConstantNode new setValue: 1)).
- n
- setSelector: #sizeOfSTArrayFromCPrimitive:
- receiver: (TVariableNode new setName: 'interpreterProxy')
- arguments: (Array with: argExpr)]].
- !

Item was added:
+ ----- Method: SmartSyntaxPluginTMethod>>resultExpressionAlwaysFails: (in category 'private') -----
+ resultExpressionAlwaysFails: aTSendNode
+ ^aTSendNode selector == #success:
+ and: [aTSendNode args first isConstant
+ and: [aTSendNode args first value == false]]!

Item was added:
+ ----- Method: SmartSyntaxPluginTMethod>>resultExpressionCanFail: (in category 'private') -----
+ resultExpressionCanFail: aTSendNode
+ "Neither asSmallIntegerObj nor asBooleanObj can fail."
+ ^(#(asSmallIntegerObj asBooleanObj) includes: aTSendNode selector) not!

Loading...