2014-09-05 09:38:04 +00:00
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
2017-04-28 13:33:43 +00:00
// Flags: --allow-natives-syntax --expose-gc --opt --no-always-opt
2014-09-05 09:38:04 +00:00
var assertDoesNotThrow ;
var assertInstanceof ;
var assertUnreachable ;
var assertOptimized ;
var assertUnoptimized ;
function classOf ( object ) { var string = Object . prototype . toString . call ( object ) ; return string . substring ( 8 , string . length - 1 ) ; }
function PrettyPrint ( value ) { return "" ; }
function PrettyPrintArrayElement ( value , index , array ) { return "" ; }
function fail ( expectedText , found , name _opt ) { }
function deepObjectEquals ( a , b ) { var aProps = Object . keys ( a ) ; aProps . sort ( ) ; var bProps = Object . keys ( b ) ; bProps . sort ( ) ; if ( ! deepEquals ( aProps , bProps ) ) { return false ; } for ( var i = 0 ; i < aProps . length ; i ++ ) { if ( ! deepEquals ( a [ aProps [ i ] ] , b [ aProps [ i ] ] ) ) { return false ; } } return true ; }
function deepEquals ( a , b ) { if ( a === b ) { if ( a === 0 ) return ( 1 / a ) === ( 1 / b ) ; return true ; } if ( typeof a != typeof b ) return false ; if ( typeof a == "number" ) return isNaN ( a ) && isNaN ( b ) ; if ( typeof a !== "object" && typeof a !== "function" ) return false ; var objectClass = classOf ( a ) ; if ( objectClass !== classOf ( b ) ) return false ; if ( objectClass === "RegExp" ) { return ( a . toString ( ) === b . toString ( ) ) ; } if ( objectClass === "Function" ) return false ; if ( objectClass === "Array" ) { var elementCount = 0 ; if ( a . length != b . length ) { return false ; } for ( var i = 0 ; i < a . length ; i ++ ) { if ( ! deepEquals ( a [ i ] , b [ i ] ) ) return false ; } return true ; } if ( objectClass == "String" || objectClass == "Number" || objectClass == "Boolean" || objectClass == "Date" ) { if ( a . valueOf ( ) !== b . valueOf ( ) ) return false ; } return deepObjectEquals ( a , b ) ; }
assertSame = function assertSame ( expected , found , name _opt ) { if ( found === expected ) { if ( expected !== 0 || ( 1 / expected ) == ( 1 / found ) ) return ; } else if ( ( expected !== expected ) && ( found !== found ) ) { return ; } fail ( PrettyPrint ( expected ) , found , name _opt ) ; } ; assertEquals = function assertEquals ( expected , found , name _opt ) { if ( ! deepEquals ( found , expected ) ) { fail ( PrettyPrint ( expected ) , found , name _opt ) ; } } ;
assertEqualsDelta = function assertEqualsDelta ( expected , found , delta , name _opt ) { assertTrue ( Math . abs ( expected - found ) <= delta , name _opt ) ; } ;
assertArrayEquals = function assertArrayEquals ( expected , found , name _opt ) { var start = "" ; if ( name _opt ) { start = name _opt + " - " ; } assertEquals ( expected . length , found . length , start + "array length" ) ; if ( expected . length == found . length ) { for ( var i = 0 ; i < expected . length ; ++ i ) { assertEquals ( expected [ i ] , found [ i ] , start + "array element at index " + i ) ; } } } ;
assertPropertiesEqual = function assertPropertiesEqual ( expected , found , name _opt ) { if ( ! deepObjectEquals ( expected , found ) ) { fail ( expected , found , name _opt ) ; } } ;
assertToStringEquals = function assertToStringEquals ( expected , found , name _opt ) { if ( expected != String ( found ) ) { fail ( expected , found , name _opt ) ; } } ;
assertTrue = function assertTrue ( value , name _opt ) { assertEquals ( true , value , name _opt ) ; } ;
assertFalse = function assertFalse ( value , name _opt ) { assertEquals ( false , value , name _opt ) ; } ;
assertNull = function assertNull ( value , name _opt ) { if ( value !== null ) { fail ( "null" , value , name _opt ) ; } } ;
assertNotNull = function assertNotNull ( value , name _opt ) { if ( value === null ) { fail ( "not null" , value , name _opt ) ; } } ;
var _ _v _39 = { } ;
var _ _v _40 = { } ;
var _ _v _41 = { } ;
var _ _v _42 = { } ;
var _ _v _43 = { } ;
var _ _v _44 = { } ;
try {
_ _v _0 = [ 1.5 , , 1.7 ] ;
_ _v _1 = { _ _v _0 : 1.8 } ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _0 ( _ _v _1 , _ _v _0 , i ) {
_ _v _1 . a = _ _v _0 [ i ] ;
gc ( ) ;
}
2019-06-14 09:50:03 +00:00
% PrepareFunctionForOptimization ( _ _f _0 ) ;
2014-09-05 09:38:04 +00:00
try {
_ _f _0 ( _ _v _1 , _ _v _0 , 0 ) ;
_ _f _0 ( _ _v _1 , _ _v _0 , 0 ) ;
% OptimizeFunctionOnNextCall ( _ _f _0 ) ;
_ _f _0 ( _ _v _1 , _ _v _0 , 1 ) ;
assertEquals ( undefined , _ _v _1 . a ) ;
_ _v _0 = [ 1 , , 3 ] ;
_ _v _1 = { ab : 5 } ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _1 ( _ _v _1 , _ _v _0 , i ) {
_ _v _1 . ab = _ _v _0 [ i ] ;
}
try {
_ _f _1 ( _ _v _1 , _ _v _0 , 1 ) ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _5 ( x ) {
return ~ x ;
}
try {
_ _f _5 ( 42 ) ;
assertEquals ( ~ 12 , _ _f _5 ( 12.45 ) ) ;
assertEquals ( ~ 46 , _ _f _5 ( 42.87 ) ) ;
_ _v _2 = 1 , _ _v _4 = 2 , _ _v _3 = 4 , _ _v _6 = 8 ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _4 ( ) {
return _ _v _2 | ( _ _v _4 | ( _ _v _3 | _ _v _6 ) ) ;
}
try {
_ _f _4 ( ) ;
_ _v _3 = "16" ;
assertEquals ( 17 | - 13 | 0 | - 5 , _ _f _4 ( ) ) ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _6 ( ) {
return _ _f _4 ( ) ;
}
try {
assertEquals ( 1 | 2 | 16 | 8 , _ _f _6 ( ) ) ;
_ _f _4 = function ( ) { return 42 ; } ;
assertEquals ( 42 , _ _f _6 ( ) ) ;
_ _v _5 = { } ;
_ _v _5 . _ _f _4 = _ _f _4 ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _7 ( o ) {
return o . _ _f _4 ( ) ;
}
try {
for ( var _ _v _7 = 0 ; _ _v _7 < 5 ; _ _v _7 ++ ) _ _f _7 ( _ _v _5 ) ;
% OptimizeFunctionOnNextCall ( _ _f _7 ) ;
_ _f _7 ( _ _v _5 ) ;
assertEquals ( 42 , _ _f _7 ( _ _v _5 ) ) ;
assertEquals ( 87 , _ _f _7 ( { _ _f _4 : function ( ) { return 87 ; } } ) ) ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _8 ( x , y ) {
x = 42 ;
y = 1 ;
y = y << "0" ;
return x | y ;
}
try {
assertEquals ( 43 , _ _f _8 ( 0 , 0 ) ) ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _2 ( x ) {
return 'lit[' + ( x + ']' ) ;
}
try {
assertEquals ( 'lit[-87]' , _ _f _2 ( - 87 ) ) ;
assertEquals ( 'lit[0]' , _ _f _2 ( 0 ) ) ;
assertEquals ( 'lit[42]' , _ _f _2 ( 42 ) ) ;
_ _v _9 = "abc" ;
gc ( ) ;
var _ _v _8 ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _9 ( n ) { return _ _v _9 . charAt ( n ) ; }
try {
for ( var _ _v _7 = 0 ; _ _v _7 < 5 ; _ _v _7 ++ ) {
_ _v _8 = _ _f _9 ( 0 ) ;
}
% OptimizeFunctionOnNextCall ( _ _f _9 ) ;
_ _v _8 = _ _f _9 ( 0 ) ;
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _3 ( _ _v _2 , _ _v _4 , _ _v _3 , _ _v _6 ) {
return _ _v _2 + _ _v _4 + _ _v _3 + _ _v _6 ;
}
try {
assertEquals ( 0x40000003 , _ _f _3 ( 1 , 1 , 2 , 0x3fffffff ) ) ;
} catch ( e ) { print ( "Caught: " + e ) ; }
try {
_ _v _19 = {
fast _smi _only : 'fast smi only elements' ,
fast : 'fast elements' ,
fast _double : 'fast double elements' ,
dictionary : 'dictionary elements' ,
external _int32 : 'external int8 elements' ,
external _uint8 : 'external uint8 elements' ,
external _int16 : 'external int16 elements' ,
external _uint16 : 'external uint16 elements' ,
external _int32 : 'external int32 elements' ,
external _uint32 : 'external uint32 elements' ,
external _float32 : 'external float32 elements' ,
external _float64 : 'external float64 elements' ,
external _uint8 _clamped : 'external uint8_clamped elements' ,
fixed _int32 : 'fixed int8 elements' ,
fixed _uint8 : 'fixed uint8 elements' ,
fixed _int16 : 'fixed int16 elements' ,
fixed _uint16 : 'fixed uint16 elements' ,
fixed _int32 : 'fixed int32 elements' ,
fixed _uint32 : 'fixed uint32 elements' ,
fixed _float32 : 'fixed float32 elements' ,
fixed _float64 : 'fixed float64 elements' ,
fixed _uint8 _clamped : 'fixed uint8_clamped elements'
}
} catch ( e ) { print ( "Caught: " + e ) ; }
function _ _f _12 ( ) {
}
_ _v _10 = { } ;
_ _v _10 . dance = 0xD15C0 ;
_ _v _10 . drink = 0xC0C0A ;
_ _f _12 ( _ _v _19 . fast , _ _v _10 ) ;
_ _v _24 = [ 1 , 2 , 3 ] ;
_ _f _12 ( _ _v _19 . fast _smi _only , _ _v _24 ) ;
_ _v _24 . dance = 0xD15C0 ;
_ _v _24 . drink = 0xC0C0A ;
_ _f _12 ( _ _v _19 . fast _smi _only , _ _v _24 ) ;
function _ _f _18 ( ) {
var _ _v _27 = new Array ( ) ;
_ _f _12 ( _ _v _19 . fast _smi _only , _ _v _27 ) ;
for ( var _ _v _18 = 0 ; _ _v _18 < 1337 ; _ _v _18 ++ ) {
var _ _v _16 = _ _v _18 ;
if ( _ _v _18 == 1336 ) {
_ _f _12 ( _ _v _19 . fast _smi _only , _ _v _27 ) ;
_ _v _16 = new Object ( ) ;
}
_ _v _27 [ _ _v _18 ] = _ _v _16 ;
}
_ _f _12 ( _ _v _19 . fast , _ _v _27 ) ;
var _ _v _15 = [ ] ;
_ _v _15 [ 912570 ] = 7 ;
_ _f _12 ( _ _v _19 . dictionary , _ _v _15 ) ;
var _ _v _26 = new Array ( 912561 ) ;
% SetAllocationTimeout ( 100000000 , 10000000 ) ;
for ( var _ _v _18 = 0 ; _ _v _18 < 0x20000 ; _ _v _18 ++ ) {
_ _v _26 [ 0 ] = _ _v _18 / 2 ;
}
_ _f _12 ( _ _v _19 . fixed _int8 , new Int8Array ( 007 ) ) ;
_ _f _12 ( _ _v _19 . fixed _uint8 , new Uint8Array ( 007 ) ) ;
_ _f _12 ( _ _v _19 . fixed _int16 , new Int16Array ( 666 ) ) ;
_ _f _12 ( _ _v _19 . fixed _uint16 , new Uint16Array ( 42 ) ) ;
_ _f _12 ( _ _v _19 . fixed _int32 , new Int32Array ( 0xF ) ) ;
_ _f _12 ( _ _v _19 . fixed _uint32 , new Uint32Array ( 23 ) ) ;
_ _f _12 ( _ _v _19 . fixed _float32 , new Float32Array ( 7 ) ) ;
_ _f _12 ( _ _v _19 . fixed _float64 , new Float64Array ( 0 ) ) ;
_ _f _12 ( _ _v _19 . fixed _uint8 _clamped , new Uint8ClampedArray ( 512 ) ) ;
var _ _v _13 = new ArrayBuffer ( 128 ) ;
_ _f _12 ( _ _v _19 . external _int8 , new Int8Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _37 . external _uint8 , new Uint8Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _19 . external _int16 , new Int16Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _19 . external _uint16 , new Uint16Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _19 . external _int32 , new Int32Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _19 . external _uint32 , new Uint32Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _19 . external _float32 , new Float32Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _19 . external _float64 , new Float64Array ( _ _v _13 ) ) ;
_ _f _12 ( _ _v _19 . external _uint8 _clamped , new Uint8ClampedArray ( _ _v _13 ) ) ;
}
try {
_ _f _18 ( ) ;
} catch ( e ) { }