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/* 17 * @tc.name:loadicbyvalue 18 * @tc.desc:test loadicbyvalue 19 * @tc.type: FUNC 20 * @tc.require: issueI5NO8G 21 */ 22var i = 3; 23var obj = { 3: "icsuccess" }; 24function func1(a) { 25 var b = a[i]; 26} 27for (let j = 300; j > 0; j--) { 28 func1(obj); 29} 30print(obj[i]); 31 32// PoC testcase 33const arr = [] 34for (let i = 0; i < 20; i++) { 35 const v0 = "p" + i; 36 const v1 = Symbol.iterator; 37 const v2 = { 38 [v1]() { }, 39 }; 40 arr[v0] = i; 41} 42const v3 = new Uint8Array(128); 43v3[arr]; 44print("test successful !!!"); 45 46var obj1 = { 47 0: 0, 48 2147483647: 1, 49 2147483648: 2, 50 4294967295: 3, 51 4294967296: 4, 52} 53 54for (let item in obj1) { 55 print(item + " " + obj1[item]); 56} 57// test ic 58var lineStr = "方舟ArK TypeScript RuntimekTS运行时(ARK TypeScript Runtime)K TypeScript Runtime是OppeScript RK TypeScripK TypeScript Runtimet Runtimeuntime)是OpeK TypeScript RuntimenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配enHarmonypeScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配上ArkTS应用使用peScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配的运行时。包含ArkTS/JS对象的分配器以及垃圾回收器(GC)、符合ECMAScript规范的标准库、用于运行ARK前端组件生成的方舟字节码(ARK Bytecode简称abc)的解释器、用于加速的内联缓存、静态类型编译器、运行时的C++/C函数接口(NAPI)等模块."; 59var str = "方舟ArkTS运行时(ARK TypeScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配器以及垃圾回收器(GC)、符合ECMAScript规范的标准库、用于运行ARK前端组件生成的方舟字节码(ARK Bytecode简称abc)的解释器、用于加速的内联缓存、静态类型编译器、运行时的C++/C函数接口(NAPI)等模块."; 60str += str; 61str += str; 62str += str; 63var c; 64var l; 65var strC; 66for (let i = 0; i < 100; i++) { 67 strC = str.split("C"); 68 c = str[i]; 69 l = str.length; 70 strC = lineStr.split("C"); 71 c = lineStr[i]; 72 l = lineStr.length; 73} 74var strObj = new String("方舟ArkTS运行时(ARK TypeScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配器以及垃圾回收器(GC)、符合ECMAScript规范的标准库、用于运行ARK前端组件生成的方舟字节码(ARK Bytecode简称abc)的解释器、用于加速的内联缓存、静态类型编译器、运行时的C++/C函数接口(NAPI)等模块."); 75for (let i = 0; i < 100; i++) { 76 strC = strObj.split("C"); 77 c = strObj[i]; 78 l = strObj.length; 79} 80 81 82for (let i = 0; i < 100; i++) { 83 let arr = [0]; 84 arr[0] = arr; 85} 86print("load ic by COWArray Success") 87 88function g(o, v) { 89 let res; 90 for (let i = 0; i < 100; i++) { 91 res = o[1]; 92 if (res != v) { 93 print("Error ",res); 94 } 95 } 96 return res; 97} 98{ 99 let pro = [1,1,1,1]; 100 let o = { 101 __proto__: pro }; 102 o[102500] = 1; 103 o["test"] = "test"; 104 print(g(o, 1)); 105 Object.defineProperty(o, "1", { value: 2 }); 106 print("change") 107 print(g(o, 2)); 108} 109{ 110 let pro = new Uint8Array(10); 111 pro[1]=1; 112 let o = { 113 __proto__: pro }; 114 o[102500] = 1; 115 o["test"] = "test"; 116 print(g(o, 1)); 117 Object.defineProperty(o, "1", { value: 2 }); 118 print("change") 119 print(g(o, 2)); 120} 121print("ic load success"); 122