Upstream version 10.39.233.0
[platform/framework/web/crosswalk.git] / src / v8 / test / mjsunit / simd / argument_object.js
1 // Copyright 2011 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
4 // met:
5 //
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.
15 //
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.
27
28 // Flags: --simd_object --allow-natives-syntax --use-escape-analysis
29
30 function testArgumentsObjectwithFloat32x4Field() {
31   "use strict";
32   var forceDeopt = { deopt:false };
33   function inner(a,b,c,d,e,f,g,h,i,j,k) {
34     var args = arguments;
35     forceDeopt.deopt;
36     assertSame(11, args.length);
37     assertSame(a, args[0]);
38     assertSame(b, args[1]);
39     assertSame(c, args[2]);
40     assertSame(d, args[3]);
41     assertSame(e, args[4]);
42     assertSame(f, args[5]);
43     assertSame(g, args[6]);
44     assertSame(h, args[7]);
45     assertSame(i, args[8]);
46     assertSame(j, args[9]);
47     assertEquals(1, args[10].x);
48     assertEquals(2, args[10].y);
49     assertEquals(3, args[10].z);
50     assertEquals(4, args[10].w);
51   }
52
53   var a = 0.5;
54   var b = 1.7;
55   var c = 123;
56   function outer() {
57     inner(
58       a - 0.3,  // double in double register
59       b + 2.3,  // integer in double register
60       c + 321,  // integer in general register
61       c - 456,  // integer in stack slot
62       a + 0.1, a + 0.2, a + 0.3, a + 0.4, a + 0.5,
63       a + 0.6,  // double in stack slot
64       SIMD.float32x4(1, 2, 3, 4)
65     );
66   }
67
68   outer();
69   outer();
70   %OptimizeFunctionOnNextCall(outer);
71   outer();
72   delete forceDeopt.deopt;
73   outer();
74 }
75
76 testArgumentsObjectwithFloat32x4Field();
77
78 function testArgumentsObjectwithInt32x4Field() {
79   "use strict";
80   var forceDeopt = { deopt:false };
81   function inner(a,b,c,d,e,f,g,h,i,j,k) {
82     var args = arguments;
83     forceDeopt.deopt;
84     assertSame(11, args.length);
85     assertSame(a, args[0]);
86     assertSame(b, args[1]);
87     assertSame(c, args[2]);
88     assertSame(d, args[3]);
89     assertSame(e, args[4]);
90     assertSame(f, args[5]);
91     assertSame(g, args[6]);
92     assertSame(h, args[7]);
93     assertSame(i, args[8]);
94     assertSame(j, args[9]);
95     assertEquals(1, args[10].x);
96     assertEquals(2, args[10].y);
97     assertEquals(3, args[10].z);
98     assertEquals(4, args[10].w);
99   }
100
101   var a = 0.5;
102   var b = 1.7;
103   var c = 123;
104   function outer() {
105     inner(
106       a - 0.3,  // double in double register
107       b + 2.3,  // integer in double register
108       c + 321,  // integer in general register
109       c - 456,  // integer in stack slot
110       a + 0.1, a + 0.2, a + 0.3, a + 0.4, a + 0.5,
111       a + 0.6,  // double in stack slot
112       SIMD.int32x4(1, 2, 3, 4)
113     );
114   }
115
116   outer();
117   outer();
118   %OptimizeFunctionOnNextCall(outer);
119   outer();
120   delete forceDeopt.deopt;
121   outer();
122 }
123
124 testArgumentsObjectwithInt32x4Field();