• 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 <thread>
17 
18 #include "ecmascript/ecma_vm.h"
19 #include "ecmascript/global_env_constants.h"
20 #include "ecmascript/global_env_constants-inl.h"
21 #include "ecmascript/ic/ic_binary_op-inl.h"
22 #include "ecmascript/interpreter/interpreter-inl.h"
23 #include "ecmascript/interpreter/slow_runtime_stub.h"
24 #include "ecmascript/object_factory.h"
25 #include "ecmascript/tests/test_helper.h"
26 
27 using namespace panda::ecmascript;
28 namespace panda::test {
29 class ICBinaryOPTest : public testing::Test {
30 public:
SetUpTestCase()31     static void SetUpTestCase()
32     {
33         GTEST_LOG_(INFO) << "SetUpTestCase";
34     }
35 
TearDownTestCase()36     static void TearDownTestCase()
37     {
38         GTEST_LOG_(INFO) << "TearDownCase";
39     }
40 
SetUp()41     void SetUp() override
42     {
43         TestHelper::CreateEcmaVMWithScope(instance, thread, scope);
44         ecmaVm = EcmaVM::Cast(instance);
45     }
46 
TearDown()47     void TearDown() override
48     {
49         TestHelper::DestroyEcmaVMWithScope(instance, scope);
50     }
51 
52     PandaVM *instance {nullptr};
53     EcmaHandleScope *scope {nullptr};
54     JSThread *thread {nullptr};
55     EcmaVM *ecmaVm = nullptr;
56 };
57 
HWTEST_F_L0(ICBinaryOPTest,AddWithTSType)58 HWTEST_F_L0(ICBinaryOPTest, AddWithTSType)
59 {
60     ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
61 
62     JSHandle<EcmaString> Str1 = factory->NewFromCanBeCompressString("AddTest");
63     JSHandle<EcmaString> Str2 = factory->NewFromCanBeCompressString("IC");
64     JSHandle<JSObject> arg4 = factory->NewEmptyJSObject();
65     JSTaggedValue arg1Value(static_cast<uint32_t>(2));
66     JSTaggedValue arg2Value(static_cast<uint32_t>(3));
67     JSTaggedValue arg3Value(static_cast<double>(9.5561));
68     JSHandle<JSTaggedValue> arg1(thread, arg1Value);
69     JSHandle<JSTaggedValue> arg2(thread, arg2Value);
70     JSHandle<JSTaggedValue> arg3(thread, arg3Value);
71 
72     JSTaggedValue resInSlowPath1 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(),
73                                                             arg2.GetTaggedValue());
74     JSHandle<JSTaggedValue> slowHandle1(thread, resInSlowPath1);
75     JSTaggedValue resInICPath1 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg2.GetTaggedValue(),
76                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
77     EXPECT_EQ(slowHandle1.GetTaggedValue(), resInICPath1);
78 
79     JSTaggedValue resInSlowPath2 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(),
80                                                             arg3.GetTaggedValue());
81     JSHandle<JSTaggedValue> slowHandle2(thread, resInSlowPath2);
82     JSTaggedValue resInICPath2 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg3.GetTaggedValue(),
83                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
84     EXPECT_EQ(slowHandle2.GetTaggedValue(), resInICPath2);
85 
86     JSTaggedValue resInSlowPath3 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, Str1.GetTaggedValue(),
87                                                             Str2.GetTaggedValue());
88     JSHandle<EcmaString> slowHandle3(thread, reinterpret_cast<EcmaString *>(resInSlowPath3.GetRawData()));
89     JSTaggedValue resInICPath3 = ICBinaryOP::AddWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), Str2.GetTaggedValue(),
90                                                            JSTaggedValue(static_cast<int>(BinaryType::STRING)));
91     ASSERT_TRUE(resInICPath3.IsString());
92     EXPECT_EQ(slowHandle3->Compare(reinterpret_cast<EcmaString *>(resInICPath3.GetRawData())), 0);
93 
94     JSTaggedValue resInSlowPath4 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, JSTaggedValue::Undefined(),
95                                                             arg2.GetTaggedValue());
96     JSHandle<JSTaggedValue> slowHandle4(thread, resInSlowPath4);
97     JSTaggedValue resInICPath4 = ICBinaryOP::AddWithTSType(thread, ecmaVm, JSTaggedValue::Undefined(),
98                                                            arg2.GetTaggedValue(),
99                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER_GEN)));
100     EXPECT_EQ(slowHandle4.GetTaggedValue(), resInICPath4);
101 
102     JSTaggedValue resInSlowPath5 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg3.GetTaggedValue(),
103                                                             Str1.GetTaggedValue());
104     JSHandle<EcmaString> slowHandle5(thread, reinterpret_cast<EcmaString *>(resInSlowPath5.GetRawData()));
105     JSTaggedValue resInICPath5 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg3.GetTaggedValue(),
106                                                            Str1.GetTaggedValue(),
107                                                            JSTaggedValue(static_cast<int>(BinaryType::STRING_GEN)));
108     ASSERT_TRUE(resInICPath5.IsString());
109     EXPECT_EQ(slowHandle5->Compare(reinterpret_cast<EcmaString *>(resInICPath5.GetRawData())), 0);
110 
111     JSTaggedValue resInSlowPath6 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, Str1.GetTaggedValue(),
112                                                             JSTaggedValue::Null());
113     JSHandle<EcmaString> slowHandle6(thread, reinterpret_cast<EcmaString *>(resInSlowPath6.GetRawData()));
114     JSTaggedValue resInICPath6 = ICBinaryOP::AddWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), JSTaggedValue::Null(),
115                                                            JSTaggedValue(static_cast<int>(BinaryType::STRING_GEN)));
116     ASSERT_TRUE(resInICPath6.IsString());
117     EXPECT_EQ(slowHandle6->Compare(reinterpret_cast<EcmaString *>(resInICPath6.GetRawData())), 0);
118 
119     JSTaggedValue resInSlowPath7 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(),
120                                                             JSTaggedValue::True());
121     JSHandle<JSTaggedValue> slowHandle7(thread, resInSlowPath7);
122     JSTaggedValue resInICPath7 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), JSTaggedValue::True(),
123                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER_GEN)));
124     EXPECT_EQ(slowHandle7.GetTaggedValue(), resInICPath7);
125 
126     JSTaggedValue resInSlowPath8 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg4.GetTaggedValue(),
127                                                             JSTaggedValue::Null());
128     JSHandle<EcmaString> slowHandle8(thread, reinterpret_cast<EcmaString *>(resInSlowPath8.GetRawData()));
129     JSTaggedValue resInICPath8 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg4.GetTaggedValue(), JSTaggedValue::Null(),
130                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
131     ASSERT_TRUE(resInICPath8.IsString());
132     EXPECT_EQ(slowHandle8->Compare(reinterpret_cast<EcmaString *>(resInICPath8.GetRawData())), 0);
133 };
134 
HWTEST_F_L0(ICBinaryOPTest,SubWithTSType)135 HWTEST_F_L0(ICBinaryOPTest, SubWithTSType)
136 {
137     JSTaggedValue arg1Value(static_cast<uint32_t>(-2));
138     JSTaggedValue arg2Value(static_cast<uint32_t>(INT32_MAX-1));
139     JSTaggedValue arg3Value(static_cast<double>(9.5561));
140     JSHandle<JSTaggedValue> arg1(thread, arg1Value);
141     JSHandle<JSTaggedValue> arg2(thread, arg2Value);
142     JSHandle<JSTaggedValue> arg3(thread, arg3Value);
143 
144     JSTaggedValue resInSlowPath1 = SlowRuntimeStub::Sub2Dyn(thread, arg1.GetTaggedValue(), arg2.GetTaggedValue());
145     JSHandle<JSTaggedValue> slowHandle1(thread, resInSlowPath1);
146     JSTaggedValue resInICPath1 = ICBinaryOP::SubWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg2.GetTaggedValue(),
147                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
148     EXPECT_EQ(slowHandle1.GetTaggedValue(), resInICPath1);
149 
150     JSTaggedValue resInSlowPath2 = SlowRuntimeStub::Sub2Dyn(thread, arg2.GetTaggedValue(), arg3.GetTaggedValue());
151     JSHandle<JSTaggedValue> slowHandle2(thread, resInSlowPath2);
152     JSTaggedValue resInICPath2 = ICBinaryOP::SubWithTSType(thread, ecmaVm, arg2.GetTaggedValue(), arg3.GetTaggedValue(),
153                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
154     EXPECT_EQ(slowHandle2.GetTaggedValue(), resInICPath2);
155 
156     JSTaggedValue resInSlowPath3 = SlowRuntimeStub::Sub2Dyn(thread, arg1.GetTaggedValue(), JSTaggedValue::True());
157     JSHandle<JSTaggedValue> slowHandle3(thread, resInSlowPath3);
158     JSTaggedValue resInICPath3 = ICBinaryOP::SubWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), JSTaggedValue::True(),
159                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
160     EXPECT_EQ(slowHandle3.GetTaggedValue(), resInICPath3);
161 };
162 
HWTEST_F_L0(ICBinaryOPTest,MulWithTSType)163 HWTEST_F_L0(ICBinaryOPTest, MulWithTSType)
164 {
165     JSTaggedValue arg1Value(static_cast<double>(28.5));
166     JSTaggedValue arg2Value(static_cast<uint16_t>(354));
167     JSTaggedValue arg3Value(static_cast<double>(9.5561));
168     JSHandle<JSTaggedValue> arg1(thread, arg1Value);
169     JSHandle<JSTaggedValue> arg2(thread, arg2Value);
170     JSHandle<JSTaggedValue> arg3(thread, arg3Value);
171 
172     JSTaggedValue resInSlowPath1 = SlowRuntimeStub::Mul2Dyn(thread, arg1.GetTaggedValue(), arg2.GetTaggedValue());
173     JSHandle<JSTaggedValue> slowHandle1(thread, resInSlowPath1);
174     JSTaggedValue resInICPath1 = ICBinaryOP::MulWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg2.GetTaggedValue(),
175                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
176     EXPECT_EQ(slowHandle1.GetTaggedValue(), resInICPath1);
177 
178     JSTaggedValue resInSlowPath2 = SlowRuntimeStub::Mul2Dyn(thread, arg2.GetTaggedValue(), arg3.GetTaggedValue());
179     JSHandle<JSTaggedValue> slowHandle2(thread, resInSlowPath2);
180     JSTaggedValue resInICPath2 = ICBinaryOP::MulWithTSType(thread, ecmaVm, arg2.GetTaggedValue(), arg3.GetTaggedValue(),
181                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
182     EXPECT_EQ(slowHandle2.GetTaggedValue(), resInICPath2);
183 
184     JSTaggedValue resInSlowPath3 = SlowRuntimeStub::Mul2Dyn(thread, arg1.GetTaggedValue(), JSTaggedValue::True());
185     JSHandle<JSTaggedValue> slowHandle3(thread, resInSlowPath3);
186     JSTaggedValue resInICPath3 = ICBinaryOP::MulWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), JSTaggedValue::True(),
187                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
188     EXPECT_EQ(slowHandle3.GetTaggedValue(), resInICPath3);
189 
190 };
191 
HWTEST_F_L0(ICBinaryOPTest,DivWithTSType)192 HWTEST_F_L0(ICBinaryOPTest, DivWithTSType)
193 {
194     JSTaggedValue arg1Value(static_cast<uint32_t>(2));
195     JSTaggedValue arg2Value(static_cast<uint32_t>(39884));
196     JSTaggedValue arg3Value(static_cast<uint32_t>(0));
197     JSTaggedValue arg4Value(static_cast<double>(934.5561));
198     JSHandle<JSTaggedValue> arg1(thread, arg1Value);
199     JSHandle<JSTaggedValue> arg2(thread, arg2Value);
200     JSHandle<JSTaggedValue> arg3(thread, arg3Value);
201     JSHandle<JSTaggedValue> arg4(thread, arg4Value);
202 
203     JSTaggedValue resInSlowPath1 = SlowRuntimeStub::Div2Dyn(thread, arg3.GetTaggedValue(), arg2.GetTaggedValue());
204     JSHandle<JSTaggedValue> slowHandle1(thread, resInSlowPath1);
205     JSTaggedValue resInICPath1 = ICBinaryOP::DivWithTSType(thread, ecmaVm, arg3.GetTaggedValue(), arg2.GetTaggedValue(),
206                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
207     EXPECT_EQ(slowHandle1.GetTaggedValue(), resInICPath1);
208 
209     JSTaggedValue resInSlowPath2 = SlowRuntimeStub::Div2Dyn(thread, arg2.GetTaggedValue(), arg3.GetTaggedValue());
210     JSHandle<JSTaggedValue> slowHandle2(thread, resInSlowPath2);
211     JSTaggedValue resInICPath2 = ICBinaryOP::DivWithTSType(thread, ecmaVm, arg2.GetTaggedValue(), arg3.GetTaggedValue(),
212                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
213     EXPECT_EQ(slowHandle2.GetTaggedValue(), resInICPath2);
214 
215     JSTaggedValue resInSlowPath3 = SlowRuntimeStub::Div2Dyn(thread, arg1.GetTaggedValue(), arg2.GetTaggedValue());
216     JSHandle<JSTaggedValue> slowHandle3(thread, resInSlowPath3);
217     JSTaggedValue resInICPath3 = ICBinaryOP::DivWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg2.GetTaggedValue(),
218                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
219     EXPECT_EQ(slowHandle3.GetTaggedValue(), resInICPath3);
220 
221     JSTaggedValue resInSlowPath4 = SlowRuntimeStub::Div2Dyn(thread, arg2.GetTaggedValue(), JSTaggedValue::True());
222     JSHandle<JSTaggedValue> slowHandle4(thread, resInSlowPath4);
223     JSTaggedValue resInICPath4 = ICBinaryOP::DivWithTSType(thread, ecmaVm, arg2.GetTaggedValue(), JSTaggedValue::True(),
224                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
225     EXPECT_EQ(slowHandle4.GetTaggedValue(), resInICPath4);
226 
227     JSTaggedValue resInSlowPath5 = SlowRuntimeStub::Div2Dyn(thread, arg4.GetTaggedValue(), JSTaggedValue::False());
228     JSHandle<JSTaggedValue> slowHandle5(thread, resInSlowPath5);
229     JSTaggedValue resInICPath5 = ICBinaryOP::DivWithTSType(thread, ecmaVm, arg4.GetTaggedValue(),
230                                                            JSTaggedValue::False(),
231                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
232     EXPECT_EQ(slowHandle5.GetTaggedValue(), resInICPath5);
233 };
234 
HWTEST_F_L0(ICBinaryOPTest,ModWithTSType)235 HWTEST_F_L0(ICBinaryOPTest, ModWithTSType)
236 {
237     JSTaggedValue arg1Value(static_cast<uint32_t>(2));
238     JSTaggedValue arg2Value(static_cast<uint32_t>(39884));
239     JSTaggedValue arg3Value(static_cast<uint32_t>(0));
240     JSTaggedValue arg4Value(static_cast<double>(934.5561));
241     JSHandle<JSTaggedValue> arg1(thread, arg1Value);
242     JSHandle<JSTaggedValue> arg2(thread, arg2Value);
243     JSHandle<JSTaggedValue> arg3(thread, arg3Value);
244     JSHandle<JSTaggedValue> arg4(thread, arg4Value);
245 
246     JSTaggedValue resInSlowPath1 = SlowRuntimeStub::Mod2Dyn(thread, arg3.GetTaggedValue(), arg2.GetTaggedValue());
247     JSHandle<JSTaggedValue> slowHandle1(thread, resInSlowPath1);
248     JSTaggedValue resInICPath1 = ICBinaryOP::ModWithTSType(thread, ecmaVm, arg3.GetTaggedValue(), arg2.GetTaggedValue(),
249                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
250     EXPECT_EQ(slowHandle1.GetTaggedValue(), resInICPath1);
251 
252     JSTaggedValue resInSlowPath2 = SlowRuntimeStub::Mod2Dyn(thread, arg2.GetTaggedValue(), arg3.GetTaggedValue());
253     JSHandle<JSTaggedValue> slowHandle2(thread, resInSlowPath2);
254     JSTaggedValue resInICPath2 = ICBinaryOP::ModWithTSType(thread, ecmaVm, arg2.GetTaggedValue(), arg3.GetTaggedValue(),
255                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
256     EXPECT_EQ(slowHandle2.GetTaggedValue(), resInICPath2);
257 
258     JSTaggedValue resInSlowPath3 = SlowRuntimeStub::Mod2Dyn(thread, arg1.GetTaggedValue(), arg2.GetTaggedValue());
259     JSHandle<JSTaggedValue> slowHandle3(thread, resInSlowPath3);
260     JSTaggedValue resInICPath3 = ICBinaryOP::ModWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg2.GetTaggedValue(),
261                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
262     EXPECT_EQ(slowHandle3.GetTaggedValue(), resInICPath3);
263 
264 
265     JSTaggedValue resInSlowPath4 = SlowRuntimeStub::Mod2Dyn(thread, arg2.GetTaggedValue(), JSTaggedValue::True());
266     JSHandle<JSTaggedValue> slowHandle4(thread, resInSlowPath4);
267     JSTaggedValue resInICPath4 = ICBinaryOP::ModWithTSType(thread, ecmaVm, arg2.GetTaggedValue(), JSTaggedValue::True(),
268                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
269     EXPECT_EQ(slowHandle4.GetTaggedValue(), resInICPath4);
270 
271 
272     JSTaggedValue resInSlowPath5 = SlowRuntimeStub::Mod2Dyn(thread, arg4.GetTaggedValue(), JSTaggedValue::False());
273     JSHandle<JSTaggedValue> slowHandle5(thread, resInSlowPath5);
274     JSTaggedValue resInICPath5 = ICBinaryOP::ModWithTSType(thread, ecmaVm, arg4.GetTaggedValue(),
275                                                            JSTaggedValue::False(),
276                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
277     EXPECT_EQ(slowHandle5.GetTaggedValue(), resInICPath5);
278 };
279 
HWTEST_F_L0(ICBinaryOPTest,ShlWithTSType)280 HWTEST_F_L0(ICBinaryOPTest, ShlWithTSType)
281 {
282     ObjectFactory *factory = ecmaVm->GetFactory();
283 
284     JSHandle<EcmaString> Str1 = factory->NewFromCanBeCompressString("225");
285     JSTaggedValue arg1(static_cast<uint32_t>(286));
286     JSTaggedValue arg3(static_cast<uint32_t>(5));
287 
288     JSTaggedValue resInICPath1 = ICBinaryOP::ShlWithTSType(thread, ecmaVm, arg1, arg3,
289                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
290     EXPECT_EQ(JSTaggedValue(9152), resInICPath1);
291 
292     JSTaggedValue resInICPath2 = ICBinaryOP::ShlWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3,
293                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
294     EXPECT_EQ(JSTaggedValue(7200), resInICPath2);
295 };
296 
HWTEST_F_L0(ICBinaryOPTest,ShrWithTSType)297 HWTEST_F_L0(ICBinaryOPTest, ShrWithTSType)
298 {
299     ObjectFactory *factory = ecmaVm->GetFactory();
300 
301     JSHandle<EcmaString> Str1 = factory->NewFromCanBeCompressString("225");
302     JSTaggedValue arg1(static_cast<uint32_t>(286));
303     JSTaggedValue arg3(static_cast<uint32_t>(5));
304 
305     JSTaggedValue resInICPath1 = ICBinaryOP::ShrWithTSType(thread, ecmaVm, arg1, arg3,
306                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
307     EXPECT_EQ(JSTaggedValue(8), resInICPath1);
308 
309     JSTaggedValue resInICPath2 = ICBinaryOP::ShrWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3,
310                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
311     EXPECT_EQ(JSTaggedValue(7), resInICPath2);
312 };
313 
HWTEST_F_L0(ICBinaryOPTest,AshrWithTSType)314 HWTEST_F_L0(ICBinaryOPTest, AshrWithTSType)
315 {
316     ObjectFactory *factory = ecmaVm->GetFactory();
317 
318     JSHandle<EcmaString> Str1 = factory->NewFromCanBeCompressString("225");
319     JSTaggedValue arg1(static_cast<uint32_t>(286));
320     JSTaggedValue arg2(static_cast<uint32_t>(-286));
321     JSTaggedValue arg3(static_cast<uint32_t>(5));
322 
323     JSTaggedValue resInICPath1 = ICBinaryOP::AshrWithTSType(thread, ecmaVm, arg1, arg3,
324                                                             JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
325     EXPECT_EQ(JSTaggedValue(8), resInICPath1);
326 
327     JSTaggedValue resInICPath3 = ICBinaryOP::AshrWithTSType(thread, ecmaVm, arg2, arg3,
328                                                             JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
329     EXPECT_EQ(JSTaggedValue(134217719), resInICPath3);
330 
331     JSTaggedValue resInICPath2 = ICBinaryOP::AshrWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3,
332                                                             JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
333     EXPECT_EQ(JSTaggedValue(7), resInICPath2);
334 
335 };
HWTEST_F_L0(ICBinaryOPTest,AndWithTSType)336 HWTEST_F_L0(ICBinaryOPTest, AndWithTSType)
337 {
338     ObjectFactory *factory = ecmaVm->GetFactory();
339 
340     JSHandle<EcmaString> Str1 = factory->NewFromCanBeCompressString("225");
341     JSTaggedValue arg1(static_cast<uint32_t>(286));
342     JSTaggedValue arg3(static_cast<uint32_t>(541));
343 
344     JSTaggedValue resInICPath1 = ICBinaryOP::AndWithTSType(thread, ecmaVm, arg1, arg3,
345                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
346     EXPECT_EQ(JSTaggedValue(28), resInICPath1);
347 
348     JSTaggedValue resInICPath2 = ICBinaryOP::AndWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3,
349                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
350     EXPECT_EQ(JSTaggedValue(1), resInICPath2);
351 };
HWTEST_F_L0(ICBinaryOPTest,OrWithTSType)352 HWTEST_F_L0(ICBinaryOPTest, OrWithTSType)
353 {
354     ObjectFactory *factory = ecmaVm->GetFactory();
355 
356     JSHandle<EcmaString> Str1 = factory->NewFromCanBeCompressString("225");
357     JSTaggedValue arg1(static_cast<uint32_t>(286));
358     JSTaggedValue arg3(static_cast<uint32_t>(523));
359 
360     JSTaggedValue resInICPath1 = ICBinaryOP::OrWithTSType(thread, ecmaVm, arg1, arg3,
361                                                           JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
362     EXPECT_EQ(JSTaggedValue(799), resInICPath1);
363 
364     JSTaggedValue resInICPath2 = ICBinaryOP::OrWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3,
365                                                           JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
366     EXPECT_EQ(JSTaggedValue(747), resInICPath2);
367 };
HWTEST_F_L0(ICBinaryOPTest,XorWithTSType)368 HWTEST_F_L0(ICBinaryOPTest, XorWithTSType)
369 {
370     ObjectFactory *factory = ecmaVm->GetFactory();
371 
372     JSHandle<EcmaString> Str1 = factory->NewFromCanBeCompressString("1225");
373     JSTaggedValue arg1(static_cast<uint32_t>(286));
374     JSTaggedValue arg3(static_cast<uint32_t>(523));
375 
376     JSTaggedValue resInICPath1 = ICBinaryOP::XorWithTSType(thread, ecmaVm, arg1, arg3,
377                                                            JSTaggedValue(static_cast<int>(BinaryType::NUMBER)));
378     EXPECT_EQ(JSTaggedValue(789), resInICPath1);
379 
380     JSTaggedValue resInICPath2 = ICBinaryOP::XorWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3,
381                                                            JSTaggedValue(static_cast<int>(BinaryType::GENERIC)));
382     EXPECT_EQ(JSTaggedValue(1730), resInICPath2);
383 };
384 }  // namespace panda::test