| OLD | NEW | 
|    1 // Copyright 2012 the V8 project authors. All rights reserved. |    1 // Copyright 2012 the V8 project authors. All rights reserved. | 
|    2 // Redistribution and use in source and binary forms, with or without |    2 // Redistribution and use in source and binary forms, with or without | 
|    3 // modification, are permitted provided that the following conditions are |    3 // modification, are permitted provided that the following conditions are | 
|    4 // met: |    4 // met: | 
|    5 // |    5 // | 
|    6 //     * Redistributions of source code must retain the above copyright |    6 //     * Redistributions of source code must retain the above copyright | 
|    7 //       notice, this list of conditions and the following disclaimer. |    7 //       notice, this list of conditions and the following disclaimer. | 
|    8 //     * Redistributions in binary form must reproduce the above |    8 //     * Redistributions in binary form must reproduce the above | 
|    9 //       copyright notice, this list of conditions and the following |    9 //       copyright notice, this list of conditions and the following | 
|   10 //       disclaimer in the documentation and/or other materials provided |   10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  376   %DeoptimizeFunction(instanceof_check); |  376   %DeoptimizeFunction(instanceof_check); | 
|  377   %ClearFunctionTypeFeedback(instanceof_check); |  377   %ClearFunctionTypeFeedback(instanceof_check); | 
|  378   instanceof_check(Array); |  378   instanceof_check(Array); | 
|  379   instanceof_check(Array); |  379   instanceof_check(Array); | 
|  380   %OptimizeFunctionOnNextCall(instanceof_check); |  380   %OptimizeFunctionOnNextCall(instanceof_check); | 
|  381   instanceof_check(Array); |  381   instanceof_check(Array); | 
|  382   assertOptimized(instanceof_check); |  382   assertOptimized(instanceof_check); | 
|  383  |  383  | 
|  384   instanceof_check(realmBArray); |  384   instanceof_check(realmBArray); | 
|  385   assertUnoptimized(instanceof_check); |  385   assertUnoptimized(instanceof_check); | 
 |  386  | 
 |  387   // Case: make sure nested arrays benefit from allocation site feedback as | 
 |  388   // well. | 
 |  389   (function() { | 
 |  390     // Make sure we handle nested arrays | 
 |  391    function get_nested_literal() { | 
 |  392      var literal = [[1,2,3,4], [2], [3]]; | 
 |  393      return literal; | 
 |  394    } | 
 |  395  | 
 |  396    obj = get_nested_literal(); | 
 |  397    assertKind(elements_kind.fast, obj); | 
 |  398    obj[0][0] = 3.5; | 
 |  399    obj[2][0] = "hello"; | 
 |  400    obj = get_nested_literal(); | 
 |  401    assertKind(elements_kind.fast_double, obj[0]); | 
 |  402    assertKind(elements_kind.fast_smi_only, obj[1]); | 
 |  403    assertKind(elements_kind.fast, obj[2]); | 
 |  404  | 
 |  405    // A more complex nested literal case. | 
 |  406    function get_deep_nested_literal() { | 
 |  407      var literal = [[1], [[2], "hello"], 3, [4]]; | 
 |  408      return literal; | 
 |  409    } | 
 |  410  | 
 |  411    obj = get_deep_nested_literal(); | 
 |  412    assertKind(elements_kind.fast_smi_only, obj[1][0]); | 
 |  413    obj[0][0] = 3.5; | 
 |  414    obj[1][0][0] = "goodbye"; | 
 |  415    assertKind(elements_kind.fast_double, obj[0]); | 
 |  416    assertKind(elements_kind.fast, obj[1][0]); | 
 |  417  | 
 |  418    obj = get_deep_nested_literal(); | 
 |  419    assertKind(elements_kind.fast_double, obj[0]); | 
 |  420    assertKind(elements_kind.fast, obj[1][0]); | 
 |  421   })(); | 
 |  422  | 
 |  423  | 
 |  424   // Make sure object literals with array fields benefit from the type feedback | 
 |  425   // that allocation mementos provide. | 
 |  426   (function() { | 
 |  427     // A literal in an object | 
 |  428     function get_object_literal() { | 
 |  429       var literal = { | 
 |  430         array: [1,2,3], | 
 |  431         data: 3.5 | 
 |  432       }; | 
 |  433       return literal; | 
 |  434     } | 
 |  435  | 
 |  436     obj = get_object_literal(); | 
 |  437     assertKind(elements_kind.fast_smi_only, obj.array); | 
 |  438     obj.array[1] = 3.5; | 
 |  439     assertKind(elements_kind.fast_double, obj.array); | 
 |  440     obj = get_object_literal(); | 
 |  441     assertKind(elements_kind.fast_double, obj.array); | 
 |  442  | 
 |  443     function get_nested_object_literal() { | 
 |  444       var literal = { | 
 |  445         array: [[1],[2],[3]], | 
 |  446         data: 3.5 | 
 |  447       }; | 
 |  448       return literal; | 
 |  449     } | 
 |  450  | 
 |  451     obj = get_nested_object_literal(); | 
 |  452     assertKind(elements_kind.fast, obj.array); | 
 |  453     assertKind(elements_kind.fast_smi_only, obj.array[1]); | 
 |  454     obj.array[1][0] = 3.5; | 
 |  455     assertKind(elements_kind.fast_double, obj.array[1]); | 
 |  456     obj = get_nested_object_literal(); | 
 |  457     assertKind(elements_kind.fast_double, obj.array[1]); | 
 |  458  | 
 |  459     %OptimizeFunctionOnNextCall(get_nested_object_literal); | 
 |  460     get_nested_object_literal(); | 
 |  461     obj = get_nested_object_literal(); | 
 |  462     assertKind(elements_kind.fast_double, obj.array[1]); | 
 |  463  | 
 |  464     // Make sure we handle nested arrays | 
 |  465     function get_nested_literal() { | 
 |  466       var literal = [[1,2,3,4], [2], [3]]; | 
 |  467       return literal; | 
 |  468     } | 
 |  469  | 
 |  470     obj = get_nested_literal(); | 
 |  471     assertKind(elements_kind.fast, obj); | 
 |  472     obj[0][0] = 3.5; | 
 |  473     obj[2][0] = "hello"; | 
 |  474     obj = get_nested_literal(); | 
 |  475     assertKind(elements_kind.fast_double, obj[0]); | 
 |  476     assertKind(elements_kind.fast_smi_only, obj[1]); | 
 |  477     assertKind(elements_kind.fast, obj[2]); | 
 |  478  | 
 |  479     // A more complex nested literal case. | 
 |  480     function get_deep_nested_literal() { | 
 |  481       var literal = [[1], [[2], "hello"], 3, [4]]; | 
 |  482       return literal; | 
 |  483     } | 
 |  484  | 
 |  485     obj = get_deep_nested_literal(); | 
 |  486     assertKind(elements_kind.fast_smi_only, obj[1][0]); | 
 |  487     obj[0][0] = 3.5; | 
 |  488     obj[1][0][0] = "goodbye"; | 
 |  489     assertKind(elements_kind.fast_double, obj[0]); | 
 |  490     assertKind(elements_kind.fast, obj[1][0]); | 
 |  491  | 
 |  492     obj = get_deep_nested_literal(); | 
 |  493     assertKind(elements_kind.fast_double, obj[0]); | 
 |  494     assertKind(elements_kind.fast, obj[1][0]); | 
 |  495   })(); | 
|  386 } |  496 } | 
| OLD | NEW |