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

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

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

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

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

Name: VMMaker.oscog-eem.2589
Author: eem
Time: 22 November 2019, 1:20:45.793955 pm
UUID: 5beddd90-a4e7-4e3d-95de-550f911e96b4
Ancestors: VMMaker.oscog-eem.2588

Slang for plugins.

Fix resultSendAlwaysFails: to include the two new failure sends, primitiveFailForFFIException:at: primitiveFailForOSError:.

As a micro optimization, if the enclosing method has type #sqInt then return the falures directly, as they're all typed as sqInt.  That should save an instruction :-)

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

Item was changed:
  ----- Method: SmartSyntaxPluginTMethod>>fixUpReturnOneStmt:on: (in category 'transforming') -----
  fixUpReturnOneStmt: stmt on: sStream
  | expr exprRetStmts "p t" |
  stmt isReturn ifFalse: [^sStream nextPut: stmt].
  expr := stmt expression.
  (expr isSend
  and: [self resultSendAlwaysFails: expr]) ifTrue:
  ["failure returns"
+ returnType = #sqInt
+ ifTrue: [sStream nextPut: (TReturnNode new setExpression: expr)]
+ ifFalse: [sStream nextPut: expr; nextPut: self nullReturnExpr].
- sStream nextPut: expr; nextPut: self nullReturnExpr.
  ^nil].
  (expr isVariable and: ['nil' = expr name]) ifTrue:
  ["^ nil -- this is never right unless automatically generated"
  sStream nextPut: stmt.
  ^nil].
  (expr isVariable and: ['self' = expr name]) ifTrue:
  ["^ self"
  fullArgs isEmpty ifFalse:
  [sStream nextPut: (self statementGuardedWithSuccess: (self popExpr: fullArgs size))].
  sStream nextPut: self nullReturnExpr.
  ^nil].
  (expr isVariable or: [expr isConstant]) ifTrue:
  ["^ variable or ^ constant without guardchecking"
  sStream
  nextPut: (sStream isEmpty "No statements to cause failure, therefore no need for failure guard."
  ifTrue:
  [self pop: fullArgs size + 1 thenReturnExpr: expr]
  ifFalse:
  [self statementGuardedWithSuccess:
  (self pop: fullArgs size + 1 thenReturnExpr: expr)]);
  nextPut: self nullReturnExpr.
  ^nil].
  "^ expr with necessary guard checking"
  "p := sStream position."
  exprRetStmts := Array streamContents:
  [:ersStream|
  (self resultExpressionCanFail: expr)
  ifTrue:
  ["t := 1."
  ersStream
  nextPut: (self assign: (self oopVariable: '_return_value') expression: expr);
  nextPut: (self statementGuardedWithSuccess: (self pop: fullArgs size + 1
  thenReturnExpr: (self oopVariable: '_return_value')))]
  ifFalse:
  ["t := 2."
  ersStream nextPut: (self pop: fullArgs size + 1 thenReturnExpr: expr)]].
  sStream isEmpty "No statements to cause failure, therefore no need for an initial failure guard."
  ifTrue: [sStream nextPutAll: exprRetStmts]
  ifFalse:
  ["t := t + 2."
  sStream nextPut: (self statementGuardedWithSuccess: exprRetStmts)].
  sStream nextPut: self nullReturnExpr.
  "Them := Dictionary new"
  "(Them at: t ifAbsentPut: [Dictionary new])
  at: self selector
  put: (sStream originalContents copyFrom: p + 1 to: sStream position)"!

Item was changed:
  ----- Method: SmartSyntaxPluginTMethod>>resultSendAlwaysFails: (in category 'private') -----
  resultSendAlwaysFails: aTSendNode
+ ^(#(primitiveFail primitiveFailFor: primitiveFailForFFIException:at: primitiveFailForOSError:) includes: aTSendNode selector)
- ^(#(primitiveFail primitiveFailFor:) includes: aTSendNode selector)
  or: [aTSendNode selector == #success:
  and: [aTSendNode args first isConstant
  and: [aTSendNode args first value == false]]]!