1 /* 2 * Copyright (c) 2022 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 27 namespace panda::ecmascript::kungfu { 28 struct StringInfoGateRef; 29 using namespace panda::ecmascript; 30 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 31 #define DEFVARIABLE(varname, type, val) Variable varname(GetEnvironment(), type, NextVariableId(), val) 32 33 #define SUBENTRY(messageId, condition) \ 34 GateRef glueArg = PtrArgument(0); \ 35 auto env = GetEnvironment(); \ 36 Label subEntry(env); \ 37 env->SubCfgEntry(&subEntry); \ 38 Label nextLabel(env); \ 39 Assert(messageId, __LINE__, glueArg, condition, &nextLabel); \ 40 Bind(&nextLabel) 41 #define SUBENTRY_WITH_GLUE(messageId, condition, glueArg) \ 42 auto env = GetEnvironment(); \ 43 Label subEntry(env); \ 44 env->SubCfgEntry(&subEntry); \ 45 Label nextLabel(env); \ 46 Assert(messageId, __LINE__, glueArg, condition, &nextLabel); \ 47 Bind(&nextLabel) 48 49 #ifndef NDEBUG 50 #define ASM_ASSERT(messageId, condition) \ 51 if (!GetEnvironment()->GetCircuit()->IsOptimizedOrFastJit() && \ 52 !GetEnvironment()->IsBaselineBuiltin()) { \ 53 SUBENTRY(messageId, condition); \ 54 EXITENTRY(); \ 55 } 56 #define ASM_ASSERT_WITH_GLUE(messageId, condition, glue) \ 57 SUBENTRY_WITH_GLUE(messageId, condition, glue) 58 #elif defined(ENABLE_ASM_ASSERT) 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_GLUE(messageId, condition, glue) \ 66 SUBENTRY_WITH_GLUE(messageId, condition, glue) 67 #else 68 #define ASM_ASSERT(messageId, ...) ((void)0) 69 #define ASM_ASSERT_WITH_GLUE(messageId, ...) ((void)0) 70 #endif 71 72 #ifndef NDEBUG 73 #define EXITENTRY() \ 74 GetEnvironment()->SubCfgExit() 75 #elif defined(ENABLE_ASM_ASSERT) 76 #define EXITENTRY() \ 77 GetEnvironment()->SubCfgExit() 78 #else 79 #define EXITENTRY() ((void)0) 80 #endif 81 82 class StubBuilder { 83 public: StubBuilder(StubBuilder * parent)84 explicit StubBuilder(StubBuilder *parent) 85 : callSignature_(parent->GetCallSignature()), env_(parent->GetEnvironment()) {} StubBuilder(CallSignature * callSignature,Environment * env)86 StubBuilder(CallSignature *callSignature, Environment *env) 87 : callSignature_(callSignature), env_(env) {} StubBuilder(Environment * env)88 explicit StubBuilder(Environment *env) 89 : env_(env) {} 90 virtual ~StubBuilder() = default; 91 NO_MOVE_SEMANTIC(StubBuilder); 92 NO_COPY_SEMANTIC(StubBuilder); 93 virtual void GenerateCircuit() = 0; GetEnvironment()94 Environment *GetEnvironment() const 95 { 96 return env_; 97 } GetCallSignature()98 CallSignature *GetCallSignature() const 99 { 100 return callSignature_; 101 } 102 int NextVariableId(); 103 // constant 104 GateRef Int8(int8_t value); 105 GateRef Int16(int16_t value); 106 GateRef Int32(int32_t value); 107 GateRef Int64(int64_t value); 108 GateRef StringPtr(std::string_view str); 109 GateRef IntPtr(int64_t value); 110 GateRef IntPtrSize(); 111 GateRef RelocatableData(uint64_t value); 112 GateRef True(); 113 GateRef False(); 114 GateRef Boolean(bool value); 115 GateRef Double(double value); 116 GateRef Undefined(); 117 GateRef Hole(); 118 GateRef SpecialHole(); 119 GateRef Null(); 120 GateRef NullPtr(); 121 GateRef Exception(); 122 // parameter 123 GateRef Argument(size_t index); 124 GateRef Int1Argument(size_t index); 125 GateRef Int32Argument(size_t index); 126 GateRef Int64Argument(size_t index); 127 GateRef TaggedArgument(size_t index); 128 GateRef TaggedPointerArgument(size_t index); 129 GateRef PtrArgument(size_t index); 130 GateRef Float32Argument(size_t index); 131 GateRef Float64Argument(size_t index); 132 GateRef Alloca(int size); 133 // control flow 134 GateRef Return(GateRef value); 135 GateRef Return(); 136 void Bind(Label *label); 137 void Jump(Label *label); 138 139 #define BRANCH(condition, trueLabel, falseLabel) \ 140 { \ 141 std::ostringstream os; \ 142 os << __func__ << ": " << #trueLabel << "- " << #falseLabel; \ 143 Branch(condition, trueLabel, falseLabel, os.str().c_str()); \ 144 } 145 146 void Branch(GateRef condition, Label *trueLabel, Label *falseLabel, const char *comment = nullptr); 147 148 #define BRANCH_LIKELY(condition, trueLabel, falseLabel) \ 149 { \ 150 std::ostringstream os; \ 151 os << __func__ << ": " << #trueLabel << "(likely)- " << #falseLabel; \ 152 BranchPredict(condition, trueLabel, falseLabel, \ 153 BranchWeight::DEOPT_WEIGHT, BranchWeight::ONE_WEIGHT, os.str().c_str()); \ 154 } 155 156 #define BRANCH_UNLIKELY(condition, trueLabel, falseLabel) \ 157 { \ 158 std::ostringstream os; \ 159 os << __func__ << ": " << #trueLabel << "(unlikely)- " << #falseLabel; \ 160 BranchPredict(condition, trueLabel, falseLabel, \ 161 BranchWeight::ONE_WEIGHT, BranchWeight::DEOPT_WEIGHT, os.str().c_str()); \ 162 } 163 164 #define BRANCH_NO_WEIGHT(condition, trueLabel, falseLabel) \ 165 { \ 166 std::ostringstream os; \ 167 os << __func__ << ": " << #trueLabel << "(no weight)- " << #falseLabel; \ 168 BranchPredict(condition, trueLabel, falseLabel, \ 169 BranchWeight::ZERO_WEIGHT, BranchWeight::ZERO_WEIGHT, os.str().c_str()); \ 170 } 171 172 void BranchPredict(GateRef condition, Label *trueLabel, Label *falseLabel, 173 uint32_t trueWeight = BranchWeight::ONE_WEIGHT, uint32_t falseWeight = BranchWeight::ONE_WEIGHT, 174 const char *comment = nullptr); 175 176 void Switch(GateRef index, Label *defaultLabel, int64_t *keysValue, Label *keysLabel, int numberOfKeys); 177 void LoopBegin(Label *loopHead); 178 void LoopEnd(Label *loopHead); 179 /// LoopEnd with safepoint 180 void LoopEnd(Label *loopHead, Environment *env, GateRef glue); 181 GateRef CheckSuspend(GateRef glue); 182 // call operation 183 GateRef CallRuntime(GateRef glue, int index, const std::vector<GateRef>& args); 184 GateRef CallRuntime(GateRef glue, int index, GateRef argc, GateRef argv); 185 GateRef CallNGCRuntime(GateRef glue, int index, 186 const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate()); 187 GateRef FastCallOptimized(GateRef glue, GateRef code, 188 const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate()); 189 GateRef CallOptimized(GateRef glue, GateRef code, 190 const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate()); 191 GateRef GetAotCodeAddr(GateRef jsFunc); 192 GateRef CallStub(GateRef glue, int index, const std::initializer_list<GateRef>& args); 193 GateRef CallBuiltinRuntime(GateRef glue, const std::initializer_list<GateRef>& args, bool isNew = false); 194 GateRef CallBuiltinRuntimeWithNewTarget(GateRef glue, const std::initializer_list<GateRef>& args); 195 void DebugPrint(GateRef thread, std::initializer_list<GateRef> args); 196 void FatalPrint(GateRef thread, std::initializer_list<GateRef> args); 197 // memory 198 GateRef Load(VariableType type, GateRef base, GateRef offset); 199 GateRef Load(VariableType type, GateRef base); 200 void Store(VariableType type, 201 GateRef glue, 202 GateRef base, 203 GateRef offset, 204 GateRef value, 205 MemoryAttribute mAttr = MemoryAttribute::Default()); 206 // arithmetic 207 GateRef TaggedCastToIntPtr(GateRef x); 208 GateRef Int16Add(GateRef x, GateRef y); 209 GateRef Int32Add(GateRef x, GateRef y); 210 GateRef Int64Add(GateRef x, GateRef y); 211 GateRef DoubleAdd(GateRef x, GateRef y); 212 GateRef PtrAdd(GateRef x, GateRef y); 213 GateRef PtrSub(GateRef x, GateRef y); 214 GateRef PtrMul(GateRef x, GateRef y); 215 GateRef IntPtrEqual(GateRef x, GateRef y); 216 GateRef Int16Sub(GateRef x, GateRef y); 217 GateRef Int32Sub(GateRef x, GateRef y); 218 GateRef Int64Sub(GateRef x, GateRef y); 219 GateRef DoubleSub(GateRef x, GateRef y); 220 GateRef Int32Mul(GateRef x, GateRef y); 221 GateRef Int64Mul(GateRef x, GateRef y); 222 GateRef DoubleMul(GateRef x, GateRef y); 223 GateRef DoubleDiv(GateRef x, GateRef y); 224 GateRef Int32Div(GateRef x, GateRef y); 225 GateRef Int32Mod(GateRef x, GateRef y); 226 GateRef DoubleMod(GateRef x, GateRef y); 227 GateRef Int64Div(GateRef x, GateRef y); 228 GateRef IntPtrDiv(GateRef x, GateRef y); 229 // bit operation 230 GateRef Int32Or(GateRef x, GateRef y); 231 GateRef Int8And(GateRef x, GateRef y); 232 GateRef Int8Xor(GateRef x, GateRef y); 233 GateRef Int32And(GateRef x, GateRef y); 234 GateRef IntPtrAnd(GateRef x, GateRef y); 235 GateRef BitAnd(GateRef x, GateRef y); 236 GateRef BitOr(GateRef x, GateRef y); 237 GateRef Int32Not(GateRef x); 238 GateRef IntPtrNot(GateRef x); 239 GateRef BoolNot(GateRef x); 240 GateRef Int32Xor(GateRef x, GateRef y); 241 GateRef FixLoadType(GateRef x); 242 GateRef Int64Or(GateRef x, GateRef y); 243 GateRef IntPtrOr(GateRef x, GateRef y); 244 GateRef Int64And(GateRef x, GateRef y); 245 GateRef Int64Xor(GateRef x, GateRef y); 246 GateRef Int64Not(GateRef x); 247 GateRef Int16LSL(GateRef x, GateRef y); 248 GateRef Int32LSL(GateRef x, GateRef y); 249 GateRef Int64LSL(GateRef x, GateRef y); 250 GateRef IntPtrLSL(GateRef x, GateRef y); 251 GateRef Int8LSR(GateRef x, GateRef y); 252 GateRef Int32LSR(GateRef x, GateRef y); 253 GateRef Int64LSR(GateRef x, GateRef y); 254 GateRef IntPtrLSR(GateRef x, GateRef y); 255 GateRef Int32ASR(GateRef x, GateRef y); 256 GateRef TaggedIsInt(GateRef x); 257 GateRef TaggedIsDouble(GateRef x); 258 GateRef TaggedIsObject(GateRef x); 259 GateRef TaggedIsNumber(GateRef x); 260 GateRef TaggedIsNumeric(GateRef x); 261 GateRef TaggedIsHole(GateRef x); 262 GateRef TaggedIsNotHole(GateRef x); 263 GateRef TaggedIsUndefined(GateRef x); 264 GateRef TaggedIsException(GateRef x); 265 GateRef TaggedIsSpecial(GateRef x); 266 GateRef TaggedIsRegularObject(GateRef x); 267 GateRef TaggedIsHeapObject(GateRef x); 268 GateRef TaggedIsAccessor(GateRef x); 269 GateRef ObjectAddressToRange(GateRef x); 270 GateRef RegionInSpace(GateRef region, RegionSpaceFlag space); 271 GateRef RegionInSpace(GateRef region, RegionSpaceFlag spaceBegin, RegionSpaceFlag spaceEnd); 272 GateRef InEdenGeneration(GateRef region); 273 GateRef InYoungGeneration(GateRef region); 274 GateRef InGeneralYoungGeneration(GateRef region); 275 GateRef InGeneralOldGeneration(GateRef region); 276 GateRef InSharedHeap(GateRef region); 277 GateRef InSharedSweepableSpace(GateRef region); 278 GateRef TaggedIsGeneratorObject(GateRef x); 279 GateRef TaggedIsJSArray(GateRef x); 280 GateRef IsTaggedArray(GateRef x); 281 GateRef TaggedIsAsyncGeneratorObject(GateRef x); 282 GateRef TaggedIsJSGlobalObject(GateRef x); 283 GateRef TaggedIsWeak(GateRef x); 284 GateRef TaggedIsPrototypeHandler(GateRef x); 285 GateRef TaggedIsStoreTSHandler(GateRef x); 286 GateRef TaggedIsTransWithProtoHandler(GateRef x); 287 GateRef TaggedIsTransitionHandler(GateRef x); 288 GateRef TaggedIsString(GateRef obj); 289 GateRef TaggedIsStringIterator(GateRef obj); 290 GateRef TaggedIsSharedObj(GateRef obj); 291 GateRef BothAreString(GateRef x, GateRef y); 292 GateRef TaggedIsStringOrSymbol(GateRef obj); 293 GateRef TaggedIsSymbol(GateRef obj); 294 GateRef TaggedIsProtoChangeMarker(GateRef obj); 295 GateRef GetNextPositionForHash(GateRef last, GateRef count, GateRef size); 296 GateRef DoubleIsNAN(GateRef x); 297 GateRef DoubleIsINF(GateRef x); 298 GateRef DoubleIsNanOrInf(GateRef x); 299 GateRef DoubleAbs(GateRef x); 300 GateRef DoubleIsInteger(GateRef x); 301 GateRef DoubleTrunc(GateRef x); 302 GateRef TaggedIsNull(GateRef x); 303 GateRef TaggedIsUndefinedOrNull(GateRef x); 304 GateRef TaggedIsUndefinedOrNullOrHole(GateRef x); 305 GateRef TaggedIsTrue(GateRef x); 306 GateRef TaggedIsFalse(GateRef x); 307 GateRef TaggedIsBoolean(GateRef x); 308 GateRef TaggedGetInt(GateRef x); 309 GateRef NumberGetInt(GateRef glue, GateRef x); 310 GateRef TaggedGetNumber(GateRef x); 311 GateRef Int8ToTaggedInt(GateRef x); 312 GateRef Int16ToTaggedInt(GateRef x); 313 GateRef IntToTaggedPtr(GateRef x); 314 GateRef IntToTaggedInt(GateRef x); 315 GateRef Int64ToTaggedInt(GateRef x); 316 GateRef Int64ToTaggedIntPtr(GateRef x); 317 GateRef DoubleToTaggedDoublePtr(GateRef x); 318 GateRef BooleanToTaggedBooleanPtr(GateRef x); 319 GateRef TaggedPtrToTaggedDoublePtr(GateRef x); 320 GateRef TaggedPtrToTaggedIntPtr(GateRef x); 321 GateRef CastDoubleToInt64(GateRef x); 322 GateRef CastFloat32ToInt32(GateRef x); 323 GateRef TaggedTrue(); 324 GateRef TaggedFalse(); 325 GateRef TaggedUndefined(); 326 // compare operation 327 GateRef Int8Equal(GateRef x, GateRef y); 328 GateRef Int8GreaterThanOrEqual(GateRef x, GateRef y); 329 GateRef Equal(GateRef x, GateRef y); 330 GateRef NotEqual(GateRef x, GateRef y); 331 GateRef Int32Equal(GateRef x, GateRef y); 332 GateRef Int32NotEqual(GateRef x, GateRef y); 333 GateRef Int64Equal(GateRef x, GateRef y); 334 GateRef DoubleEqual(GateRef x, GateRef y); 335 GateRef DoubleNotEqual(GateRef x, GateRef y); 336 GateRef Int64NotEqual(GateRef x, GateRef y); 337 GateRef DoubleLessThan(GateRef x, GateRef y); 338 GateRef DoubleLessThanOrEqual(GateRef x, GateRef y); 339 GateRef DoubleGreaterThan(GateRef x, GateRef y); 340 GateRef DoubleGreaterThanOrEqual(GateRef x, GateRef y); 341 GateRef Int32GreaterThan(GateRef x, GateRef y); 342 GateRef Int32LessThan(GateRef x, GateRef y); 343 GateRef Int32GreaterThanOrEqual(GateRef x, GateRef y); 344 GateRef Int32LessThanOrEqual(GateRef x, GateRef y); 345 GateRef Int32UnsignedGreaterThan(GateRef x, GateRef y); 346 GateRef Int32UnsignedLessThan(GateRef x, GateRef y); 347 GateRef Int32UnsignedGreaterThanOrEqual(GateRef x, GateRef y); 348 GateRef Int32UnsignedLessThanOrEqual(GateRef x, GateRef y); 349 GateRef Int64GreaterThan(GateRef x, GateRef y); 350 GateRef Int64LessThan(GateRef x, GateRef y); 351 GateRef Int64LessThanOrEqual(GateRef x, GateRef y); 352 GateRef Int64GreaterThanOrEqual(GateRef x, GateRef y); 353 GateRef Int64UnsignedLessThanOrEqual(GateRef x, GateRef y); 354 GateRef Int64UnsignedGreaterThanOrEqual(GateRef x, GateRef y); 355 GateRef IntPtrGreaterThan(GateRef x, GateRef y); 356 // cast operation 357 GateRef ChangeInt64ToIntPtr(GateRef val); 358 GateRef ZExtInt32ToPtr(GateRef val); 359 GateRef ChangeIntPtrToInt32(GateRef val); 360 GateRef ToLength(GateRef glue, GateRef target); 361 362 // math operation 363 GateRef Sqrt(GateRef x); 364 GateRef GetSetterFromAccessor(GateRef accessor); 365 GateRef GetElementsArray(GateRef object); 366 void SetElementsArray(VariableType type, GateRef glue, GateRef object, GateRef elementsArray, 367 MemoryAttribute mAttr = MemoryAttribute::Default()); 368 GateRef GetPropertiesArray(GateRef object); 369 // SetProperties in js_object.h 370 void SetPropertiesArray(VariableType type, GateRef glue, GateRef object, GateRef propsArray, 371 MemoryAttribute mAttr = MemoryAttribute::Default()); 372 GateRef GetHash(GateRef object); 373 void SetHash(GateRef glue, GateRef object, GateRef hash); 374 GateRef GetLengthOfTaggedArray(GateRef array); 375 GateRef GetLengthOfJSTypedArray(GateRef array); 376 GateRef GetExtraLengthOfTaggedArray(GateRef array); 377 void SetExtraLengthOfTaggedArray(GateRef glue, GateRef array, GateRef len); 378 // object operation 379 GateRef IsJSHClass(GateRef obj); 380 GateRef LoadHClass(GateRef object); 381 void CanNotConvertNotValidObject(GateRef obj); 382 void IsNotPropertyKey(GateRef obj); 383 GateRef CreateDataProperty(GateRef glue, GateRef obj, GateRef proKey, GateRef value); 384 GateRef CreateDataPropertyOrThrow(GateRef glue, GateRef onj, GateRef proKey, GateRef value); 385 GateRef DefineField(GateRef glue, GateRef obj, GateRef proKey, GateRef value); 386 void StoreHClass(GateRef glue, GateRef object, GateRef hClass); 387 void StoreHClassWithoutBarrier(GateRef glue, GateRef object, GateRef hClass); 388 void StoreBuiltinHClass(GateRef glue, GateRef object, GateRef hClass); 389 void StorePrototype(GateRef glue, GateRef hclass, GateRef prototype); 390 void CopyAllHClass(GateRef glue, GateRef dstHClass, GateRef scrHClass); 391 GateRef GetObjectType(GateRef hClass); 392 GateRef IsDictionaryMode(GateRef object); 393 GateRef IsDictionaryModeByHClass(GateRef hClass); 394 GateRef IsDictionaryElement(GateRef hClass); 395 GateRef IsStableElements(GateRef hClass); 396 GateRef HasConstructorByHClass(GateRef hClass); 397 GateRef HasConstructor(GateRef object); 398 GateRef IsClassConstructorFromBitField(GateRef bitfield); 399 GateRef IsClassConstructor(GateRef object); 400 GateRef IsClassPrototype(GateRef object); 401 GateRef IsExtensible(GateRef object); 402 GateRef TaggedObjectIsEcmaObject(GateRef obj); 403 GateRef IsEcmaObject(GateRef obj); 404 GateRef IsDataView(GateRef obj); 405 GateRef IsSymbol(GateRef obj); 406 GateRef IsString(GateRef obj); 407 GateRef IsLineString(GateRef obj); 408 GateRef IsSlicedString(GateRef obj); 409 GateRef IsConstantString(GateRef obj); 410 GateRef IsLiteralString(GateRef obj); 411 GateRef IsTreeString(GateRef obj); 412 GateRef TreeStringIsFlat(GateRef string); 413 GateRef TaggedIsBigInt(GateRef obj); 414 GateRef TaggedIsPropertyBox(GateRef obj); 415 GateRef TaggedObjectIsBigInt(GateRef obj); 416 GateRef IsJsProxy(GateRef obj); 417 GateRef IsJSShared(GateRef obj); 418 GateRef IsProfileTypeInfoCell0(GateRef obj); 419 GateRef IsJSGlobalObject(GateRef obj); 420 GateRef IsNativeModuleFailureInfo(GateRef obj); 421 GateRef IsModuleNamespace(GateRef obj); 422 GateRef IsNativePointer(GateRef obj); 423 GateRef IsSourceTextModule(GateRef obj); 424 GateRef ObjIsSpecialContainer(GateRef obj); 425 GateRef IsJSPrimitiveRef(GateRef obj); 426 GateRef IsJSFunctionBase(GateRef obj); 427 GateRef IsConstructor(GateRef object); 428 GateRef IsBase(GateRef func); 429 GateRef IsDerived(GateRef func); 430 GateRef IsJsArray(GateRef obj); 431 GateRef IsJsSArray(GateRef obj); 432 GateRef IsByteArray(GateRef obj); 433 GateRef IsJsCOWArray(GateRef obj); 434 GateRef IsMutantTaggedArray(GateRef elements); 435 GateRef IsJSObject(GateRef obj); 436 GateRef IsEnumerable(GateRef attr); 437 GateRef IsWritable(GateRef attr); 438 GateRef IsConfigable(GateRef attr); 439 GateRef IsDefaultAttribute(GateRef attr); 440 GateRef IsArrayLengthWritable(GateRef glue, GateRef receiver); 441 GateRef IsAccessor(GateRef attr); 442 GateRef IsInlinedProperty(GateRef attr); 443 GateRef IsField(GateRef attr); 444 GateRef IsNonSharedStoreField(GateRef attr); 445 GateRef IsStoreShared(GateRef attr); 446 GateRef IsElement(GateRef attr); 447 GateRef IsStringElement(GateRef attr); 448 GateRef IsNumber(GateRef attr); 449 GateRef IsStringLength(GateRef attr); 450 GateRef IsTypedArrayElement(GateRef attr); 451 GateRef IsNonExist(GateRef attr); 452 GateRef IsJSAPIVector(GateRef attr); 453 GateRef IsJSAPIStack(GateRef obj); 454 GateRef IsJSAPIPlainArray(GateRef obj); 455 GateRef IsJSAPIQueue(GateRef obj); 456 GateRef IsJSAPIDeque(GateRef obj); 457 GateRef IsJSAPILightWeightMap(GateRef obj); 458 GateRef IsJSAPILightWeightSet(GateRef obj); 459 GateRef IsLinkedNode(GateRef obj); 460 GateRef IsJSAPIHashMap(GateRef obj); 461 GateRef IsJSAPIHashSet(GateRef obj); 462 GateRef IsJSAPILinkedList(GateRef obj); 463 GateRef IsJSAPIList(GateRef obj); 464 GateRef IsJSAPIArrayList(GateRef obj); 465 GateRef IsJSObjectType(GateRef obj, JSType jsType); 466 GateRef IsJSRegExp(GateRef obj); 467 GateRef GetTarget(GateRef proxyObj); 468 GateRef HandlerBaseIsAccessor(GateRef attr); 469 GateRef HandlerBaseIsJSArray(GateRef attr); 470 GateRef HandlerBaseIsInlinedProperty(GateRef attr); 471 GateRef HandlerBaseGetOffset(GateRef attr); 472 GateRef HandlerBaseGetAttrIndex(GateRef attr); 473 GateRef HandlerBaseGetRep(GateRef attr); 474 GateRef IsInvalidPropertyBox(GateRef obj); 475 GateRef IsAccessorPropertyBox(GateRef obj); 476 GateRef GetValueFromPropertyBox(GateRef obj); 477 void SetValueToPropertyBox(GateRef glue, GateRef obj, GateRef value); 478 GateRef GetTransitionHClass(GateRef obj); 479 GateRef GetTransitionHandlerInfo(GateRef obj); 480 GateRef GetTransWithProtoHClass(GateRef obj); 481 GateRef GetTransWithProtoHandlerInfo(GateRef obj); 482 GateRef GetProtoCell(GateRef object); 483 GateRef GetPrototypeHandlerHolder(GateRef object); 484 GateRef GetPrototypeHandlerHandlerInfo(GateRef object); 485 GateRef GetStoreTSHandlerHolder(GateRef object); 486 GateRef GetStoreTSHandlerHandlerInfo(GateRef object); 487 inline GateRef GetPrototype(GateRef glue, GateRef object); 488 GateRef GetHasChanged(GateRef object); 489 GateRef HclassIsPrototypeHandler(GateRef hClass); 490 GateRef HclassIsTransitionHandler(GateRef hClass); 491 GateRef HclassIsPropertyBox(GateRef hClass); 492 GateRef PropAttrGetOffset(GateRef attr); 493 GateRef GetCtorPrototype(GateRef ctor); 494 GateRef InstanceOf(GateRef glue, GateRef object, GateRef target, GateRef profileTypeInfo, GateRef slotId, 495 ProfileOperation callback); 496 GateRef OrdinaryHasInstance(GateRef glue, GateRef target, GateRef obj); 497 void TryFastHasInstance(GateRef glue, GateRef instof, GateRef target, GateRef object, Label *fastPath, 498 Label *exit, Variable *result, ProfileOperation callback); 499 GateRef SameValue(GateRef glue, GateRef left, GateRef right); 500 GateRef SameValueZero(GateRef glue, GateRef left, GateRef right); 501 GateRef HasStableElements(GateRef glue, GateRef obj); 502 GateRef IsStableJSArguments(GateRef glue, GateRef obj); 503 GateRef IsStableJSArray(GateRef glue, GateRef obj); 504 GateRef IsTypedArray(GateRef obj); 505 GateRef IsStableArguments(GateRef hClass); 506 GateRef IsStableArray(GateRef hClass); 507 GateRef GetProfileTypeInfo(GateRef jsFunc); 508 GateRef UpdateProfileTypeInfo(GateRef glue, GateRef jsFunc); 509 // SetDictionaryOrder func in property_attribute.h 510 GateRef SetDictionaryOrderFieldInPropAttr(GateRef attr, GateRef value); 511 GateRef GetPrototypeFromHClass(GateRef hClass); 512 GateRef GetEnumCacheFromHClass(GateRef hClass); 513 GateRef GetProtoChangeMarkerFromHClass(GateRef hClass); 514 GateRef GetLayoutFromHClass(GateRef hClass); 515 GateRef GetBitFieldFromHClass(GateRef hClass); 516 GateRef GetLengthFromString(GateRef value); 517 GateRef CalcHashcodeForInt(GateRef value); 518 void CalcHashcodeForDouble(GateRef value, Variable *res, Label *exit); 519 void CalcHashcodeForObject(GateRef glue, GateRef value, Variable *res, Label *exit); 520 GateRef GetHashcodeFromString(GateRef glue, GateRef value, GateRef hir = Circuit::NullGate()); 521 inline GateRef IsIntegerString(GateRef string); 522 inline void SetRawHashcode(GateRef glue, GateRef str, GateRef rawHashcode, GateRef isInteger); 523 inline GateRef GetRawHashFromString(GateRef value); 524 GateRef TryGetHashcodeFromString(GateRef string); 525 inline GateRef GetMixHashcode(GateRef string); 526 GateRef GetFirstFromTreeString(GateRef string); 527 GateRef GetSecondFromTreeString(GateRef string); 528 GateRef GetIsAllTaggedPropFromHClass(GateRef hclass); 529 void SetBitFieldToHClass(GateRef glue, GateRef hClass, GateRef bitfield); 530 void SetIsAllTaggedProp(GateRef glue, GateRef hclass, GateRef hasRep); 531 void SetPrototypeToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef proto); 532 void SetProtoChangeDetailsToHClass(VariableType type, GateRef glue, GateRef hClass, 533 GateRef protoChange); 534 void SetLayoutToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef attr, 535 MemoryAttribute mAttr = MemoryAttribute::Default()); 536 void SetHClassTypeIDToHClass(GateRef glue, GateRef hClass, GateRef id); 537 void SetEnumCacheToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef key); 538 void SetTransitionsToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef transition); 539 void SetParentToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef parent); 540 void SetIsProtoTypeToHClass(GateRef glue, GateRef hClass, GateRef value); 541 inline void SetIsTS(GateRef glue, GateRef hClass, GateRef value); 542 GateRef IsProtoTypeHClass(GateRef hClass); 543 void SetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass, 544 GateRef value, GateRef attrOffset, VariableType type = VariableType::JS_ANY(), 545 MemoryAttribute mAttr = MemoryAttribute::Default()); 546 GateRef GetPropertyInlinedProps(GateRef obj, GateRef hClass, 547 GateRef index); 548 GateRef GetInlinedPropOffsetFromHClass(GateRef hclass, GateRef attrOffset); 549 550 void IncNumberOfProps(GateRef glue, GateRef hClass); 551 GateRef GetNumberOfPropsFromHClass(GateRef hClass); 552 GateRef HasDeleteProperty(GateRef hClass); 553 GateRef IsTSHClass(GateRef hClass); 554 void SetNumberOfPropsToHClass(GateRef glue, GateRef hClass, GateRef value); 555 void SetElementsKindToTrackInfo(GateRef glue, GateRef trackInfo, GateRef elementsKind); 556 void SetSpaceFlagToTrackInfo(GateRef glue, GateRef trackInfo, GateRef spaceFlag); 557 GateRef GetElementsKindFromHClass(GateRef hClass); 558 GateRef GetObjectSizeFromHClass(GateRef hClass); 559 GateRef GetInlinedPropsStartFromHClass(GateRef hClass); 560 GateRef GetInlinedPropertiesFromHClass(GateRef hClass); 561 void ThrowTypeAndReturn(GateRef glue, int messageId, GateRef val); 562 GateRef GetValueFromTaggedArray(GateRef elements, GateRef index); 563 GateRef GetUnsharedConstpoolIndex(GateRef constpool); 564 GateRef GetUnsharedConstpoolFromGlue(GateRef glue, GateRef constpool); 565 GateRef GetUnsharedConstpool(GateRef array, GateRef index); 566 GateRef GetValueFromMutantTaggedArray(GateRef elements, GateRef index); 567 void CheckUpdateSharedType(bool isDicMode, Variable *result, GateRef glue, GateRef receiver, GateRef attr, 568 GateRef value, Label *executeSetProp, Label *exit); 569 void CheckUpdateSharedType(bool isDicMode, Variable *result, GateRef glue, GateRef receiver, GateRef attr, 570 GateRef value, Label *executeSetProp, Label *exit, GateRef SCheckModelIsCHECK); 571 void MatchFieldType(Variable *result, GateRef glue, GateRef fieldType, GateRef value, Label *executeSetProp, 572 Label *exit); 573 GateRef GetFieldTypeFromHandler(GateRef attr); 574 GateRef ClearSharedStoreKind(GateRef handlerInfo); 575 GateRef UpdateSOutOfBoundsForHandler(GateRef handlerInfo); 576 void RestoreElementsKindToGeneric(GateRef glue, GateRef jsHClass); 577 GateRef GetTaggedValueWithElementsKind(GateRef receiver, GateRef index); 578 void FastSetValueWithElementsKind(GateRef glue, GateRef elements, GateRef rawValue, 579 GateRef index, ElementsKind kind); 580 GateRef SetValueWithElementsKind(GateRef glue, GateRef receiver, GateRef rawValue, GateRef index, 581 GateRef needTransition, GateRef extraKind); 582 GateRef CopyJSArrayToTaggedArrayArgs(GateRef glue, GateRef srcObj); 583 void SetValueToTaggedArrayWithAttr( 584 GateRef glue, GateRef array, GateRef index, GateRef key, GateRef val, GateRef attr); 585 void SetValueToTaggedArrayWithRep( 586 GateRef glue, GateRef array, GateRef index, GateRef val, GateRef rep, Label *repChange); 587 588 void SetValueToTaggedArray(VariableType valType, GateRef glue, GateRef array, GateRef index, GateRef val, 589 MemoryAttribute mAttr = MemoryAttribute::Default()); 590 void UpdateValueAndAttributes(GateRef glue, GateRef elements, GateRef index, GateRef value, GateRef attr); 591 GateRef IsSpecialIndexedObj(GateRef jsType); 592 GateRef IsSpecialContainer(GateRef jsType); 593 GateRef IsSharedArray(GateRef jsType); 594 GateRef IsAccessorInternal(GateRef value); 595 template<typename DictionaryT> 596 GateRef GetAttributesFromDictionary(GateRef elements, GateRef entry); 597 template<typename DictionaryT> 598 GateRef GetValueFromDictionary(GateRef elements, GateRef entry); 599 template<typename DictionaryT> 600 GateRef GetKeyFromDictionary(GateRef elements, GateRef entry); 601 GateRef GetPropAttrFromLayoutInfo(GateRef layout, GateRef entry); 602 void UpdateFieldType(GateRef glue, GateRef hclass, GateRef attr); 603 GateRef GetPropertiesAddrFromLayoutInfo(GateRef layout); 604 GateRef GetPropertyMetaDataFromAttr(GateRef attr); 605 GateRef TranslateToRep(GateRef value); 606 GateRef GetKeyFromLayoutInfo(GateRef layout, GateRef entry); 607 void MatchFieldType(GateRef fieldType, GateRef value, Label *executeSetProp, Label *typeMismatch); 608 GateRef FindElementWithCache(GateRef glue, GateRef layoutInfo, GateRef hClass, 609 GateRef key, GateRef propsNum, GateRef hir = Circuit::NullGate()); 610 GateRef FindElementFromNumberDictionary(GateRef glue, GateRef elements, GateRef index); 611 GateRef FindEntryFromNameDictionary(GateRef glue, GateRef elements, GateRef key, GateRef hir = Circuit::NullGate()); 612 GateRef IsMatchInTransitionDictionary(GateRef element, GateRef key, GateRef metaData, GateRef attr); 613 GateRef FindEntryFromTransitionDictionary(GateRef glue, GateRef elements, GateRef key, GateRef metaData); 614 GateRef JSObjectGetProperty(GateRef obj, GateRef hClass, GateRef propAttr); 615 void JSObjectSetProperty(GateRef glue, GateRef obj, GateRef hClass, GateRef attr, GateRef key, GateRef value); 616 GateRef ShouldCallSetter(GateRef receiver, GateRef holder, GateRef accessor, GateRef attr); 617 GateRef CallSetterHelper(GateRef glue, GateRef holder, GateRef accessor, GateRef value, ProfileOperation callback); 618 GateRef SetHasConstructorCondition(GateRef glue, GateRef receiver, GateRef key); 619 GateRef AddPropertyByName(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef propertyAttributes, 620 ProfileOperation callback); 621 GateRef IsUtf16String(GateRef string); 622 GateRef IsUtf8String(GateRef string); 623 GateRef IsInternalString(GateRef string); 624 GateRef IsDigit(GateRef ch); 625 void TryToGetInteger(GateRef string, Variable *num, Label *success, Label *failed); 626 GateRef StringToElementIndex(GateRef glue, GateRef string); 627 GateRef ComputeElementCapacity(GateRef oldLength); 628 GateRef ComputeNonInlinedFastPropsCapacity(GateRef glue, GateRef oldLength, 629 GateRef maxNonInlinedFastPropsCapacity); 630 GateRef FindTransitions(GateRef glue, GateRef hClass, GateRef key, GateRef attr, GateRef value); 631 GateRef CheckHClassForRep(GateRef hClass, GateRef rep); 632 void TransitionForRepChange(GateRef glue, GateRef receiver, GateRef key, GateRef attr); 633 void TransitToElementsKind(GateRef glue, GateRef receiver, GateRef value, GateRef kind); 634 void TryMigrateToGenericKindForJSObject(GateRef glue, GateRef receiver, GateRef oldKind); 635 GateRef TaggedToRepresentation(GateRef value); 636 GateRef TaggedToElementKind(GateRef value); 637 GateRef LdGlobalRecord(GateRef glue, GateRef key); 638 GateRef LoadFromField(GateRef receiver, GateRef handlerInfo); 639 GateRef LoadGlobal(GateRef cell); 640 GateRef LoadElement(GateRef glue, GateRef receiver, GateRef key); 641 GateRef LoadStringElement(GateRef glue, GateRef receiver, GateRef key); 642 GateRef TryToElementsIndex(GateRef glue, GateRef key); 643 GateRef CheckPolyHClass(GateRef cachedValue, GateRef hClass); 644 GateRef LoadICWithHandler( 645 GateRef glue, GateRef receiver, GateRef holder, GateRef handler, ProfileOperation callback); 646 GateRef StoreICWithHandler(GateRef glue, GateRef receiver, GateRef holder, 647 GateRef value, GateRef handler, ProfileOperation callback = ProfileOperation()); 648 GateRef ICStoreElement(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef handlerInfo, 649 bool updateHandler = false, GateRef profileTypeInfo = Gate::InvalidGateRef, 650 GateRef slotId = Gate::InvalidGateRef); 651 GateRef GetArrayLength(GateRef object); 652 GateRef DoubleToInt(GateRef glue, GateRef x, size_t bits = base::INT32_BITS); 653 void SetArrayLength(GateRef glue, GateRef object, GateRef len); 654 GateRef StoreField(GateRef glue, GateRef receiver, GateRef value, GateRef handler, ProfileOperation callback); 655 GateRef StoreWithTransition(GateRef glue, GateRef receiver, GateRef value, GateRef handler, 656 ProfileOperation callback, bool withPrototype = false); 657 GateRef StoreGlobal(GateRef glue, GateRef value, GateRef cell); 658 void JSHClassAddProperty(GateRef glue, GateRef receiver, GateRef key, GateRef attr, GateRef value); 659 void NotifyHClassChanged(GateRef glue, GateRef oldHClass, GateRef newHClass); 660 GateRef GetInt64OfTInt(GateRef x); 661 GateRef GetInt32OfTInt(GateRef x); 662 GateRef GetDoubleOfTInt(GateRef x); 663 GateRef GetDoubleOfTDouble(GateRef x); 664 GateRef GetInt32OfTNumber(GateRef x); 665 GateRef GetDoubleOfTNumber(GateRef x); 666 GateRef LoadObjectFromWeakRef(GateRef x); 667 GateRef ExtFloat32ToDouble(GateRef x); 668 GateRef ChangeInt32ToFloat32(GateRef x); 669 GateRef ChangeInt32ToFloat64(GateRef x); 670 GateRef ChangeUInt32ToFloat64(GateRef x); 671 GateRef ChangeFloat64ToInt32(GateRef x); 672 GateRef TruncDoubleToFloat32(GateRef x); 673 GateRef DeletePropertyOrThrow(GateRef glue, GateRef obj, GateRef value); 674 inline GateRef ToObject(GateRef glue, GateRef obj); 675 GateRef DeleteProperty(GateRef glue, GateRef obj, GateRef value); 676 inline GateRef OrdinaryNewJSObjectCreate(GateRef glue, GateRef proto); 677 inline GateRef NewJSPrimitiveRef(GateRef glue, size_t index, GateRef obj); 678 GateRef ModuleNamespaceDeleteProperty(GateRef glue, GateRef obj, GateRef value); 679 GateRef Int64ToTaggedPtr(GateRef x); 680 GateRef TruncInt16ToInt8(GateRef x); 681 GateRef TruncInt32ToInt16(GateRef x); 682 GateRef TruncInt32ToInt8(GateRef x); 683 GateRef TruncFloatToInt64(GateRef x); 684 GateRef CastInt32ToFloat32(GateRef x); 685 GateRef CastInt64ToFloat64(GateRef x); 686 GateRef SExtInt32ToInt64(GateRef x); 687 GateRef SExtInt16ToInt64(GateRef x); 688 GateRef SExtInt16ToInt32(GateRef x); 689 GateRef SExtInt8ToInt64(GateRef x); 690 GateRef SExtInt8ToInt32(GateRef x); 691 GateRef SExtInt1ToInt64(GateRef x); 692 GateRef SExtInt1ToInt32(GateRef x); 693 GateRef ZExtInt8ToInt16(GateRef x); 694 GateRef ZExtInt32ToInt64(GateRef x); 695 GateRef ZExtInt1ToInt64(GateRef x); 696 GateRef ZExtInt1ToInt32(GateRef x); 697 GateRef ZExtInt8ToInt32(GateRef x); 698 GateRef ZExtInt8ToInt64(GateRef x); 699 GateRef ZExtInt8ToPtr(GateRef x); 700 GateRef ZExtInt16ToPtr(GateRef x); 701 GateRef SExtInt32ToPtr(GateRef x); 702 GateRef ZExtInt16ToInt32(GateRef x); 703 GateRef ZExtInt16ToInt64(GateRef x); 704 GateRef TruncInt64ToInt32(GateRef x); 705 GateRef TruncPtrToInt32(GateRef x); 706 GateRef TruncInt64ToInt1(GateRef x); 707 GateRef TruncInt32ToInt1(GateRef x); 708 GateRef GetGlobalConstantAddr(GateRef index); 709 GateRef GetGlobalConstantOffset(ConstantIndex index); 710 GateRef IsCallableFromBitField(GateRef bitfield); 711 GateRef IsCallable(GateRef obj); 712 GateRef GetOffsetFieldInPropAttr(GateRef attr); 713 GateRef SetOffsetFieldInPropAttr(GateRef attr, GateRef value); 714 GateRef SetIsInlinePropsFieldInPropAttr(GateRef attr, GateRef value); 715 GateRef SetTrackTypeInPropAttr(GateRef attr, GateRef type); 716 GateRef GetTrackTypeInPropAttr(GateRef attr); 717 GateRef GetSharedFieldTypeInPropAttr(GateRef attr); 718 GateRef GetDictSharedFieldTypeInPropAttr(GateRef attr); 719 GateRef GetRepInPropAttr(GateRef attr); 720 GateRef IsIntRepInPropAttr(GateRef attr); 721 GateRef IsDoubleRepInPropAttr(GateRef attr); 722 GateRef IsTaggedRepInPropAttr(GateRef attr); 723 GateRef SetTaggedRepInPropAttr(GateRef attr); 724 template<class T> 725 void SetHClassBit(GateRef glue, GateRef hClass, GateRef value); 726 template<typename DictionaryT> 727 void UpdateValueInDict(GateRef glue, GateRef elements, GateRef index, GateRef value); 728 GateRef GetBitMask(GateRef bitoffset); 729 GateRef IntPtrEuqal(GateRef x, GateRef y); 730 void SetValueWithAttr(GateRef glue, GateRef obj, GateRef offset, GateRef key, GateRef value, GateRef attr); 731 void SetValueWithRep(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef rep, Label *repChange); 732 void SetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, bool withEden = false, 733 MemoryAttribute::ShareFlag share = MemoryAttribute::UNKNOWN); 734 GateRef GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, 735 ProfileOperation callback, GateRef hir = Circuit::NullGate()); 736 GateRef GetPropertyByName(GateRef glue, GateRef receiver, GateRef key, 737 ProfileOperation callback, GateRef isInternal, bool canUseIsInternal = false); 738 GateRef FastGetPropertyByName(GateRef glue, GateRef obj, GateRef key, ProfileOperation callback); 739 GateRef FastGetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, 740 ProfileOperation callback, GateRef hir = Circuit::NullGate()); 741 GateRef GetPropertyByValue(GateRef glue, GateRef receiver, GateRef keyValue, ProfileOperation callback); 742 void FastSetPropertyByName(GateRef glue, GateRef obj, GateRef key, GateRef value, 743 ProfileOperation callback = ProfileOperation()); 744 void FastSetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, GateRef value); 745 GateRef SetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, 746 GateRef value, bool useOwn, ProfileOperation callback = ProfileOperation(), bool defineSemantics = false); 747 GateRef DefinePropertyByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value); 748 GateRef SetPropertyByName(GateRef glue, GateRef receiver, GateRef key, 749 GateRef value, bool useOwn, GateRef isInternal, ProfileOperation callback = ProfileOperation(), 750 bool canUseIsInternal = false, bool defineSemantics = false); // Crawl prototype chain 751 GateRef DefinePropertyByName(GateRef glue, GateRef receiver, GateRef key, 752 GateRef value, GateRef isInternal, GateRef SCheckModelIsCHECK, 753 ProfileOperation callback = ProfileOperation()); 754 GateRef SetPropertyByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, bool useOwn, 755 ProfileOperation callback = ProfileOperation(), bool defineSemantics = false); 756 GateRef DefinePropertyByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, 757 GateRef SCheckModelIsCHECK, ProfileOperation callback = ProfileOperation()); 758 GateRef GetParentEnv(GateRef object); 759 GateRef GetSendableParentEnv(GateRef object); 760 GateRef GetPropertiesFromLexicalEnv(GateRef object, GateRef index); 761 GateRef GetPropertiesFromSendableEnv(GateRef object, GateRef index); 762 GateRef GetKeyFromLexivalEnv(GateRef lexicalEnv, GateRef levelIndex, GateRef slotIndex); 763 void SetPropertiesToLexicalEnv(GateRef glue, GateRef object, GateRef index, GateRef value); 764 void SetPropertiesToSendableEnv(GateRef glue, GateRef object, GateRef index, GateRef value); 765 GateRef GetHomeObjectFromJSFunction(GateRef object); 766 GateRef GetCallFieldFromMethod(GateRef method); 767 GateRef GetSendableEnvFromModule(GateRef module); 768 GateRef IsSendableFunctionModule(GateRef module); 769 inline GateRef GetBuiltinId(GateRef method); 770 void SetLexicalEnvToFunction(GateRef glue, GateRef object, GateRef lexicalEnv, 771 MemoryAttribute mAttr = MemoryAttribute::Default()); 772 void SetProtoTransRootHClassToFunction(GateRef glue, GateRef object, GateRef hclass, 773 MemoryAttribute mAttr = MemoryAttribute::Default()); 774 void SetProtoOrHClassToFunction(GateRef glue, GateRef function, GateRef value, 775 MemoryAttribute mAttr = MemoryAttribute::Default()); 776 void SetWorkNodePointerToFunction(GateRef glue, GateRef function, GateRef value, 777 MemoryAttribute mAttr = MemoryAttribute::Default()); 778 void SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value, 779 MemoryAttribute mAttr = MemoryAttribute::Default()); 780 void SetModuleToFunction(GateRef glue, GateRef function, GateRef value, 781 MemoryAttribute mAttr = MemoryAttribute::Default()); 782 void SetMethodToFunction(GateRef glue, GateRef function, GateRef value, 783 MemoryAttribute mAttr = MemoryAttribute::Default()); 784 void SetCodeEntryToFunction(GateRef glue, GateRef function, GateRef value); 785 void SetCompiledCodeFlagToFunctionFromMethod(GateRef glue, GateRef function, GateRef value); 786 void SetLengthToFunction(GateRef glue, GateRef function, GateRef value); 787 void SetRawProfileTypeInfoToFunction(GateRef glue, GateRef function, GateRef value, 788 MemoryAttribute mAttr = MemoryAttribute::Default()); 789 void SetValueToProfileTypeInfoCell(GateRef glue, GateRef profileTypeInfoCell, GateRef value); 790 void UpdateProfileTypeInfoCellType(GateRef glue, GateRef profileTypeInfoCell); 791 void SetJSObjectTaggedField(GateRef glue, GateRef object, size_t offset, GateRef value); 792 void SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value, 793 MemoryAttribute mAttr = MemoryAttribute::Default()); 794 void SetCompiledCodeFlagToFunction(GateRef glue, GateRef function, GateRef value); 795 void SetTaskConcurrentFuncFlagToFunction(GateRef glue, GateRef function, GateRef value); 796 void SetBitFieldToFunction(GateRef glue, GateRef function, GateRef value); 797 void SetMachineCodeToFunction(GateRef glue, GateRef function, GateRef value, 798 MemoryAttribute mAttr = MemoryAttribute::Default()); 799 GateRef GetGlobalObject(GateRef glue); 800 GateRef GetMethodFromFunction(GateRef function); 801 GateRef GetModuleFromFunction(GateRef function); 802 GateRef GetLengthFromFunction(GateRef function); 803 GateRef GetHomeObjectFromFunction(GateRef function); 804 GateRef GetEntryIndexOfGlobalDictionary(GateRef entry); 805 GateRef GetBoxFromGlobalDictionary(GateRef object, GateRef entry); 806 GateRef GetValueFromGlobalDictionary(GateRef object, GateRef entry); 807 GateRef GetPropertiesFromJSObject(GateRef object); 808 template<OpCode Op, MachineType Type> 809 GateRef BinaryOp(GateRef x, GateRef y); 810 template<OpCode Op, MachineType Type> 811 GateRef BinaryOpWithOverflow(GateRef x, GateRef y); 812 GateRef GetGlobalOwnProperty(GateRef glue, GateRef receiver, GateRef key, ProfileOperation callback); 813 GateRef AddElementInternal(GateRef glue, GateRef receiver, GateRef index, GateRef value, GateRef attr); 814 GateRef ShouldTransToDict(GateRef capcity, GateRef index); 815 void NotifyStableArrayElementsGuardians(GateRef glue, GateRef receiver); 816 GateRef GrowElementsCapacity(GateRef glue, GateRef receiver, GateRef capacity); 817 818 inline GateRef GetObjectFromConstPool(GateRef constpool, GateRef index); 819 GateRef GetConstPoolFromFunction(GateRef jsFunc); 820 GateRef GetStringFromConstPool(GateRef glue, GateRef constpool, GateRef index); 821 GateRef GetMethodFromConstPool(GateRef glue, GateRef constpool, GateRef index); 822 GateRef GetArrayLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module); 823 GateRef GetObjectLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module); 824 void SetElementsKindToJSHClass(GateRef glue, GateRef jsHclass, GateRef elementsKind); 825 void SetExtensibleToBitfield(GateRef glue, GateRef obj, bool isExtensible); 826 void SetCallableToBitfield(GateRef glue, GateRef obj, bool isCallable); 827 828 // fast path 829 GateRef FastEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 830 GateRef FastStrictEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 831 GateRef FastStringEqual(GateRef glue, GateRef left, GateRef right); 832 GateRef FastMod(GateRef gule, GateRef left, GateRef right, ProfileOperation callback); 833 GateRef FastTypeOf(GateRef left, GateRef right); 834 GateRef FastMul(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 835 GateRef FastDiv(GateRef left, GateRef right, ProfileOperation callback); 836 GateRef FastAdd(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 837 GateRef FastSub(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 838 GateRef FastToBoolean(GateRef value, bool flag = true); 839 GateRef FastToBooleanWithProfile(GateRef value, ProfileOperation callback, bool flag = true); 840 GateRef FastToBooleanWithProfileBaseline(GateRef value, ProfileOperation callback, bool flag = true); 841 842 // Add SpecialContainer 843 GateRef GetContainerProperty(GateRef glue, GateRef receiver, GateRef index, GateRef jsType); 844 GateRef JSAPIContainerGet(GateRef glue, GateRef receiver, GateRef index); 845 846 // for-in 847 GateRef NextInternal(GateRef glue, GateRef iter); 848 GateRef GetLengthFromForInIterator(GateRef iter); 849 GateRef GetIndexFromForInIterator(GateRef iter); 850 GateRef GetKeysFromForInIterator(GateRef iter); 851 GateRef GetObjectFromForInIterator(GateRef iter); 852 GateRef GetCachedHclassFromForInIterator(GateRef iter); 853 void SetLengthOfForInIterator(GateRef glue, GateRef iter, GateRef length); 854 void SetIndexOfForInIterator(GateRef glue, GateRef iter, GateRef index); 855 void SetKeysOfForInIterator(GateRef glue, GateRef iter, GateRef keys); 856 void SetObjectOfForInIterator(GateRef glue, GateRef iter, GateRef object); 857 void SetCachedHclassOfForInIterator(GateRef glue, GateRef iter, GateRef hclass); 858 void IncreaseInteratorIndex(GateRef glue, GateRef iter, GateRef index); 859 void SetNextIndexOfArrayIterator(GateRef glue, GateRef iter, GateRef nextIndex); 860 void SetIteratedArrayOfArrayIterator(GateRef glue, GateRef iter, GateRef iteratedArray); 861 void SetBitFieldOfArrayIterator(GateRef glue, GateRef iter, GateRef kind); 862 GateRef GetEnumCacheKind(GateRef glue, GateRef enumCache); 863 GateRef GetEmptyArray(GateRef glue); 864 GateRef IsEnumCacheValid(GateRef receiver, GateRef cachedHclass, GateRef kind); 865 GateRef NeedCheckProperty(GateRef receiver); 866 867 GateRef EnumerateObjectProperties(GateRef glue, GateRef obj); 868 GateRef GetFunctionPrototype(GateRef glue, size_t index); 869 GateRef ToPrototypeOrObj(GateRef glue, GateRef obj); 870 GateRef IsSpecialKeysObject(GateRef obj); 871 GateRef IsSlowKeysObject(GateRef obj); 872 GateRef TryGetEnumCache(GateRef glue, GateRef obj); 873 GateRef GetNumberOfElements(GateRef obj); 874 GateRef IsSimpleEnumCacheValid(GateRef obj); 875 GateRef IsEnumCacheWithProtoChainInfoValid(GateRef obj); 876 877 // Exception handle 878 GateRef HasPendingException(GateRef glue); 879 void ReturnExceptionIfAbruptCompletion(GateRef glue); 880 881 // ElementsKind Operations 882 GateRef ValueIsSpecialHole(GateRef x); 883 GateRef ElementsKindIsIntOrHoleInt(GateRef kind); 884 GateRef ElementsKindIsNumOrHoleNum(GateRef kind); 885 GateRef ElementsKindIsHeapKind(GateRef kind); 886 void MigrateArrayWithKind(GateRef glue, GateRef object, GateRef oldKind, GateRef newKind); 887 GateRef MigrateFromRawValueToHeapValues(GateRef glue, GateRef object, GateRef needCOW, GateRef isIntKind); 888 GateRef MigrateFromHeapValueToRawValue(GateRef glue, GateRef object, GateRef needCOW, GateRef isIntKind); 889 void MigrateFromHoleIntToHoleNumber(GateRef glue, GateRef object); 890 void MigrateFromHoleNumberToHoleInt(GateRef glue, GateRef object); 891 892 // method operator 893 GateRef IsJSFunction(GateRef obj); 894 GateRef IsBoundFunction(GateRef obj); 895 GateRef IsJSOrBoundFunction(GateRef obj); 896 GateRef GetMethodFromJSFunctionOrProxy(GateRef jsfunc); 897 GateRef IsNativeMethod(GateRef method); 898 GateRef GetFuncKind(GateRef method); 899 GateRef HasPrototype(GateRef kind); 900 GateRef HasAccessor(GateRef kind); 901 GateRef IsClassConstructorKind(GateRef kind); 902 GateRef IsGeneratorKind(GateRef kind); 903 GateRef IsBaseKind(GateRef kind); 904 GateRef IsBaseConstructorKind(GateRef kind); 905 GateRef IsSendableFunction(GateRef method); 906 907 GateRef IsAOTLiteralInfo(GateRef info); 908 GateRef GetIhcFromAOTLiteralInfo(GateRef info); 909 GateRef IsAotWithCallField(GateRef method); 910 GateRef IsFastCall(GateRef method); 911 GateRef JudgeAotAndFastCall(GateRef jsFunc, CircuitBuilder::JudgeMethodType type); 912 GateRef GetInternalString(GateRef glue, GateRef key); 913 GateRef GetExpectedNumOfArgs(GateRef method); 914 GateRef GetMethod(GateRef glue, GateRef obj, GateRef key, GateRef profileTypeInfo, GateRef slotId); 915 // proxy operator 916 GateRef GetMethodFromJSProxy(GateRef proxy); 917 GateRef GetHandlerFromJSProxy(GateRef proxy); 918 GateRef GetTargetFromJSProxy(GateRef proxy); 919 inline void SetHotnessCounter(GateRef glue, GateRef method, GateRef value); 920 inline void SaveHotnessCounterIfNeeded(GateRef glue, GateRef sp, GateRef hotnessCounter, JSCallMode mode); 921 inline void SavePcIfNeeded(GateRef glue); 922 inline void SaveJumpSizeIfNeeded(GateRef glue, GateRef jumpSize); 923 inline GateRef ComputeTaggedArraySize(GateRef length); 924 inline GateRef GetGlobalConstantValue( 925 VariableType type, GateRef glue, ConstantIndex index); 926 inline GateRef GetSingleCharTable(GateRef glue); 927 inline GateRef IsEnableElementsKind(GateRef glue); 928 inline GateRef GetGlobalEnvValue(VariableType type, GateRef env, size_t index); 929 GateRef CallGetterHelper(GateRef glue, GateRef receiver, GateRef holder, 930 GateRef accessor, ProfileOperation callback, GateRef hir = Circuit::NullGate()); 931 GateRef ConstructorCheck(GateRef glue, GateRef ctor, GateRef outPut, GateRef thisObj); 932 GateRef GetCallSpreadArgs(GateRef glue, GateRef array, ProfileOperation callBack); 933 GateRef GetIterator(GateRef glue, GateRef obj, ProfileOperation callback); 934 // For BaselineJIT 935 GateRef FastToBooleanBaseline(GateRef value, bool flag = true); 936 GateRef GetBaselineCodeAddr(GateRef baselineCode); 937 938 GateRef IsFastTypeArray(GateRef jsType); 939 GateRef GetTypeArrayPropertyByName(GateRef glue, GateRef receiver, GateRef holder, GateRef key, GateRef jsType); 940 GateRef SetTypeArrayPropertyByName(GateRef glue, GateRef receiver, GateRef holder, GateRef key, GateRef value, 941 GateRef jsType); 942 GateRef TryStringOrSymbolToElementIndex(GateRef glue, GateRef key); 943 inline GateRef DispatchBuiltins(GateRef glue, GateRef builtinsId, const std::vector<GateRef>& args); 944 inline GateRef DispatchBuiltinsWithArgv(GateRef glue, GateRef builtinsId, const std::vector<GateRef>& args); 945 GateRef ComputeSizeUtf8(GateRef length); 946 GateRef ComputeSizeUtf16(GateRef length); 947 GateRef AlignUp(GateRef x, GateRef alignment); 948 inline void SetLength(GateRef glue, GateRef str, GateRef length, bool compressed); 949 inline void SetLength(GateRef glue, GateRef str, GateRef length, GateRef isCompressed); 950 void Assert(int messageId, int line, GateRef glue, GateRef condition, Label *nextLabel); 951 952 GateRef GetNormalStringData(const StringInfoGateRef &stringInfoGate); 953 954 void Comment(GateRef glue, const std::string &str); 955 GateRef ToNumber(GateRef glue, GateRef tagged); 956 inline GateRef LoadPfHeaderFromConstPool(GateRef jsFunc); 957 GateRef RemoveTaggedWeakTag(GateRef weak); 958 inline GateRef LoadHCIndexFromConstPool(GateRef cachedArray, GateRef cachedLength, GateRef traceId, Label *miss); 959 inline GateRef LoadHCIndexInfosFromConstPool(GateRef jsFunc); 960 inline GateRef GetAttrIndex(GateRef index); 961 inline GateRef GetAttr(GateRef layoutInfo, GateRef index); 962 inline GateRef GetKey(GateRef layoutInfo, GateRef index); 963 inline GateRef GetKeyIndex(GateRef index); 964 GateRef CalArrayRelativePos(GateRef index, GateRef arrayLen); 965 GateRef AppendSkipHole(GateRef glue, GateRef first, GateRef second, GateRef copyLength); 966 GateRef IntToEcmaString(GateRef glue, GateRef number); 967 GateRef ToCharCode(GateRef number); 968 GateRef NumberToString(GateRef glue, GateRef number); 969 inline GateRef GetViewedArrayBuffer(GateRef dataView); 970 inline GateRef GetByteOffset(GateRef dataView); 971 inline GateRef GetByteLength(GateRef dataView); 972 inline GateRef GetArrayBufferData(GateRef buffer); 973 GateRef IsDetachedBuffer(GateRef buffer); 974 inline GateRef IsMarkerCellValid(GateRef cell); 975 inline GateRef GetAccessorHasChanged(GateRef obj); 976 inline GateRef ComputeTaggedTypedArraySize(GateRef elementSize, GateRef length); 977 GateRef ChangeTaggedPointerToInt64(GateRef x); 978 inline GateRef GetPropertiesCache(GateRef glue); 979 GateRef GetIndexFromPropertiesCache(GateRef glue, GateRef cache, GateRef cls, GateRef key, 980 GateRef hir = Circuit::NullGate()); 981 inline void SetToPropertiesCache(GateRef glue, GateRef cache, GateRef cls, GateRef key, GateRef result, 982 GateRef hir = Circuit::NullGate()); 983 GateRef HashFromHclassAndKey(GateRef glue, GateRef cls, GateRef key, GateRef hir = Circuit::NullGate()); 984 GateRef GetKeyHashCode(GateRef glue, GateRef key, GateRef hir = Circuit::NullGate()); 985 inline GateRef GetSortedKey(GateRef layoutInfo, GateRef index); 986 inline GateRef GetSortedIndex(GateRef layoutInfo, GateRef index); 987 inline GateRef GetSortedIndex(GateRef attr); 988 inline void StoreWithoutBarrier(VariableType type, GateRef base, GateRef offset, GateRef value); 989 GateRef DefineFunc(GateRef glue, GateRef constpool, GateRef index, 990 FunctionKind targetKind = FunctionKind::LAST_FUNCTION_KIND); 991 GateRef BinarySearch(GateRef glue, GateRef layoutInfo, GateRef key, GateRef propsNum, 992 GateRef hir = Circuit::NullGate()); 993 GateRef GetLastLeaveFrame(GateRef glue); 994 void UpdateProfileTypeInfoCellToFunction(GateRef glue, GateRef function, 995 GateRef profileTypeInfo, GateRef slotId); 996 GateRef Loadlocalmodulevar(GateRef glue, GateRef index, GateRef module); 997 GateRef GetArgumentsElements(GateRef glue, GateRef argvTaggedArray, GateRef argv); 998 999 private: 1000 using BinaryOperation = std::function<GateRef(Environment*, GateRef, GateRef)>; 1001 template<OpCode Op> 1002 GateRef FastAddSubAndMul(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 1003 GateRef FastIntDiv(GateRef left, GateRef right, Label *bailout, ProfileOperation callback); 1004 template<OpCode Op> 1005 GateRef FastBinaryOp(GateRef glue, GateRef left, GateRef right, 1006 const BinaryOperation& intOp, const BinaryOperation& floatOp, ProfileOperation callback); 1007 GateRef TryStringAdd(Environment *env, GateRef glue, GateRef left, GateRef right, 1008 const BinaryOperation& intOp, const BinaryOperation& floatOp, ProfileOperation callback); 1009 GateRef NumberOperation(Environment *env, GateRef left, GateRef right, 1010 const BinaryOperation& intOp, 1011 const BinaryOperation& floatOp, 1012 ProfileOperation callback); 1013 void SetSValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef objectRegion, 1014 GateRef valueRegion); 1015 1016 void SetNonSValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef objectRegion, 1017 GateRef valueRegion, bool withEden); 1018 void InitializeArguments(); 1019 void CheckDetectorName(GateRef glue, GateRef key, Label *fallthrough, Label *slow); 1020 GateRef CanDoubleRepresentInt(GateRef exp, GateRef expBits, GateRef fractionBits); 1021 GateRef CalIteratorKey(GateRef glue); 1022 1023 CallSignature *callSignature_ {nullptr}; 1024 Environment *env_; 1025 }; 1026 } // namespace panda::ecmascript::kungfu 1027 #endif // ECMASCRIPT_COMPILER_STUB_BUILDER_H 1028