[Nice-commit] Nice/src/gnu/expr ApplyExp.java,1.7,1.8 Expression.java,1.3,1.4 LoopExp.java,1.7,1.8
Brought to you by:
bonniot
|
From: <ar...@us...> - 2003-03-20 14:58:31
|
Update of /cvsroot/nice/Nice/src/gnu/expr
In directory sc8-pr-cvs1:/tmp/cvs-serv12577/F:/nice/src/gnu/expr
Modified Files:
ApplyExp.java Expression.java LoopExp.java
Log Message:
ShortCircuitOp makes use of Branchable if possible to generate better bytecode.
Index: ApplyExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/expr/ApplyExp.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ApplyExp.java 19 Mar 2003 16:45:14 -0000 1.7
--- ApplyExp.java 20 Mar 2003 14:58:23 -0000 1.8
***************
*** 516,529 ****
}
- public Branchable getBranchable()
- {
- if (func instanceof QuoteExp)
- {
- Object proc = ((QuoteExp) func).getValue();
- if (proc instanceof Branchable)
- return (Branchable)proc;
- }
- return null;
- }
-
}
--- 516,518 ----
Index: Expression.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/expr/Expression.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Expression.java 26 Nov 2001 11:09:49 -0000 1.3
--- Expression.java 20 Mar 2003 14:58:24 -0000 1.4
***************
*** 195,197 ****
--- 195,213 ----
return (flags & flag) != 0;
}
+
+ public Branchable getBranchable()
+ {
+ if (this instanceof ApplyExp)
+ {
+ Expression func = ((ApplyExp)this).func;
+ if (func instanceof QuoteExp)
+ {
+ Object proc = ((QuoteExp) func).getValue();
+ if (proc instanceof Branchable)
+ return (Branchable)proc;
+ }
+ }
+ return null;
+ }
+
}
Index: LoopExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/expr/LoopExp.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** LoopExp.java 19 Mar 2003 16:45:14 -0000 1.7
--- LoopExp.java 20 Mar 2003 14:58:24 -0000 1.8
***************
*** 89,107 ****
Jump to label <code>to</code> if <code>ifExp</code> is true.
! Optimizes the case where ifExp is a integer comparison,
since specific JVM bytecode handle these cases.
*/
private void compileIfJump(Compilation comp, Expression ifExp, Label to)
{
! if (ifExp instanceof ApplyExp)
! {
! ApplyExp app = (ApplyExp) ifExp;
! Branchable branchOp = app.getBranchable();
! if (branchOp != null)
! {
! branchOp.compileJump(comp, app.args, to);
! return;
! }
! }
// General case
--- 89,103 ----
Jump to label <code>to</code> if <code>ifExp</code> is true.
! Optimizes the case where ifExp is a branchable operator,
since specific JVM bytecode handle these cases.
*/
private void compileIfJump(Compilation comp, Expression ifExp, Label to)
{
! Branchable branchOp = ifExp.getBranchable();
! if (branchOp != null)
! {
! branchOp.compileJump(comp, ((ApplyExp)ifExp).args, to);
! return;
! }
// General case
|