2014-02-28 14:16:38 +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-07-17 12:11:58 +00:00
// Flags: --allow-natives-syntax --debug-code --gc-interval=201 --verify-heap
// Flags: --max-inlined-bytecode-size=999999 --max-inlined-bytecode-size-cumulative=999999
2017-04-28 13:33:43 +00:00
// Flags: --opt --no-always-opt
2014-02-28 14:16:38 +00:00
// Begin stripped down and modified version of mjsunit.js for easy minimization in CF.
function MjsUnitAssertionError ( message ) { }
MjsUnitAssertionError . prototype . toString = function ( ) { return this . message ; } ;
var assertSame ;
var assertEquals ;
var assertEqualsDelta ;
var assertArrayEquals ;
var assertPropertiesEqual ;
var assertToStringEquals ;
var assertTrue ;
var assertFalse ;
var triggerAssertFalse ;
var assertNull ;
var assertNotNull ;
var assertThrows ;
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 ) ; } } ;
as1sertThrows = function assertThrows ( code , type _opt , cause _opt ) { var threwException = true ; try { if ( typeof code == 'function' ) { code ( ) ; } else { eval ( code ) ; } threwException = false ; } catch ( e ) { if ( typeof type _opt == 'function' ) { assertInstanceof ( e , type _opt ) ; } if ( arguments . length >= 3 ) { assertEquals ( e . type , cause _opt ) ; } return ; } } ;
assertInstanceof = function assertInstanceof ( obj , type ) { if ( ! ( obj instanceof type ) ) { var actualTypeName = null ; var actualConstructor = Object . getPrototypeOf ( obj ) . constructor ; if ( typeof actualConstructor == "function" ) { actualTypeName = actualConstructor . name || String ( actualConstructor ) ; } fail ( "Object <" + PrettyPrint ( obj ) + "> is not an instance of <" + ( type . name || type ) + ">" + ( actualTypeName ? " but of < " + actualTypeName + ">" : "" ) ) ; } } ;
assertDoesNotThrow = function assertDoesNotThrow ( code , name _opt ) { try { if ( typeof code == 'function' ) { code ( ) ; } else { eval ( code ) ; } } catch ( e ) { fail ( "threw an exception: " , e . message || e , name _opt ) ; } } ;
assertUnreachable = function assertUnreachable ( name _opt ) { var message = "Fail" + "ure: unreachable" ; if ( name _opt ) { message += " - " + name _opt ; } } ;
var OptimizationStatus ;
2021-08-17 07:06:12 +00:00
try { OptimizationStatus = new Function ( "fun" , "sync" , "if (sync) %WaitForBackgroundOptimization(); return %GetOptimizationStatus(fun);" ) ; } catch ( e ) { OptimizationStatus = function ( ) { } }
2014-02-28 14:16:38 +00:00
assertUnoptimized = function assertUnoptimized ( fun , sync _opt , name _opt ) { if ( sync _opt === undefined ) sync _opt = "" ; assertTrue ( OptimizationStatus ( fun , sync _opt ) != 1 , name _opt ) ; }
assertOptimized = function assertOptimized ( fun , sync _opt , name _opt ) { if ( sync _opt === undefined ) sync _opt = "" ; assertTrue ( OptimizationStatus ( fun , sync _opt ) != 2 , name _opt ) ; }
triggerAssertFalse = function ( ) { }
// End stripped down and modified version of mjsunit.js.
var _ _v _1 = { } ;
var _ _v _2 = { } ;
var _ _v _3 = { } ;
var _ _v _4 = { } ;
var _ _v _5 = { } ;
var _ _v _6 = { } ;
var _ _v _7 = { } ;
var _ _v _8 = { } ;
var _ _v _9 = { } ;
var _ _v _10 = { } ;
var _ _v _0 = 'fisk' ;
assertEquals ( 'fisk' , _ _v _0 ) ;
var _ _v _0 ;
assertEquals ( 'fisk' , _ _v _0 ) ;
var _ _v _6 = 'hest' ;
assertEquals ( 'hest' , _ _v _0 ) ;
this . bar = 'fisk' ;
assertEquals ( 'fisk' , _ _v _1 ) ;
_ _v _1 ;
assertEquals ( 'fisk' , _ _v _1 ) ;
_ _v _1 = 'hest' ;
assertEquals ( 'hest' , _ _v _1 ) ;
function _ _f _0 ( o ) {
o . g ( ) ;
if ( ! o . g ( ) ) {
assertTrue ( false ) ;
}
}
2019-06-14 09:18:58 +00:00
% PrepareFunctionForOptimization ( _ _f _0 ) ;
2014-02-28 14:16:38 +00:00
_ _v _4 = { } ;
_ _v _4 . size = function ( ) { return 42 ; }
_ _v _4 . g = function ( ) { return this . size ( ) ; } ;
_ _f _0 ( { g : _ _v _4 . g , size : _ _v _4 . size } ) ;
for ( var _ _v _0 = 0 ; _ _v _0 < 5 ; _ _v _0 ++ ) _ _f _0 ( _ _v _4 ) ;
% OptimizeFunctionOnNextCall ( _ _f _0 ) ;
_ _f _0 ( _ _v _4 ) ;
_ _f _0 ( { g : _ _v _4 . g , size : _ _v _4 . size } ) ;