• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "ecmascript/compiler/call_signature.h"
17 namespace panda::ecmascript::kungfu {
18 #ifndef NDEBUG
DEF_CALL_SIGNATURE(FooAOT)19 DEF_CALL_SIGNATURE(FooAOT)
20 {
21     // 7 : 7 input parameters
22     CallSignature fooAot("FooAOT", 0, 7,
23         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
24     *callSign = fooAot;
25     std::array<VariableType, 7> params = { // 7 : 7 input parameters
26         VariableType::NATIVE_POINTER(),
27         VariableType::INT64(),
28         VariableType::JS_ANY(),     // calltarget
29         VariableType::JS_ANY(),     // newTarget
30         VariableType::JS_ANY(),     // thisTarget
31         VariableType::JS_ANY(),     // a
32         VariableType::JS_ANY(),     // b
33     };
34     callSign->SetParameters(params.data());
35     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
36 }
37 
DEF_CALL_SIGNATURE(Foo1AOT)38 DEF_CALL_SIGNATURE(Foo1AOT)
39 {
40     // 7 : 7 input parameters
41     CallSignature foo1Aot("Foo1AOT", 0, 7,
42         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
43     *callSign = foo1Aot;
44     std::array<VariableType, 7> params = { // 7 : 7 input parameters
45         VariableType::NATIVE_POINTER(),
46         VariableType::INT64(),
47         VariableType::JS_ANY(),     // calltarget
48         VariableType::JS_ANY(),     // newTarget
49         VariableType::JS_ANY(),     // thisTarget
50         VariableType::JS_ANY(),     // a
51         VariableType::JS_ANY(),     // b
52     };
53     callSign->SetParameters(params.data());
54     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
55 }
56 
DEF_CALL_SIGNATURE(Foo2AOT)57 DEF_CALL_SIGNATURE(Foo2AOT)
58 {
59     // 7 : 7 input parameters
60     CallSignature foo2Aot("Foo2AOT", 0, 7,
61         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
62     *callSign = foo2Aot;
63     std::array<VariableType, 7> params = { // 7 : 7 input parameters
64         VariableType::NATIVE_POINTER(),
65         VariableType::INT64(),
66         VariableType::JS_ANY(),     // calltarget
67         VariableType::JS_ANY(),     // newTarget
68         VariableType::JS_ANY(),     // thisTarget
69         VariableType::JS_ANY(),     // a
70         VariableType::JS_ANY(),     // b
71     };
72     callSign->SetParameters(params.data());
73     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
74 }
75 
DEF_CALL_SIGNATURE(FooNativeAOT)76 DEF_CALL_SIGNATURE(FooNativeAOT)
77 {
78     // 7 : 7 input parameters
79     CallSignature foo2Aot("FooNativeAOT", 0, 7,
80         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
81     *callSign = foo2Aot;
82     std::array<VariableType, 7> params = { // 7 : 7 input parameters
83         VariableType::NATIVE_POINTER(),
84         VariableType::INT64(),
85         VariableType::JS_ANY(),     // calltarget
86         VariableType::JS_ANY(),     // newTarget
87         VariableType::JS_ANY(),     // thisTarget
88         VariableType::JS_ANY(),     // a
89         VariableType::JS_ANY(),     // b
90     };
91     callSign->SetParameters(params.data());
92     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
93 }
94 
DEF_CALL_SIGNATURE(FooBoundAOT)95 DEF_CALL_SIGNATURE(FooBoundAOT)
96 {
97     // 7 : 7 input parameters
98     CallSignature foo2Aot("FooBoundAOT", 0, 7,
99         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
100     *callSign = foo2Aot;
101     std::array<VariableType, 7> params = { // 7 : 7 input parameters
102         VariableType::NATIVE_POINTER(),
103         VariableType::INT64(),
104         VariableType::JS_ANY(),     // calltarget
105         VariableType::JS_ANY(),     // newTarget
106         VariableType::JS_ANY(),     // thisTarget
107         VariableType::JS_ANY(),     // a
108         VariableType::JS_ANY(),     // b
109     };
110     callSign->SetParameters(params.data());
111     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
112 }
113 
DEF_CALL_SIGNATURE(Bar1AOT)114 DEF_CALL_SIGNATURE(Bar1AOT)
115 {
116     // 8 : 8 input parameters
117     CallSignature barAot("Bar1AOT", 0, 8,
118         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
119     *callSign = barAot;
120     std::array<VariableType, 8> params = { // 8 : 8 input parameters
121         VariableType::NATIVE_POINTER(),
122         VariableType::INT64(),
123         VariableType::JS_ANY(),     // calltarget
124         VariableType::JS_ANY(),     // newTarget
125         VariableType::JS_ANY(),     // thisTarget
126         VariableType::JS_ANY(),     // a
127         VariableType::JS_ANY(),     // b
128         VariableType::JS_ANY(),     // c
129     };
130     callSign->SetParameters(params.data());
131     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
132 }
133 
DEF_CALL_SIGNATURE(BarAOT)134 DEF_CALL_SIGNATURE(BarAOT)
135 {
136     // 7 : 7 input parameters
137     CallSignature barAot("BarAOT", 0, 7,
138         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
139     *callSign = barAot;
140     std::array<VariableType, 7> params = { // 7 : 7 input parameters
141         VariableType::NATIVE_POINTER(),
142         VariableType::INT64(),
143         VariableType::JS_ANY(),     // calltarget
144         VariableType::JS_ANY(),     // newTarget
145         VariableType::JS_ANY(),     // thisTarget
146         VariableType::JS_ANY(),     // a
147         VariableType::JS_ANY(),     // b
148     };
149     callSign->SetParameters(params.data());
150     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
151 }
152 
DEF_CALL_SIGNATURE(FooProxyAOT)153 DEF_CALL_SIGNATURE(FooProxyAOT)
154 {
155     // 8 : 8 input parameters
156     CallSignature fooProxyAot("FooProxyAOT", 0, 7,
157         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
158     *callSign = fooProxyAot;
159     std::array<VariableType, 7> params = { // 7 : 7 input parameters
160         VariableType::NATIVE_POINTER(),
161         VariableType::INT64(),
162         VariableType::JS_ANY(),     // calltarget
163         VariableType::JS_ANY(),     // newTarget
164         VariableType::JS_ANY(),     // thisTarget
165         VariableType::JS_ANY(),     // a
166         VariableType::JS_ANY(),     // b
167     };
168     callSign->SetParameters(params.data());
169     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
170 }
171 
DEF_CALL_SIGNATURE(FooProxy2AOT)172 DEF_CALL_SIGNATURE(FooProxy2AOT)
173 {
174     // 7 : 7 input parameters
175     CallSignature FooProxy2AOT("FooProxy2AOT", 0, 7,
176         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
177     *callSign = FooProxy2AOT;
178     std::array<VariableType, 7> params = { // 7 : 7 input parameters
179         VariableType::NATIVE_POINTER(),
180         VariableType::INT64(),
181         VariableType::JS_ANY(),     // calltarget
182         VariableType::JS_ANY(),     // newTarget
183         VariableType::JS_ANY(),     // thisTarget
184         VariableType::JS_ANY(),     // a
185         VariableType::JS_ANY(),     // b
186     };
187     callSign->SetParameters(params.data());
188     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
189 }
190 
DEF_CALL_SIGNATURE(Bar2AOT)191 DEF_CALL_SIGNATURE(Bar2AOT)
192 {
193     // 5 : 5 input parameters
194     CallSignature bar2Aot("Bar2AOT", 0, 5,
195         ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY());
196     *callSign = bar2Aot;
197     std::array<VariableType, 5> params = { // 5 : 5 input parameters
198         VariableType::NATIVE_POINTER(),
199         VariableType::INT64(),
200         VariableType::JS_ANY(),     // calltarget
201         VariableType::JS_ANY(),     // newTarget
202         VariableType::JS_ANY(),     // thisTarget
203     };
204     callSign->SetParameters(params.data());
205     callSign->SetVariadicArgs(true);
206     callSign->SetCallConv(CallSignature::CallConv::WebKitJSCallConv);
207 }
208 
DEF_CALL_SIGNATURE(TestAbsoluteAddressRelocation)209 DEF_CALL_SIGNATURE(TestAbsoluteAddressRelocation)
210 {
211     // 1 : 1 input parameters
212     CallSignature TestAbsoluteAddressRelocation("TestAbsoluteAddressRelocation", 0, 1,
213         ArgumentsOrder::DEFAULT_ORDER, VariableType::INT64()); // undefined or hole
214     *callSign = TestAbsoluteAddressRelocation;
215     // 1 : 1 input parameters
216     std::array<VariableType, 1> params = {
217         VariableType::INT64(),
218     };
219     callSign->SetParameters(params.data());
220 }
221 
222 #endif
223 }  // namespace panda::ecmascript::kungfu