1 /* 2 * Copyright (c) 2025 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 #ifndef ECMASCRIPT_COMPILER_STUB_BUILDER_H 17 #define ECMASCRIPT_COMPILER_STUB_BUILDER_H 18 19 #include "ecmascript/base/config.h" 20 #include "ecmascript/compiler/call_signature.h" 21 #include "ecmascript/compiler/circuit_builder.h" 22 #include "ecmascript/compiler/lcr_gate_meta_data.h" 23 #include "ecmascript/compiler/profiler_operation.h" 24 #include "ecmascript/compiler/share_gate_meta_data.h" 25 #include "ecmascript/compiler/variable_type.h" 26 #include "ecmascript/ic/mega_ic_cache.h" 27 28 namespace panda::ecmascript::kungfu { 29 struct StringInfoGateRef; 30 using namespace panda::ecmascript; 31 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 32 #define DEFVARIABLE(varname, type, val) Variable varname(GetEnvironment(), type, NextVariableId(), val) 33 34 #define SUBENTRY(messageId, condition) \ 35 GateRef glueArg = PtrArgument(0); \ 36 auto env = GetEnvironment(); \ 37 Label subEntry(env); \ 38 env->SubCfgEntry(&subEntry); \ 39 Label nextLabel(env); \ 40 Assert(messageId, __LINE__, glueArg, condition, &nextLabel); \ 41 Bind(&nextLabel) 42 #define SUBENTRY_WITH_LINE(messageId, condition, line) \ 43 GateRef glueArg = PtrArgument(0); \ 44 auto env = GetEnvironment(); \ 45 Label subEntry(env); \ 46 env->SubCfgEntry(&subEntry); \ 47 Label nextLabel(env); \ 48 Assert(messageId, line, glueArg, condition, &nextLabel); \ 49 Bind(&nextLabel) 50 #define SUBENTRY_WITH_GLUE(messageId, condition, glueArg) \ 51 auto env = GetEnvironment(); \ 52 Label subEntry(env); \ 53 env->SubCfgEntry(&subEntry); \ 54 Label nextLabel(env); \ 55 Assert(messageId, __LINE__, glueArg, condition, &nextLabel); \ 56 Bind(&nextLabel) 57 58 #ifndef NDEBUG 59 #define ASM_ASSERT(messageId, condition) \ 60 if (!GetEnvironment()->GetCircuit()->IsOptimizedOrFastJit() && \ 61 !GetEnvironment()->IsBaselineBuiltin()) { \ 62 SUBENTRY(messageId, condition); \ 63 EXITENTRY(); \ 64 } 65 #define ASM_ASSERT_WITH_LINE(messageId, condition, line) \ 66 if (!GetEnvironment()->GetCircuit()->IsOptimizedOrFastJit() && !GetEnvironment()->IsBaselineBuiltin()) { \ 67 SUBENTRY_WITH_LINE(messageId, condition, line); \ 68 EXITENTRY(); \ 69 } 70 #define ASM_ASSERT_WITH_GLUE(messageId, condition, glue) \ 71 SUBENTRY_WITH_GLUE(messageId, condition, glue) 72 #elif defined(ENABLE_ASM_ASSERT) 73 #define ASM_ASSERT(messageId, condition) \ 74 if (!GetEnvironment()->GetCircuit()->IsOptimizedOrFastJit() && \ 75 !GetEnvironment()->IsBaselineBuiltin()) { \ 76 SUBENTRY(messageId, condition); \ 77 EXITENTRY(); \ 78 } 79 #define ASM_ASSERT_WITH_GLUE(messageId, condition, glue) \ 80 SUBENTRY_WITH_GLUE(messageId, condition, glue) 81 #else 82 #define ASM_ASSERT(messageId, ...) ((void)0) 83 #define ASM_ASSERT_WITH_GLUE(messageId, ...) ((void)0) 84 #define ASM_ASSERT_WITH_LINE(messageId, ...) ((void)0) 85 #endif 86 87 #ifndef NDEBUG 88 #define EXITENTRY() \ 89 GetEnvironment()->SubCfgExit() 90 #elif defined(ENABLE_ASM_ASSERT) 91 #define EXITENTRY() \ 92 GetEnvironment()->SubCfgExit() 93 #else 94 #define EXITENTRY() ((void)0) 95 #endif 96 97 class StubBuilder { 98 public: StubBuilder(StubBuilder * parent)99 explicit StubBuilder(StubBuilder *parent) 100 : callSignature_(parent->GetCallSignature()), env_(parent->GetEnvironment()) {} StubBuilder(StubBuilder * parent,GateRef globalEnv)101 StubBuilder(StubBuilder *parent, GateRef globalEnv) 102 : callSignature_(parent->GetCallSignature()), env_(parent->GetEnvironment()), globalEnv_(globalEnv) {} StubBuilder(CallSignature * callSignature,Environment * env)103 StubBuilder(CallSignature *callSignature, Environment *env) 104 : callSignature_(callSignature), env_(env) {} StubBuilder(CallSignature * callSignature,Environment * env,GateRef globalEnv)105 StubBuilder(CallSignature *callSignature, Environment *env, GateRef globalEnv) 106 : callSignature_(callSignature), env_(env), globalEnv_(globalEnv) {} StubBuilder(Environment * env)107 explicit StubBuilder(Environment *env) 108 : env_(env) {} StubBuilder(Environment * env,GateRef globalEnv)109 StubBuilder(Environment *env, GateRef globalEnv) 110 : env_(env), globalEnv_(globalEnv) {} 111 virtual ~StubBuilder() = default; 112 NO_MOVE_SEMANTIC(StubBuilder); 113 NO_COPY_SEMANTIC(StubBuilder); 114 virtual void GenerateCircuit() = 0; GetEnvironment()115 Environment *GetEnvironment() const 116 { 117 return env_; 118 } GetCallSignature()119 CallSignature *GetCallSignature() const 120 { 121 return callSignature_; 122 } GetCurrentGlobalEnv()123 inline GateRef GetCurrentGlobalEnv() 124 { 125 if (globalEnv_ == Gate::InvalidGateRef) { 126 LOG_FULL(FATAL) << "globalEnv_ is InvalidGateRef"; 127 UNREACHABLE(); 128 } 129 return globalEnv_; 130 } SetCurrentGlobalEnv(GateRef globalEnv)131 inline void SetCurrentGlobalEnv(GateRef globalEnv) 132 { 133 globalEnv_ = globalEnv; 134 } 135 GateRef ReadSp(); 136 GateRef CheckStackOverflow(GateRef glue); 137 int NextVariableId(); 138 // constant 139 GateRef Int8(int8_t value); 140 GateRef Int16(int16_t value); 141 GateRef Int32(int32_t value); 142 GateRef Int64(int64_t value); 143 GateRef TaggedInt(int32_t value); 144 GateRef StringPtr(std::string_view str); 145 GateRef IntPtr(int64_t value); 146 GateRef IntPtrSize(); 147 GateRef RelocatableData(uint64_t value); 148 GateRef True(); 149 GateRef False(); 150 GateRef Boolean(bool value); 151 GateRef Double(double value); 152 GateRef Undefined(); 153 GateRef Hole(); 154 GateRef SpecialHole(); 155 GateRef Null(); 156 GateRef NullPtr(); 157 GateRef Exception(); 158 // parameter 159 GateRef Argument(size_t index); 160 GateRef Int1Argument(size_t index); 161 GateRef Int32Argument(size_t index); 162 GateRef Int64Argument(size_t index); 163 GateRef TaggedArgument(size_t index); 164 GateRef TaggedPointerArgument(size_t index); 165 GateRef PtrArgument(size_t index); 166 GateRef Float32Argument(size_t index); 167 GateRef Float64Argument(size_t index); 168 GateRef Alloca(int size); 169 // control flow 170 GateRef Return(GateRef value); 171 GateRef Return(); 172 void Bind(Label *label); 173 void Jump(Label *label); 174 void Branch(GateRef condition, Label *trueLabel, Label *falseLabel, 175 uint32_t trueWeight = BranchWeight::ONE_WEIGHT, uint32_t falseWeight = BranchWeight::ONE_WEIGHT, 176 const char *comment = nullptr); 177 178 void Switch(GateRef index, Label *defaultLabel, 179 const int64_t *keysValue, Label *keysLabel, int numberOfKeys); 180 void Switch(GateRef index, Label *defaultLabel, 181 const int64_t *keysValue, Label * const *keysLabel, int numberOfKeys); 182 void LoopBegin(Label *loopHead); 183 void LoopEnd(Label *loopHead); 184 void LoopEndWithCheckSafePoint(Label *loopHead, Environment *env, GateRef glue); 185 GateRef CheckSuspend(GateRef glue); 186 GateRef CheckSuspendForCMCGC(GateRef glue); 187 // call operation 188 GateRef CallRuntime(GateRef glue, int index, const std::vector<GateRef>& args); 189 GateRef CallRuntime(GateRef glue, int index, GateRef argc, GateRef argv); 190 GateRef CallRuntimeWithGlobalEnv(GateRef glue, GateRef globalEnv, int index, const std::vector<GateRef>& args); 191 GateRef CallRuntimeWithGlobalEnv(GateRef glue, GateRef globalEnv, int index, GateRef argc, GateRef argv); 192 GateRef CallRuntimeWithCurrentEnv(GateRef glue, GateRef currentEnv, int index, const std::vector<GateRef>& args); 193 194 GateRef CallNGCRuntime(GateRef glue, int index, 195 const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate()); 196 GateRef FastCallOptimized(GateRef glue, GateRef code, 197 const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate()); 198 GateRef CallOptimized(GateRef glue, GateRef code, 199 const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate()); 200 GateRef GetAotCodeAddr(GateRef jsFunc); 201 GateRef CallStub(GateRef glue, int index, const std::initializer_list<GateRef>& args); 202 GateRef CallCommonStub(GateRef glue, int index, const std::initializer_list<GateRef>& args, 203 GateRef hir = Circuit::NullGate()); 204 GateRef CallBuiltinRuntime(GateRef glue, const std::initializer_list<GateRef>& args, bool isNew = false); 205 GateRef CallBuiltinRuntimeWithNewTarget(GateRef glue, const std::initializer_list<GateRef>& args); 206 void DebugPrint(GateRef thread, std::initializer_list<GateRef> args); 207 void FatalPrint(GateRef thread, std::initializer_list<GateRef> args); 208 // memory 209 GateRef Load(VariableType type, GateRef glue, GateRef base, GateRef offset, 210 MemoryAttribute mAttr = MemoryAttribute::Default()); 211 GateRef LoadZeroOffset(VariableType type, GateRef glue, GateRef base, 212 MemoryAttribute mAttr = MemoryAttribute::Default()); 213 GateRef LoadPrimitive(VariableType type, GateRef base, GateRef offset); 214 GateRef LoadZeroOffsetPrimitive(VariableType type, GateRef base); 215 void Store(VariableType type, 216 GateRef glue, 217 GateRef base, 218 GateRef offset, 219 GateRef value, 220 MemoryAttribute mAttr = MemoryAttribute::Default()); 221 // arithmetic 222 GateRef TaggedCastToIntPtr(GateRef x); 223 GateRef Int16Add(GateRef x, GateRef y); 224 GateRef Int32Add(GateRef x, GateRef y); 225 GateRef Int64Add(GateRef x, GateRef y); 226 GateRef DoubleAdd(GateRef x, GateRef y); 227 GateRef PtrAdd(GateRef x, GateRef y); 228 GateRef PtrSub(GateRef x, GateRef y); 229 GateRef PtrMul(GateRef x, GateRef y); 230 GateRef IntPtrEqual(GateRef x, GateRef y); 231 GateRef Int16Sub(GateRef x, GateRef y); 232 GateRef Int32Sub(GateRef x, GateRef y); 233 GateRef Int64Sub(GateRef x, GateRef y); 234 GateRef DoubleSub(GateRef x, GateRef y); 235 GateRef Int32Mul(GateRef x, GateRef y); 236 GateRef Int64Mul(GateRef x, GateRef y); 237 GateRef DoubleMul(GateRef x, GateRef y); 238 GateRef DoubleDiv(GateRef x, GateRef y); 239 GateRef Int32Div(GateRef x, GateRef y); 240 GateRef Int32Mod(GateRef x, GateRef y); 241 GateRef DoubleMod(GateRef x, GateRef y); 242 GateRef Int64Div(GateRef x, GateRef y); 243 GateRef IntPtrDiv(GateRef x, GateRef y); 244 GateRef IntPtrMod(GateRef x, GateRef y); 245 GateRef Int32Min(GateRef x, GateRef y); 246 GateRef Int32Max(GateRef x, GateRef y); 247 // bit operation 248 GateRef Int16Or(GateRef x, GateRef y); 249 GateRef Int16And(GateRef x, GateRef y); 250 GateRef Int32Or(GateRef x, GateRef y); 251 GateRef Int8And(GateRef x, GateRef y); 252 GateRef Int8Xor(GateRef x, GateRef y); 253 GateRef Int32And(GateRef x, GateRef y); 254 GateRef IntPtrAnd(GateRef x, GateRef y); 255 GateRef BitAnd(GateRef x, GateRef y); 256 GateRef BitOr(GateRef x, GateRef y); 257 GateRef Int32Not(GateRef x); 258 GateRef IntPtrNot(GateRef x); 259 GateRef BoolNot(GateRef x); 260 GateRef Int32Xor(GateRef x, GateRef y); 261 GateRef FixLoadType(GateRef x); 262 GateRef Int64Or(GateRef x, GateRef y); 263 GateRef Int64FetchOr(GateRef x, GateRef y, MemoryAttribute mAttr); 264 GateRef IntPtrOr(GateRef x, GateRef y); 265 GateRef Int64And(GateRef x, GateRef y); 266 GateRef Int64Xor(GateRef x, GateRef y); 267 GateRef Int64Not(GateRef x); 268 GateRef Int16LSL(GateRef x, GateRef y); 269 GateRef Int32LSL(GateRef x, GateRef y); 270 GateRef Int64LSL(GateRef x, GateRef y); 271 GateRef IntPtrLSL(GateRef x, GateRef y); 272 GateRef Int8LSR(GateRef x, GateRef y); 273 GateRef Int16LSR(GateRef x, GateRef y); 274 GateRef Int32LSR(GateRef x, GateRef y); 275 GateRef Int64LSR(GateRef x, GateRef y); 276 GateRef IntPtrLSR(GateRef x, GateRef y); 277 GateRef Int32ASR(GateRef x, GateRef y); 278 GateRef TaggedIsInt(GateRef x); 279 GateRef TaggedIsDouble(GateRef x); 280 GateRef TaggedIsObject(GateRef x); 281 GateRef TaggedIsNumber(GateRef x); 282 GateRef TaggedIsNumeric(GateRef glue, GateRef x); 283 GateRef TaggedIsHole(GateRef x); 284 GateRef TaggedIsNotHole(GateRef x); 285 GateRef TaggedIsUndefined(GateRef x); 286 GateRef TaggedIsException(GateRef x); 287 GateRef TaggedIsSpecial(GateRef x); 288 GateRef TaggedIsRegularObject(GateRef glue, GateRef x); 289 GateRef TaggedIsHeapObject(GateRef x); 290 GateRef TaggedIsAccessor(GateRef glue, GateRef x); 291 GateRef TaggedIsInternalAccessor(GateRef glue, GateRef x); 292 GateRef TaggedIsNativeModuleFailureInfo(GateRef glue, GateRef x); 293 GateRef ObjectAddressToRange(GateRef x); 294 GateRef RegionInSpace(GateRef region, RegionSpaceFlag space); 295 GateRef RegionInSpace(GateRef region, RegionSpaceFlag spaceBegin, RegionSpaceFlag spaceEnd); 296 GateRef InYoungGeneration(GateRef region); 297 GateRef InGeneralOldGeneration(GateRef region); 298 GateRef InSharedHeap(GateRef region); 299 GateRef InSharedSweepableSpace(GateRef region); 300 GateRef TaggedIsGeneratorObject(GateRef glue, GateRef x); 301 GateRef TaggedIsJSArray(GateRef glue, GateRef x); 302 GateRef TaggedIsJSProxy(GateRef glue, GateRef x); 303 GateRef IsTaggedArray(GateRef glue, GateRef x); 304 GateRef TaggedIsAsyncGeneratorObject(GateRef glue, GateRef x); 305 GateRef TaggedIsJSGlobalObject(GateRef glue, GateRef x); 306 GateRef TaggedIsWeak(GateRef x); 307 GateRef TaggedIsPrototypeHandler(GateRef glue, GateRef x); 308 GateRef TaggedIsStoreAOTHandler(GateRef glue, GateRef x); 309 GateRef TaggedIsTransWithProtoHandler(GateRef glue, GateRef x); 310 GateRef TaggedIsTransitionHandler(GateRef glue, GateRef x); 311 GateRef TaggedIsString(GateRef glue, GateRef obj); 312 GateRef TaggedIsStringIterator(GateRef glue, GateRef obj); 313 GateRef TaggedIsSharedObj(GateRef glue, GateRef obj); 314 GateRef BothAreString(GateRef glue, GateRef x, GateRef y); 315 GateRef TaggedIsStringOrSymbol(GateRef glue, GateRef obj); 316 GateRef TaggedIsSymbol(GateRef glue, GateRef obj); 317 GateRef TaggedIsArrayIterator(GateRef glue, GateRef obj); 318 GateRef TaggedIsArrayBuffer(GateRef glue, GateRef obj); 319 GateRef TaggedIsProtoChangeMarker(GateRef glue, GateRef obj); 320 GateRef GetNextPositionForHash(GateRef last, GateRef count, GateRef size); 321 GateRef DoubleIsNAN(GateRef x); 322 GateRef DoubleIsINF(GateRef x); 323 GateRef DoubleIsNanOrInf(GateRef x); 324 GateRef DoubleAbs(GateRef x); 325 GateRef DoubleIsInteger(GateRef x); 326 GateRef DoubleIsWithinInt32(GateRef x); 327 GateRef DoubleTrunc(GateRef x); 328 GateRef TaggedIsNull(GateRef x); 329 GateRef TaggedIsNotNull(GateRef x); 330 GateRef TaggedIsUndefinedOrNull(GateRef x); 331 GateRef TaggedIsUndefinedOrNullOrHole(GateRef x); 332 GateRef TaggedIsTrue(GateRef x); 333 GateRef TaggedIsFalse(GateRef x); 334 GateRef TaggedIsBoolean(GateRef x); 335 GateRef TaggedIsNativePointer(GateRef glue, GateRef x); 336 GateRef TaggedGetInt(GateRef x); 337 GateRef NumberGetInt(GateRef glue, GateRef x); 338 GateRef TaggedGetNumber(GateRef x); 339 GateRef Int8ToTaggedInt(GateRef x); 340 GateRef Int16ToTaggedInt(GateRef x); 341 GateRef IntToTaggedPtr(GateRef x); 342 GateRef IntToTaggedInt(GateRef x); 343 GateRef Int64ToTaggedInt(GateRef x); 344 GateRef Int64ToTaggedIntPtr(GateRef x); 345 GateRef DoubleToTaggedDouble(GateRef x); 346 GateRef DoubleToTaggedDoublePtr(GateRef x); 347 GateRef BooleanToTaggedBooleanPtr(GateRef x); 348 GateRef TaggedPtrToTaggedDoublePtr(GateRef x); 349 GateRef TaggedPtrToTaggedIntPtr(GateRef x); 350 GateRef CastDoubleToInt64(GateRef x); 351 GateRef CastFloat32ToInt32(GateRef x); 352 GateRef TaggedTrue(); 353 GateRef TaggedFalse(); 354 GateRef TaggedUndefined(); 355 GateRef Int64BitReverse(GateRef x); 356 GateRef Int32BitReverse(GateRef x); 357 GateRef Int16BitReverse(GateRef x); 358 GateRef Int8BitReverse(GateRef x); 359 // compare operation 360 GateRef Int8Equal(GateRef x, GateRef y); 361 GateRef Int8GreaterThanOrEqual(GateRef x, GateRef y); 362 GateRef Equal(GateRef x, GateRef y); 363 GateRef NotEqual(GateRef x, GateRef y); 364 GateRef Int32Equal(GateRef x, GateRef y); 365 GateRef Int32NotEqual(GateRef x, GateRef y); 366 GateRef Int64Equal(GateRef x, GateRef y); 367 GateRef DoubleEqual(GateRef x, GateRef y); 368 GateRef DoubleNotEqual(GateRef x, GateRef y); 369 GateRef Int64NotEqual(GateRef x, GateRef y); 370 GateRef DoubleLessThan(GateRef x, GateRef y); 371 GateRef DoubleLessThanOrEqual(GateRef x, GateRef y); 372 GateRef DoubleGreaterThan(GateRef x, GateRef y); 373 GateRef DoubleGreaterThanOrEqual(GateRef x, GateRef y); 374 GateRef Int32GreaterThan(GateRef x, GateRef y); 375 GateRef Int32LessThan(GateRef x, GateRef y); 376 GateRef Int32GreaterThanOrEqual(GateRef x, GateRef y); 377 GateRef Int32LessThanOrEqual(GateRef x, GateRef y); 378 GateRef Int32UnsignedGreaterThan(GateRef x, GateRef y); 379 GateRef Int32UnsignedLessThan(GateRef x, GateRef y); 380 GateRef Int32UnsignedGreaterThanOrEqual(GateRef x, GateRef y); 381 GateRef Int32UnsignedLessThanOrEqual(GateRef x, GateRef y); 382 GateRef Int64GreaterThan(GateRef x, GateRef y); 383 GateRef Int64LessThan(GateRef x, GateRef y); 384 GateRef Int64LessThanOrEqual(GateRef x, GateRef y); 385 GateRef Int64GreaterThanOrEqual(GateRef x, GateRef y); 386 GateRef Int64UnsignedLessThanOrEqual(GateRef x, GateRef y); 387 GateRef Int64UnsignedGreaterThan(GateRef x, GateRef y); 388 GateRef Int64UnsignedGreaterThanOrEqual(GateRef x, GateRef y); 389 GateRef IntPtrLessThan(GateRef x, GateRef y); 390 GateRef IntPtrLessThanOrEqual(GateRef x, GateRef y); 391 GateRef IntPtrGreaterThan(GateRef x, GateRef y); 392 GateRef IntPtrGreaterThanOrEqual(GateRef x, GateRef y); 393 // cast operation 394 GateRef ChangeInt64ToIntPtr(GateRef val); 395 GateRef ZExtInt32ToPtr(GateRef val); 396 GateRef ChangeIntPtrToInt32(GateRef val); 397 GateRef ToLength(GateRef glue, GateRef target); 398 GateRef ToIndex(GateRef glue, GateRef tagged); 399 400 // math operation 401 GateRef Sqrt(GateRef x); 402 GateRef GetSetterFromAccessor(GateRef glue, GateRef accessor); 403 GateRef GetElementsArray(GateRef glue, GateRef object); 404 void SetElementsArray(VariableType type, GateRef glue, GateRef object, GateRef elementsArray, 405 MemoryAttribute mAttr = MemoryAttribute::Default()); 406 GateRef GetPropertiesArray(GateRef glue, GateRef object); 407 // SetProperties in js_object.h 408 void SetPropertiesArray(VariableType type, GateRef glue, GateRef object, GateRef propsArray, 409 MemoryAttribute mAttr = MemoryAttribute::Default()); 410 GateRef GetHash(GateRef glue, GateRef object); 411 void SetHash(GateRef glue, GateRef object, GateRef hash); 412 GateRef GetLengthOfTaggedArray(GateRef array); 413 GateRef GetLengthOfJSTypedArray(GateRef array); 414 GateRef GetExtraLengthOfTaggedArray(GateRef array); 415 void SetExtraLengthOfTaggedArray(GateRef glue, GateRef array, GateRef len); 416 // object operation 417 GateRef IsJSHClass(GateRef glue, GateRef obj); 418 GateRef LoadHclassImpl(GateRef glue, GateRef object, int line); 419 420 void CanNotConvertNotValidObject(GateRef glue, GateRef obj); 421 void IsNotValidObject(GateRef flag); 422 void IsNotPropertyKey(GateRef obj); 423 GateRef CreateDataProperty(GateRef glue, GateRef obj, GateRef proKey, GateRef value); 424 GateRef CreateDataPropertyOrThrow(GateRef glue, GateRef onj, GateRef proKey, GateRef value); 425 GateRef DefineField(GateRef glue, GateRef obj, GateRef proKey, GateRef value); 426 void StoreHClass(GateRef glue, GateRef object, GateRef hClass, 427 MemoryAttribute mAttr = MemoryAttribute::NeedBarrier()); 428 void TransitionHClass(GateRef glue, GateRef object, GateRef hClass, 429 MemoryAttribute mAttr = MemoryAttribute::NeedBarrier()); 430 void StoreBuiltinHClass(GateRef glue, GateRef object, GateRef hClass); 431 void StorePrototype(GateRef glue, GateRef hclass, GateRef prototype); 432 void CopyAllHClass(GateRef glue, GateRef dstHClass, GateRef scrHClass); 433 void FuncOrHClassCompare(GateRef glue, GateRef funcOrHClass, 434 Label *match, Label *slowPath, size_t index); 435 void GetIteratorResult(GateRef glue, Variable *result, GateRef obj, 436 Label *isPendingException, Label *noPendingException); 437 void HClassCompareAndCheckDetector(GateRef glue, GateRef hclass, 438 Label *match, Label *slowPath, 439 size_t indexHClass, bool isMap); 440 void TryFastGetArrayIterator(GateRef glue, GateRef hclass, GateRef jsType, 441 Label *slowPath2, Label *matchArray); 442 void TryFastGetIterator(GateRef glue, GateRef obj, GateRef hclass, 443 Variable &result, Label *slowPath, Label *exit, 444 Label *isPendingException); 445 GateRef IsDetectorInvalid(GateRef glue, size_t indexDetector); 446 GateRef GetObjectType(GateRef hClass); 447 GateRef IsDictionaryMode(GateRef glue, GateRef object); 448 GateRef IsDictionaryModeByHClass(GateRef hClass); 449 GateRef IsDictionaryElement(GateRef hClass); 450 GateRef IsJSArrayPrototypeModified(GateRef hClass); 451 GateRef IsStableElements(GateRef hClass); 452 GateRef HasConstructorByHClass(GateRef hClass); 453 GateRef HasConstructor(GateRef glue, GateRef object); 454 GateRef IsClassConstructorFromBitField(GateRef bitfield); 455 GateRef IsClassConstructor(GateRef glue, GateRef object); 456 GateRef IsClassPrototype(GateRef glue, GateRef object); 457 GateRef IsExtensible(GateRef glue, GateRef object); 458 GateRef TaggedObjectIsEcmaObject(GateRef glue, GateRef obj); 459 GateRef IsEcmaObject(GateRef glue, GateRef obj); 460 GateRef IsDataView(GateRef glue, GateRef obj); 461 GateRef IsSymbol(GateRef glue, GateRef obj); 462 GateRef IsString(GateRef glue, GateRef obj); 463 GateRef IsLineString(GateRef glue, GateRef obj); 464 GateRef IsSlicedString(GateRef glue, GateRef obj); 465 GateRef IsTreeString(GateRef glue, GateRef obj); 466 GateRef TreeStringIsFlat(GateRef glue, GateRef string); 467 GateRef TaggedIsBigInt(GateRef glue, GateRef obj); 468 GateRef TaggedIsPropertyBox(GateRef glue, GateRef obj); 469 GateRef TaggedObjectIsBigInt(GateRef glue, GateRef obj); 470 GateRef IsJsProxy(GateRef glue, GateRef obj); 471 GateRef IsJSShared(GateRef glue, GateRef obj); 472 GateRef IsProfileTypeInfoCell0(GateRef glue, GateRef obj); 473 GateRef IsJSGlobalObject(GateRef glue, GateRef obj); 474 GateRef IsNativeModuleFailureInfo(GateRef glue, GateRef obj); 475 GateRef IsModuleNamespace(GateRef glue, GateRef obj); 476 GateRef IsNativePointer(GateRef glue, GateRef obj); 477 GateRef IsSourceTextModule(GateRef glue, GateRef obj); 478 GateRef IsSpecialContainer(GateRef glue, GateRef obj); 479 GateRef IsJSPrimitiveRef(GateRef glue, GateRef obj); 480 GateRef IsJSFunctionBase(GateRef glue, GateRef obj); 481 GateRef IsConstructor(GateRef glue, GateRef object); 482 GateRef IsBase(GateRef glue, GateRef func); 483 GateRef IsDerived(GateRef glue, GateRef func); 484 GateRef IsJsArray(GateRef glue, GateRef obj); 485 GateRef IsJsSArray(GateRef glue, GateRef obj); 486 GateRef IsByteArray(GateRef glue, GateRef obj); 487 GateRef IsJsCOWArray(GateRef glue, GateRef obj); 488 GateRef IsCOWArray(GateRef glue, GateRef obj); 489 GateRef IsMutantTaggedArray(GateRef glue, GateRef elements); 490 GateRef IsJSObject(GateRef glue, GateRef obj); 491 GateRef IsGlobalEnv(GateRef glue, GateRef obj); 492 GateRef IsLexicalEnv(GateRef glue, GateRef obj); 493 GateRef IsSFunctionEnv(GateRef glue, GateRef obj); 494 GateRef IsEnumerable(GateRef attr); 495 GateRef IsWritable(GateRef attr); 496 GateRef IsConfigable(GateRef attr); 497 GateRef IsDefaultAttribute(GateRef attr); 498 GateRef IsArrayLengthWritable(GateRef glue, GateRef receiver); 499 GateRef IsArrayLengthWritableForNonDictMode(GateRef glue, GateRef receiver); 500 GateRef IsAccessor(GateRef attr); 501 GateRef IsInlinedProperty(GateRef attr); 502 GateRef IsField(GateRef attr); 503 GateRef IsNonSharedStoreField(GateRef attr); 504 GateRef IsStoreShared(GateRef attr); 505 GateRef IsElement(GateRef attr); 506 GateRef IsStringElement(GateRef attr); 507 GateRef IsNumberHandler(GateRef attr); 508 GateRef IsBooleanHandler(GateRef attr); 509 GateRef IsStringLength(GateRef attr); 510 GateRef IsTypedArrayElement(GateRef attr); 511 GateRef IsNonExist(GateRef attr); 512 GateRef IsJSAPIVector(GateRef glue, GateRef attr); 513 GateRef IsJSAPIStack(GateRef glue, GateRef obj); 514 GateRef IsJSAPIPlainArray(GateRef glue, GateRef obj); 515 GateRef IsJSAPIQueue(GateRef glue, GateRef obj); 516 GateRef IsJSAPIDeque(GateRef glue, GateRef obj); 517 GateRef IsJSAPILightWeightMap(GateRef glue, GateRef obj); 518 GateRef IsJSAPILightWeightSet(GateRef glue, GateRef obj); 519 GateRef IsLinkedNode(GateRef glue, GateRef obj); 520 GateRef IsJSAPIHashMap(GateRef glue, GateRef obj); 521 GateRef IsJSAPIHashSet(GateRef glue, GateRef obj); 522 GateRef IsJSAPILinkedList(GateRef glue, GateRef obj); 523 GateRef IsJSAPIList(GateRef glue, GateRef obj); 524 GateRef IsJSAPIArrayList(GateRef glue, GateRef obj); 525 GateRef IsJSCollator(GateRef glue, GateRef obj); 526 GateRef IsJSObjectType(GateRef glue, GateRef obj, JSType jsType); 527 GateRef IsJSRegExp(GateRef glue, GateRef obj); 528 GateRef GetTarget(GateRef glue, GateRef proxyObj); 529 GateRef HandlerBaseIsAccessor(GateRef attr); 530 GateRef HandlerBaseIsJSArray(GateRef attr); 531 GateRef HandlerBaseIsInlinedProperty(GateRef attr); 532 GateRef HandlerBaseGetOffset(GateRef attr); 533 GateRef HandlerBaseGetAttrIndex(GateRef attr); 534 GateRef HandlerBaseGetRep(GateRef attr); 535 GateRef IsInvalidPropertyBox(GateRef glue, GateRef obj); 536 GateRef IsAccessorPropertyBox(GateRef glue, GateRef obj); 537 GateRef GetValueFromPropertyBox(GateRef glue, GateRef obj); 538 void SetValueToPropertyBox(GateRef glue, GateRef obj, GateRef value); 539 GateRef GetTransitionHClass(GateRef glue, GateRef obj); 540 GateRef GetTransitionHandlerInfo(GateRef glue, GateRef obj); 541 GateRef GetTransWithProtoHClass(GateRef glue, GateRef obj); 542 GateRef GetTransWithProtoHandlerInfo(GateRef glue, GateRef obj); 543 GateRef GetPrototypeHandlerProtoCell(GateRef glue, GateRef object); 544 GateRef GetTransWithProtoHandlerProtoCell(GateRef glue, GateRef object); 545 GateRef GetStoreAOTHandlerProtoCell(GateRef glue, GateRef object); 546 GateRef GetPrototypeHandlerHolder(GateRef glue, GateRef object); 547 GateRef GetPrototypeHandlerHandlerInfo(GateRef glue, GateRef object); 548 void SetPrototypeHandlerHandlerInfo(GateRef glue, GateRef obj, GateRef value); 549 GateRef GetStoreAOTHandlerHolder(GateRef glue, GateRef object); 550 GateRef GetStoreAOTHandlerHandlerInfo(GateRef glue, GateRef object); 551 inline GateRef GetLengthOfJSArray(GateRef array); 552 inline GateRef GetPrototype(GateRef glue, GateRef object); 553 inline GateRef GetHasChanged(GateRef object); 554 inline GateRef GetNotFoundHasChanged(GateRef object); 555 GateRef HclassIsPrototypeHandler(GateRef hClass); 556 GateRef HclassIsTransitionHandler(GateRef hClass); 557 GateRef HclassIsPropertyBox(GateRef hClass); 558 GateRef PropAttrGetOffset(GateRef attr); 559 GateRef GetCtorPrototype(GateRef glue, GateRef ctor); 560 GateRef HasFunctionPrototype(GateRef glue, GateRef ctor); 561 GateRef InstanceOf(GateRef glue, GateRef object, GateRef target, GateRef profileTypeInfo, GateRef slotId, 562 ProfileOperation callback); 563 GateRef OrdinaryHasInstance(GateRef glue, GateRef target, GateRef obj); 564 void TryFastHasInstance(GateRef glue, GateRef instof, GateRef target, GateRef object, Label *fastPath, 565 Label *exit, Variable *result, ProfileOperation callback); 566 GateRef ConvertTaggedValueWithElementsKind(GateRef glue, GateRef value, GateRef extraKind); 567 GateRef SameValue(GateRef glue, GateRef left, GateRef right); 568 GateRef SameValueZero(GateRef glue, GateRef left, GateRef right); 569 GateRef IsStableJSArguments(GateRef glue, GateRef obj); 570 GateRef IsStableJSArray(GateRef glue, GateRef obj); 571 GateRef IsTypedArray(GateRef glue, GateRef obj); 572 GateRef IsSharedTypedArray(GateRef glue, GateRef obj); 573 GateRef IsStableArguments(GateRef hClass); 574 GateRef IsStableArray(GateRef hClass); 575 GateRef GetProfileTypeInfo(GateRef glue, GateRef jsFunc); 576 GateRef UpdateProfileTypeInfo(GateRef glue, GateRef jsFunc); 577 // SetDictionaryOrder func in property_attribute.h 578 GateRef SetDictionaryOrderFieldInPropAttr(GateRef attr, GateRef value); 579 GateRef GetPrototypeFromHClass(GateRef glue, GateRef hClass); 580 GateRef GetEnumCacheFromHClass(GateRef glue, GateRef hClass); 581 GateRef GetProtoChangeMarkerFromHClass(GateRef glue, GateRef hClass); 582 GateRef GetLayoutFromHClass(GateRef glue, GateRef hClass); 583 GateRef GetBitFieldFromHClass(GateRef hClass); 584 GateRef GetArrayElementsGuardians(GateRef env); 585 GateRef GetTypedArraySpeciesProtectDetector(GateRef env); 586 GateRef GetArrayIteratorDetector(GateRef env); 587 GateRef GetMapIteratorDetector(GateRef env); 588 GateRef GetSetIteratorDetector(GateRef env); 589 void SetArrayElementsGuardians(GateRef glue, GateRef env, GateRef value); 590 GateRef GetLengthFromString(GateRef value); 591 GateRef CalcHashcodeForInt(GateRef value); 592 void CalcHashcodeForDouble(GateRef value, Variable *res, Label *exit); 593 void CalcHashcodeForObject(GateRef glue, GateRef value, Variable *res, Label *exit); 594 GateRef GetHashcodeFromString(GateRef glue, GateRef value, GateRef hir = Circuit::NullGate()); 595 inline void SetMixHashcode(GateRef glue, GateRef str, GateRef mixHashcode); 596 GateRef TryGetHashcodeFromString(GateRef string); 597 GateRef GetFirstFromTreeString(GateRef glue, GateRef string); 598 GateRef GetSecondFromTreeString(GateRef glue, GateRef string); 599 GateRef GetIsAllTaggedPropFromHClass(GateRef hclass); 600 void SetBitFieldToHClass(GateRef glue, GateRef hClass, GateRef bitfield); 601 void SetIsAllTaggedProp(GateRef glue, GateRef hclass, GateRef hasRep); 602 void SetPrototypeToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef proto); 603 GateRef GetProtoChangeDetails(GateRef glue, GateRef hClass); 604 void SetProtoChangeDetailsToHClass(VariableType type, GateRef glue, GateRef hClass, 605 GateRef protoChange); 606 void SetLayoutToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef attr, 607 MemoryAttribute mAttr = MemoryAttribute::Default()); 608 void SetHClassTypeIDToHClass(GateRef glue, GateRef hClass, GateRef id); 609 void SetEnumCacheToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef key); 610 void SetDependentInfosToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef value); 611 void SetTransitionsToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef transition); 612 GateRef GetTransitionsFromHClass(GateRef glue, GateRef hClass); 613 void SetParentToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef parent); 614 void SetIsPrototypeToHClass(GateRef glue, GateRef hClass, GateRef value); 615 GateRef SetIsStableToBitField(GateRef bitfield, GateRef isStable); 616 inline void SetIsAOT(GateRef glue, GateRef hClass, GateRef value); 617 GateRef IsPrototypeHClass(GateRef hClass); 618 void SetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass, 619 GateRef value, GateRef attrOffset, VariableType type = VariableType::JS_ANY(), 620 MemoryAttribute mAttr = MemoryAttribute::Default()); 621 GateRef GetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass, 622 GateRef index); 623 GateRef GetInlinedPropOffsetFromHClass(GateRef hclass, GateRef attrOffset); 624 inline GateRef IsObjSizeTrackingInProgress(GateRef hclass); 625 inline GateRef GetConstructionCounter(GateRef hclass); 626 inline void SetConstructionCounter(GateRef glue, GateRef hclass, GateRef count); 627 628 void IncNumberOfProps(GateRef glue, GateRef hClass); 629 GateRef GetNumberOfPropsFromHClass(GateRef hClass); 630 GateRef HasDeleteProperty(GateRef hClass); 631 GateRef IsAOTHClass(GateRef hClass); 632 void SetNumberOfPropsToHClass(GateRef glue, GateRef hClass, GateRef value); 633 void SetElementsKindToTrackInfo(GateRef glue, GateRef trackInfo, GateRef elementsKind); 634 void SetSpaceFlagToTrackInfo(GateRef glue, GateRef trackInfo, GateRef spaceFlag); 635 GateRef GetElementsKindFromHClass(GateRef hClass); 636 GateRef GetObjectSizeFromHClass(GateRef hClass); 637 GateRef GetInlinedPropsStartFromHClass(GateRef hClass); 638 GateRef GetInlinedPropertiesFromHClass(GateRef hClass); 639 void ThrowTypeAndReturn(GateRef glue, int messageId, GateRef val); 640 GateRef GetValueFromTaggedArray(GateRef glue, GateRef elements, GateRef index); 641 GateRef GetDataPtrInTaggedArray(GateRef array); 642 GateRef GetDataPtrInTaggedArray(GateRef array, GateRef index); 643 GateRef GetUnsharedConstpoolIndex(GateRef glue, GateRef constpool); 644 GateRef GetUnsharedConstpoolFromGlue(GateRef glue, GateRef constpool); 645 GateRef GetUnsharedConstpool(GateRef glue, GateRef array, GateRef index); 646 GateRef GetValueFromMutantTaggedArray(GateRef elements, GateRef index); 647 void SharedObjectStoreBarrierWithTypeCheck(bool isDicMode, Variable *result, GateRef glue, GateRef attr, 648 GateRef value, Variable *newValue, Label *executeSharedSetProp, Label *exit); 649 void SharedObjectStoreBarrierWithTypeCheck(bool isDicMode, Variable *result, GateRef glue, GateRef attr, 650 GateRef value, Variable *newValue, Label *executeSharedSetProp, Label *exit, GateRef SCheckModelIsCHECK); 651 void SharedObjectStoreBarrierWithTypeCheck(Variable *result, GateRef glue, GateRef fieldType, GateRef value, 652 Variable *newValue, Label *executeSharedSetProp, Label *exit); 653 void SharedObjectStoreBarrier(GateRef glue, GateRef value, Variable *newValue, Label *exit); 654 GateRef GetFieldTypeFromHandler(GateRef attr); 655 GateRef ClearSharedStoreKind(GateRef handlerInfo); 656 GateRef UpdateSOutOfBoundsForHandler(GateRef handlerInfo); 657 void RestoreElementsKindToGeneric(GateRef glue, GateRef jsHClass); 658 GateRef GetTaggedValueWithElementsKind(GateRef glue, GateRef receiver, GateRef index); 659 void FastSetValueWithElementsKind(GateRef glue, GateRef receiver, GateRef elements, GateRef rawValue, 660 GateRef index, ElementsKind kind, bool needTransition = false); 661 GateRef SetValueWithElementsKind(GateRef glue, GateRef receiver, GateRef rawValue, GateRef index, 662 GateRef needTransition, GateRef extraKind); 663 GateRef CopyJSArrayToTaggedArrayArgs(GateRef glue, GateRef srcObj); 664 void SetValueToTaggedArrayWithAttr( 665 GateRef glue, GateRef array, GateRef index, GateRef key, GateRef val, GateRef attr); 666 void SetValueToTaggedArrayWithRep( 667 GateRef glue, GateRef array, GateRef index, GateRef val, GateRef rep, Label *repChange); 668 669 void SetValueToTaggedArray(VariableType valType, GateRef glue, GateRef array, GateRef index, GateRef val, 670 MemoryAttribute mAttr = MemoryAttribute::Default()); 671 void UpdateValueAndAttributes(GateRef glue, GateRef elements, GateRef index, GateRef value, GateRef attr); 672 GateRef IsSpecialIndexedObj(GateRef jsType); 673 GateRef IsArrayListOrVector(GateRef jsType); 674 GateRef IsSharedArray(GateRef jsType); 675 GateRef IsAccessorInternal(GateRef glue, GateRef value); 676 template<typename DictionaryT> 677 GateRef GetAttributesFromDictionary(GateRef glue, GateRef elements, GateRef entry); 678 template<typename DictionaryT> 679 GateRef GetValueFromDictionary(GateRef glue, GateRef elements, GateRef entry); 680 template<typename DictionaryT> 681 GateRef GetKeyFromDictionary(GateRef glue, GateRef elements, GateRef entry); 682 GateRef GetPropAttrFromLayoutInfo(GateRef glue, GateRef layout, GateRef entry); 683 void UpdateFieldType(GateRef glue, GateRef hclass, GateRef attr); 684 GateRef GetPropertiesAddrFromLayoutInfo(GateRef layout); 685 GateRef GetPropertyMetaDataFromAttr(GateRef attr); 686 GateRef TranslateToRep(GateRef value); 687 GateRef GetKeyFromLayoutInfo(GateRef glue, GateRef layout, GateRef entry); 688 void MatchFieldType(GateRef glue, GateRef fieldType, GateRef value, Label *executeSetProp, Label *typeMismatch); 689 GateRef FindElementWithCache(GateRef glue, GateRef layoutInfo, GateRef hClass, 690 GateRef key, GateRef propsNum, GateRef hir = Circuit::NullGate()); 691 GateRef FindElementFromNumberDictionary(GateRef glue, GateRef elements, GateRef index); 692 template<typename HashTableT> 693 GateRef FindEntryFromHashTable(GateRef glue, GateRef elements, GateRef key, GateRef hir = Circuit::NullGate()); 694 GateRef IsMatchInTransitionDictionary(GateRef element, GateRef key, GateRef metaData, GateRef attr); 695 GateRef FindEntryFromTransitionDictionary(GateRef glue, GateRef elements, GateRef key, GateRef metaData); 696 GateRef JSObjectHasProperty(GateRef glue, GateRef obj, GateRef key, GateRef hir = Circuit::NullGate()); 697 GateRef JSObjectGetPropertyWithRep(GateRef glue, GateRef obj, GateRef hClass, GateRef propAttr); 698 void JSObjectSetProperty(GateRef glue, GateRef obj, GateRef hClass, GateRef attr, GateRef key, GateRef value); 699 GateRef ShouldCallSetter(GateRef glue, GateRef receiver, GateRef holder, GateRef accessor, GateRef attr); 700 GateRef CallSetterHelper(GateRef glue, 701 GateRef holder, 702 GateRef accessor, 703 GateRef value, 704 ProfileOperation callback, 705 bool mayThrow = true); 706 GateRef AddPropertyByName(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef propertyAttributes, 707 ProfileOperation callback); 708 GateRef IsUtf16String(GateRef string); 709 GateRef IsUtf8String(GateRef string); 710 GateRef IsInternalString(GateRef string); 711 GateRef IsDigit(GateRef ch); 712 GateRef ComputeElementCapacity(GateRef oldLength); 713 GateRef ComputeNonInlinedFastPropsCapacity(GateRef glue, GateRef oldLength, 714 GateRef maxNonInlinedFastPropsCapacity); 715 GateRef FindTransitions(GateRef glue, GateRef hClass, GateRef key, GateRef attr, GateRef value); 716 GateRef CheckHClassForRep(GateRef glue, GateRef hClass, GateRef rep); 717 void TransitionForRepChange(GateRef glue, GateRef receiver, GateRef key, GateRef attr); 718 void TransitToElementsKind(GateRef glue, GateRef receiver, GateRef value, GateRef kind); 719 void TryMigrateToGenericKindForJSObject(GateRef glue, GateRef receiver, GateRef oldKind); 720 GateRef TaggedToRepresentation(GateRef value); 721 GateRef TaggedToElementKind(GateRef glue, GateRef value); 722 GateRef LdGlobalRecord(GateRef glue, GateRef key); 723 GateRef LoadFromField(GateRef glue, GateRef receiver, GateRef handlerInfo); 724 GateRef LoadGlobal(GateRef glue, GateRef cell); 725 GateRef LoadElement(GateRef glue, GateRef receiver, GateRef key); 726 GateRef LoadStringElement(GateRef glue, GateRef receiver, GateRef key); 727 GateRef TryToElementsIndex(GateRef glue, GateRef key); 728 GateRef CheckPolyHClass(GateRef glue, GateRef cachedValue, GateRef hClass); 729 GateRef LoadICWithHandler( 730 GateRef glue, GateRef receiver, GateRef holder, GateRef handler, ProfileOperation callback); 731 GateRef StoreICWithHandler(GateRef glue, GateRef receiver, GateRef holder, 732 GateRef value, GateRef handler, ProfileOperation callback = ProfileOperation()); 733 GateRef TaggedArraySetValue(GateRef glue, GateRef receiver, GateRef value, GateRef index, GateRef capacity); 734 GateRef ICStoreElement(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef handlerInfo, 735 bool updateHandler = false, GateRef profileTypeInfo = Gate::InvalidGateRef, 736 GateRef slotId = Gate::InvalidGateRef); 737 GateRef GetArrayLength(GateRef object); 738 GateRef DoubleToInt(GateRef glue, GateRef x, size_t bits = base::INT32_BITS); 739 void SetArrayLength(GateRef glue, GateRef object, GateRef len); 740 GateRef StoreField(GateRef glue, GateRef receiver, GateRef value, GateRef handler, ProfileOperation callback); 741 GateRef StoreWithTransition(GateRef glue, GateRef receiver, GateRef value, GateRef handler, 742 ProfileOperation callback, bool withPrototype = false); 743 GateRef StoreGlobal(GateRef glue, GateRef value, GateRef cell); 744 void JSHClassAddProperty(GateRef glue, GateRef receiver, GateRef key, GateRef attr, GateRef value); 745 void NotifyHClassChanged(GateRef glue, GateRef oldHClass, GateRef newHClass); 746 GateRef GetInt64OfTInt(GateRef x); 747 GateRef GetInt32OfTInt(GateRef x); 748 GateRef GetDoubleOfTInt(GateRef x); 749 GateRef GetDoubleOfTDouble(GateRef x); 750 GateRef GetInt32OfTNumber(GateRef x); 751 GateRef GetDoubleOfTNumber(GateRef x); 752 GateRef LoadObjectFromWeakRef(GateRef x); 753 GateRef ExtFloat32ToDouble(GateRef x); 754 GateRef ChangeInt32ToFloat32(GateRef x); 755 GateRef ChangeInt32ToFloat64(GateRef x); 756 GateRef ChangeUInt32ToFloat64(GateRef x); 757 GateRef ChangeFloat64ToInt32(GateRef x); 758 GateRef TruncDoubleToFloat32(GateRef x); 759 GateRef DeletePropertyOrThrow(GateRef glue, GateRef obj, GateRef value); 760 inline GateRef ToObject(GateRef glue, GateRef globalEnv, GateRef obj); 761 GateRef DeleteProperty(GateRef glue, GateRef obj, GateRef value); 762 inline GateRef OrdinaryNewJSObjectCreate(GateRef glue, GateRef proto); 763 inline GateRef NewJSPrimitiveRef(GateRef glue, GateRef globalEnv, size_t index, GateRef obj); 764 GateRef ModuleNamespaceDeleteProperty(GateRef glue, GateRef obj, GateRef value); 765 GateRef Int64ToTaggedPtr(GateRef x); 766 GateRef TruncInt16ToInt8(GateRef x); 767 GateRef TruncInt32ToInt16(GateRef x); 768 GateRef TruncInt32ToInt8(GateRef x); 769 GateRef TruncFloatToInt64(GateRef x); 770 GateRef CastInt32ToFloat32(GateRef x); 771 GateRef CastInt64ToFloat64(GateRef x); 772 GateRef SExtInt32ToInt64(GateRef x); 773 GateRef SExtInt16ToInt64(GateRef x); 774 GateRef SExtInt16ToInt32(GateRef x); 775 GateRef SExtInt8ToInt64(GateRef x); 776 GateRef SExtInt8ToInt32(GateRef x); 777 GateRef SExtInt1ToInt64(GateRef x); 778 GateRef SExtInt1ToInt32(GateRef x); 779 GateRef ZExtInt8ToInt16(GateRef x); 780 GateRef ZExtInt32ToInt64(GateRef x); 781 GateRef ZExtInt1ToInt64(GateRef x); 782 GateRef ZExtInt1ToInt32(GateRef x); 783 GateRef ZExtInt8ToInt32(GateRef x); 784 GateRef ZExtInt8ToInt64(GateRef x); 785 GateRef ZExtInt8ToPtr(GateRef x); 786 GateRef ZExtInt16ToPtr(GateRef x); 787 GateRef SExtInt32ToPtr(GateRef x); 788 GateRef ZExtInt16ToInt32(GateRef x); 789 GateRef ZExtInt16ToInt64(GateRef x); 790 GateRef TruncInt64ToInt32(GateRef x); 791 GateRef TruncInt64ToInt16(GateRef x); 792 GateRef TruncPtrToInt32(GateRef x); 793 GateRef TruncInt64ToInt1(GateRef x); 794 GateRef TruncInt32ToInt1(GateRef x); 795 GateRef GetGlobalConstantAddr(GateRef index); 796 GateRef GetGlobalConstantOffset(ConstantIndex index); 797 GateRef IsCallableFromBitField(GateRef bitfield); 798 GateRef IsCallable(GateRef glue, GateRef obj); 799 GateRef TaggedIsCallable(GateRef glue, GateRef obj); 800 GateRef GetOffsetFieldInPropAttr(GateRef attr); 801 GateRef SetOffsetFieldInPropAttr(GateRef attr, GateRef value); 802 GateRef SetIsInlinePropsFieldInPropAttr(GateRef attr, GateRef value); 803 GateRef SetTrackTypeInPropAttr(GateRef attr, GateRef type); 804 GateRef GetTrackTypeInPropAttr(GateRef attr); 805 GateRef GetSharedFieldTypeInPropAttr(GateRef attr); 806 GateRef GetDictSharedFieldTypeInPropAttr(GateRef attr); 807 GateRef GetRepInPropAttr(GateRef attr); 808 GateRef IsIntRepInPropAttr(GateRef attr); 809 GateRef IsDoubleRepInPropAttr(GateRef attr); 810 GateRef IsTaggedRepInPropAttr(GateRef attr); 811 GateRef SetTaggedRepInPropAttr(GateRef attr); 812 GateRef SetEnumerableFiledInPropAttr(GateRef attr, GateRef value); 813 GateRef SetWritableFieldInPropAttr(GateRef attr, GateRef value); 814 GateRef SetConfigurableFieldInPropAttr(GateRef attr, GateRef value); 815 template<class T> 816 void SetHClassBit(GateRef glue, GateRef hClass, GateRef value); 817 template<typename DictionaryT> 818 void UpdateValueInDict(GateRef glue, GateRef elements, GateRef index, GateRef value); 819 GateRef GetBitMask(GateRef bitoffset); 820 GateRef IntPtrEuqal(GateRef x, GateRef y); 821 GateRef IntPtrNotEqual(GateRef x, GateRef y); 822 void SetValueWithAttr(GateRef glue, GateRef obj, GateRef offset, GateRef key, GateRef value, GateRef attr); 823 void SetValueWithRep(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef rep, Label *repChange); 824 void VerifyBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value); 825 GateRef GetCMCRegionRSet(GateRef obj); 826 GateRef GetCMCRegionType(GateRef obj); 827 GateRef GetGCPhase(GateRef glue); 828 GateRef GetGCReason(GateRef glue); 829 GateRef CMCIsInYoungSpace(GateRef regionType); 830 GateRef IsOldToYoung(GateRef objRegionType, GateRef valueRegionType); 831 void MarkRSetCardTable(GateRef obj, Label *exit); 832 GateRef ShouldGetGCReason(GateRef gcPhase); 833 GateRef ShouldProcessSATB(GateRef gcPhase); 834 GateRef ShouldUpdateRememberSet(GateRef glue, GateRef gcPhase); 835 GateRef NeedSkipReadBarrier(GateRef glue); 836 void CMCSetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value); 837 void CMCArrayCopyWriteBarrier(GateRef glue, GateRef dstObj, GateRef src, GateRef dst, GateRef count); 838 void CMCArrayCopyWriteBarrierSameArray(GateRef glue, GateRef dstObj, GateRef src, GateRef dst, GateRef count); 839 void SetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, 840 MemoryAttribute::ShareFlag share = MemoryAttribute::UNKNOWN); 841 GateRef GetValueWithBarrier(GateRef glue, GateRef addr); 842 GateRef FastReadBarrier(GateRef glue, GateRef addr, GateRef value); 843 GateRef IsHeapAddress(GateRef glue, GateRef value); 844 GateRef GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, 845 ProfileOperation callback, GateRef hir = Circuit::NullGate()); 846 GateRef GetPropertyByName(GateRef glue, 847 GateRef target, 848 GateRef propKey, 849 GateRef receiver = Circuit::NullGate(), 850 ProfileOperation callback = ProfileOperation(), 851 GateRef isInternal = Circuit::NullGate(), 852 bool canUseIsInternal = false, 853 GateRef hir = Circuit::NullGate()); 854 void CallGetterIfAccessor(GateRef glue, GateRef holder, Variable *value, Variable *attr, 855 Label *isFoundData, Label *isFoundAccessor); 856 void TryGetOwnProperty(GateRef glue, GateRef holder, GateRef key, GateRef hir, 857 Variable *rValue, Variable *rAttr, Label *isFoundData, Label *isFoundAccessor, 858 Label *notFound, Label *callRuntime); 859 GateRef FastGetPropertyByName(GateRef glue, GateRef obj, GateRef key, 860 ProfileOperation callback, GateRef hir = Circuit::NullGate()); 861 GateRef FastGetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, 862 ProfileOperation callback, GateRef hir = Circuit::NullGate()); 863 GateRef GetPropertyByValue(GateRef glue, 864 GateRef target, 865 GateRef propKey, 866 GateRef receiver = Circuit::NullGate(), 867 ProfileOperation callback = ProfileOperation()); 868 void FastSetPropertyByName(GateRef glue, GateRef obj, GateRef key, GateRef value, 869 ProfileOperation callback = ProfileOperation()); 870 void FastSetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, GateRef value); 871 GateRef SetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value, bool useOwn, 872 ProfileOperation callback = ProfileOperation(), bool defineSemantics = false, 873 bool mayThrow = true); 874 GateRef DefinePropertyByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value); 875 GateRef SetPropertyByName(GateRef glue, 876 GateRef receiver, 877 GateRef key, 878 GateRef value, 879 bool useOwn, 880 GateRef isInternal, 881 ProfileOperation callback = ProfileOperation(), 882 bool canUseIsInternal = false, 883 bool defineSemantics = false, 884 bool mayThrow = true); // Crawl prototype chain 885 GateRef DefinePropertyByName(GateRef glue, GateRef receiver, GateRef key, 886 GateRef value, GateRef isInternal, GateRef SCheckModelIsCHECK, 887 ProfileOperation callback = ProfileOperation()); 888 GateRef SetPropertyByValue(GateRef glue, 889 GateRef receiver, 890 GateRef key, 891 GateRef value, 892 bool useOwn, 893 ProfileOperation callback = ProfileOperation(), 894 bool defineSemantics = false, 895 bool mayThrow = true); 896 GateRef DefinePropertyByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, 897 GateRef SCheckModelIsCHECK, ProfileOperation callback = ProfileOperation()); 898 GateRef GetParentEnv(GateRef glue, GateRef object); 899 GateRef GetSendableParentEnv(GateRef glue, GateRef object); 900 GateRef GetPropertiesFromLexicalEnv(GateRef glue, GateRef object, GateRef index); 901 GateRef GetPropertiesFromSendableEnv(GateRef glue, GateRef object, GateRef index); 902 GateRef GetKeyFromLexivalEnv(GateRef glue, GateRef lexicalEnv, GateRef levelIndex, GateRef slotIndex); 903 void SetPropertiesToLexicalEnv(GateRef glue, GateRef object, GateRef index, GateRef value); 904 void SetPropertiesToSendableEnv(GateRef glue, GateRef object, GateRef index, GateRef value); 905 GateRef GetHomeObjectFromJSFunction(GateRef glue, GateRef object); 906 GateRef GetCallFieldFromMethod(GateRef method); 907 GateRef GetSendableEnvFromModule(GateRef glue, GateRef module); 908 GateRef GetProtoOrHClass(GateRef glue, GateRef function); 909 GateRef GetViewedArrayBufferOrByteArray(GateRef glue, GateRef typedArray); 910 GateRef IsSendableFunctionModule(GateRef glue, GateRef module); 911 GateRef GetFunctionLexicalEnv(GateRef glue, GateRef function); 912 inline GateRef GetBuiltinId(GateRef method); 913 void SetLexicalEnvToFunction(GateRef glue, GateRef object, GateRef lexicalEnv, 914 MemoryAttribute mAttr = MemoryAttribute::Default()); 915 void SetProtoOrHClassToFunction(GateRef glue, GateRef function, GateRef value, 916 MemoryAttribute mAttr = MemoryAttribute::Default()); 917 void SetWorkNodePointerToFunction(GateRef glue, GateRef function, GateRef value, 918 MemoryAttribute mAttr = MemoryAttribute::Default()); 919 void SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value, 920 MemoryAttribute mAttr = MemoryAttribute::Default()); 921 void SetModuleToFunction(GateRef glue, GateRef function, GateRef value, 922 MemoryAttribute mAttr = MemoryAttribute::Default()); 923 void SetMethodToFunction(GateRef glue, GateRef function, GateRef value, 924 MemoryAttribute mAttr = MemoryAttribute::Default()); 925 void SetCodeEntryToFunctionFromMethod(GateRef glue, GateRef function, GateRef value); 926 void SetCodeEntryToFunctionFromFuncEntry(GateRef glue, GateRef function, GateRef value); 927 void SetNativePointerToFunctionFromMethod(GateRef glue, GateRef function, GateRef value); 928 void SetCompiledCodeFlagToFunctionFromMethod(GateRef glue, GateRef function, GateRef value); 929 void SetLengthToFunction(GateRef glue, GateRef function, GateRef value); 930 void SetRawProfileTypeInfoToFunction(GateRef glue, GateRef function, GateRef value, 931 MemoryAttribute mAttr = MemoryAttribute::Default()); 932 void SetValueToProfileTypeInfoCell(GateRef glue, GateRef profileTypeInfoCell, GateRef value); 933 void UpdateProfileTypeInfoCellType(GateRef glue, GateRef profileTypeInfoCell); 934 void SetJSObjectTaggedField(GateRef glue, GateRef object, size_t offset, GateRef value); 935 void SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value, 936 MemoryAttribute mAttr = MemoryAttribute::Default()); 937 void SetCompiledCodeFlagToFunction(GateRef glue, GateRef function, GateRef value); 938 void SetCompiledFastCallFlagToFunction(GateRef glue, GateRef function, GateRef value); 939 void SetCompiledFuncEntry(GateRef glue, GateRef jsFunc, GateRef codeEntry, GateRef isFastCall); 940 GateRef GetFuncEntryDes(GateRef glue, GateRef machineCode, GateRef codeAddr); 941 GateRef GetFuncEntryDesAddress(GateRef machineCode); 942 GateRef IsAlign(GateRef address, GateRef alignByte); 943 void SetTaskConcurrentFuncFlagToFunction(GateRef glue, GateRef function, GateRef value); 944 void SetBitFieldToFunction(GateRef glue, GateRef function, GateRef value, 945 MemoryAttribute mAttr = MemoryAttribute::Default()); 946 void SetMachineCodeToFunction(GateRef glue, GateRef function, GateRef value, 947 MemoryAttribute mAttr = MemoryAttribute::Default()); 948 void SetTypedArrayName(GateRef glue, GateRef typedArray, GateRef name, 949 MemoryAttribute mAttr = MemoryAttribute::Default()); 950 void SetContentType(GateRef glue, GateRef typedArray, GateRef type); 951 void SetViewedArrayBufferOrByteArray(GateRef glue, GateRef typedArray, GateRef data, 952 MemoryAttribute mAttr = MemoryAttribute::Default()); 953 void SetByteLength(GateRef glue, GateRef typedArray, GateRef byteLength); 954 void SetByteOffset(GateRef glue, GateRef typedArray, GateRef offset); 955 void SetTypedArrayLength(GateRef glue, GateRef typedArray, GateRef arrayLength); 956 GateRef GetGlobalEnv(GateRef glue); 957 GateRef GetGlobalObject(GateRef glue, GateRef globalEnv); 958 GateRef GetCurrentGlobalEnv(GateRef glue, GateRef currentEnv); 959 void SetGlueGlobalEnv(GateRef glue, GateRef globalEnv); 960 void SetGlueGlobalEnvFromCurrentEnv(GateRef glue, GateRef currentEnv); 961 GateRef GetMethodFromFunction(GateRef glue, GateRef function); 962 GateRef GetModuleFromFunction(GateRef glue, GateRef function); 963 GateRef GetLengthFromFunction(GateRef function); 964 GateRef GetHomeObjectFromFunction(GateRef glue, GateRef function); 965 GateRef GetEntryIndexOfGlobalDictionary(GateRef entry); 966 GateRef GetBoxFromGlobalDictionary(GateRef glue, GateRef object, GateRef entry); 967 GateRef GetValueFromGlobalDictionary(GateRef glue, GateRef object, GateRef entry); 968 GateRef GetPropertiesFromJSObject(GateRef glue, GateRef object); 969 template<OpCode Op, MachineType Type> 970 GateRef BinaryOp(GateRef x, GateRef y); 971 template<OpCode Op, MachineType Type> 972 GateRef BinaryOpWithOverflow(GateRef x, GateRef y); 973 GateRef GetGlobalOwnProperty(GateRef glue, GateRef receiver, GateRef key, ProfileOperation callback); 974 GateRef AddElementInternal(GateRef glue, GateRef receiver, GateRef index, GateRef value, GateRef attr); 975 GateRef ShouldTransToDict(GateRef capcity, GateRef index); 976 void NotifyArrayPrototypeChangedGuardians(GateRef glue, GateRef receiver); 977 GateRef GrowElementsCapacity(GateRef glue, GateRef receiver, GateRef capacity); 978 979 inline GateRef GetObjectFromConstPool(GateRef glue, GateRef constpool, GateRef index); 980 GateRef GetConstPoolFromFunction(GateRef glue, GateRef jsFunc); 981 GateRef GetStringFromConstPool(GateRef glue, GateRef constpool, GateRef index); 982 GateRef GetMethodFromConstPool(GateRef glue, GateRef constpool, GateRef index); 983 GateRef GetArrayLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module); 984 GateRef GetObjectLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module); 985 void SetElementsKindToJSHClass(GateRef glue, GateRef jsHclass, GateRef elementsKind); 986 void SetExtensibleToBitfield(GateRef glue, GateRef obj, bool isExtensible); 987 void SetCallableToBitfield(GateRef glue, GateRef obj, bool isCallable); 988 989 // fast path 990 GateRef FastEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 991 GateRef FastStrictEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 992 GateRef FastStringEqual(GateRef glue, GateRef left, GateRef right); 993 GateRef FastStringEqualWithoutRTStub(GateRef glue, GateRef left, GateRef right); 994 GateRef StringCompare(GateRef glue, GateRef left, GateRef right); 995 GateRef FastMod(GateRef gule, GateRef left, GateRef right, ProfileOperation callback); 996 GateRef FastTypeOf(GateRef left, GateRef right); 997 GateRef FastMul(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 998 GateRef FastDiv(GateRef left, GateRef right, ProfileOperation callback); 999 GateRef FastAdd(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 1000 GateRef FastSub(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 1001 GateRef FastToBoolean(GateRef glue, GateRef value, bool flag = true); 1002 GateRef FastToBooleanWithProfile(GateRef glue, GateRef value, ProfileOperation callback, bool flag = true); 1003 GateRef FastToBooleanWithProfileBaseline(GateRef glue, GateRef value, ProfileOperation callback, bool flag = true); 1004 1005 // Add SpecialContainer 1006 GateRef JSAPIContainerGet(GateRef glue, GateRef receiver, GateRef index); 1007 1008 // for-in 1009 GateRef NextInternal(GateRef glue, GateRef iter); 1010 GateRef GetCacheKindFromForInIterator(GateRef iter); 1011 GateRef GetLengthFromForInIterator(GateRef iter); 1012 GateRef GetIndexFromForInIterator(GateRef iter); 1013 GateRef GetKeysFromForInIterator(GateRef glue, GateRef iter); 1014 GateRef GetObjectFromForInIterator(GateRef glue, GateRef iter); 1015 GateRef GetCachedHClassFromForInIterator(GateRef glue, GateRef iter); 1016 void SetLengthOfForInIterator(GateRef glue, GateRef iter, GateRef length); 1017 void SetIndexOfForInIterator(GateRef glue, GateRef iter, GateRef index); 1018 void SetCacheKindForInIterator(GateRef glue, GateRef iter, GateRef cacheKind); 1019 void SetKeysOfForInIterator(GateRef glue, GateRef iter, GateRef keys); 1020 void SetObjectOfForInIterator(GateRef glue, GateRef iter, GateRef object); 1021 void SetCachedHClassOfForInIterator(GateRef glue, GateRef iter, GateRef hclass); 1022 void IncreaseIteratorIndex(GateRef glue, GateRef iter, GateRef index); 1023 void SetNextIndexOfArrayIterator(GateRef glue, GateRef iter, GateRef nextIndex); 1024 void IncreaseArrayIteratorIndex(GateRef glue, GateRef iter, GateRef index); 1025 void SetIteratedArrayOfArrayIterator(GateRef glue, GateRef iter, GateRef iteratedArray); 1026 void SetBitFieldOfArrayIterator(GateRef glue, GateRef iter, GateRef kind); 1027 GateRef GetArrayIterationKind(GateRef iter); 1028 GateRef GetEnumCacheKindFromEnumCache(GateRef enumCache); 1029 GateRef GetEnumCacheOwnFromEnumCache(GateRef glue, GateRef enumCache); 1030 GateRef GetEnumCacheAllFromEnumCache(GateRef glue, GateRef enumCache); 1031 GateRef GetProtoChainInfoEnumCacheFromEnumCache(GateRef glue, GateRef enumCache); 1032 GateRef GetEmptyArray(GateRef glue); 1033 GateRef IsEnumCacheValid(GateRef glue, GateRef receiver, GateRef cachedHclass, GateRef kind); 1034 GateRef NeedCheckProperty(GateRef glue, GateRef receiver); 1035 1036 GateRef EnumerateObjectProperties(GateRef glue, GateRef obj); 1037 GateRef GetOrCreateEnumCacheFromHClass(GateRef glue, GateRef hClass); 1038 GateRef GetFunctionPrototype(GateRef glue, size_t index); 1039 GateRef ToPrototypeOrObj(GateRef glue, GateRef obj); 1040 GateRef ToPropertyKey(GateRef glue, GateRef tagged); 1041 GateRef TaggedIsEnumCache(GateRef glue, GateRef obj); 1042 GateRef TaggedIsPropertyKey(GateRef glue, GateRef obj); 1043 GateRef HasProperty(GateRef glue, GateRef obj, GateRef key, GateRef hir = Circuit::NullGate()); 1044 GateRef IsIn(GateRef glue, GateRef prop, GateRef obj); 1045 GateRef IsSpecialKeysObject(GateRef glue, GateRef obj); 1046 GateRef IsSlowKeysObject(GateRef glue, GateRef obj); 1047 GateRef IsSimpleEnumCacheValid(GateRef glue, GateRef obj); 1048 GateRef IsProtoChainCacheValid(GateRef glue, GateRef obj); 1049 GateRef TryGetEnumCache(GateRef glue, GateRef obj); 1050 GateRef GetNumberOfElements(GateRef glue, GateRef obj); 1051 GateRef IsEnumCacheWithProtoChainInfoValid(GateRef glue, GateRef obj); 1052 1053 // Exception handle 1054 GateRef HasPendingException(GateRef glue); 1055 void ReturnExceptionIfAbruptCompletion(GateRef glue); 1056 1057 // ElementsKind Operations 1058 GateRef ValueIsSpecialHole(GateRef x); 1059 GateRef ElementsKindIsInt(GateRef kind); 1060 GateRef ElementsKindIsIntOrHoleInt(GateRef kind); 1061 GateRef ElementsKindIsNumber(GateRef kind); 1062 GateRef ElementsKindIsNumOrHoleNum(GateRef kind); 1063 GateRef ElementsKindIsString(GateRef kind); 1064 GateRef ElementsKindIsStringOrHoleString(GateRef kind); 1065 GateRef ElementsKindIsHeapKind(GateRef kind); 1066 GateRef ElementsKindHasHole(GateRef kind); 1067 // dstAddr/srcAddr is the address will be copied to/from. 1068 // It can be a derived pointer point to the middle of an object. 1069 // Note: dstObj is the object address for dstAddr, it must point to the head of an object. 1070 void ArrayCopyAndHoleToUndefined(GateRef glue, GateRef srcObj, GateRef srcAddr, GateRef dstObj, 1071 GateRef dstAddr, GateRef length, GateRef needBarrier); 1072 GateRef ThreeInt64Min(GateRef first, GateRef second, GateRef third); 1073 void MigrateArrayWithKind(GateRef glue, GateRef object, GateRef oldKind, GateRef newKind); 1074 GateRef MigrateFromRawValueToHeapValues(GateRef glue, GateRef object, GateRef needCOW, GateRef isIntKind); 1075 GateRef MigrateFromHeapValueToRawValue(GateRef glue, GateRef object, GateRef needCOW, GateRef isIntKind); 1076 void MigrateFromHoleIntToHoleNumber(GateRef glue, GateRef object); 1077 void MigrateFromHoleNumberToHoleInt(GateRef glue, GateRef object); 1078 1079 // method operator 1080 GateRef IsJSFunction(GateRef glue, GateRef obj); 1081 GateRef IsBoundFunction(GateRef glue, GateRef obj); 1082 GateRef IsJSOrBoundFunction(GateRef glue, GateRef obj); 1083 GateRef GetMethodFromJSFunctionOrProxy(GateRef glue, GateRef object); 1084 GateRef IsNativeMethod(GateRef method); 1085 GateRef GetFuncKind(GateRef method); 1086 GateRef HasPrototype(GateRef kind); 1087 GateRef HasAccessor(GateRef kind); 1088 GateRef IsClassConstructorKind(GateRef kind); 1089 GateRef IsGeneratorKind(GateRef kind); 1090 GateRef IsBaseKind(GateRef kind); 1091 GateRef IsBaseConstructorKind(GateRef kind); 1092 GateRef IsSendableFunction(GateRef method); 1093 1094 GateRef IsAOTLiteralInfo(GateRef glue, GateRef info); 1095 GateRef GetIhcFromAOTLiteralInfo(GateRef glue, GateRef info); 1096 GateRef IsAotWithCallField(GateRef method); 1097 GateRef IsFastCall(GateRef method); 1098 GateRef JudgeAotAndFastCall(GateRef jsFunc, CircuitBuilder::JudgeMethodType type); 1099 GateRef GetInternalString(GateRef glue, GateRef key); 1100 GateRef GetExpectedNumOfArgs(GateRef method); 1101 GateRef GetMethod(GateRef glue, GateRef obj, GateRef key, GateRef profileTypeInfo, GateRef slotId); 1102 // proxy operator 1103 GateRef GetMethodFromJSProxy(GateRef glue, GateRef proxy); 1104 GateRef GetHandlerFromJSProxy(GateRef glue, GateRef proxy); 1105 GateRef GetTargetFromJSProxy(GateRef glue, GateRef proxy); 1106 inline void SetHotnessCounter(GateRef glue, GateRef method, GateRef value); 1107 inline void SaveHotnessCounterIfNeeded(GateRef glue, GateRef sp, GateRef hotnessCounter, JSCallMode mode); 1108 inline void SavePcIfNeeded(GateRef glue); 1109 inline void SaveJumpSizeIfNeeded(GateRef glue, GateRef jumpSize); 1110 inline GateRef ComputeTaggedArraySize(GateRef length); 1111 inline GateRef GetGlobalConstantValue( 1112 VariableType type, GateRef glue, ConstantIndex index); 1113 GateRef GetGlobalConstantValue(VariableType type, GateRef glue, GateRef index); 1114 inline GateRef GetSingleCharTable(GateRef glue); 1115 inline GateRef IsEnableMutantArray(GateRef glue); 1116 inline GateRef IsEnableElementsKind(GateRef glue); 1117 inline GateRef GetGlobalEnvValue(VariableType type, GateRef glue, GateRef env, size_t index); 1118 GateRef CallGetterHelper(GateRef glue, GateRef receiver, GateRef holder, 1119 GateRef accessor, ProfileOperation callback, GateRef hir = Circuit::NullGate()); 1120 GateRef ConstructorCheck(GateRef glue, GateRef ctor, GateRef outPut, GateRef thisObj); 1121 GateRef GetCallSpreadArgs(GateRef glue, GateRef array, ProfileOperation callBack); 1122 GateRef GetIterator(GateRef glue, GateRef obj, ProfileOperation callback); 1123 // For BaselineJIT 1124 GateRef FastToBooleanBaseline(GateRef glue, GateRef value, bool flag = true); 1125 GateRef GetBaselineCodeAddr(GateRef baselineCode); 1126 1127 GateRef IsFastTypeArray(GateRef jsType); 1128 GateRef IsJSProxy(GateRef jsType); 1129 GateRef GetTypeArrayPropertyByName(GateRef glue, GateRef receiver, GateRef holder, GateRef key, GateRef jsType); 1130 GateRef SetTypeArrayPropertyByName(GateRef glue, GateRef receiver, GateRef holder, GateRef key, GateRef value, 1131 GateRef jsType); 1132 GateRef TryStringOrSymbolToElementIndex(GateRef glue, GateRef key); 1133 inline GateRef DispatchBuiltins(GateRef glue, GateRef builtinsId, const std::vector<GateRef>& args, 1134 GateRef hir = Circuit::NullGate()); 1135 inline GateRef DispatchBuiltinsWithArgv(GateRef glue, GateRef builtinsId, const std::vector<GateRef> &args); 1136 GateRef ComputeSizeUtf8(GateRef length); 1137 GateRef ComputeSizeUtf16(GateRef length); 1138 GateRef AlignUp(GateRef x, GateRef alignment); 1139 GateRef AlignDown(GateRef x, GateRef alignment); 1140 inline void InitStringLengthAndFlags(GateRef glue, GateRef str, GateRef length, bool compressed); 1141 inline void InitStringLengthAndFlags(GateRef glue, GateRef str, GateRef length, GateRef isCompressed); 1142 void Assert(int messageId, int line, GateRef glue, GateRef condition, Label *nextLabel); 1143 1144 GateRef GetNormalStringData(GateRef glue, const StringInfoGateRef &stringInfoGate); 1145 1146 void Comment(GateRef glue, const std::string &str); 1147 GateRef ToNumber(GateRef glue, GateRef tagged); 1148 inline GateRef LoadPfHeaderFromConstPool(GateRef glue, GateRef jsFunc); 1149 GateRef RemoveTaggedWeakTag(GateRef weak); 1150 inline GateRef LoadHCIndexFromConstPool(GateRef glue, GateRef cachedArray, GateRef cachedLength, GateRef traceId, 1151 Label *miss); 1152 inline GateRef LoadHCIndexInfosFromConstPool(GateRef glue, GateRef jsFunc); 1153 inline GateRef GetAttrIndex(GateRef index); 1154 inline GateRef GetAttr(GateRef glue, GateRef layoutInfo, GateRef index); 1155 inline GateRef GetKey(GateRef glue, GateRef layoutInfo, GateRef index); 1156 inline GateRef GetKeyIndex(GateRef index); 1157 GateRef CalArrayRelativePos(GateRef index, GateRef arrayLen); 1158 GateRef AppendSkipHole(GateRef glue, GateRef first, GateRef second, GateRef copyLength); 1159 GateRef IntToEcmaString(GateRef glue, GateRef number); 1160 GateRef ToCharCode(GateRef number); 1161 GateRef NumberToString(GateRef glue, GateRef number); 1162 inline GateRef GetAccGetter(GateRef glue, GateRef accesstor); 1163 inline GateRef GetAccSetter(GateRef glue, GateRef accesstor); 1164 inline GateRef GetViewedArrayBuffer(GateRef glue, GateRef dataView); 1165 inline GateRef GetByteOffset(GateRef dataView); 1166 inline GateRef GetByteLength(GateRef dataView); 1167 inline GateRef GetArrayBufferData(GateRef glue, GateRef buffer); 1168 inline GateRef GetArrayBufferByteLength(GateRef buffer); 1169 inline void SetArrayBufferByteLength(GateRef glue, GateRef buffer, GateRef length); 1170 GateRef IsDetachedBuffer(GateRef glue, GateRef buffer); 1171 inline GateRef IsMarkerCellValid(GateRef cell); 1172 inline GateRef GetAccessorHasChanged(GateRef obj); 1173 inline GateRef ComputeTaggedTypedArraySize(GateRef elementSize, GateRef length); 1174 GateRef ChangeTaggedPointerToInt64(GateRef x); 1175 inline GateRef GetPropertiesCache(GateRef glue); 1176 inline GateRef GetMegaICCache(GateRef glue, MegaICCache::MegaICKind kind); 1177 inline GateRef GetModuleLogger(GateRef glue); 1178 inline GateRef GetStageOfHotReload(GateRef glue); 1179 inline GateRef GetModuleManager(GateRef glue); 1180 inline void IncMegaProbeCount(GateRef glue); 1181 inline void IncMegaHitCount(GateRef glue); 1182 GateRef GetIndexFromPropertiesCache(GateRef glue, GateRef cache, GateRef cls, GateRef key, 1183 GateRef hir = Circuit::NullGate()); 1184 GateRef GetHandlerFromMegaICCache(GateRef glue, GateRef cache, GateRef cls, GateRef key); 1185 inline void SetToPropertiesCache(GateRef glue, GateRef cache, GateRef cls, GateRef key, GateRef result, 1186 GateRef hir = Circuit::NullGate()); 1187 GateRef HashFromHclassAndKey(GateRef glue, GateRef cls, GateRef key, GateRef hir = Circuit::NullGate()); 1188 GateRef HashFromHclassAndStringKey(GateRef glue, GateRef cls, GateRef key); 1189 GateRef HashSecondaryFromHclassAndStringKey(GateRef glue, GateRef cls, GateRef key); 1190 GateRef GetKeyHashCode(GateRef glue, GateRef key, GateRef hir = Circuit::NullGate()); 1191 GateRef GetStringKeyHashCode(GateRef glue, GateRef key, GateRef hir = Circuit::NullGate()); 1192 inline GateRef GetSortedKey(GateRef glue, GateRef layoutInfo, GateRef index); 1193 inline GateRef GetSortedIndex(GateRef glue, GateRef layoutInfo, GateRef index); 1194 inline GateRef GetSortedIndex(GateRef attr); 1195 inline void StoreWithoutBarrier(VariableType type, GateRef base, GateRef offset, GateRef value); 1196 GateRef DefineFunc(GateRef glue, GateRef constpool, GateRef index, 1197 FunctionKind targetKind = FunctionKind::LAST_FUNCTION_KIND); 1198 GateRef BinarySearch(GateRef glue, GateRef layoutInfo, GateRef key, GateRef propsNum, 1199 GateRef hir = Circuit::NullGate()); 1200 GateRef GetLastLeaveFrame(GateRef glue); 1201 void UpdateProfileTypeInfoCellToFunction(GateRef glue, GateRef function, 1202 GateRef profileTypeInfo, GateRef slotId); 1203 1204 // start: Fast path of Loading Module variable. 1205 GateRef Loadlocalmodulevar(GateRef glue, GateRef index, GateRef module); 1206 inline void ResolvedModuleMustBeSourceTextModule(GateRef glue, GateRef resolvedModule); 1207 inline void ModuleEnvMustBeDefined(GateRef curEnv); 1208 inline void CheckIsResolvedIndexBinding(GateRef glue, GateRef resolution); 1209 inline void RecordNameMustBeString(GateRef glue, GateRef recordName); 1210 inline GateRef GetNameDictionary(GateRef glue, GateRef module); 1211 inline GateRef GetCurrentModuleEnv(GateRef glue, GateRef curModule); 1212 inline GateRef GetBitFieldFromSourceTextModule(GateRef curModule); 1213 inline GateRef GetRequestedModules(GateRef glue, GateRef module); 1214 inline GateRef GetNamespaceFromSourceTextModule(GateRef glue, GateRef module); 1215 inline GateRef GetResolveModuleFromResolvedIndexBinding(GateRef glue, GateRef resolvedBinding); 1216 inline GateRef GetResolveModuleFromResolvedBinding(GateRef glue, GateRef resolvedBinding); 1217 inline GateRef GetIdxOfResolvedIndexBinding(GateRef resolvedBinding); 1218 inline void SetIsUpdatedFromResolvedBindingOfResolvedIndexBinding(GateRef glue, GateRef resolvedBinding, 1219 GateRef value); 1220 inline GateRef GetIdxOfResolvedRecordIndexBinding(GateRef resolvedBinding); 1221 inline GateRef GetModuleRecord(GateRef glue, GateRef resolvedBinding); 1222 inline GateRef GetBindingName(GateRef glue, GateRef resolvedBinding); 1223 inline GateRef IsResolvedIndexBinding(GateRef glue, GateRef resolvedBinding); 1224 inline GateRef IsResolvedBinding(GateRef glue, GateRef resolvedBinding); 1225 inline GateRef IsResolvedRecordIndexBinding(GateRef glue, GateRef resolvedBinding); 1226 inline GateRef IsResolvedRecordBinding(GateRef glue, GateRef resolvedBinding); 1227 inline GateRef IsLdEndExecPatchMain(GateRef glue); 1228 inline GateRef GetModuleType(GateRef module); 1229 inline GateRef IsNativeModule(GateRef module); 1230 inline GateRef IsCjsModule(GateRef module); 1231 inline GateRef GetSharedType(GateRef module); 1232 inline GateRef IsSharedModule(GateRef module); 1233 inline GateRef GetCjsModuleFunction(GateRef glue); 1234 void ModuleEnvMustBeValid(GateRef glue, GateRef curEnv); 1235 GateRef SearchFromModuleCache(GateRef glue, GateRef moduleName); 1236 GateRef GetNativeOrCjsExports(GateRef glue, GateRef resolvedModule); 1237 GateRef GetValueFromExportObject(GateRef glue, GateRef exports, GateRef index); 1238 GateRef GetNativeOrCjsModuleValue(GateRef glue, GateRef module, GateRef index); 1239 GateRef GetModuleValueByIndex(GateRef glue, GateRef module, GateRef index, GateRef isThrow); 1240 GateRef GetModuleValue(GateRef glue, GateRef module, GateRef index); 1241 GateRef GetNativeOrCjsModuleValueByName(GateRef glue, GateRef module, GateRef bindingName); 1242 GateRef ResolveElementOfObject(GateRef glue, GateRef hClass, GateRef exportName, 1243 GateRef module, GateRef layOutInfo); 1244 GateRef ResolveExportObject(GateRef glue, GateRef module, GateRef exports, GateRef exportName); 1245 GateRef UpdateBindingAndGetModuleValue(GateRef glue, GateRef module, GateRef requiredModule, 1246 GateRef index, GateRef bindingName); 1247 GateRef GetResolvedRecordIndexBindingModule(GateRef glue, GateRef module, GateRef resolvedBinding); 1248 GateRef GetResolvedRecordBindingModule(GateRef glue, GateRef module, GateRef resolvedBinding); 1249 GateRef LoadExternalmodulevar(GateRef glue, GateRef index, GateRef curModule); 1250 // end: Fast path of Loading Module variable. 1251 1252 GateRef LoadModuleNamespaceByIndex(GateRef glue, GateRef index, GateRef module); 1253 GateRef GetArgumentsElements(GateRef glue, GateRef argvTaggedArray, GateRef argv); 1254 void TryToJitReuseCompiledFunc(GateRef glue, GateRef jsFunc, GateRef profileTypeInfoCell); 1255 void StartTraceLoadDetail(GateRef glue, GateRef receiver, GateRef profileTypeInfo, GateRef slotId); 1256 void StartTraceLoadGetter(GateRef glue); 1257 void StartTraceLoadSlowPath(GateRef glue); 1258 void EndTraceLoad(GateRef glue); 1259 void StartTraceLoadValueDetail(GateRef glue, GateRef receiver, GateRef profileTypeInfo, 1260 GateRef slotId, GateRef key); 1261 void StartTraceLoadValueSlowPath(GateRef glue); 1262 void EndTraceLoadValue(GateRef glue); 1263 void StartTraceStoreDetail(GateRef glue, GateRef receiver, GateRef profileTypeInfo, GateRef slotId); 1264 void StartTraceStoreFastPath(GateRef glue); 1265 void StartTraceStoreSlowPath(GateRef glue); 1266 void EndTraceStore(GateRef glue); 1267 void StartTraceCallDetail(GateRef glue, GateRef profileTypeInfo, GateRef slotId); 1268 void EndTraceCall(GateRef glue); 1269 void StartTraceDefineFunc(GateRef glue, GateRef methodId, GateRef profileTypeInfo, GateRef slotId); 1270 void EndTraceDefineFunc(GateRef glue); 1271 void UpdateProfileTypeInfoAsMega(GateRef glue, GateRef profileTypeInfo, GateRef slotId); 1272 GateRef GetIsFastCall(GateRef machineCode); 1273 // compute new elementKind from sub elements 1274 GateRef ComputeTaggedArrayElementKind(GateRef glue, GateRef array, GateRef offset, GateRef end); 1275 GateRef GetElementsKindHClass(GateRef glue, GateRef elementKind); 1276 GateRef NeedBarrier(GateRef kind); 1277 GateRef JSTaggedValueToString(GateRef glue, GateRef val, GateRef hir = Circuit::NullGate()); 1278 GateRef SpecialToString(GateRef glue, GateRef specialVal); 1279 GateRef ToPrimitive(GateRef glue, GateRef value, PreferredPrimitiveType type, 1280 GateRef hir = Circuit::NullGate()); 1281 GateRef GetPrimitiveTypeString(GateRef glue, PreferredPrimitiveType type); 1282 GateRef OrdinaryToPrimitive(GateRef glue, GateRef value, 1283 PreferredPrimitiveType type, GateRef hir = Circuit::NullGate()); 1284 GateRef CallFunction(GateRef glue, GateRef func); 1285 1286 enum CopyKind { 1287 SameArray, 1288 DifferentArray, 1289 }; 1290 // dstAddr/srcAddr is the address will be copied to/from. 1291 // It can be a derived pointer point to the middle of an object. 1292 // Note: dstObj is the object address for dstAddr, it must point to the head of an object. 1293 void ArrayCopy(GateRef glue, GateRef srcObj, GateRef srcAddr, GateRef dstObj, GateRef dstAddr, 1294 GateRef taggedValueCount, GateRef needBarrier, CopyKind copyKind); 1295 protected: 1296 static constexpr int LOOP_UNROLL_FACTOR = 2; 1297 static constexpr int ELEMENTS_KIND_HCLASS_NUM = 12; 1298 static constexpr int SPECIAL_VALUE_NUM = 5; 1299 static int64_t SPECIAL_VALUE[SPECIAL_VALUE_NUM]; 1300 static ConstantIndex SPECIAL_STRING_INDEX[SPECIAL_VALUE_NUM]; 1301 1302 private: 1303 using BinaryOperation = std::function<GateRef(Environment*, GateRef, GateRef)>; 1304 template<OpCode Op> 1305 GateRef FastAddSubAndMul(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 1306 GateRef FastIntDiv(GateRef left, GateRef right, Label *bailout, ProfileOperation callback); 1307 template<OpCode Op> 1308 GateRef FastBinaryOp(GateRef glue, GateRef left, GateRef right, 1309 const BinaryOperation& intOp, const BinaryOperation& floatOp, ProfileOperation callback); 1310 GateRef TryStringAdd(Environment *env, GateRef glue, GateRef left, GateRef right, 1311 const BinaryOperation& intOp, const BinaryOperation& floatOp, ProfileOperation callback); 1312 GateRef NumberOperation(Environment *env, GateRef left, GateRef right, 1313 const BinaryOperation& intOp, 1314 const BinaryOperation& floatOp, 1315 ProfileOperation callback); 1316 void SetSValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef objectRegion, 1317 GateRef valueRegion); 1318 1319 void SetNonSValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef objectRegion, 1320 GateRef valueRegion); 1321 void InitializeArguments(); 1322 void CheckDetectorName(GateRef glue, GateRef key, Label *fallthrough, Label *slow); 1323 GateRef CanDoubleRepresentInt(GateRef exp, GateRef expBits, GateRef fractionBits); 1324 GateRef CalIteratorKey(GateRef glue); 1325 1326 template <class LabelPtrGetter> 1327 void SwitchGeneric(GateRef index, Label *defaultLabel, Span<const int64_t> keysValue, 1328 LabelPtrGetter getIthLabelFn); 1329 GateRef StringCompareContents(GateRef glue, GateRef left, GateRef right, GateRef init, GateRef minLength); 1330 1331 CallSignature *callSignature_ {nullptr}; 1332 Environment *env_; 1333 GateRef globalEnv_ {Gate::InvalidGateRef}; 1334 }; 1335 } // namespace panda::ecmascript::kungfu 1336 #endif // ECMASCRIPT_COMPILER_STUB_BUILDER_H 1337