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 TaggedIsInternalAccessor(GateRef x); 270 GateRef ObjectAddressToRange(GateRef x); 271 GateRef RegionInSpace(GateRef region, RegionSpaceFlag space); 272 GateRef RegionInSpace(GateRef region, RegionSpaceFlag spaceBegin, RegionSpaceFlag spaceEnd); 273 GateRef InEdenGeneration(GateRef region); 274 GateRef InYoungGeneration(GateRef region); 275 GateRef InGeneralYoungGeneration(GateRef region); 276 GateRef InGeneralOldGeneration(GateRef region); 277 GateRef InSharedHeap(GateRef region); 278 GateRef InSharedSweepableSpace(GateRef region); 279 GateRef TaggedIsGeneratorObject(GateRef x); 280 GateRef TaggedIsJSArray(GateRef x); 281 GateRef IsTaggedArray(GateRef x); 282 GateRef TaggedIsAsyncGeneratorObject(GateRef x); 283 GateRef TaggedIsJSGlobalObject(GateRef x); 284 GateRef TaggedIsWeak(GateRef x); 285 GateRef TaggedIsPrototypeHandler(GateRef x); 286 GateRef TaggedIsStoreTSHandler(GateRef x); 287 GateRef TaggedIsTransWithProtoHandler(GateRef x); 288 GateRef TaggedIsTransitionHandler(GateRef x); 289 GateRef TaggedIsString(GateRef obj); 290 GateRef TaggedIsStringIterator(GateRef obj); 291 GateRef TaggedIsSharedObj(GateRef obj); 292 GateRef BothAreString(GateRef x, GateRef y); 293 GateRef TaggedIsStringOrSymbol(GateRef obj); 294 GateRef TaggedIsSymbol(GateRef obj); 295 GateRef TaggedIsProtoChangeMarker(GateRef obj); 296 GateRef GetNextPositionForHash(GateRef last, GateRef count, GateRef size); 297 GateRef DoubleIsNAN(GateRef x); 298 GateRef DoubleIsINF(GateRef x); 299 GateRef DoubleIsNanOrInf(GateRef x); 300 GateRef DoubleAbs(GateRef x); 301 GateRef DoubleIsInteger(GateRef x); 302 GateRef DoubleTrunc(GateRef x); 303 GateRef TaggedIsNull(GateRef x); 304 GateRef TaggedIsUndefinedOrNull(GateRef x); 305 GateRef TaggedIsUndefinedOrNullOrHole(GateRef x); 306 GateRef TaggedIsTrue(GateRef x); 307 GateRef TaggedIsFalse(GateRef x); 308 GateRef TaggedIsBoolean(GateRef x); 309 GateRef TaggedGetInt(GateRef x); 310 GateRef NumberGetInt(GateRef glue, GateRef x); 311 GateRef TaggedGetNumber(GateRef x); 312 GateRef Int8ToTaggedInt(GateRef x); 313 GateRef Int16ToTaggedInt(GateRef x); 314 GateRef IntToTaggedPtr(GateRef x); 315 GateRef IntToTaggedInt(GateRef x); 316 GateRef Int64ToTaggedInt(GateRef x); 317 GateRef Int64ToTaggedIntPtr(GateRef x); 318 GateRef DoubleToTaggedDoublePtr(GateRef x); 319 GateRef BooleanToTaggedBooleanPtr(GateRef x); 320 GateRef TaggedPtrToTaggedDoublePtr(GateRef x); 321 GateRef TaggedPtrToTaggedIntPtr(GateRef x); 322 GateRef CastDoubleToInt64(GateRef x); 323 GateRef CastFloat32ToInt32(GateRef x); 324 GateRef TaggedTrue(); 325 GateRef TaggedFalse(); 326 GateRef TaggedUndefined(); 327 // compare operation 328 GateRef Int8Equal(GateRef x, GateRef y); 329 GateRef Int8GreaterThanOrEqual(GateRef x, GateRef y); 330 GateRef Equal(GateRef x, GateRef y); 331 GateRef NotEqual(GateRef x, GateRef y); 332 GateRef Int32Equal(GateRef x, GateRef y); 333 GateRef Int32NotEqual(GateRef x, GateRef y); 334 GateRef Int64Equal(GateRef x, GateRef y); 335 GateRef DoubleEqual(GateRef x, GateRef y); 336 GateRef DoubleNotEqual(GateRef x, GateRef y); 337 GateRef Int64NotEqual(GateRef x, GateRef y); 338 GateRef DoubleLessThan(GateRef x, GateRef y); 339 GateRef DoubleLessThanOrEqual(GateRef x, GateRef y); 340 GateRef DoubleGreaterThan(GateRef x, GateRef y); 341 GateRef DoubleGreaterThanOrEqual(GateRef x, GateRef y); 342 GateRef Int32GreaterThan(GateRef x, GateRef y); 343 GateRef Int32LessThan(GateRef x, GateRef y); 344 GateRef Int32GreaterThanOrEqual(GateRef x, GateRef y); 345 GateRef Int32LessThanOrEqual(GateRef x, GateRef y); 346 GateRef Int32UnsignedGreaterThan(GateRef x, GateRef y); 347 GateRef Int32UnsignedLessThan(GateRef x, GateRef y); 348 GateRef Int32UnsignedGreaterThanOrEqual(GateRef x, GateRef y); 349 GateRef Int32UnsignedLessThanOrEqual(GateRef x, GateRef y); 350 GateRef Int64GreaterThan(GateRef x, GateRef y); 351 GateRef Int64LessThan(GateRef x, GateRef y); 352 GateRef Int64LessThanOrEqual(GateRef x, GateRef y); 353 GateRef Int64GreaterThanOrEqual(GateRef x, GateRef y); 354 GateRef Int64UnsignedLessThanOrEqual(GateRef x, GateRef y); 355 GateRef Int64UnsignedGreaterThan(GateRef x, GateRef y); 356 GateRef Int64UnsignedGreaterThanOrEqual(GateRef x, GateRef y); 357 GateRef IntPtrGreaterThan(GateRef x, GateRef y); 358 // cast operation 359 GateRef ChangeInt64ToIntPtr(GateRef val); 360 GateRef ZExtInt32ToPtr(GateRef val); 361 GateRef ChangeIntPtrToInt32(GateRef val); 362 GateRef ToLength(GateRef glue, GateRef target); 363 364 // math operation 365 GateRef Sqrt(GateRef x); 366 GateRef GetSetterFromAccessor(GateRef accessor); 367 GateRef GetElementsArray(GateRef object); 368 void SetElementsArray(VariableType type, GateRef glue, GateRef object, GateRef elementsArray, 369 MemoryAttribute mAttr = MemoryAttribute::Default()); 370 GateRef GetPropertiesArray(GateRef object); 371 // SetProperties in js_object.h 372 void SetPropertiesArray(VariableType type, GateRef glue, GateRef object, GateRef propsArray, 373 MemoryAttribute mAttr = MemoryAttribute::Default()); 374 GateRef GetHash(GateRef object); 375 void SetHash(GateRef glue, GateRef object, GateRef hash); 376 GateRef GetLengthOfTaggedArray(GateRef array); 377 GateRef GetLengthOfJSTypedArray(GateRef array); 378 GateRef GetExtraLengthOfTaggedArray(GateRef array); 379 void SetExtraLengthOfTaggedArray(GateRef glue, GateRef array, GateRef len); 380 // object operation 381 GateRef IsJSHClass(GateRef obj); 382 GateRef LoadHClass(GateRef object); 383 void CanNotConvertNotValidObject(GateRef obj); 384 void IsNotPropertyKey(GateRef obj); 385 GateRef CreateDataProperty(GateRef glue, GateRef obj, GateRef proKey, GateRef value); 386 GateRef CreateDataPropertyOrThrow(GateRef glue, GateRef onj, GateRef proKey, GateRef value); 387 GateRef DefineField(GateRef glue, GateRef obj, GateRef proKey, GateRef value); 388 void StoreHClass(GateRef glue, GateRef object, GateRef hClass); 389 void StoreHClassWithoutBarrier(GateRef glue, GateRef object, GateRef hClass); 390 void StoreBuiltinHClass(GateRef glue, GateRef object, GateRef hClass); 391 void StorePrototype(GateRef glue, GateRef hclass, GateRef prototype); 392 void CopyAllHClass(GateRef glue, GateRef dstHClass, GateRef scrHClass); 393 GateRef GetObjectType(GateRef hClass); 394 GateRef IsDictionaryMode(GateRef object); 395 GateRef IsDictionaryModeByHClass(GateRef hClass); 396 GateRef IsDictionaryElement(GateRef hClass); 397 GateRef IsStableElements(GateRef hClass); 398 GateRef HasConstructorByHClass(GateRef hClass); 399 GateRef HasConstructor(GateRef object); 400 GateRef IsClassConstructorFromBitField(GateRef bitfield); 401 GateRef IsClassConstructor(GateRef object); 402 GateRef IsClassPrototype(GateRef object); 403 GateRef IsExtensible(GateRef object); 404 GateRef TaggedObjectIsEcmaObject(GateRef obj); 405 GateRef IsEcmaObject(GateRef obj); 406 GateRef IsDataView(GateRef obj); 407 GateRef IsSymbol(GateRef obj); 408 GateRef IsString(GateRef obj); 409 GateRef IsLineString(GateRef obj); 410 GateRef IsSlicedString(GateRef obj); 411 GateRef IsConstantString(GateRef obj); 412 GateRef IsLiteralString(GateRef obj); 413 GateRef IsTreeString(GateRef obj); 414 GateRef TreeStringIsFlat(GateRef string); 415 GateRef TaggedIsBigInt(GateRef obj); 416 GateRef TaggedIsPropertyBox(GateRef obj); 417 GateRef TaggedObjectIsBigInt(GateRef obj); 418 GateRef IsJsProxy(GateRef obj); 419 GateRef IsJSShared(GateRef obj); 420 GateRef IsProfileTypeInfoCell0(GateRef obj); 421 GateRef IsJSGlobalObject(GateRef obj); 422 GateRef IsNativeModuleFailureInfo(GateRef obj); 423 GateRef IsModuleNamespace(GateRef obj); 424 GateRef IsNativePointer(GateRef obj); 425 GateRef IsSourceTextModule(GateRef obj); 426 GateRef ObjIsSpecialContainer(GateRef obj); 427 GateRef IsJSPrimitiveRef(GateRef obj); 428 GateRef IsJSFunctionBase(GateRef obj); 429 GateRef IsConstructor(GateRef object); 430 GateRef IsBase(GateRef func); 431 GateRef IsDerived(GateRef func); 432 GateRef IsJsArray(GateRef obj); 433 GateRef IsJsSArray(GateRef obj); 434 GateRef IsByteArray(GateRef obj); 435 GateRef IsJsCOWArray(GateRef obj); 436 GateRef IsMutantTaggedArray(GateRef elements); 437 GateRef IsJSObject(GateRef obj); 438 GateRef IsEnumerable(GateRef attr); 439 GateRef IsWritable(GateRef attr); 440 GateRef IsConfigable(GateRef attr); 441 GateRef IsDefaultAttribute(GateRef attr); 442 GateRef IsArrayLengthWritable(GateRef glue, GateRef receiver); 443 GateRef IsAccessor(GateRef attr); 444 GateRef IsInlinedProperty(GateRef attr); 445 GateRef IsField(GateRef attr); 446 GateRef IsNonSharedStoreField(GateRef attr); 447 GateRef IsStoreShared(GateRef attr); 448 GateRef IsElement(GateRef attr); 449 GateRef IsStringElement(GateRef attr); 450 GateRef IsNumber(GateRef attr); 451 GateRef IsStringLength(GateRef attr); 452 GateRef IsTypedArrayElement(GateRef attr); 453 GateRef IsNonExist(GateRef attr); 454 GateRef IsJSAPIVector(GateRef attr); 455 GateRef IsJSAPIStack(GateRef obj); 456 GateRef IsJSAPIPlainArray(GateRef obj); 457 GateRef IsJSAPIQueue(GateRef obj); 458 GateRef IsJSAPIDeque(GateRef obj); 459 GateRef IsJSAPILightWeightMap(GateRef obj); 460 GateRef IsJSAPILightWeightSet(GateRef obj); 461 GateRef IsLinkedNode(GateRef obj); 462 GateRef IsJSAPIHashMap(GateRef obj); 463 GateRef IsJSAPIHashSet(GateRef obj); 464 GateRef IsJSAPILinkedList(GateRef obj); 465 GateRef IsJSAPIList(GateRef obj); 466 GateRef IsJSAPIArrayList(GateRef obj); 467 GateRef IsJSObjectType(GateRef obj, JSType jsType); 468 GateRef IsJSRegExp(GateRef obj); 469 GateRef GetTarget(GateRef proxyObj); 470 GateRef HandlerBaseIsAccessor(GateRef attr); 471 GateRef HandlerBaseIsJSArray(GateRef attr); 472 GateRef HandlerBaseIsInlinedProperty(GateRef attr); 473 GateRef HandlerBaseGetOffset(GateRef attr); 474 GateRef HandlerBaseGetAttrIndex(GateRef attr); 475 GateRef HandlerBaseGetRep(GateRef attr); 476 GateRef IsInvalidPropertyBox(GateRef obj); 477 GateRef IsAccessorPropertyBox(GateRef obj); 478 GateRef GetValueFromPropertyBox(GateRef obj); 479 void SetValueToPropertyBox(GateRef glue, GateRef obj, GateRef value); 480 GateRef GetTransitionHClass(GateRef obj); 481 GateRef GetTransitionHandlerInfo(GateRef obj); 482 GateRef GetTransWithProtoHClass(GateRef obj); 483 GateRef GetTransWithProtoHandlerInfo(GateRef obj); 484 GateRef GetProtoCell(GateRef object); 485 GateRef GetPrototypeHandlerHolder(GateRef object); 486 GateRef GetPrototypeHandlerHandlerInfo(GateRef object); 487 GateRef GetStoreTSHandlerHolder(GateRef object); 488 GateRef GetStoreTSHandlerHandlerInfo(GateRef object); 489 inline GateRef GetPrototype(GateRef glue, GateRef object); 490 GateRef GetHasChanged(GateRef object); 491 GateRef HclassIsPrototypeHandler(GateRef hClass); 492 GateRef HclassIsTransitionHandler(GateRef hClass); 493 GateRef HclassIsPropertyBox(GateRef hClass); 494 GateRef PropAttrGetOffset(GateRef attr); 495 GateRef GetCtorPrototype(GateRef ctor); 496 GateRef InstanceOf(GateRef glue, GateRef object, GateRef target, GateRef profileTypeInfo, GateRef slotId, 497 ProfileOperation callback); 498 GateRef OrdinaryHasInstance(GateRef glue, GateRef target, GateRef obj); 499 void TryFastHasInstance(GateRef glue, GateRef instof, GateRef target, GateRef object, Label *fastPath, 500 Label *exit, Variable *result, ProfileOperation callback); 501 GateRef SameValue(GateRef glue, GateRef left, GateRef right); 502 GateRef SameValueZero(GateRef glue, GateRef left, GateRef right); 503 GateRef HasStableElements(GateRef glue, GateRef obj); 504 GateRef IsStableJSArguments(GateRef glue, GateRef obj); 505 GateRef IsStableJSArray(GateRef glue, GateRef obj); 506 GateRef IsTypedArray(GateRef obj); 507 GateRef IsStableArguments(GateRef hClass); 508 GateRef IsStableArray(GateRef hClass); 509 GateRef GetProfileTypeInfo(GateRef jsFunc); 510 GateRef UpdateProfileTypeInfo(GateRef glue, GateRef jsFunc); 511 // SetDictionaryOrder func in property_attribute.h 512 GateRef SetDictionaryOrderFieldInPropAttr(GateRef attr, GateRef value); 513 GateRef GetPrototypeFromHClass(GateRef hClass); 514 GateRef GetEnumCacheFromHClass(GateRef hClass); 515 GateRef GetProtoChangeMarkerFromHClass(GateRef hClass); 516 GateRef GetLayoutFromHClass(GateRef hClass); 517 GateRef GetBitFieldFromHClass(GateRef hClass); 518 GateRef GetLengthFromString(GateRef value); 519 GateRef CalcHashcodeForInt(GateRef value); 520 void CalcHashcodeForDouble(GateRef value, Variable *res, Label *exit); 521 void CalcHashcodeForObject(GateRef glue, GateRef value, Variable *res, Label *exit); 522 GateRef GetHashcodeFromString(GateRef glue, GateRef value, GateRef hir = Circuit::NullGate()); 523 inline GateRef IsIntegerString(GateRef string); 524 inline void SetRawHashcode(GateRef glue, GateRef str, GateRef rawHashcode, GateRef isInteger); 525 inline GateRef GetRawHashFromString(GateRef value); 526 GateRef TryGetHashcodeFromString(GateRef string); 527 inline GateRef GetMixHashcode(GateRef string); 528 GateRef GetFirstFromTreeString(GateRef string); 529 GateRef GetSecondFromTreeString(GateRef string); 530 GateRef GetIsAllTaggedPropFromHClass(GateRef hclass); 531 void SetBitFieldToHClass(GateRef glue, GateRef hClass, GateRef bitfield); 532 void SetIsAllTaggedProp(GateRef glue, GateRef hclass, GateRef hasRep); 533 void SetPrototypeToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef proto); 534 void SetProtoChangeDetailsToHClass(VariableType type, GateRef glue, GateRef hClass, 535 GateRef protoChange); 536 void SetLayoutToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef attr, 537 MemoryAttribute mAttr = MemoryAttribute::Default()); 538 void SetHClassTypeIDToHClass(GateRef glue, GateRef hClass, GateRef id); 539 void SetEnumCacheToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef key); 540 void SetTransitionsToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef transition); 541 void SetParentToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef parent); 542 void SetIsProtoTypeToHClass(GateRef glue, GateRef hClass, GateRef value); 543 inline void SetIsTS(GateRef glue, GateRef hClass, GateRef value); 544 GateRef IsProtoTypeHClass(GateRef hClass); 545 void SetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass, 546 GateRef value, GateRef attrOffset, VariableType type = VariableType::JS_ANY(), 547 MemoryAttribute mAttr = MemoryAttribute::Default()); 548 GateRef GetPropertyInlinedProps(GateRef obj, GateRef hClass, 549 GateRef index); 550 GateRef GetInlinedPropOffsetFromHClass(GateRef hclass, GateRef attrOffset); 551 552 void IncNumberOfProps(GateRef glue, GateRef hClass); 553 GateRef GetNumberOfPropsFromHClass(GateRef hClass); 554 GateRef HasDeleteProperty(GateRef hClass); 555 GateRef IsTSHClass(GateRef hClass); 556 void SetNumberOfPropsToHClass(GateRef glue, GateRef hClass, GateRef value); 557 void SetElementsKindToTrackInfo(GateRef glue, GateRef trackInfo, GateRef elementsKind); 558 void SetSpaceFlagToTrackInfo(GateRef glue, GateRef trackInfo, GateRef spaceFlag); 559 GateRef GetElementsKindFromHClass(GateRef hClass); 560 GateRef GetObjectSizeFromHClass(GateRef hClass); 561 GateRef GetInlinedPropsStartFromHClass(GateRef hClass); 562 GateRef GetInlinedPropertiesFromHClass(GateRef hClass); 563 void ThrowTypeAndReturn(GateRef glue, int messageId, GateRef val); 564 GateRef GetValueFromTaggedArray(GateRef elements, GateRef index); 565 GateRef GetUnsharedConstpoolIndex(GateRef constpool); 566 GateRef GetUnsharedConstpoolFromGlue(GateRef glue, GateRef constpool); 567 GateRef GetUnsharedConstpool(GateRef array, GateRef index); 568 GateRef GetValueFromMutantTaggedArray(GateRef elements, GateRef index); 569 void CheckUpdateSharedType(bool isDicMode, Variable *result, GateRef glue, GateRef receiver, GateRef attr, 570 GateRef value, Label *executeSetProp, Label *exit); 571 void CheckUpdateSharedType(bool isDicMode, Variable *result, GateRef glue, GateRef receiver, GateRef attr, 572 GateRef value, Label *executeSetProp, Label *exit, GateRef SCheckModelIsCHECK); 573 void MatchFieldType(Variable *result, GateRef glue, GateRef fieldType, GateRef value, Label *executeSetProp, 574 Label *exit); 575 GateRef GetFieldTypeFromHandler(GateRef attr); 576 GateRef ClearSharedStoreKind(GateRef handlerInfo); 577 GateRef UpdateSOutOfBoundsForHandler(GateRef handlerInfo); 578 void RestoreElementsKindToGeneric(GateRef glue, GateRef jsHClass); 579 GateRef GetTaggedValueWithElementsKind(GateRef receiver, GateRef index); 580 void FastSetValueWithElementsKind(GateRef glue, GateRef elements, GateRef rawValue, 581 GateRef index, ElementsKind kind); 582 GateRef SetValueWithElementsKind(GateRef glue, GateRef receiver, GateRef rawValue, GateRef index, 583 GateRef needTransition, GateRef extraKind); 584 GateRef CopyJSArrayToTaggedArrayArgs(GateRef glue, GateRef srcObj); 585 void SetValueToTaggedArrayWithAttr( 586 GateRef glue, GateRef array, GateRef index, GateRef key, GateRef val, GateRef attr); 587 void SetValueToTaggedArrayWithRep( 588 GateRef glue, GateRef array, GateRef index, GateRef val, GateRef rep, Label *repChange); 589 590 void SetValueToTaggedArray(VariableType valType, GateRef glue, GateRef array, GateRef index, GateRef val, 591 MemoryAttribute mAttr = MemoryAttribute::Default()); 592 void UpdateValueAndAttributes(GateRef glue, GateRef elements, GateRef index, GateRef value, GateRef attr); 593 GateRef IsSpecialIndexedObj(GateRef jsType); 594 GateRef IsSpecialContainer(GateRef jsType); 595 GateRef IsSharedArray(GateRef jsType); 596 GateRef IsAccessorInternal(GateRef value); 597 template<typename DictionaryT> 598 GateRef GetAttributesFromDictionary(GateRef elements, GateRef entry); 599 template<typename DictionaryT> 600 GateRef GetValueFromDictionary(GateRef elements, GateRef entry); 601 template<typename DictionaryT> 602 GateRef GetKeyFromDictionary(GateRef elements, GateRef entry); 603 GateRef GetPropAttrFromLayoutInfo(GateRef layout, GateRef entry); 604 void UpdateFieldType(GateRef glue, GateRef hclass, GateRef attr); 605 GateRef GetPropertiesAddrFromLayoutInfo(GateRef layout); 606 GateRef GetPropertyMetaDataFromAttr(GateRef attr); 607 GateRef TranslateToRep(GateRef value); 608 GateRef GetKeyFromLayoutInfo(GateRef layout, GateRef entry); 609 void MatchFieldType(GateRef fieldType, GateRef value, Label *executeSetProp, Label *typeMismatch); 610 GateRef FindElementWithCache(GateRef glue, GateRef layoutInfo, GateRef hClass, 611 GateRef key, GateRef propsNum, GateRef hir = Circuit::NullGate()); 612 GateRef FindElementFromNumberDictionary(GateRef glue, GateRef elements, GateRef index); 613 GateRef FindEntryFromNameDictionary(GateRef glue, GateRef elements, GateRef key, GateRef hir = Circuit::NullGate()); 614 GateRef IsMatchInTransitionDictionary(GateRef element, GateRef key, GateRef metaData, GateRef attr); 615 GateRef FindEntryFromTransitionDictionary(GateRef glue, GateRef elements, GateRef key, GateRef metaData); 616 GateRef JSObjectGetProperty(GateRef obj, GateRef hClass, GateRef propAttr); 617 void JSObjectSetProperty(GateRef glue, GateRef obj, GateRef hClass, GateRef attr, GateRef key, GateRef value); 618 GateRef ShouldCallSetter(GateRef receiver, GateRef holder, GateRef accessor, GateRef attr); 619 GateRef CallSetterHelper(GateRef glue, GateRef holder, GateRef accessor, GateRef value, ProfileOperation callback); 620 GateRef SetHasConstructorCondition(GateRef glue, GateRef receiver, GateRef key); 621 GateRef AddPropertyByName(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef propertyAttributes, 622 ProfileOperation callback); 623 GateRef IsUtf16String(GateRef string); 624 GateRef IsUtf8String(GateRef string); 625 GateRef IsInternalString(GateRef string); 626 GateRef IsDigit(GateRef ch); 627 void TryToGetInteger(GateRef string, Variable *num, Label *success, Label *failed); 628 GateRef StringToElementIndex(GateRef glue, GateRef string); 629 GateRef ComputeElementCapacity(GateRef oldLength); 630 GateRef ComputeNonInlinedFastPropsCapacity(GateRef glue, GateRef oldLength, 631 GateRef maxNonInlinedFastPropsCapacity); 632 GateRef FindTransitions(GateRef glue, GateRef hClass, GateRef key, GateRef attr, GateRef value); 633 GateRef CheckHClassForRep(GateRef hClass, GateRef rep); 634 void TransitionForRepChange(GateRef glue, GateRef receiver, GateRef key, GateRef attr); 635 void TransitToElementsKind(GateRef glue, GateRef receiver, GateRef value, GateRef kind); 636 void TryMigrateToGenericKindForJSObject(GateRef glue, GateRef receiver, GateRef oldKind); 637 GateRef TaggedToRepresentation(GateRef value); 638 GateRef TaggedToElementKind(GateRef value); 639 GateRef LdGlobalRecord(GateRef glue, GateRef key); 640 GateRef LoadFromField(GateRef receiver, GateRef handlerInfo); 641 GateRef LoadGlobal(GateRef cell); 642 GateRef LoadElement(GateRef glue, GateRef receiver, GateRef key); 643 GateRef LoadStringElement(GateRef glue, GateRef receiver, GateRef key); 644 GateRef TryToElementsIndex(GateRef glue, GateRef key); 645 GateRef CheckPolyHClass(GateRef cachedValue, GateRef hClass); 646 GateRef LoadICWithHandler( 647 GateRef glue, GateRef receiver, GateRef holder, GateRef handler, ProfileOperation callback); 648 GateRef StoreICWithHandler(GateRef glue, GateRef receiver, GateRef holder, 649 GateRef value, GateRef handler, ProfileOperation callback = ProfileOperation()); 650 GateRef ICStoreElement(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef handlerInfo, 651 bool updateHandler = false, GateRef profileTypeInfo = Gate::InvalidGateRef, 652 GateRef slotId = Gate::InvalidGateRef); 653 GateRef GetArrayLength(GateRef object); 654 GateRef DoubleToInt(GateRef glue, GateRef x, size_t bits = base::INT32_BITS); 655 void SetArrayLength(GateRef glue, GateRef object, GateRef len); 656 GateRef StoreField(GateRef glue, GateRef receiver, GateRef value, GateRef handler, ProfileOperation callback); 657 GateRef StoreWithTransition(GateRef glue, GateRef receiver, GateRef value, GateRef handler, 658 ProfileOperation callback, bool withPrototype = false); 659 GateRef StoreGlobal(GateRef glue, GateRef value, GateRef cell); 660 void JSHClassAddProperty(GateRef glue, GateRef receiver, GateRef key, GateRef attr, GateRef value); 661 void NotifyHClassChanged(GateRef glue, GateRef oldHClass, GateRef newHClass); 662 GateRef GetInt64OfTInt(GateRef x); 663 GateRef GetInt32OfTInt(GateRef x); 664 GateRef GetDoubleOfTInt(GateRef x); 665 GateRef GetDoubleOfTDouble(GateRef x); 666 GateRef GetInt32OfTNumber(GateRef x); 667 GateRef GetDoubleOfTNumber(GateRef x); 668 GateRef LoadObjectFromWeakRef(GateRef x); 669 GateRef ExtFloat32ToDouble(GateRef x); 670 GateRef ChangeInt32ToFloat32(GateRef x); 671 GateRef ChangeInt32ToFloat64(GateRef x); 672 GateRef ChangeUInt32ToFloat64(GateRef x); 673 GateRef ChangeFloat64ToInt32(GateRef x); 674 GateRef TruncDoubleToFloat32(GateRef x); 675 GateRef DeletePropertyOrThrow(GateRef glue, GateRef obj, GateRef value); 676 inline GateRef ToObject(GateRef glue, GateRef obj); 677 GateRef DeleteProperty(GateRef glue, GateRef obj, GateRef value); 678 inline GateRef OrdinaryNewJSObjectCreate(GateRef glue, GateRef proto); 679 inline GateRef NewJSPrimitiveRef(GateRef glue, size_t index, GateRef obj); 680 GateRef ModuleNamespaceDeleteProperty(GateRef glue, GateRef obj, GateRef value); 681 GateRef Int64ToTaggedPtr(GateRef x); 682 GateRef TruncInt16ToInt8(GateRef x); 683 GateRef TruncInt32ToInt16(GateRef x); 684 GateRef TruncInt32ToInt8(GateRef x); 685 GateRef TruncFloatToInt64(GateRef x); 686 GateRef CastInt32ToFloat32(GateRef x); 687 GateRef CastInt64ToFloat64(GateRef x); 688 GateRef SExtInt32ToInt64(GateRef x); 689 GateRef SExtInt16ToInt64(GateRef x); 690 GateRef SExtInt16ToInt32(GateRef x); 691 GateRef SExtInt8ToInt64(GateRef x); 692 GateRef SExtInt8ToInt32(GateRef x); 693 GateRef SExtInt1ToInt64(GateRef x); 694 GateRef SExtInt1ToInt32(GateRef x); 695 GateRef ZExtInt8ToInt16(GateRef x); 696 GateRef ZExtInt32ToInt64(GateRef x); 697 GateRef ZExtInt1ToInt64(GateRef x); 698 GateRef ZExtInt1ToInt32(GateRef x); 699 GateRef ZExtInt8ToInt32(GateRef x); 700 GateRef ZExtInt8ToInt64(GateRef x); 701 GateRef ZExtInt8ToPtr(GateRef x); 702 GateRef ZExtInt16ToPtr(GateRef x); 703 GateRef SExtInt32ToPtr(GateRef x); 704 GateRef ZExtInt16ToInt32(GateRef x); 705 GateRef ZExtInt16ToInt64(GateRef x); 706 GateRef TruncInt64ToInt32(GateRef x); 707 GateRef TruncPtrToInt32(GateRef x); 708 GateRef TruncInt64ToInt1(GateRef x); 709 GateRef TruncInt32ToInt1(GateRef x); 710 GateRef GetGlobalConstantAddr(GateRef index); 711 GateRef GetGlobalConstantOffset(ConstantIndex index); 712 GateRef IsCallableFromBitField(GateRef bitfield); 713 GateRef IsCallable(GateRef obj); 714 GateRef GetOffsetFieldInPropAttr(GateRef attr); 715 GateRef SetOffsetFieldInPropAttr(GateRef attr, GateRef value); 716 GateRef SetIsInlinePropsFieldInPropAttr(GateRef attr, GateRef value); 717 GateRef SetTrackTypeInPropAttr(GateRef attr, GateRef type); 718 GateRef GetTrackTypeInPropAttr(GateRef attr); 719 GateRef GetSharedFieldTypeInPropAttr(GateRef attr); 720 GateRef GetDictSharedFieldTypeInPropAttr(GateRef attr); 721 GateRef GetRepInPropAttr(GateRef attr); 722 GateRef IsIntRepInPropAttr(GateRef attr); 723 GateRef IsDoubleRepInPropAttr(GateRef attr); 724 GateRef IsTaggedRepInPropAttr(GateRef attr); 725 GateRef SetTaggedRepInPropAttr(GateRef attr); 726 template<class T> 727 void SetHClassBit(GateRef glue, GateRef hClass, GateRef value); 728 template<typename DictionaryT> 729 void UpdateValueInDict(GateRef glue, GateRef elements, GateRef index, GateRef value); 730 GateRef GetBitMask(GateRef bitoffset); 731 GateRef IntPtrEuqal(GateRef x, GateRef y); 732 void SetValueWithAttr(GateRef glue, GateRef obj, GateRef offset, GateRef key, GateRef value, GateRef attr); 733 void SetValueWithRep(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef rep, Label *repChange); 734 void SetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, bool withEden = false, 735 MemoryAttribute::ShareFlag share = MemoryAttribute::UNKNOWN); 736 GateRef GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, 737 ProfileOperation callback, GateRef hir = Circuit::NullGate()); 738 GateRef GetPropertyByName(GateRef glue, GateRef receiver, GateRef key, 739 ProfileOperation callback, GateRef isInternal, bool canUseIsInternal = false); 740 GateRef FastGetPropertyByName(GateRef glue, GateRef obj, GateRef key, ProfileOperation callback); 741 GateRef FastGetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, 742 ProfileOperation callback, GateRef hir = Circuit::NullGate()); 743 GateRef GetPropertyByValue(GateRef glue, GateRef receiver, GateRef keyValue, ProfileOperation callback); 744 void FastSetPropertyByName(GateRef glue, GateRef obj, GateRef key, GateRef value, 745 ProfileOperation callback = ProfileOperation()); 746 void FastSetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, GateRef value); 747 GateRef SetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, 748 GateRef value, bool useOwn, ProfileOperation callback = ProfileOperation(), bool defineSemantics = false); 749 GateRef DefinePropertyByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value); 750 GateRef SetPropertyByName(GateRef glue, GateRef receiver, GateRef key, 751 GateRef value, bool useOwn, GateRef isInternal, ProfileOperation callback = ProfileOperation(), 752 bool canUseIsInternal = false, bool defineSemantics = false); // Crawl prototype chain 753 GateRef DefinePropertyByName(GateRef glue, GateRef receiver, GateRef key, 754 GateRef value, GateRef isInternal, GateRef SCheckModelIsCHECK, 755 ProfileOperation callback = ProfileOperation()); 756 GateRef SetPropertyByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, bool useOwn, 757 ProfileOperation callback = ProfileOperation(), bool defineSemantics = false); 758 GateRef DefinePropertyByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, 759 GateRef SCheckModelIsCHECK, ProfileOperation callback = ProfileOperation()); 760 GateRef GetParentEnv(GateRef object); 761 GateRef GetSendableParentEnv(GateRef object); 762 GateRef GetPropertiesFromLexicalEnv(GateRef object, GateRef index); 763 GateRef GetPropertiesFromSendableEnv(GateRef object, GateRef index); 764 GateRef GetKeyFromLexivalEnv(GateRef lexicalEnv, GateRef levelIndex, GateRef slotIndex); 765 void SetPropertiesToLexicalEnv(GateRef glue, GateRef object, GateRef index, GateRef value); 766 void SetPropertiesToSendableEnv(GateRef glue, GateRef object, GateRef index, GateRef value); 767 GateRef GetHomeObjectFromJSFunction(GateRef object); 768 GateRef GetCallFieldFromMethod(GateRef method); 769 GateRef GetSendableEnvFromModule(GateRef module); 770 GateRef IsSendableFunctionModule(GateRef module); 771 inline GateRef GetBuiltinId(GateRef method); 772 void SetLexicalEnvToFunction(GateRef glue, GateRef object, GateRef lexicalEnv, 773 MemoryAttribute mAttr = MemoryAttribute::Default()); 774 void SetProtoTransRootHClassToFunction(GateRef glue, GateRef object, GateRef hclass, 775 MemoryAttribute mAttr = MemoryAttribute::Default()); 776 void SetProtoOrHClassToFunction(GateRef glue, GateRef function, GateRef value, 777 MemoryAttribute mAttr = MemoryAttribute::Default()); 778 void SetWorkNodePointerToFunction(GateRef glue, GateRef function, GateRef value, 779 MemoryAttribute mAttr = MemoryAttribute::Default()); 780 void SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value, 781 MemoryAttribute mAttr = MemoryAttribute::Default()); 782 void SetModuleToFunction(GateRef glue, GateRef function, GateRef value, 783 MemoryAttribute mAttr = MemoryAttribute::Default()); 784 void SetMethodToFunction(GateRef glue, GateRef function, GateRef value, 785 MemoryAttribute mAttr = MemoryAttribute::Default()); 786 void SetCodeEntryToFunction(GateRef glue, GateRef function, GateRef value); 787 void SetCompiledCodeFlagToFunctionFromMethod(GateRef glue, GateRef function, GateRef value); 788 void SetLengthToFunction(GateRef glue, GateRef function, GateRef value); 789 void SetRawProfileTypeInfoToFunction(GateRef glue, GateRef function, GateRef value, 790 MemoryAttribute mAttr = MemoryAttribute::Default()); 791 void SetValueToProfileTypeInfoCell(GateRef glue, GateRef profileTypeInfoCell, GateRef value); 792 void UpdateProfileTypeInfoCellType(GateRef glue, GateRef profileTypeInfoCell); 793 void SetJSObjectTaggedField(GateRef glue, GateRef object, size_t offset, GateRef value); 794 void SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value, 795 MemoryAttribute mAttr = MemoryAttribute::Default()); 796 void SetCompiledCodeFlagToFunction(GateRef glue, GateRef function, GateRef value); 797 void SetTaskConcurrentFuncFlagToFunction(GateRef glue, GateRef function, GateRef value); 798 void SetBitFieldToFunction(GateRef glue, GateRef function, GateRef value); 799 void SetMachineCodeToFunction(GateRef glue, GateRef function, GateRef value, 800 MemoryAttribute mAttr = MemoryAttribute::Default()); 801 GateRef GetGlobalObject(GateRef glue); 802 GateRef GetMethodFromFunction(GateRef function); 803 GateRef GetModuleFromFunction(GateRef function); 804 GateRef GetLengthFromFunction(GateRef function); 805 GateRef GetHomeObjectFromFunction(GateRef function); 806 GateRef GetEntryIndexOfGlobalDictionary(GateRef entry); 807 GateRef GetBoxFromGlobalDictionary(GateRef object, GateRef entry); 808 GateRef GetValueFromGlobalDictionary(GateRef object, GateRef entry); 809 GateRef GetPropertiesFromJSObject(GateRef object); 810 template<OpCode Op, MachineType Type> 811 GateRef BinaryOp(GateRef x, GateRef y); 812 template<OpCode Op, MachineType Type> 813 GateRef BinaryOpWithOverflow(GateRef x, GateRef y); 814 GateRef GetGlobalOwnProperty(GateRef glue, GateRef receiver, GateRef key, ProfileOperation callback); 815 GateRef AddElementInternal(GateRef glue, GateRef receiver, GateRef index, GateRef value, GateRef attr); 816 GateRef ShouldTransToDict(GateRef capcity, GateRef index); 817 void NotifyStableArrayElementsGuardians(GateRef glue, GateRef receiver); 818 GateRef GrowElementsCapacity(GateRef glue, GateRef receiver, GateRef capacity); 819 820 inline GateRef GetObjectFromConstPool(GateRef constpool, GateRef index); 821 GateRef GetConstPoolFromFunction(GateRef jsFunc); 822 GateRef GetStringFromConstPool(GateRef glue, GateRef constpool, GateRef index); 823 GateRef GetMethodFromConstPool(GateRef glue, GateRef constpool, GateRef index); 824 GateRef GetArrayLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module); 825 GateRef GetObjectLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module); 826 void SetElementsKindToJSHClass(GateRef glue, GateRef jsHclass, GateRef elementsKind); 827 void SetExtensibleToBitfield(GateRef glue, GateRef obj, bool isExtensible); 828 void SetCallableToBitfield(GateRef glue, GateRef obj, bool isCallable); 829 830 // fast path 831 GateRef FastEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 832 GateRef FastStrictEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 833 GateRef FastStringEqual(GateRef glue, GateRef left, GateRef right); 834 GateRef FastMod(GateRef gule, GateRef left, GateRef right, ProfileOperation callback); 835 GateRef FastTypeOf(GateRef left, GateRef right); 836 GateRef FastMul(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 837 GateRef FastDiv(GateRef left, GateRef right, ProfileOperation callback); 838 GateRef FastAdd(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 839 GateRef FastSub(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 840 GateRef FastToBoolean(GateRef value, bool flag = true); 841 GateRef FastToBooleanWithProfile(GateRef value, ProfileOperation callback, bool flag = true); 842 GateRef FastToBooleanWithProfileBaseline(GateRef value, ProfileOperation callback, bool flag = true); 843 844 // Add SpecialContainer 845 GateRef GetContainerProperty(GateRef glue, GateRef receiver, GateRef index, GateRef jsType); 846 GateRef JSAPIContainerGet(GateRef glue, GateRef receiver, GateRef index); 847 848 // for-in 849 GateRef NextInternal(GateRef glue, GateRef iter); 850 GateRef GetLengthFromForInIterator(GateRef iter); 851 GateRef GetIndexFromForInIterator(GateRef iter); 852 GateRef GetKeysFromForInIterator(GateRef iter); 853 GateRef GetObjectFromForInIterator(GateRef iter); 854 GateRef GetCachedHclassFromForInIterator(GateRef iter); 855 void SetLengthOfForInIterator(GateRef glue, GateRef iter, GateRef length); 856 void SetIndexOfForInIterator(GateRef glue, GateRef iter, GateRef index); 857 void SetKeysOfForInIterator(GateRef glue, GateRef iter, GateRef keys); 858 void SetObjectOfForInIterator(GateRef glue, GateRef iter, GateRef object); 859 void SetCachedHclassOfForInIterator(GateRef glue, GateRef iter, GateRef hclass); 860 void IncreaseInteratorIndex(GateRef glue, GateRef iter, GateRef index); 861 void SetNextIndexOfArrayIterator(GateRef glue, GateRef iter, GateRef nextIndex); 862 void SetIteratedArrayOfArrayIterator(GateRef glue, GateRef iter, GateRef iteratedArray); 863 void SetBitFieldOfArrayIterator(GateRef glue, GateRef iter, GateRef kind); 864 GateRef GetEnumCacheKind(GateRef glue, GateRef enumCache); 865 GateRef GetEmptyArray(GateRef glue); 866 GateRef IsEnumCacheValid(GateRef receiver, GateRef cachedHclass, GateRef kind); 867 GateRef NeedCheckProperty(GateRef receiver); 868 869 GateRef EnumerateObjectProperties(GateRef glue, GateRef obj); 870 GateRef GetFunctionPrototype(GateRef glue, size_t index); 871 GateRef ToPrototypeOrObj(GateRef glue, GateRef obj); 872 GateRef IsSpecialKeysObject(GateRef obj); 873 GateRef IsSlowKeysObject(GateRef obj); 874 GateRef TryGetEnumCache(GateRef glue, GateRef obj); 875 GateRef GetNumberOfElements(GateRef obj); 876 GateRef IsSimpleEnumCacheValid(GateRef obj); 877 GateRef IsEnumCacheWithProtoChainInfoValid(GateRef obj); 878 879 // Exception handle 880 GateRef HasPendingException(GateRef glue); 881 void ReturnExceptionIfAbruptCompletion(GateRef glue); 882 883 // ElementsKind Operations 884 GateRef ValueIsSpecialHole(GateRef x); 885 GateRef ElementsKindIsIntOrHoleInt(GateRef kind); 886 GateRef ElementsKindIsNumOrHoleNum(GateRef kind); 887 GateRef ElementsKindIsHeapKind(GateRef kind); 888 void MigrateArrayWithKind(GateRef glue, GateRef object, GateRef oldKind, GateRef newKind); 889 GateRef MigrateFromRawValueToHeapValues(GateRef glue, GateRef object, GateRef needCOW, GateRef isIntKind); 890 GateRef MigrateFromHeapValueToRawValue(GateRef glue, GateRef object, GateRef needCOW, GateRef isIntKind); 891 void MigrateFromHoleIntToHoleNumber(GateRef glue, GateRef object); 892 void MigrateFromHoleNumberToHoleInt(GateRef glue, GateRef object); 893 894 // method operator 895 GateRef IsJSFunction(GateRef obj); 896 GateRef IsBoundFunction(GateRef obj); 897 GateRef IsJSOrBoundFunction(GateRef obj); 898 GateRef GetMethodFromJSFunctionOrProxy(GateRef jsfunc); 899 GateRef IsNativeMethod(GateRef method); 900 GateRef GetFuncKind(GateRef method); 901 GateRef HasPrototype(GateRef kind); 902 GateRef HasAccessor(GateRef kind); 903 GateRef IsClassConstructorKind(GateRef kind); 904 GateRef IsGeneratorKind(GateRef kind); 905 GateRef IsBaseKind(GateRef kind); 906 GateRef IsBaseConstructorKind(GateRef kind); 907 GateRef IsSendableFunction(GateRef method); 908 909 GateRef IsAOTLiteralInfo(GateRef info); 910 GateRef GetIhcFromAOTLiteralInfo(GateRef info); 911 GateRef IsAotWithCallField(GateRef method); 912 GateRef IsFastCall(GateRef method); 913 GateRef JudgeAotAndFastCall(GateRef jsFunc, CircuitBuilder::JudgeMethodType type); 914 GateRef GetInternalString(GateRef glue, GateRef key); 915 GateRef GetExpectedNumOfArgs(GateRef method); 916 GateRef GetMethod(GateRef glue, GateRef obj, GateRef key, GateRef profileTypeInfo, GateRef slotId); 917 // proxy operator 918 GateRef GetMethodFromJSProxy(GateRef proxy); 919 GateRef GetHandlerFromJSProxy(GateRef proxy); 920 GateRef GetTargetFromJSProxy(GateRef proxy); 921 inline void SetHotnessCounter(GateRef glue, GateRef method, GateRef value); 922 inline void SaveHotnessCounterIfNeeded(GateRef glue, GateRef sp, GateRef hotnessCounter, JSCallMode mode); 923 inline void SavePcIfNeeded(GateRef glue); 924 inline void SaveJumpSizeIfNeeded(GateRef glue, GateRef jumpSize); 925 inline GateRef ComputeTaggedArraySize(GateRef length); 926 inline GateRef GetGlobalConstantValue( 927 VariableType type, GateRef glue, ConstantIndex index); 928 inline GateRef GetSingleCharTable(GateRef glue); 929 inline GateRef IsEnableElementsKind(GateRef glue); 930 inline GateRef GetGlobalEnvValue(VariableType type, GateRef env, size_t index); 931 GateRef CallGetterHelper(GateRef glue, GateRef receiver, GateRef holder, 932 GateRef accessor, ProfileOperation callback, GateRef hir = Circuit::NullGate()); 933 GateRef ConstructorCheck(GateRef glue, GateRef ctor, GateRef outPut, GateRef thisObj); 934 GateRef GetCallSpreadArgs(GateRef glue, GateRef array, ProfileOperation callBack); 935 GateRef GetIterator(GateRef glue, GateRef obj, ProfileOperation callback); 936 // For BaselineJIT 937 GateRef FastToBooleanBaseline(GateRef value, bool flag = true); 938 GateRef GetBaselineCodeAddr(GateRef baselineCode); 939 940 GateRef IsFastTypeArray(GateRef jsType); 941 GateRef GetTypeArrayPropertyByName(GateRef glue, GateRef receiver, GateRef holder, GateRef key, GateRef jsType); 942 GateRef SetTypeArrayPropertyByName(GateRef glue, GateRef receiver, GateRef holder, GateRef key, GateRef value, 943 GateRef jsType); 944 GateRef TryStringOrSymbolToElementIndex(GateRef glue, GateRef key); 945 inline GateRef DispatchBuiltins(GateRef glue, GateRef builtinsId, const std::vector<GateRef>& args); 946 inline GateRef DispatchBuiltinsWithArgv(GateRef glue, GateRef builtinsId, const std::vector<GateRef>& args); 947 GateRef ComputeSizeUtf8(GateRef length); 948 GateRef ComputeSizeUtf16(GateRef length); 949 GateRef AlignUp(GateRef x, GateRef alignment); 950 inline void SetLength(GateRef glue, GateRef str, GateRef length, bool compressed); 951 inline void SetLength(GateRef glue, GateRef str, GateRef length, GateRef isCompressed); 952 void Assert(int messageId, int line, GateRef glue, GateRef condition, Label *nextLabel); 953 954 GateRef GetNormalStringData(const StringInfoGateRef &stringInfoGate); 955 956 void Comment(GateRef glue, const std::string &str); 957 GateRef ToNumber(GateRef glue, GateRef tagged); 958 inline GateRef LoadPfHeaderFromConstPool(GateRef jsFunc); 959 GateRef RemoveTaggedWeakTag(GateRef weak); 960 inline GateRef LoadHCIndexFromConstPool(GateRef cachedArray, GateRef cachedLength, GateRef traceId, Label *miss); 961 inline GateRef LoadHCIndexInfosFromConstPool(GateRef jsFunc); 962 inline GateRef GetAttrIndex(GateRef index); 963 inline GateRef GetAttr(GateRef layoutInfo, GateRef index); 964 inline GateRef GetKey(GateRef layoutInfo, GateRef index); 965 inline GateRef GetKeyIndex(GateRef index); 966 GateRef CalArrayRelativePos(GateRef index, GateRef arrayLen); 967 GateRef AppendSkipHole(GateRef glue, GateRef first, GateRef second, GateRef copyLength); 968 GateRef IntToEcmaString(GateRef glue, GateRef number); 969 GateRef ToCharCode(GateRef number); 970 GateRef NumberToString(GateRef glue, GateRef number); 971 inline GateRef GetAccGetter(GateRef accesstor); 972 inline GateRef GetAccSetter(GateRef accesstor); 973 inline GateRef GetViewedArrayBuffer(GateRef dataView); 974 inline GateRef GetByteOffset(GateRef dataView); 975 inline GateRef GetByteLength(GateRef dataView); 976 inline GateRef GetArrayBufferData(GateRef buffer); 977 GateRef IsDetachedBuffer(GateRef buffer); 978 inline GateRef IsMarkerCellValid(GateRef cell); 979 inline GateRef GetAccessorHasChanged(GateRef obj); 980 inline GateRef ComputeTaggedTypedArraySize(GateRef elementSize, GateRef length); 981 GateRef ChangeTaggedPointerToInt64(GateRef x); 982 inline GateRef GetPropertiesCache(GateRef glue); 983 GateRef GetIndexFromPropertiesCache(GateRef glue, GateRef cache, GateRef cls, GateRef key, 984 GateRef hir = Circuit::NullGate()); 985 inline void SetToPropertiesCache(GateRef glue, GateRef cache, GateRef cls, GateRef key, GateRef result, 986 GateRef hir = Circuit::NullGate()); 987 GateRef HashFromHclassAndKey(GateRef glue, GateRef cls, GateRef key, GateRef hir = Circuit::NullGate()); 988 GateRef GetKeyHashCode(GateRef glue, GateRef key, GateRef hir = Circuit::NullGate()); 989 inline GateRef GetSortedKey(GateRef layoutInfo, GateRef index); 990 inline GateRef GetSortedIndex(GateRef layoutInfo, GateRef index); 991 inline GateRef GetSortedIndex(GateRef attr); 992 inline void StoreWithoutBarrier(VariableType type, GateRef base, GateRef offset, GateRef value); 993 GateRef DefineFunc(GateRef glue, GateRef constpool, GateRef index, 994 FunctionKind targetKind = FunctionKind::LAST_FUNCTION_KIND); 995 GateRef BinarySearch(GateRef glue, GateRef layoutInfo, GateRef key, GateRef propsNum, 996 GateRef hir = Circuit::NullGate()); 997 GateRef GetLastLeaveFrame(GateRef glue); 998 void UpdateProfileTypeInfoCellToFunction(GateRef glue, GateRef function, 999 GateRef profileTypeInfo, GateRef slotId); 1000 GateRef Loadlocalmodulevar(GateRef glue, GateRef index, GateRef module); 1001 GateRef GetArgumentsElements(GateRef glue, GateRef argvTaggedArray, GateRef argv); 1002 1003 private: 1004 using BinaryOperation = std::function<GateRef(Environment*, GateRef, GateRef)>; 1005 template<OpCode Op> 1006 GateRef FastAddSubAndMul(GateRef glue, GateRef left, GateRef right, ProfileOperation callback); 1007 GateRef FastIntDiv(GateRef left, GateRef right, Label *bailout, ProfileOperation callback); 1008 template<OpCode Op> 1009 GateRef FastBinaryOp(GateRef glue, GateRef left, GateRef right, 1010 const BinaryOperation& intOp, const BinaryOperation& floatOp, ProfileOperation callback); 1011 GateRef TryStringAdd(Environment *env, GateRef glue, GateRef left, GateRef right, 1012 const BinaryOperation& intOp, const BinaryOperation& floatOp, ProfileOperation callback); 1013 GateRef NumberOperation(Environment *env, GateRef left, GateRef right, 1014 const BinaryOperation& intOp, 1015 const BinaryOperation& floatOp, 1016 ProfileOperation callback); 1017 void SetSValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef objectRegion, 1018 GateRef valueRegion); 1019 1020 void SetNonSValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef objectRegion, 1021 GateRef valueRegion, bool withEden); 1022 void InitializeArguments(); 1023 void CheckDetectorName(GateRef glue, GateRef key, Label *fallthrough, Label *slow); 1024 GateRef CanDoubleRepresentInt(GateRef exp, GateRef expBits, GateRef fractionBits); 1025 GateRef CalIteratorKey(GateRef glue); 1026 1027 CallSignature *callSignature_ {nullptr}; 1028 Environment *env_; 1029 }; 1030 } // namespace panda::ecmascript::kungfu 1031 #endif // ECMASCRIPT_COMPILER_STUB_BUILDER_H 1032