jsx / JSX

JSX - a faster, safer, easier JavaScript
http://jsx.github.io/
MIT License
1.46k stars 102 forks source link

ArrayLengthOptimizer unexpectedly dies #321

Closed nyuichi closed 10 years ago

nyuichi commented 10 years ago

ArrayLengthOptimizer dies when a for-statement has no expression for post-expr.

// foo.jsx
class C {
    function m () : void {

        var ary = new int[];

        for (var i = 0; i < ary.length;) {
        }

    }
}
$ bin/jsx --release foo.jsx 2>&1       
fatal error: optimizer 'array-length' died unexpectedly, dumping the logsstarting optimizer: lto
[lto] marking class as final: C
finished optimizer: lto
starting optimizer: no-assert
[no-assert] starting optimization of Number.isNaN(:number)
[no-assert] finished optimization of Number.isNaN(:number)
[no-assert] starting optimization of Math.abs(:number)
[no-assert] finished optimization of Math.abs(:number)
[no-assert] starting optimization of Math.max(:number,:number)
[no-assert] finished optimization of Math.max(:number,:number)
[no-assert] starting optimization of Math.min(:number,:number)
[no-assert] finished optimization of Math.min(:number,:number)
[no-assert] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[no-assert] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[no-assert] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[no-assert] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[no-assert] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[no-assert] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[no-assert] starting optimization of C#m()
[no-assert] finished optimization of C#m()
[no-assert] starting optimization of C#constructor()
[no-assert] finished optimization of C#constructor()
finished optimizer: no-assert
starting optimizer: no-log
[no-log] starting optimization of Number.isNaN(:number)
[no-log] finished optimization of Number.isNaN(:number)
[no-log] starting optimization of Math.abs(:number)
[no-log] finished optimization of Math.abs(:number)
[no-log] starting optimization of Math.max(:number,:number)
[no-log] finished optimization of Math.max(:number,:number)
[no-log] starting optimization of Math.min(:number,:number)
[no-log] finished optimization of Math.min(:number,:number)
[no-log] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[no-log] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[no-log] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[no-log] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[no-log] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[no-log] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[no-log] starting optimization of C#m()
[no-log] finished optimization of C#m()
[no-log] starting optimization of C#constructor()
[no-log] finished optimization of C#constructor()
finished optimizer: no-log
starting optimizer: no-debug
[no-debug] set JSX.DEBUG = false
finished optimizer: no-debug
starting optimizer: fold-const
[fold-const] starting optimization of Number.isNaN(:number)
[fold-const] finished optimization of Number.isNaN(:number)
[fold-const] starting optimization of Math.abs(:number)
[fold-const] finished optimization of Math.abs(:number)
[fold-const] starting optimization of Math.max(:number,:number)
[fold-const] finished optimization of Math.max(:number,:number)
[fold-const] starting optimization of Math.min(:number,:number)
[fold-const] finished optimization of Math.min(:number,:number)
[fold-const] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[fold-const] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[fold-const] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[fold-const] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[fold-const] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[fold-const] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[fold-const] starting optimization of C#m()
[fold-const] finished optimization of C#m()
[fold-const] starting optimization of C#constructor()
[fold-const] finished optimization of C#constructor()
finished optimizer: fold-const
starting optimizer: determine-callee
[determine-callee] starting optimization of Number.isNaN(:number)
[determine-callee] finished optimization of Number.isNaN(:number)
[determine-callee] starting optimization of Math.abs(:number)
[determine-callee] finished optimization of Math.abs(:number)
[determine-callee] starting optimization of Math.max(:number,:number)
[determine-callee] finished optimization of Math.max(:number,:number)
[determine-callee] starting optimization of Math.min(:number,:number)
[determine-callee] finished optimization of Math.min(:number,:number)
[determine-callee] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[determine-callee] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[determine-callee] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[determine-callee] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[determine-callee] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[determine-callee] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[determine-callee] starting optimization of C#m()
[determine-callee] finished optimization of C#m()
[determine-callee] starting optimization of C#constructor()
[determine-callee] finished optimization of C#constructor()
finished optimizer: determine-callee
starting optimizer: tail-rec
[tail-rec] starting optimization of Number.isNaN(:number)
[tail-rec] finished optimization of Number.isNaN(:number)
[tail-rec] starting optimization of Math.abs(:number)
[tail-rec] finished optimization of Math.abs(:number)
[tail-rec] starting optimization of Math.max(:number,:number)
[tail-rec] finished optimization of Math.max(:number,:number)
[tail-rec] starting optimization of Math.min(:number,:number)
[tail-rec] finished optimization of Math.min(:number,:number)
[tail-rec] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[tail-rec] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[tail-rec] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[tail-rec] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[tail-rec] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[tail-rec] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[tail-rec] starting optimization of C#m()
[tail-rec] finished optimization of C#m()
[tail-rec] starting optimization of C#constructor()
[tail-rec] finished optimization of C#constructor()
finished optimizer: tail-rec
starting optimizer: return-if
[return-if] starting optimization of Number.isNaN(:number)
[return-if] Number.isNaN(:number) N
[return-if] finished optimization of Number.isNaN(:number)
[return-if] starting optimization of Math.abs(:number)
[return-if] Math.abs(:number) N
[return-if] finished optimization of Math.abs(:number)
[return-if] starting optimization of Math.max(:number,:number)
[return-if] Math.max(:number,:number) N
[return-if] finished optimization of Math.max(:number,:number)
[return-if] starting optimization of Math.min(:number,:number)
[return-if] Math.min(:number,:number) N
[return-if] finished optimization of Math.min(:number,:number)
[return-if] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[return-if] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[return-if] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[return-if] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[return-if] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[return-if] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[return-if] starting optimization of C#m()
[return-if] finished optimization of C#m()
[return-if] starting optimization of C#constructor()
[return-if] finished optimization of C#constructor()
finished optimizer: return-if
starting optimizer: inline
[inline] starting optimization of Number.isNaN(:number)
[return-if] Number.isNaN(:number) N
[inline] finished optimization of Number.isNaN(:number)
[inline] starting optimization of Math.abs(:number)
[return-if] Math.abs(:number) N
[inline] finished optimization of Math.abs(:number)
[inline] starting optimization of Math.max(:number,:number)
[return-if] Math.max(:number,:number) N
[inline] finished optimization of Math.max(:number,:number)
[inline] starting optimization of Math.min(:number,:number)
[return-if] Math.min(:number,:number) N
[inline] finished optimization of Math.min(:number,:number)
[inline] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[inline] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[inline] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[inline] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[inline] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[inline] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[inline] starting optimization of C#m()
[inline] finished optimization of C#m()
[inline] starting optimization of C#constructor()
[inline] finished optimization of C#constructor()
finished optimizer: inline
starting optimizer: dce
[dce] starting optimization of Number.isNaN(:number)
[dce] finished optimization of Number.isNaN(:number)
[dce] starting optimization of Math.abs(:number)
[dce] finished optimization of Math.abs(:number)
[dce] starting optimization of Math.max(:number,:number)
[dce] finished optimization of Math.max(:number,:number)
[dce] starting optimization of Math.min(:number,:number)
[dce] finished optimization of Math.min(:number,:number)
[dce] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[dce] resetting cache for: 'l' at /Users/yuichi/workspace/JSX/lib/built-in.jsx:315:6
[dce] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[dce] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[dce] resetting cache for: 'l' at /Users/yuichi/workspace/JSX/lib/built-in.jsx:315:6
[dce] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[dce] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[dce] resetting cache for: 'l' at /Users/yuichi/workspace/JSX/lib/built-in.jsx:315:6
[dce] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[dce] starting optimization of C#m()
[dce] resetting cache for: 'ary' at foo.jsx:4:6
[dce] finished optimization of C#m()
[dce] starting optimization of C#constructor()
[dce] finished optimization of C#constructor()
finished optimizer: dce
starting optimizer: unbox
[unbox] starting optimization of Number.isNaN(:number)
[unbox] finished optimization of Number.isNaN(:number)
[unbox] starting optimization of Math.abs(:number)
[unbox] finished optimization of Math.abs(:number)
[unbox] starting optimization of Math.max(:number,:number)
[unbox] finished optimization of Math.max(:number,:number)
[unbox] starting optimization of Math.min(:number,:number)
[unbox] finished optimization of Math.min(:number,:number)
[unbox] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[unbox] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[unbox] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[unbox] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[unbox] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[unbox] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[unbox] starting optimization of C#m()
[unbox] finished optimization of C#m()
[unbox] starting optimization of C#constructor()
[unbox] finished optimization of C#constructor()
finished optimizer: unbox
starting optimizer: fold-const
[fold-const] starting optimization of Number.isNaN(:number)
[fold-const] finished optimization of Number.isNaN(:number)
[fold-const] starting optimization of Math.abs(:number)
[fold-const] finished optimization of Math.abs(:number)
[fold-const] starting optimization of Math.max(:number,:number)
[fold-const] finished optimization of Math.max(:number,:number)
[fold-const] starting optimization of Math.min(:number,:number)
[fold-const] finished optimization of Math.min(:number,:number)
[fold-const] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[fold-const] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[fold-const] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[fold-const] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[fold-const] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[fold-const] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[fold-const] starting optimization of C#m()
[fold-const] finished optimization of C#m()
[fold-const] starting optimization of C#constructor()
[fold-const] finished optimization of C#constructor()
finished optimizer: fold-const
starting optimizer: lcse
[lcse] starting optimization of Number.isNaN(:number)
[lcse] optimizing expressions starting
[lcse] finished optimization of Number.isNaN(:number)
[lcse] starting optimization of Math.abs(:number)
[lcse] optimizing expressions starting
[lcse] clearing lcse cache
[lcse] finished optimization of Math.abs(:number)
[lcse] starting optimization of Math.max(:number,:number)
[lcse] optimizing expressions starting
[lcse] clearing lcse cache
[lcse] finished optimization of Math.max(:number,:number)
[lcse] starting optimization of Math.min(:number,:number)
[lcse] optimizing expressions starting
[lcse] clearing lcse cache
[lcse] finished optimization of Math.min(:number,:number)
[lcse] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[lcse] optimizing expressions starting
[lcse] clearing lcse cache
[lcse] optimizing expressions starting
[lcse] clearing lcse entry for local name: l
[lcse] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[lcse] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[lcse] optimizing expressions starting
[lcse] clearing lcse cache
[lcse] optimizing expressions starting
[lcse] clearing lcse entry for local name: l
[lcse] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[lcse] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[lcse] optimizing expressions starting
[lcse] clearing lcse cache
[lcse] optimizing expressions starting
[lcse] clearing lcse entry for local name: l
[lcse] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[lcse] starting optimization of C#m()
[lcse] optimizing expressions starting
[lcse] new expression
[lcse] clearing lcse cache
[lcse] clearing lcse entry for local name: ary
[lcse] finished optimization of C#m()
[lcse] starting optimization of C#constructor()
[lcse] finished optimization of C#constructor()
finished optimizer: lcse
starting optimizer: dce
[dce] starting optimization of Number.isNaN(:number)
[dce] finished optimization of Number.isNaN(:number)
[dce] starting optimization of Math.abs(:number)
[dce] finished optimization of Math.abs(:number)
[dce] starting optimization of Math.max(:number,:number)
[dce] finished optimization of Math.max(:number,:number)
[dce] starting optimization of Math.min(:number,:number)
[dce] finished optimization of Math.min(:number,:number)
[dce] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[dce] resetting cache for: 'l' at /Users/yuichi/workspace/JSX/lib/built-in.jsx:315:6
[dce] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[dce] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[dce] resetting cache for: 'l' at /Users/yuichi/workspace/JSX/lib/built-in.jsx:315:6
[dce] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[dce] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[dce] resetting cache for: 'l' at /Users/yuichi/workspace/JSX/lib/built-in.jsx:315:6
[dce] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[dce] starting optimization of C#m()
[dce] resetting cache for: 'ary' at foo.jsx:4:6
[dce] finished optimization of C#m()
[dce] starting optimization of C#constructor()
[dce] finished optimization of C#constructor()
finished optimizer: dce
starting optimizer: fold-const
[fold-const] starting optimization of Number.isNaN(:number)
[fold-const] finished optimization of Number.isNaN(:number)
[fold-const] starting optimization of Math.abs(:number)
[fold-const] finished optimization of Math.abs(:number)
[fold-const] starting optimization of Math.max(:number,:number)
[fold-const] finished optimization of Math.max(:number,:number)
[fold-const] starting optimization of Math.min(:number,:number)
[fold-const] finished optimization of Math.min(:number,:number)
[fold-const] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[fold-const] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[fold-const] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[fold-const] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[fold-const] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[fold-const] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[fold-const] starting optimization of C#m()
[fold-const] finished optimization of C#m()
[fold-const] starting optimization of C#constructor()
[fold-const] finished optimization of C#constructor()
finished optimizer: fold-const
starting optimizer: array-length
[array-length] starting optimization of Number.isNaN(:number)
[array-length] finished optimization of Number.isNaN(:number)
[array-length] starting optimization of Math.abs(:number)
[array-length] finished optimization of Math.abs(:number)
[array-length] starting optimization of Math.max(:number,:number)
[array-length] finished optimization of Math.max(:number,:number)
[array-length] starting optimization of Math.min(:number,:number)
[array-length] finished optimization of Math.min(:number,:number)
[array-length] starting optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[array-length] finished optimization of Array.<string>#_forEach(:function (: Nullable.<string>) : void)
[array-length] starting optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[array-length] finished optimization of Array.<number>#_forEach(:function (: Nullable.<number>) : void)
[array-length] starting optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[array-length] finished optimization of Array.<int>#_forEach(:function (: Nullable.<int>) : void)
[array-length] starting optimization of C#m()
[array-length] C#m() optimizing 'for' at foo.jsx:6:2
[array-length] rewriting ary$len to ary$len$0

/Users/yuichi/workspace/JSX/bin/jsx:22470
                throw $__jsx_catch_0;
                      ^
TypeError: Cannot call method 'forEachExpression$F$LExpression$F$LExpression$V$B$' of null
    at Object._ArrayLengthOptimizeCommand._optimizeArrayLength$LMemberFunctionDefinition$LForStatement$LLocalVariable$ (/Users/yuichi/workspace/JSX/bin/jsx:23907:28)
    at onStatement (/Users/yuichi/workspace/JSX/bin/jsx:23843:11)
    at Util$forEachStatement$F$LStatement$B$ALStatement$ (/Users/yuichi/workspace/JSX/bin/jsx:751:10)
    at Object.MemberFunctionDefinition.forEachStatement$F$LStatement$B$ (/Users/yuichi/workspace/JSX/bin/jsx:15936:9)
    at Object._ArrayLengthOptimizeCommand.optimizeFunction$LMemberFunctionDefinition$ (/Users/yuichi/workspace/JSX/bin/jsx:23829:10)
    at doit (/Users/yuichi/workspace/JSX/bin/jsx:22557:9)
    at /Users/yuichi/workspace/JSX/bin/jsx:22575:6
    at Object.ClassDefinition.forEachMember$F$LMemberDefinition$B$ (/Users/yuichi/workspace/JSX/bin/jsx:13640:9)
    at /Users/yuichi/workspace/JSX/bin/jsx:22561:12
    at onClassDef (/Users/yuichi/workspace/JSX/bin/jsx:28464:9)
kazuho commented 10 years ago

:+1: