14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci#include "ecmascript/compiler/access_object_stub_builder.h" 164514f5e3Sopenharmony_ci#include "ecmascript/compiler/ic_stub_builder.h" 174514f5e3Sopenharmony_ci#include "ecmascript/compiler/interpreter_stub-inl.h" 184514f5e3Sopenharmony_ci#include "ecmascript/compiler/profiler_stub_builder.h" 194514f5e3Sopenharmony_ci#include "ecmascript/compiler/rt_call_signature.h" 204514f5e3Sopenharmony_ci#include "ecmascript/compiler/stub_builder-inl.h" 214514f5e3Sopenharmony_ci#include "ecmascript/ic/profile_type_info.h" 224514f5e3Sopenharmony_ci 234514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu { 244514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::LoadObjByName(GateRef glue, GateRef receiver, GateRef prop, const StringIdInfo &info, 254514f5e3Sopenharmony_ci GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback) 264514f5e3Sopenharmony_ci{ 274514f5e3Sopenharmony_ci auto env = GetEnvironment(); 284514f5e3Sopenharmony_ci Label entry(env); 294514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 304514f5e3Sopenharmony_ci Label exit(env); 314514f5e3Sopenharmony_ci Label tryFastPath(env); 324514f5e3Sopenharmony_ci Label slowPath(env); 334514f5e3Sopenharmony_ci Label tryPreDump(env); 344514f5e3Sopenharmony_ci 354514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 364514f5e3Sopenharmony_ci GateRef value = 0; 374514f5e3Sopenharmony_ci ICStubBuilder builder(this); 384514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId); 394514f5e3Sopenharmony_ci builder.LoadICByName(&result, &tryFastPath, &tryPreDump, &exit, callback); 404514f5e3Sopenharmony_ci Bind(&tryFastPath); 414514f5e3Sopenharmony_ci { 424514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 434514f5e3Sopenharmony_ci result = GetPropertyByName(glue, receiver, propKey, callback, True()); 444514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 454514f5e3Sopenharmony_ci } 464514f5e3Sopenharmony_ci Bind(&tryPreDump); 474514f5e3Sopenharmony_ci { 484514f5e3Sopenharmony_ci callback.TryPreDump(); 494514f5e3Sopenharmony_ci Jump(&slowPath); 504514f5e3Sopenharmony_ci } 514514f5e3Sopenharmony_ci Bind(&slowPath); 524514f5e3Sopenharmony_ci { 534514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 544514f5e3Sopenharmony_ci result = 554514f5e3Sopenharmony_ci CallRuntime(glue, RTSTUB_ID(LoadICByName), {profileTypeInfo, receiver, propKey, IntToTaggedInt(slotId)}); 564514f5e3Sopenharmony_ci Jump(&exit); 574514f5e3Sopenharmony_ci } 584514f5e3Sopenharmony_ci Bind(&exit); 594514f5e3Sopenharmony_ci auto ret = *result; 604514f5e3Sopenharmony_ci env->SubCfgExit(); 614514f5e3Sopenharmony_ci return ret; 624514f5e3Sopenharmony_ci} 634514f5e3Sopenharmony_ci 644514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::LoadPrivatePropertyByName( 654514f5e3Sopenharmony_ci GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback) 664514f5e3Sopenharmony_ci{ 674514f5e3Sopenharmony_ci auto env = GetEnvironment(); 684514f5e3Sopenharmony_ci Label entry(env); 694514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 704514f5e3Sopenharmony_ci Label exit(env); 714514f5e3Sopenharmony_ci Label tryFastPath(env); 724514f5e3Sopenharmony_ci Label slowPath(env); 734514f5e3Sopenharmony_ci Label tryPreDump(env); 744514f5e3Sopenharmony_ci 754514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 764514f5e3Sopenharmony_ci GateRef value = 0; 774514f5e3Sopenharmony_ci ICStubBuilder builder(this); 784514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId); 794514f5e3Sopenharmony_ci builder.LoadICByName(&result, &tryFastPath, &tryPreDump, &exit, callback); 804514f5e3Sopenharmony_ci Bind(&tryFastPath); 814514f5e3Sopenharmony_ci { 824514f5e3Sopenharmony_ci result = GetPropertyByName(glue, receiver, key, callback, True()); 834514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 844514f5e3Sopenharmony_ci } 854514f5e3Sopenharmony_ci Bind(&tryPreDump); 864514f5e3Sopenharmony_ci { 874514f5e3Sopenharmony_ci callback.TryPreDump(); 884514f5e3Sopenharmony_ci Jump(&slowPath); 894514f5e3Sopenharmony_ci } 904514f5e3Sopenharmony_ci Bind(&slowPath); 914514f5e3Sopenharmony_ci { 924514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(LoadICByName), {profileTypeInfo, receiver, key, IntToTaggedInt(slotId)}); 934514f5e3Sopenharmony_ci Jump(&exit); 944514f5e3Sopenharmony_ci } 954514f5e3Sopenharmony_ci Bind(&exit); 964514f5e3Sopenharmony_ci auto ret = *result; 974514f5e3Sopenharmony_ci env->SubCfgExit(); 984514f5e3Sopenharmony_ci return ret; 994514f5e3Sopenharmony_ci} 1004514f5e3Sopenharmony_ci 1014514f5e3Sopenharmony_ci// Used for deprecated bytecodes which will not support ic 1024514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::DeprecatedLoadObjByName(GateRef glue, GateRef receiver, GateRef propKey) 1034514f5e3Sopenharmony_ci{ 1044514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1054514f5e3Sopenharmony_ci Label entry(env); 1064514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 1074514f5e3Sopenharmony_ci Label exit(env); 1084514f5e3Sopenharmony_ci Label fastPath(env); 1094514f5e3Sopenharmony_ci Label slowPath(env); 1104514f5e3Sopenharmony_ci 1114514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 1124514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath); 1134514f5e3Sopenharmony_ci Bind(&fastPath); 1144514f5e3Sopenharmony_ci { 1154514f5e3Sopenharmony_ci result = GetPropertyByName(glue, receiver, propKey, ProfileOperation(), True()); 1164514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 1174514f5e3Sopenharmony_ci } 1184514f5e3Sopenharmony_ci Bind(&slowPath); 1194514f5e3Sopenharmony_ci { 1204514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(LoadICByName), 1214514f5e3Sopenharmony_ci { Undefined(), receiver, propKey, IntToTaggedInt(Int32(0xFF)) }); // 0xFF: invalid slot id 1224514f5e3Sopenharmony_ci Jump(&exit); 1234514f5e3Sopenharmony_ci } 1244514f5e3Sopenharmony_ci Bind(&exit); 1254514f5e3Sopenharmony_ci auto ret = *result; 1264514f5e3Sopenharmony_ci env->SubCfgExit(); 1274514f5e3Sopenharmony_ci return ret; 1284514f5e3Sopenharmony_ci} 1294514f5e3Sopenharmony_ci 1304514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StoreObjByName(GateRef glue, GateRef receiver, GateRef prop, const StringIdInfo &info, 1314514f5e3Sopenharmony_ci GateRef value, GateRef profileTypeInfo, GateRef slotId, 1324514f5e3Sopenharmony_ci ProfileOperation callback) 1334514f5e3Sopenharmony_ci{ 1344514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1354514f5e3Sopenharmony_ci Label entry(env); 1364514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 1374514f5e3Sopenharmony_ci Label exit(env); 1384514f5e3Sopenharmony_ci Label tryFastPath(env); 1394514f5e3Sopenharmony_ci Label slowPath(env); 1404514f5e3Sopenharmony_ci Label tryPreDump(env); 1414514f5e3Sopenharmony_ci 1424514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 1434514f5e3Sopenharmony_ci ICStubBuilder builder(this); 1444514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId, callback); 1454514f5e3Sopenharmony_ci builder.StoreICByName(&result, &tryFastPath, &tryPreDump, &exit); 1464514f5e3Sopenharmony_ci Bind(&tryFastPath); 1474514f5e3Sopenharmony_ci { 1484514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 1494514f5e3Sopenharmony_ci result = SetPropertyByName(glue, receiver, propKey, value, false, True(), callback); 1504514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 1514514f5e3Sopenharmony_ci } 1524514f5e3Sopenharmony_ci Bind(&tryPreDump); 1534514f5e3Sopenharmony_ci { 1544514f5e3Sopenharmony_ci callback.TryPreDump(); 1554514f5e3Sopenharmony_ci Jump(&slowPath); 1564514f5e3Sopenharmony_ci } 1574514f5e3Sopenharmony_ci Bind(&slowPath); 1584514f5e3Sopenharmony_ci { 1594514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 1604514f5e3Sopenharmony_ci result = CallRuntime( 1614514f5e3Sopenharmony_ci glue, RTSTUB_ID(StoreICByName), {profileTypeInfo, receiver, propKey, value, IntToTaggedInt(slotId)}); 1624514f5e3Sopenharmony_ci Jump(&exit); 1634514f5e3Sopenharmony_ci } 1644514f5e3Sopenharmony_ci 1654514f5e3Sopenharmony_ci Bind(&exit); 1664514f5e3Sopenharmony_ci auto ret = *result; 1674514f5e3Sopenharmony_ci env->SubCfgExit(); 1684514f5e3Sopenharmony_ci return ret; 1694514f5e3Sopenharmony_ci} 1704514f5e3Sopenharmony_ci 1714514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StorePrivatePropertyByName(GateRef glue, 1724514f5e3Sopenharmony_ci GateRef receiver, 1734514f5e3Sopenharmony_ci GateRef key, 1744514f5e3Sopenharmony_ci GateRef value, 1754514f5e3Sopenharmony_ci GateRef profileTypeInfo, 1764514f5e3Sopenharmony_ci GateRef slotId, 1774514f5e3Sopenharmony_ci ProfileOperation callback) 1784514f5e3Sopenharmony_ci{ 1794514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1804514f5e3Sopenharmony_ci Label entry(env); 1814514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 1824514f5e3Sopenharmony_ci Label exit(env); 1834514f5e3Sopenharmony_ci Label tryFastPath(env); 1844514f5e3Sopenharmony_ci Label slowPath(env); 1854514f5e3Sopenharmony_ci Label tryPreDump(env); 1864514f5e3Sopenharmony_ci 1874514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 1884514f5e3Sopenharmony_ci ICStubBuilder builder(this); 1894514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId, callback); 1904514f5e3Sopenharmony_ci builder.StoreICByName(&result, &tryFastPath, &tryPreDump, &exit); 1914514f5e3Sopenharmony_ci Bind(&tryFastPath); 1924514f5e3Sopenharmony_ci { 1934514f5e3Sopenharmony_ci result = SetPropertyByName(glue, receiver, key, value, false, True(), callback); 1944514f5e3Sopenharmony_ci Branch(TaggedIsHole(*result), &slowPath, &exit); 1954514f5e3Sopenharmony_ci } 1964514f5e3Sopenharmony_ci Bind(&tryPreDump); 1974514f5e3Sopenharmony_ci { 1984514f5e3Sopenharmony_ci callback.TryPreDump(); 1994514f5e3Sopenharmony_ci Jump(&slowPath); 2004514f5e3Sopenharmony_ci } 2014514f5e3Sopenharmony_ci Bind(&slowPath); 2024514f5e3Sopenharmony_ci { 2034514f5e3Sopenharmony_ci result = CallRuntime( 2044514f5e3Sopenharmony_ci glue, RTSTUB_ID(StoreICByName), {profileTypeInfo, receiver, key, value, IntToTaggedInt(slotId)}); 2054514f5e3Sopenharmony_ci Jump(&exit); 2064514f5e3Sopenharmony_ci } 2074514f5e3Sopenharmony_ci 2084514f5e3Sopenharmony_ci Bind(&exit); 2094514f5e3Sopenharmony_ci auto ret = *result; 2104514f5e3Sopenharmony_ci env->SubCfgExit(); 2114514f5e3Sopenharmony_ci return ret; 2124514f5e3Sopenharmony_ci} 2134514f5e3Sopenharmony_ci 2144514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::ResolvePropKey(GateRef glue, GateRef prop, const StringIdInfo &info) 2154514f5e3Sopenharmony_ci{ 2164514f5e3Sopenharmony_ci if (jsFunc_ != Circuit::NullGate()) { 2174514f5e3Sopenharmony_ci GateRef constpool = GetConstPoolFromFunction(jsFunc_); 2184514f5e3Sopenharmony_ci return GetStringFromConstPool(glue, constpool, ChangeIntPtrToInt32(prop)); 2194514f5e3Sopenharmony_ci } 2204514f5e3Sopenharmony_ci if (!info.IsValid()) { 2214514f5e3Sopenharmony_ci return prop; 2224514f5e3Sopenharmony_ci } 2234514f5e3Sopenharmony_ci ASSERT(info.IsValid()); 2244514f5e3Sopenharmony_ci InterpreterToolsStubBuilder builder(GetCallSignature(), GetEnvironment()); 2254514f5e3Sopenharmony_ci GateRef stringId = builder.GetStringId(info); 2264514f5e3Sopenharmony_ci return GetStringFromConstPool(glue, info.GetConstantPool(), stringId); 2274514f5e3Sopenharmony_ci} 2284514f5e3Sopenharmony_ci 2294514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::LoadObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo, 2304514f5e3Sopenharmony_ci GateRef slotId, ProfileOperation callback) 2314514f5e3Sopenharmony_ci{ 2324514f5e3Sopenharmony_ci auto env = GetEnvironment(); 2334514f5e3Sopenharmony_ci Label entry(env); 2344514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 2354514f5e3Sopenharmony_ci Label exit(env); 2364514f5e3Sopenharmony_ci Label tryFastPath(env); 2374514f5e3Sopenharmony_ci Label slowPath(env); 2384514f5e3Sopenharmony_ci Label tryPreDump(env); 2394514f5e3Sopenharmony_ci 2404514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 2414514f5e3Sopenharmony_ci GateRef value = 0; 2424514f5e3Sopenharmony_ci ICStubBuilder builder(this); 2434514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId, key); 2444514f5e3Sopenharmony_ci builder.LoadICByValue(&result, &tryFastPath, &tryPreDump, &exit, callback); 2454514f5e3Sopenharmony_ci Bind(&tryFastPath); 2464514f5e3Sopenharmony_ci { 2474514f5e3Sopenharmony_ci result = GetPropertyByValue(glue, receiver, key, callback); 2484514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 2494514f5e3Sopenharmony_ci } 2504514f5e3Sopenharmony_ci Bind(&tryPreDump); 2514514f5e3Sopenharmony_ci { 2524514f5e3Sopenharmony_ci callback.TryPreDump(); 2534514f5e3Sopenharmony_ci Jump(&slowPath); 2544514f5e3Sopenharmony_ci } 2554514f5e3Sopenharmony_ci Bind(&slowPath); 2564514f5e3Sopenharmony_ci { 2574514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(LoadICByValue), {profileTypeInfo, receiver, key, IntToTaggedInt(slotId)}); 2584514f5e3Sopenharmony_ci Jump(&exit); 2594514f5e3Sopenharmony_ci } 2604514f5e3Sopenharmony_ci Bind(&exit); 2614514f5e3Sopenharmony_ci auto ret = *result; 2624514f5e3Sopenharmony_ci env->SubCfgExit(); 2634514f5e3Sopenharmony_ci return ret; 2644514f5e3Sopenharmony_ci} 2654514f5e3Sopenharmony_ci 2664514f5e3Sopenharmony_ci// Used for deprecated bytecodes which will not support ic 2674514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::DeprecatedLoadObjByValue(GateRef glue, GateRef receiver, GateRef key) 2684514f5e3Sopenharmony_ci{ 2694514f5e3Sopenharmony_ci auto env = GetEnvironment(); 2704514f5e3Sopenharmony_ci Label entry(env); 2714514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 2724514f5e3Sopenharmony_ci Label exit(env); 2734514f5e3Sopenharmony_ci Label fastPath(env); 2744514f5e3Sopenharmony_ci Label slowPath(env); 2754514f5e3Sopenharmony_ci 2764514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 2774514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath); 2784514f5e3Sopenharmony_ci Bind(&fastPath); 2794514f5e3Sopenharmony_ci { 2804514f5e3Sopenharmony_ci result = GetPropertyByValue(glue, receiver, key, ProfileOperation()); 2814514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 2824514f5e3Sopenharmony_ci } 2834514f5e3Sopenharmony_ci Bind(&slowPath); 2844514f5e3Sopenharmony_ci { 2854514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(LoadICByValue), 2864514f5e3Sopenharmony_ci { Undefined(), receiver, key, IntToTaggedInt(Int32(0xFF)) }); // 0xFF: invalied slot id 2874514f5e3Sopenharmony_ci Jump(&exit); 2884514f5e3Sopenharmony_ci } 2894514f5e3Sopenharmony_ci Bind(&exit); 2904514f5e3Sopenharmony_ci auto ret = *result; 2914514f5e3Sopenharmony_ci env->SubCfgExit(); 2924514f5e3Sopenharmony_ci return ret; 2934514f5e3Sopenharmony_ci} 2944514f5e3Sopenharmony_ci 2954514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StoreObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, 2964514f5e3Sopenharmony_ci GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback) 2974514f5e3Sopenharmony_ci{ 2984514f5e3Sopenharmony_ci auto env = GetEnvironment(); 2994514f5e3Sopenharmony_ci Label entry(env); 3004514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 3014514f5e3Sopenharmony_ci Label exit(env); 3024514f5e3Sopenharmony_ci Label tryFastPath(env); 3034514f5e3Sopenharmony_ci Label slowPath(env); 3044514f5e3Sopenharmony_ci Label tryPreDump(env); 3054514f5e3Sopenharmony_ci 3064514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 3074514f5e3Sopenharmony_ci ICStubBuilder builder(this); 3084514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId, key, callback); 3094514f5e3Sopenharmony_ci builder.StoreICByValue(&result, &tryFastPath, &tryPreDump, &exit); 3104514f5e3Sopenharmony_ci Bind(&tryFastPath); 3114514f5e3Sopenharmony_ci { 3124514f5e3Sopenharmony_ci result = SetPropertyByValue(glue, receiver, key, value, false, callback); 3134514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 3144514f5e3Sopenharmony_ci } 3154514f5e3Sopenharmony_ci Bind(&tryPreDump); 3164514f5e3Sopenharmony_ci { 3174514f5e3Sopenharmony_ci callback.TryPreDump(); 3184514f5e3Sopenharmony_ci Jump(&slowPath); 3194514f5e3Sopenharmony_ci } 3204514f5e3Sopenharmony_ci Bind(&slowPath); 3214514f5e3Sopenharmony_ci { 3224514f5e3Sopenharmony_ci result = CallRuntime( 3234514f5e3Sopenharmony_ci glue, RTSTUB_ID(StoreICByValue), {profileTypeInfo, receiver, key, value, IntToTaggedInt(slotId)}); 3244514f5e3Sopenharmony_ci Jump(&exit); 3254514f5e3Sopenharmony_ci } 3264514f5e3Sopenharmony_ci Bind(&exit); 3274514f5e3Sopenharmony_ci auto ret = *result; 3284514f5e3Sopenharmony_ci env->SubCfgExit(); 3294514f5e3Sopenharmony_ci return ret; 3304514f5e3Sopenharmony_ci} 3314514f5e3Sopenharmony_ci 3324514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StoreOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value, 3334514f5e3Sopenharmony_ci GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback) 3344514f5e3Sopenharmony_ci{ 3354514f5e3Sopenharmony_ci auto env = GetEnvironment(); 3364514f5e3Sopenharmony_ci Label entry(env); 3374514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 3384514f5e3Sopenharmony_ci Label exit(env); 3394514f5e3Sopenharmony_ci Label tryFastPath(env); 3404514f5e3Sopenharmony_ci Label slowPath(env); 3414514f5e3Sopenharmony_ci Label tryPreDump(env); 3424514f5e3Sopenharmony_ci 3434514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 3444514f5e3Sopenharmony_ci ICStubBuilder builder(this); 3454514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId, IntToTaggedPtr(index), callback); 3464514f5e3Sopenharmony_ci builder.StoreICByValue(&result, &tryFastPath, &tryPreDump, &exit); 3474514f5e3Sopenharmony_ci Bind(&tryFastPath); 3484514f5e3Sopenharmony_ci { 3494514f5e3Sopenharmony_ci Label isHeapObject(env); 3504514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath); 3514514f5e3Sopenharmony_ci Bind(&isHeapObject); 3524514f5e3Sopenharmony_ci Label notClassConstructor(env); 3534514f5e3Sopenharmony_ci BRANCH(IsClassConstructor(receiver), &slowPath, ¬ClassConstructor); 3544514f5e3Sopenharmony_ci Bind(¬ClassConstructor); 3554514f5e3Sopenharmony_ci Label notClassPrototype(env); 3564514f5e3Sopenharmony_ci BRANCH(IsClassPrototype(receiver), &slowPath, ¬ClassPrototype); 3574514f5e3Sopenharmony_ci Bind(¬ClassPrototype); 3584514f5e3Sopenharmony_ci result = SetPropertyByIndex(glue, receiver, index, value, true); 3594514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 3604514f5e3Sopenharmony_ci } 3614514f5e3Sopenharmony_ci Bind(&tryPreDump); 3624514f5e3Sopenharmony_ci { 3634514f5e3Sopenharmony_ci callback.TryPreDump(); 3644514f5e3Sopenharmony_ci Jump(&slowPath); 3654514f5e3Sopenharmony_ci } 3664514f5e3Sopenharmony_ci Bind(&slowPath); 3674514f5e3Sopenharmony_ci { 3684514f5e3Sopenharmony_ci result = CallRuntime(glue, 3694514f5e3Sopenharmony_ci RTSTUB_ID(StoreOwnICByValue), 3704514f5e3Sopenharmony_ci {profileTypeInfo, receiver, IntToTaggedInt(index), value, IntToTaggedInt(slotId)}); 3714514f5e3Sopenharmony_ci Jump(&exit); 3724514f5e3Sopenharmony_ci } 3734514f5e3Sopenharmony_ci Bind(&exit); 3744514f5e3Sopenharmony_ci auto ret = *result; 3754514f5e3Sopenharmony_ci env->SubCfgExit(); 3764514f5e3Sopenharmony_ci return ret; 3774514f5e3Sopenharmony_ci} 3784514f5e3Sopenharmony_ci 3794514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::TryLoadGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info, 3804514f5e3Sopenharmony_ci GateRef profileTypeInfo, GateRef slotId, 3814514f5e3Sopenharmony_ci ProfileOperation callback) 3824514f5e3Sopenharmony_ci{ 3834514f5e3Sopenharmony_ci auto env = GetEnvironment(); 3844514f5e3Sopenharmony_ci Label entry(env); 3854514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 3864514f5e3Sopenharmony_ci Label exit(env); 3874514f5e3Sopenharmony_ci Label tryFastPath(env); 3884514f5e3Sopenharmony_ci Label slowPath(env); 3894514f5e3Sopenharmony_ci 3904514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 3914514f5e3Sopenharmony_ci GateRef receiver = 0; 3924514f5e3Sopenharmony_ci GateRef value = 0; 3934514f5e3Sopenharmony_ci ICStubBuilder builder(this); 3944514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId); 3954514f5e3Sopenharmony_ci builder.TryLoadGlobalICByName(&result, &tryFastPath, &slowPath, &exit); 3964514f5e3Sopenharmony_ci Bind(&tryFastPath); 3974514f5e3Sopenharmony_ci { 3984514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 3994514f5e3Sopenharmony_ci GateRef record = LdGlobalRecord(glue, propKey); 4004514f5e3Sopenharmony_ci Label foundInRecord(env); 4014514f5e3Sopenharmony_ci Label notFoundInRecord(env); 4024514f5e3Sopenharmony_ci BRANCH(TaggedIsUndefined(record), ¬FoundInRecord, &foundInRecord); 4034514f5e3Sopenharmony_ci Bind(&foundInRecord); 4044514f5e3Sopenharmony_ci { 4054514f5e3Sopenharmony_ci result = Load(VariableType::JS_ANY(), record, IntPtr(PropertyBox::VALUE_OFFSET)); 4064514f5e3Sopenharmony_ci Jump(&exit); 4074514f5e3Sopenharmony_ci } 4084514f5e3Sopenharmony_ci Bind(¬FoundInRecord); 4094514f5e3Sopenharmony_ci { 4104514f5e3Sopenharmony_ci GateRef globalObject = GetGlobalObject(glue); 4114514f5e3Sopenharmony_ci result = GetGlobalOwnProperty(glue, globalObject, propKey, callback); 4124514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 4134514f5e3Sopenharmony_ci } 4144514f5e3Sopenharmony_ci } 4154514f5e3Sopenharmony_ci Bind(&slowPath); 4164514f5e3Sopenharmony_ci { 4174514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 4184514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(TryLdGlobalICByName), 4194514f5e3Sopenharmony_ci { profileTypeInfo, propKey, IntToTaggedInt(slotId) }); 4204514f5e3Sopenharmony_ci Jump(&exit); 4214514f5e3Sopenharmony_ci } 4224514f5e3Sopenharmony_ci 4234514f5e3Sopenharmony_ci Bind(&exit); 4244514f5e3Sopenharmony_ci auto ret = *result; 4254514f5e3Sopenharmony_ci env->SubCfgExit(); 4264514f5e3Sopenharmony_ci return ret; 4274514f5e3Sopenharmony_ci} 4284514f5e3Sopenharmony_ci 4294514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::TryStoreGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info, 4304514f5e3Sopenharmony_ci GateRef value, GateRef profileTypeInfo, GateRef slotId, 4314514f5e3Sopenharmony_ci ProfileOperation callback) 4324514f5e3Sopenharmony_ci{ 4334514f5e3Sopenharmony_ci auto env = GetEnvironment(); 4344514f5e3Sopenharmony_ci Label entry(env); 4354514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 4364514f5e3Sopenharmony_ci Label exit(env); 4374514f5e3Sopenharmony_ci Label tryFastPath(env); 4384514f5e3Sopenharmony_ci Label slowPath(env); 4394514f5e3Sopenharmony_ci 4404514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Undefined()); 4414514f5e3Sopenharmony_ci GateRef receiver = 0; 4424514f5e3Sopenharmony_ci ICStubBuilder builder(this); 4434514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId); 4444514f5e3Sopenharmony_ci builder.TryStoreGlobalICByName(&result, &tryFastPath, &slowPath, &exit); 4454514f5e3Sopenharmony_ci Bind(&tryFastPath); 4464514f5e3Sopenharmony_ci { 4474514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 4484514f5e3Sopenharmony_ci GateRef record = LdGlobalRecord(glue, propKey); 4494514f5e3Sopenharmony_ci Label foundInRecord(env); 4504514f5e3Sopenharmony_ci Label notFoundInRecord(env); 4514514f5e3Sopenharmony_ci BRANCH(TaggedIsUndefined(record), ¬FoundInRecord, &foundInRecord); 4524514f5e3Sopenharmony_ci Bind(&foundInRecord); 4534514f5e3Sopenharmony_ci { 4544514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(TryUpdateGlobalRecord), { propKey, value }); 4554514f5e3Sopenharmony_ci Jump(&exit); 4564514f5e3Sopenharmony_ci } 4574514f5e3Sopenharmony_ci Bind(¬FoundInRecord); 4584514f5e3Sopenharmony_ci { 4594514f5e3Sopenharmony_ci GateRef globalObject = GetGlobalObject(glue); 4604514f5e3Sopenharmony_ci result = GetGlobalOwnProperty(glue, globalObject, propKey, callback); 4614514f5e3Sopenharmony_ci Label isFoundInGlobal(env); 4624514f5e3Sopenharmony_ci Label notFoundInGlobal(env); 4634514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), ¬FoundInGlobal, &isFoundInGlobal); 4644514f5e3Sopenharmony_ci Bind(&isFoundInGlobal); 4654514f5e3Sopenharmony_ci { 4664514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StGlobalVar), { propKey, value }); 4674514f5e3Sopenharmony_ci Jump(&exit); 4684514f5e3Sopenharmony_ci } 4694514f5e3Sopenharmony_ci Bind(¬FoundInGlobal); 4704514f5e3Sopenharmony_ci { 4714514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(ThrowReferenceError), { propKey }); 4724514f5e3Sopenharmony_ci Jump(&exit); 4734514f5e3Sopenharmony_ci } 4744514f5e3Sopenharmony_ci } 4754514f5e3Sopenharmony_ci } 4764514f5e3Sopenharmony_ci Bind(&slowPath); 4774514f5e3Sopenharmony_ci { 4784514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 4794514f5e3Sopenharmony_ci GateRef globalObject = GetGlobalObject(glue); 4804514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StoreMiss), 4814514f5e3Sopenharmony_ci { profileTypeInfo, globalObject, propKey, value, IntToTaggedInt(slotId), 4824514f5e3Sopenharmony_ci IntToTaggedInt(Int32(static_cast<int>(ICKind::NamedGlobalTryStoreIC))) }); 4834514f5e3Sopenharmony_ci Jump(&exit); 4844514f5e3Sopenharmony_ci } 4854514f5e3Sopenharmony_ci 4864514f5e3Sopenharmony_ci Bind(&exit); 4874514f5e3Sopenharmony_ci auto ret = *result; 4884514f5e3Sopenharmony_ci env->SubCfgExit(); 4894514f5e3Sopenharmony_ci return ret; 4904514f5e3Sopenharmony_ci} 4914514f5e3Sopenharmony_ci 4924514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::LoadGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info, 4934514f5e3Sopenharmony_ci GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback) 4944514f5e3Sopenharmony_ci{ 4954514f5e3Sopenharmony_ci auto env = GetEnvironment(); 4964514f5e3Sopenharmony_ci Label entry(env); 4974514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 4984514f5e3Sopenharmony_ci Label exit(env); 4994514f5e3Sopenharmony_ci Label tryFastPath(env); 5004514f5e3Sopenharmony_ci Label slowPath(env); 5014514f5e3Sopenharmony_ci 5024514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 5034514f5e3Sopenharmony_ci GateRef receiver = 0; 5044514f5e3Sopenharmony_ci GateRef value = 0; 5054514f5e3Sopenharmony_ci ICStubBuilder builder(this); 5064514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId); 5074514f5e3Sopenharmony_ci builder.TryLoadGlobalICByName(&result, &tryFastPath, &slowPath, &exit); 5084514f5e3Sopenharmony_ci Bind(&tryFastPath); 5094514f5e3Sopenharmony_ci { 5104514f5e3Sopenharmony_ci GateRef globalObject = GetGlobalObject(glue); 5114514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 5124514f5e3Sopenharmony_ci result = GetGlobalOwnProperty(glue, globalObject, propKey, callback); 5134514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 5144514f5e3Sopenharmony_ci } 5154514f5e3Sopenharmony_ci Bind(&slowPath); 5164514f5e3Sopenharmony_ci { 5174514f5e3Sopenharmony_ci GateRef globalObject = GetGlobalObject(glue); 5184514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 5194514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(LdGlobalICVar), 5204514f5e3Sopenharmony_ci { globalObject, propKey, profileTypeInfo, IntToTaggedInt(slotId) }); 5214514f5e3Sopenharmony_ci Jump(&exit); 5224514f5e3Sopenharmony_ci } 5234514f5e3Sopenharmony_ci 5244514f5e3Sopenharmony_ci Bind(&exit); 5254514f5e3Sopenharmony_ci auto ret = *result; 5264514f5e3Sopenharmony_ci env->SubCfgExit(); 5274514f5e3Sopenharmony_ci return ret; 5284514f5e3Sopenharmony_ci} 5294514f5e3Sopenharmony_ci 5304514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StoreGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info, 5314514f5e3Sopenharmony_ci GateRef value, GateRef profileTypeInfo, GateRef slotId) 5324514f5e3Sopenharmony_ci{ 5334514f5e3Sopenharmony_ci auto env = GetEnvironment(); 5344514f5e3Sopenharmony_ci Label entry(env); 5354514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 5364514f5e3Sopenharmony_ci Label exit(env); 5374514f5e3Sopenharmony_ci Label tryFastPath(env); 5384514f5e3Sopenharmony_ci Label slowPath(env); 5394514f5e3Sopenharmony_ci 5404514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Undefined()); 5414514f5e3Sopenharmony_ci GateRef receiver = 0; 5424514f5e3Sopenharmony_ci ICStubBuilder builder(this); 5434514f5e3Sopenharmony_ci builder.SetParameters(glue, receiver, profileTypeInfo, value, slotId); 5444514f5e3Sopenharmony_ci builder.TryStoreGlobalICByName(&result, &tryFastPath, &slowPath, &exit); 5454514f5e3Sopenharmony_ci Bind(&tryFastPath); 5464514f5e3Sopenharmony_ci { 5474514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 5484514f5e3Sopenharmony_ci // IR later 5494514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StGlobalVar), { propKey, value }); 5504514f5e3Sopenharmony_ci Jump(&exit); 5514514f5e3Sopenharmony_ci } 5524514f5e3Sopenharmony_ci Bind(&slowPath); 5534514f5e3Sopenharmony_ci { 5544514f5e3Sopenharmony_ci GateRef propKey = ResolvePropKey(glue, prop, info); 5554514f5e3Sopenharmony_ci GateRef globalObject = GetGlobalObject(glue); 5564514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StoreMiss), 5574514f5e3Sopenharmony_ci { profileTypeInfo, globalObject, propKey, value, IntToTaggedInt(slotId), 5584514f5e3Sopenharmony_ci IntToTaggedInt(Int32(static_cast<int>(ICKind::NamedGlobalStoreIC))) }); 5594514f5e3Sopenharmony_ci Jump(&exit); 5604514f5e3Sopenharmony_ci } 5614514f5e3Sopenharmony_ci 5624514f5e3Sopenharmony_ci Bind(&exit); 5634514f5e3Sopenharmony_ci auto ret = *result; 5644514f5e3Sopenharmony_ci env->SubCfgExit(); 5654514f5e3Sopenharmony_ci return ret; 5664514f5e3Sopenharmony_ci} 5674514f5e3Sopenharmony_ci 5684514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value) 5694514f5e3Sopenharmony_ci{ 5704514f5e3Sopenharmony_ci auto env = GetEnvironment(); 5714514f5e3Sopenharmony_ci Label entry(env); 5724514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 5734514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 5744514f5e3Sopenharmony_ci Label isHeapObject(env); 5754514f5e3Sopenharmony_ci Label slowPath(env); 5764514f5e3Sopenharmony_ci Label exit(env); 5774514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath); 5784514f5e3Sopenharmony_ci Bind(&isHeapObject); 5794514f5e3Sopenharmony_ci Label notClassConstructor(env); 5804514f5e3Sopenharmony_ci BRANCH(IsClassConstructor(receiver), &slowPath, ¬ClassConstructor); 5814514f5e3Sopenharmony_ci Bind(¬ClassConstructor); 5824514f5e3Sopenharmony_ci Label notClassPrototype(env); 5834514f5e3Sopenharmony_ci BRANCH(IsClassPrototype(receiver), &slowPath, ¬ClassPrototype); 5844514f5e3Sopenharmony_ci Bind(¬ClassPrototype); 5854514f5e3Sopenharmony_ci { 5864514f5e3Sopenharmony_ci result = SetPropertyByIndex(glue, receiver, TruncInt64ToInt32(index), value, true); 5874514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 5884514f5e3Sopenharmony_ci } 5894514f5e3Sopenharmony_ci Bind(&slowPath); 5904514f5e3Sopenharmony_ci { 5914514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StOwnByIndex), {receiver, IntToTaggedInt(index), value }); 5924514f5e3Sopenharmony_ci Jump(&exit); 5934514f5e3Sopenharmony_ci } 5944514f5e3Sopenharmony_ci Bind(&exit); 5954514f5e3Sopenharmony_ci auto ret = *result; 5964514f5e3Sopenharmony_ci env->SubCfgExit(); 5974514f5e3Sopenharmony_ci return ret; 5984514f5e3Sopenharmony_ci} 5994514f5e3Sopenharmony_ci 6004514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StOwnByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value) 6014514f5e3Sopenharmony_ci{ 6024514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6034514f5e3Sopenharmony_ci Label entry(env); 6044514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6054514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 6064514f5e3Sopenharmony_ci Label isHeapObject(env); 6074514f5e3Sopenharmony_ci Label slowPath(env); 6084514f5e3Sopenharmony_ci Label exit(env); 6094514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath); 6104514f5e3Sopenharmony_ci Bind(&isHeapObject); 6114514f5e3Sopenharmony_ci Label notClassConstructor(env); 6124514f5e3Sopenharmony_ci BRANCH(IsClassConstructor(receiver), &slowPath, ¬ClassConstructor); 6134514f5e3Sopenharmony_ci Bind(¬ClassConstructor); 6144514f5e3Sopenharmony_ci Label notClassPrototype(env); 6154514f5e3Sopenharmony_ci BRANCH(IsClassPrototype(receiver), &slowPath, ¬ClassPrototype); 6164514f5e3Sopenharmony_ci Bind(¬ClassPrototype); 6174514f5e3Sopenharmony_ci { 6184514f5e3Sopenharmony_ci result = SetPropertyByValue(glue, receiver, key, value, true); 6194514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 6204514f5e3Sopenharmony_ci } 6214514f5e3Sopenharmony_ci Bind(&slowPath); 6224514f5e3Sopenharmony_ci { 6234514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StOwnByValue), { receiver, key, value }); 6244514f5e3Sopenharmony_ci Jump(&exit); 6254514f5e3Sopenharmony_ci } 6264514f5e3Sopenharmony_ci Bind(&exit); 6274514f5e3Sopenharmony_ci auto ret = *result; 6284514f5e3Sopenharmony_ci env->SubCfgExit(); 6294514f5e3Sopenharmony_ci return ret; 6304514f5e3Sopenharmony_ci} 6314514f5e3Sopenharmony_ci 6324514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StOwnByName(GateRef glue, GateRef receiver, GateRef key, GateRef value) 6334514f5e3Sopenharmony_ci{ 6344514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6354514f5e3Sopenharmony_ci Label entry(env); 6364514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6374514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 6384514f5e3Sopenharmony_ci Label isJSObject(env); 6394514f5e3Sopenharmony_ci Label slowPath(env); 6404514f5e3Sopenharmony_ci Label exit(env); 6414514f5e3Sopenharmony_ci BRANCH(IsJSObject(receiver), &isJSObject, &slowPath); 6424514f5e3Sopenharmony_ci Bind(&isJSObject); 6434514f5e3Sopenharmony_ci Label notClassConstructor(env); 6444514f5e3Sopenharmony_ci BRANCH(IsClassConstructor(receiver), &slowPath, ¬ClassConstructor); 6454514f5e3Sopenharmony_ci Bind(¬ClassConstructor); 6464514f5e3Sopenharmony_ci Label notClassPrototype(env); 6474514f5e3Sopenharmony_ci BRANCH(IsClassPrototype(receiver), &slowPath, ¬ClassPrototype); 6484514f5e3Sopenharmony_ci Bind(¬ClassPrototype); 6494514f5e3Sopenharmony_ci { 6504514f5e3Sopenharmony_ci result = SetPropertyByName(glue, receiver, key, value, true, True()); 6514514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 6524514f5e3Sopenharmony_ci } 6534514f5e3Sopenharmony_ci Bind(&slowPath); 6544514f5e3Sopenharmony_ci { 6554514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StOwnByName), { receiver, key, value }); 6564514f5e3Sopenharmony_ci Jump(&exit); 6574514f5e3Sopenharmony_ci } 6584514f5e3Sopenharmony_ci Bind(&exit); 6594514f5e3Sopenharmony_ci auto ret = *result; 6604514f5e3Sopenharmony_ci env->SubCfgExit(); 6614514f5e3Sopenharmony_ci return ret; 6624514f5e3Sopenharmony_ci} 6634514f5e3Sopenharmony_ci 6644514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StOwnByValueWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value) 6654514f5e3Sopenharmony_ci{ 6664514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6674514f5e3Sopenharmony_ci Label entry(env); 6684514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6694514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 6704514f5e3Sopenharmony_ci Label isHeapObject(env); 6714514f5e3Sopenharmony_ci Label slowPath(env); 6724514f5e3Sopenharmony_ci Label notClassConstructor(env); 6734514f5e3Sopenharmony_ci Label notClassPrototype(env); 6744514f5e3Sopenharmony_ci Label notHole(env); 6754514f5e3Sopenharmony_ci Label exit(env); 6764514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath); 6774514f5e3Sopenharmony_ci Bind(&isHeapObject); 6784514f5e3Sopenharmony_ci { 6794514f5e3Sopenharmony_ci BRANCH(IsClassConstructor(receiver), &slowPath, ¬ClassConstructor); 6804514f5e3Sopenharmony_ci Bind(¬ClassConstructor); 6814514f5e3Sopenharmony_ci { 6824514f5e3Sopenharmony_ci BRANCH(IsClassPrototype(receiver), &slowPath, ¬ClassPrototype); 6834514f5e3Sopenharmony_ci Bind(¬ClassPrototype); 6844514f5e3Sopenharmony_ci { 6854514f5e3Sopenharmony_ci result = SetPropertyByValue(glue, receiver, key, value, true, ProfileOperation(), true); 6864514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, ¬Hole); 6874514f5e3Sopenharmony_ci Bind(¬Hole); 6884514f5e3Sopenharmony_ci { 6894514f5e3Sopenharmony_ci Label notexception(env); 6904514f5e3Sopenharmony_ci BRANCH(TaggedIsException(*result), &exit, ¬exception); 6914514f5e3Sopenharmony_ci Bind(¬exception); 6924514f5e3Sopenharmony_ci CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { value, key }); 6934514f5e3Sopenharmony_ci Jump(&exit); 6944514f5e3Sopenharmony_ci } 6954514f5e3Sopenharmony_ci } 6964514f5e3Sopenharmony_ci } 6974514f5e3Sopenharmony_ci } 6984514f5e3Sopenharmony_ci Bind(&slowPath); 6994514f5e3Sopenharmony_ci { 7004514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StOwnByValueWithNameSet), { receiver, key, value }); 7014514f5e3Sopenharmony_ci Jump(&exit); 7024514f5e3Sopenharmony_ci } 7034514f5e3Sopenharmony_ci Bind(&exit); 7044514f5e3Sopenharmony_ci auto ret = *result; 7054514f5e3Sopenharmony_ci env->SubCfgExit(); 7064514f5e3Sopenharmony_ci return ret; 7074514f5e3Sopenharmony_ci} 7084514f5e3Sopenharmony_ci 7094514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StOwnByNameWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value) 7104514f5e3Sopenharmony_ci{ 7114514f5e3Sopenharmony_ci auto env = GetEnvironment(); 7124514f5e3Sopenharmony_ci Label entry(env); 7134514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 7144514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 7154514f5e3Sopenharmony_ci Label isJSObject(env); 7164514f5e3Sopenharmony_ci Label notJSObject(env); 7174514f5e3Sopenharmony_ci Label notClassConstructor(env); 7184514f5e3Sopenharmony_ci Label notClassPrototype(env); 7194514f5e3Sopenharmony_ci Label notHole(env); 7204514f5e3Sopenharmony_ci Label exit(env); 7214514f5e3Sopenharmony_ci BRANCH(IsJSObject(receiver), &isJSObject, ¬JSObject); 7224514f5e3Sopenharmony_ci Bind(&isJSObject); 7234514f5e3Sopenharmony_ci { 7244514f5e3Sopenharmony_ci BRANCH(IsClassConstructor(receiver), ¬JSObject, ¬ClassConstructor); 7254514f5e3Sopenharmony_ci Bind(¬ClassConstructor); 7264514f5e3Sopenharmony_ci { 7274514f5e3Sopenharmony_ci BRANCH(IsClassPrototype(receiver), ¬JSObject, ¬ClassPrototype); 7284514f5e3Sopenharmony_ci Bind(¬ClassPrototype); 7294514f5e3Sopenharmony_ci { 7304514f5e3Sopenharmony_ci result = SetPropertyByName(glue, receiver, key, value, true, True(), ProfileOperation(), false, true); 7314514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), ¬JSObject, ¬Hole); 7324514f5e3Sopenharmony_ci Bind(¬Hole); 7334514f5e3Sopenharmony_ci { 7344514f5e3Sopenharmony_ci Label notException(env); 7354514f5e3Sopenharmony_ci BRANCH(TaggedIsException(*result), &exit, ¬Exception); 7364514f5e3Sopenharmony_ci Bind(¬Exception); 7374514f5e3Sopenharmony_ci CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), {value, key}); 7384514f5e3Sopenharmony_ci Jump(&exit); 7394514f5e3Sopenharmony_ci } 7404514f5e3Sopenharmony_ci } 7414514f5e3Sopenharmony_ci } 7424514f5e3Sopenharmony_ci } 7434514f5e3Sopenharmony_ci Bind(¬JSObject); 7444514f5e3Sopenharmony_ci { 7454514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StOwnByNameWithNameSet), { receiver, key, value }); 7464514f5e3Sopenharmony_ci Jump(&exit); 7474514f5e3Sopenharmony_ci } 7484514f5e3Sopenharmony_ci Bind(&exit); 7494514f5e3Sopenharmony_ci auto ret = *result; 7504514f5e3Sopenharmony_ci env->SubCfgExit(); 7514514f5e3Sopenharmony_ci return ret; 7524514f5e3Sopenharmony_ci} 7534514f5e3Sopenharmony_ci 7544514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::StObjByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value) 7554514f5e3Sopenharmony_ci{ 7564514f5e3Sopenharmony_ci auto env = GetEnvironment(); 7574514f5e3Sopenharmony_ci Label entry(env); 7584514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 7594514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 7604514f5e3Sopenharmony_ci Label exit(env); 7614514f5e3Sopenharmony_ci Label fastPath(env); 7624514f5e3Sopenharmony_ci Label slowPath(env); 7634514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath); 7644514f5e3Sopenharmony_ci Bind(&fastPath); 7654514f5e3Sopenharmony_ci { 7664514f5e3Sopenharmony_ci result = SetPropertyByIndex(glue, receiver, TruncInt64ToInt32(index), value, false); 7674514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 7684514f5e3Sopenharmony_ci } 7694514f5e3Sopenharmony_ci Bind(&slowPath); 7704514f5e3Sopenharmony_ci { 7714514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(StObjByIndex), {receiver, IntToTaggedInt(index), value}); 7724514f5e3Sopenharmony_ci Jump(&exit); 7734514f5e3Sopenharmony_ci } 7744514f5e3Sopenharmony_ci Bind(&exit); 7754514f5e3Sopenharmony_ci auto ret = *result; 7764514f5e3Sopenharmony_ci env->SubCfgExit(); 7774514f5e3Sopenharmony_ci return ret; 7784514f5e3Sopenharmony_ci} 7794514f5e3Sopenharmony_ci 7804514f5e3Sopenharmony_ciGateRef AccessObjectStubBuilder::LdObjByIndex(GateRef glue, GateRef receiver, GateRef index) 7814514f5e3Sopenharmony_ci{ 7824514f5e3Sopenharmony_ci auto env = GetEnvironment(); 7834514f5e3Sopenharmony_ci Label entry(env); 7844514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 7854514f5e3Sopenharmony_ci DEFVARIABLE(varAcc, VariableType::JS_ANY(), Hole()); 7864514f5e3Sopenharmony_ci Label fastPath(env); 7874514f5e3Sopenharmony_ci Label slowPath(env); 7884514f5e3Sopenharmony_ci Label exit(env); 7894514f5e3Sopenharmony_ci BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath); 7904514f5e3Sopenharmony_ci Bind(&fastPath); 7914514f5e3Sopenharmony_ci { 7924514f5e3Sopenharmony_ci varAcc = GetPropertyByIndex(glue, receiver, TruncInt64ToInt32(index), ProfileOperation()); 7934514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*varAcc), &slowPath, &exit); 7944514f5e3Sopenharmony_ci } 7954514f5e3Sopenharmony_ci Bind(&slowPath); 7964514f5e3Sopenharmony_ci { 7974514f5e3Sopenharmony_ci GateRef undefined = Undefined(); 7984514f5e3Sopenharmony_ci auto args = { receiver, IntToTaggedInt(index), TaggedFalse(), undefined }; 7994514f5e3Sopenharmony_ci varAcc = CallRuntime(glue, RTSTUB_ID(LdObjByIndex), args); 8004514f5e3Sopenharmony_ci Jump(&exit); 8014514f5e3Sopenharmony_ci } 8024514f5e3Sopenharmony_ci Bind(&exit); 8034514f5e3Sopenharmony_ci auto ret = *varAcc; 8044514f5e3Sopenharmony_ci env->SubCfgExit(); 8054514f5e3Sopenharmony_ci return ret; 8064514f5e3Sopenharmony_ci} 8074514f5e3Sopenharmony_ci} // namespace panda::ecmascript::kungfu 808