| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 function test_adaptation() { | 106 function test_adaptation() { |
| 107 adapt2to4(1, 2); | 107 adapt2to4(1, 2); |
| 108 adapt4to2(1, 2, 3, 4); | 108 adapt4to2(1, 2, 3, 4); |
| 109 } | 109 } |
| 110 | 110 |
| 111 test_adaptation(); | 111 test_adaptation(); |
| 112 test_adaptation(); | 112 test_adaptation(); |
| 113 %OptimizeFunctionOnNextCall(test_adaptation); | 113 %OptimizeFunctionOnNextCall(test_adaptation); |
| 114 test_adaptation(); | 114 test_adaptation(); |
| 115 })(); | 115 })(); |
| 116 | |
| 117 // Test arguments access from the inlined function. | |
| 118 function uninlinable(v) { | |
| 119 assertEquals(0, v); | |
| 120 try { } catch (e) { } | |
| 121 return 0; | |
| 122 } | |
| 123 | |
| 124 function toarr_inner() { | |
| 125 var a = arguments; | |
| 126 var marker = a[0]; | |
| 127 uninlinable(uninlinable(0, 0), marker.x); | |
| 128 | |
| 129 var r = new Array(); | |
| 130 for (var i = a.length - 1; i >= 1; i--) { | |
| 131 r.push(a[i]); | |
| 132 } | |
| 133 | |
| 134 return r; | |
| 135 } | |
| 136 | |
| 137 function toarr1(marker, a, b, c) { | |
| 138 return toarr_inner(marker, a / 2, b / 2, c / 2); | |
| 139 } | |
| 140 | |
| 141 function toarr2(marker, a, b, c) { | |
| 142 var x = 0; | |
| 143 return uninlinable(uninlinable(0, 0), | |
| 144 x = toarr_inner(marker, a / 2, b / 2, c / 2)), x; | |
| 145 } | |
| 146 | |
| 147 function test_toarr(toarr) { | |
| 148 var marker = { x: 0 }; | |
| 149 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
| 150 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
| 151 %OptimizeFunctionOnNextCall(toarr); | |
| 152 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
| 153 delete marker.x; | |
| 154 assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6)); | |
| 155 } | |
| 156 | |
| 157 test_toarr(toarr1); | |
| 158 test_toarr(toarr2); | |
| OLD | NEW |