Disabling JIT in Safari 6 to workaround severe Javascript JIT bugs

后端 未结 3 1617
既然无缘
既然无缘 2021-02-05 06:56

We found a severe problem with the interpretation of our Javascript code that only occurs on iOS 5/Safari 6 (then current iPad release) that we think is due to critical bug in t

3条回答
  •  隐瞒了意图╮
    2021-02-05 07:16

    Try-catch blocks seem to disable the JIT compiler on Safari 6 on Lion for the part directly inside the try block (this code worked for me on Safari 6.0.1 7536.26.14 and OS X Lion).

    // test function
    utility.test = function(){
        try {
            var a = 0; // counter for index
            for (var b = this.getStart(); b !== null; b = b.getNext()) // iterate over all cells
                b.$f = a++; // assign index to cell and then increment
        }
        catch (e) { throw e }
        this.$f5 = !1; // random code
    };
    

    This is at least a documented behavior of the current version of Google's V8 (see the Google I/O presentation on V8), but I don't know for Safari.

    If you want to disable it for the whole script, one solution would be to compile your JS to wrap every function's content inside a try-catch with a tool such as burrito.

    Good job on making this reproducible!

提交回复
热议问题