OLD | NEW |
---|---|
1 | |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 2 // Copyright 2013 the V8 project authors. All rights reserved. |
adamk
2016/05/13 20:33:39
We now use a shorter copyright boilerplate (which
gsathya
2016/05/13 21:11:52
Done.
| |
2 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
4 // met: | 5 // met: |
5 // | 6 // |
6 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 11 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 12 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 13 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 14 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 15 // from this software without specific prior written permission. |
15 // | 16 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 // (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. | 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 28 |
28 // Flags: --allow-natives-syntax --no-use-osr | 29 function getLength(a) { |
29 | 30 return a.length; |
30 function foo(a, i, v) { | |
31 a[0] = v; | |
32 a[i] = v; | |
33 } | 31 } |
34 | 32 |
35 function foo_int(a, i, v) { | 33 function getByteLength(a) { |
36 a[0] = v; | 34 return a.byteLength; |
37 a[i] = v; | |
38 } | 35 } |
39 | 36 |
40 var A1 = [1.2, 2.3]; | 37 function getByteOffset(a) { |
41 var A2 = [1.2, 2.3]; | 38 return a.byteOffset; |
42 var A3 = [1.2, 2.3]; | 39 } |
43 | 40 |
44 var A1_int = [12, 23]; | 41 var a = new Uint8Array([1, 2, 3]); |
45 var A2_int = [12, 23]; | 42 getLength(a); |
46 var A3_int = [12, 23]; | 43 getLength(a); |
47 | 44 |
48 foo(A1, 1, 3.4); | 45 Object.defineProperty(a.__proto__, 'length', { |
adamk
2016/05/13 20:33:39
Formatting is weird here, looks like you have an e
gsathya
2016/05/13 21:11:53
Done.
| |
49 foo(A2, 1, 3.4); | 46 value: 42 |
50 %OptimizeFunctionOnNextCall(foo); | 47 }); |
51 foo(A3, 1, 3.4); | |
52 | 48 |
53 foo_int(A1_int, 1, 34); | 49 assertEquals(getLength(a), 42); |
adamk
2016/05/13 20:33:39
Nit: the ordering for assertEquals is "expected, a
gsathya
2016/05/13 21:11:52
Done.
| |
54 foo_int(A2_int, 1, 34); | 50 assertEquals(a.length, 42); |
55 %OptimizeFunctionOnNextCall(foo_int); | |
56 foo_int(A3_int, 1, 34); | |
57 | 51 |
58 assertEquals(A1[0], A3[0]); | 52 getByteLength(a); |
59 assertEquals(A1[1], A3[1]); | 53 getByteLength(a); |
60 assertEquals(A1_int[0], A3_int[0]); | 54 |
61 assertEquals(A1_int[1], A3_int[1]); | 55 Object.defineProperty(a.__proto__, 'byteLength', { |
56 value: 42 | |
57 }); | |
58 | |
59 assertEquals(getByteLength(a), 42); | |
60 assertEquals(a.byteLength, 42); | |
61 | |
62 getByteOffset(a); | |
63 getByteOffset(a); | |
64 | |
65 Object.defineProperty(a.__proto__, 'byteOffset', { | |
66 value: 42 | |
67 }); | |
68 | |
69 assertEquals(getByteOffset(a), 42); | |
70 assertEquals(a.byteOffset, 42); | |
OLD | NEW |