1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 // Flags: --allow-natives-syntax
30 var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
39 %OptimizeFunctionOnNextCall(aoo);
43 // Key is HChange, used by either dehoised or non-dehoisted
56 %OptimizeFunctionOnNextCall(boo);
60 // Key is HMul(-i ==> i * (-1))
63 for (var i = 4; i > 0; i -= 1) {
64 ret += a[-i + 4]; // dehoisted
72 %OptimizeFunctionOnNextCall(coo);
76 // Key is HPhi, used only by dehoisted
79 for (var i = 0; i < 5; i += 1) {
80 ret += a[i + 1]; // dehoisted
86 %OptimizeFunctionOnNextCall(doo);
89 // Key is HPhi, but used by both dehoisted and non-dehoisted
90 // sign extend is useless
93 for (var i = 0; i < 5; i += 1) {
94 ret += a[i]; // non-dehoisted
95 ret += a[i + 1]; // dehoisted
102 %OptimizeFunctionOnNextCall(eoo);
107 // Key is HPhi, but used by either dehoisted or non-dehoisted
110 for (var i = -3; i < 4; i += 1) {
112 ret += a[i + 4]; // dehoisted
114 ret += a[i]; // non-dehoisted
123 %OptimizeFunctionOnNextCall(foo);
126 // Key is HPhi, but not induction variable
138 %OptimizeFunctionOnNextCall(goo);
141 // Key is return value of function
145 %NeverOptimizeFunction(index);
147 return a[index() + 3];
152 %OptimizeFunctionOnNextCall(hoo);
155 // Sign extension of key makes AssertZeroExtended fail in DoBoundsCheck
157 return a[i] + a[i + 1];
162 %OptimizeFunctionOnNextCall(ioo);