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 11 matching lines...) Expand all Loading... | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax --expose-gc | 28 // Flags: --allow-natives-syntax --expose-gc |
29 | 29 |
30 var a = new Int32Array(1024); | 30 var a = new Int32Array(1024); |
31 | 31 |
32 // Test that we do not assert if the accessed index has not an int32 rep. | |
33 { | |
34 var v = [0, 1, 2, 3, 4, 5, 6, 7,8, 9]; | |
Toon Verwaest
2012/09/12 15:51:47
nit:
The indentation seems to be off.
There's no s
| |
35 | |
36 function test(vector, base) { | |
37 var r = 0; | |
38 var a1 = base + 1; | |
39 var a2 = base + 2; | |
40 var a3 = base + 3; | |
41 var a4 = base + 4; | |
42 if (a1 == 2) { | |
43 r += vector[a1]; | |
44 r += vector[a4]; | |
45 r += vector[a2]; | |
46 r += vector[a3]; | |
47 } else { | |
48 return r; | |
Toon Verwaest
2012/09/12 15:51:47
nit:
We can just drop the else branch.
| |
49 } | |
50 return r; | |
51 } | |
52 | |
53 test(v,1); | |
54 test(v,1); | |
55 test(v,"a"); | |
56 test(v,"a"); | |
57 %OptimizeFunctionOnNextCall(test); | |
58 test(v,0); | |
59 } | |
60 | |
32 function test_base(base,cond) { | 61 function test_base(base,cond) { |
33 a[base + 1] = 1; | 62 a[base + 1] = 1; |
34 a[base + 4] = 2; | 63 a[base + 4] = 2; |
35 a[base + 3] = 3; | 64 a[base + 3] = 3; |
36 a[base + 2] = 4; | 65 a[base + 2] = 4; |
37 a[base + 4] = base + 4; | 66 a[base + 4] = base + 4; |
38 if (cond) { | 67 if (cond) { |
39 a[base + 1] = 1; | 68 a[base + 1] = 1; |
40 a[base + 2] = 2; | 69 a[base + 2] = 2; |
41 a[base + 2] = 3; | 70 a[base + 2] = 3; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 short_test(short_a, 50); | 179 short_test(short_a, 50); |
151 short_test(short_a, 50); | 180 short_test(short_a, 50); |
152 %OptimizeFunctionOnNextCall(short_test); | 181 %OptimizeFunctionOnNextCall(short_test); |
153 short_a.length = 10; | 182 short_a.length = 10; |
154 short_test(a, 0); | 183 short_test(a, 0); |
155 assertTrue(%GetOptimizationStatus(short_test) != 1); | 184 assertTrue(%GetOptimizationStatus(short_test) != 1); |
156 | 185 |
157 | 186 |
158 gc(); | 187 gc(); |
159 | 188 |
OLD | NEW |