| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (support_smi_only_arrays) { | 88 if (support_smi_only_arrays) { |
| 89 | 89 |
| 90 function get_literal(x) { | 90 function get_literal(x) { |
| 91 var literal = [1, 2, x]; | 91 var literal = [1, 2, x]; |
| 92 return literal; | 92 return literal; |
| 93 } | 93 } |
| 94 | 94 |
| 95 get_literal(3); | 95 get_literal(3); |
| 96 // It's important to store a from before we crankshaft get_literal, because |
| 97 // mementos won't be created from crankshafted code at all. |
| 98 a = get_literal(3); |
| 99 %OptimizeFunctionOnNextCall(get_literal); |
| 96 get_literal(3); | 100 get_literal(3); |
| 97 %OptimizeFunctionOnNextCall(get_literal); | |
| 98 a = get_literal(3); | |
| 99 assertOptimized(get_literal); | 101 assertOptimized(get_literal); |
| 100 assertTrue(%HasFastSmiElements(a)); | 102 assertTrue(%HasFastSmiElements(a)); |
| 103 // a has a memento so the transition caused by the store will affect the |
| 104 // boilerplate. |
| 101 a[0] = 3.5; | 105 a[0] = 3.5; |
| 102 | 106 |
| 103 // We should have transitioned the boilerplate array to double, and | 107 // We should have transitioned the boilerplate array to double, and |
| 104 // crankshafted code should de-opt on the unexpected elements kind | 108 // crankshafted code should de-opt on the unexpected elements kind |
| 105 b = get_literal(3); | 109 b = get_literal(3); |
| 106 assertTrue(%HasFastDoubleElements(b)); | 110 assertTrue(%HasFastDoubleElements(b)); |
| 107 assertEquals([1, 2, 3], b); | 111 assertEquals([1, 2, 3], b); |
| 108 assertUnoptimized(get_literal); | 112 assertUnoptimized(get_literal); |
| 109 | 113 |
| 110 // Optimize again | 114 // Optimize again |
| (...skipping 11 matching lines...) Expand all Loading... |
| 122 return [a, b, c]; | 126 return [a, b, c]; |
| 123 } | 127 } |
| 124 | 128 |
| 125 a = bar(1, 2, 3); | 129 a = bar(1, 2, 3); |
| 126 a[0] = 3.5; | 130 a[0] = 3.5; |
| 127 a[1] = 'hi'; | 131 a[1] = 'hi'; |
| 128 b = bar(1, 2, 3); | 132 b = bar(1, 2, 3); |
| 129 assertKind(elements_kind.fast, b); | 133 assertKind(elements_kind.fast, b); |
| 130 })(); | 134 })(); |
| 131 } | 135 } |
| OLD | NEW |