1 /* 2 * Copyright (c) 2021-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_JS_HCLASS_H 17 #define ECMASCRIPT_JS_HCLASS_H 18 19 #include "ecmascript/ecma_macros.h" 20 #include "ecmascript/elements.h" 21 #include "ecmascript/js_tagged_value.h" 22 #include "ecmascript/mem/tagged_object.h" 23 #include "ecmascript/mem/barriers.h" 24 #include "ecmascript/mem/slots.h" 25 #include "ecmascript/mem/visitor.h" 26 #include "ecmascript/property_attributes.h" 27 28 #include "libpandabase/utils/bit_field.h" 29 30 /* 31 * JS Object and JS HClass Layout 32 * 33 * Properties JS Object JS HClass 34 * +------------+ +------------+ +------------------+ 35 * |arrayHClass + <---------| |JS HClass +-------------->| meta hclass | 36 * +------------+ | +------------+ +------------------+ 37 * | property 0 | | |Hash | | hclass level | 38 * +------------+ | +------------+ +------------------+ 39 * | property 1 | |------- |Properties | | supers[] | 40 * +------------+ +------------+ +------------------+ 41 * |... | |------- |Elements | | vtable[] | 42 * +------------+ | +------------+ +------------------+ 43 * | |inl-prop-0 | | prototype | 44 * Elements | +------------+ +------------------+ 45 * +------------+ | |inl-prop-1 | | layout | 46 * |arrayHClass + <---------| +------------+ +------------------+ 47 * +------------+ |... | | transitions | 48 * | value 0 | +------------+ +------------------+ 49 * +------------+ | parent | 50 * | value 1 | +------------------+ 51 * +------------+ |ProtoChangeMarker | 52 * |... | +------------------+ 53 * +------------+ | EnumCache | 54 * +------------------+ 55 * 56 * Proto: [[Prototype]] in Ecma spec 57 * Layout: record key and attr 58 * ProtoChangeMarker, ProtoChangeDetails: monitor [[prototype]] chain 59 * EnumCache: use for for-in syntax 60 * 61 */ 62 namespace panda::ecmascript { 63 class ProtoChangeDetails; 64 class PropertyLookupResult; 65 namespace pgo { 66 class HClassLayoutDesc; 67 class PGOHClassTreeDesc; 68 } // namespace pgo 69 using HClassLayoutDesc = pgo::HClassLayoutDesc; 70 using PGOHClassTreeDesc = pgo::PGOHClassTreeDesc; 71 72 struct Reference; 73 74 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 75 #define JSTYPE_DECL /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 76 INVALID = 0, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 77 JS_OBJECT, /* JS_OBJECT_FIRST ////////////////////////////////////////////////////////////////////// */ \ 78 JS_SHARED_OBJECT, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 79 JS_REALM, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 80 JS_FUNCTION_BASE, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 81 JS_FUNCTION, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 82 JS_SHARED_FUNCTION, /* /////////////////////////////////////////////////////////////////-PADDING */ \ 83 JS_PROXY_REVOC_FUNCTION, /* /////////////////////////////////////////////////////////////////-PADDING */ \ 84 JS_PROMISE_REACTIONS_FUNCTION, /* /////////////////////////////////////////////////////////////////-PADDING */ \ 85 JS_PROMISE_EXECUTOR_FUNCTION, /* /////////////////////////////////////////////////////////////////-PADDING */ \ 86 JS_ASYNC_MODULE_FULFILLED_FUNCTION, /* ////////////////////////////////////////////////////////////-PADDING */ \ 87 JS_ASYNC_MODULE_REJECTED_FUNCTION, /* /////////////////////////////////////////////////////////////-PADDING */ \ 88 JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION, /* //////////////////////////////////////////////////////-PADDING */ \ 89 JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION, /* //////////////////////////////////////////////////////-PADDING */ \ 90 JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN, /* ///////////////////////////////////////-PADDING */ \ 91 JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION, /* ///////////////////////////////////////////////////////-PADDING */ \ 92 JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION, /* //////////////////////////////////////////////////////-PADDING */ \ 93 JS_PROMISE_FINALLY_FUNCTION, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 94 JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION, /* ///////////////////////////////////////////////////-PADDING */ \ 95 JS_GENERATOR_FUNCTION, /* /////////////////////////////////////////////////////////////////////////-PADDING */ \ 96 JS_ASYNC_GENERATOR_FUNCTION, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 97 JS_ASYNC_FUNCTION, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 98 JS_INTL_BOUND_FUNCTION, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 99 JS_ASYNC_AWAIT_STATUS_FUNCTION, /* ////////////////////////////////////////////////////////////////-PADDING */ \ 100 JS_BOUND_FUNCTION, /* //////////////////////////////////////////////////////////////////////////////////// */ \ 101 \ 102 JS_ERROR, /* JS_ERROR_FIRST /////////////////////////////////////////////////////////////-PADDING */ \ 103 JS_EVAL_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 104 JS_RANGE_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 105 JS_REFERENCE_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 106 JS_TYPE_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 107 JS_AGGREGATE_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 108 JS_URI_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 109 JS_SYNTAX_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 110 JS_OOM_ERROR, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 111 JS_TERMINATION_ERROR, /* JS_ERROR_LAST ///////////////////////////////////////////////////////////////////// */\ 112 \ 113 JS_REG_EXP, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 114 JS_SET, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 115 JS_MAP, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 116 JS_WEAK_MAP, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 117 JS_WEAK_SET, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 118 JS_WEAK_REF, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 119 JS_FINALIZATION_REGISTRY, /* //////////////////////////////////////////////////////////////////////-PADDING */ \ 120 JS_DATE, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 121 JS_ITERATOR, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 122 JS_ASYNCITERATOR, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 123 JS_ASYNC_FROM_SYNC_ITERATOR, /* ///////////////////////////////////////////////////////////////////-PADDING */ \ 124 JS_FORIN_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 125 JS_MAP_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 126 JS_SET_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 127 JS_REG_EXP_ITERATOR, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 128 JS_API_ARRAYLIST_ITERATOR, /* /////////////////////////////////////////////////////////////////////-PADDING */ \ 129 JS_API_DEQUE_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 130 JS_API_HASHMAP_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 131 JS_API_HASHSET_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 132 JS_API_LIGHT_WEIGHT_MAP_ITERATOR, /* //////////////////////////////////////////////////////////////-PADDING */ \ 133 JS_API_LIGHT_WEIGHT_SET_ITERATOR, /* /////////////////////////////////////////////////////////////-PADDING */ \ 134 JS_API_PLAIN_ARRAY_ITERATOR, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 135 JS_API_QUEUE_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 136 JS_API_STACK_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 137 JS_API_TREEMAP_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 138 JS_API_TREESET_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 139 JS_API_VECTOR_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 140 JS_API_LINKED_LIST_ITERATOR, /* ///////////////////////////////////////////////////////////////////-PADDING */ \ 141 JS_API_LIST_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 142 JS_ARRAY_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 143 JS_STRING_ITERATOR, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 144 JS_INTL, /* ///////////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 145 JS_LOCALE, /* /////////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 146 JS_DATE_TIME_FORMAT, /* ///////////////////////////////////////////////////////////////////////////-PADDING */ \ 147 JS_RELATIVE_TIME_FORMAT, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 148 JS_NUMBER_FORMAT, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 149 JS_COLLATOR, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 150 JS_PLURAL_RULES, /* ///////////////////////////////////////////////////////////////////////////////-PADDING */ \ 151 JS_DISPLAYNAMES, /* ///////////////////////////////////////////////////////////////////////////////-PADDING */ \ 152 JS_LIST_FORMAT, /* ///////////////////////////////////////////////////////////////////////////////-PADDING */ \ 153 \ 154 JS_ARRAY_BUFFER, /* ///////////////////////////////////////////////////////////////////////////////-PADDING */ \ 155 JS_SHARED_ARRAY_BUFFER, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 156 JS_PROMISE, /* ///////////////////////////////////////////////////////////////////////////////-PADDING */ \ 157 JS_DATA_VIEW, /* /////////////////////////////////////////////////////////////////////////////////////// */ \ 158 JS_ARGUMENTS, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 159 JS_GENERATOR_OBJECT, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 160 JS_ASYNC_GENERATOR_OBJECT, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 161 JS_ASYNC_FUNC_OBJECT, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 162 \ 163 /* SPECIAL indexed objects begin, DON'T CHANGE HERE ///////////////////////////////////////////////-PADDING */ \ 164 JS_ARRAY, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 165 JS_API_ARRAY_LIST, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 166 JS_API_LIGHT_WEIGHT_MAP, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 167 JS_API_LIGHT_WEIGHT_SET, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 168 JS_API_VECTOR, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 169 JS_API_LINKED_LIST, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 170 JS_API_LIST, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 171 JS_API_HASH_MAP, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 172 JS_API_HASH_SET, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 173 JS_API_TREE_MAP, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 174 JS_API_TREE_SET, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 175 JS_API_DEQUE, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 176 JS_API_STACK, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 177 JS_API_PLAIN_ARRAY, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 178 JS_API_QUEUE, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 179 JS_TYPED_ARRAY, /* JS_TYPED_ARRAY_FIRST /////////////////////////////////////////////////////////////////// */ \ 180 JS_INT8_ARRAY, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 181 JS_UINT8_ARRAY, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 182 JS_UINT8_CLAMPED_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 183 JS_INT16_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 184 JS_UINT16_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 185 JS_INT32_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 186 JS_UINT32_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 187 JS_FLOAT32_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 188 JS_FLOAT64_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 189 JS_BIGINT64_ARRAY, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 190 JS_BIGUINT64_ARRAY, /* JS_TYPED_ARRAY_LAST ///////////////////////////////////////////////////////////// */\ 191 JS_PRIMITIVE_REF, /* number\boolean\string. SPECIAL indexed objects end, DON'T CHANGE HERE ////////-PADDING */ \ 192 JS_MODULE_NAMESPACE, /* ///////////////////////////////////////////////////////////////////////////-PADDING */ \ 193 JS_CJS_MODULE, /* /////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 194 JS_CJS_EXPORTS, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 195 JS_CJS_REQUIRE, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 196 JS_GLOBAL_OBJECT, /* JS_OBJECT_LAST/////////////////////////////////////////////////////////////////-PADDING */\ 197 JS_PROXY, /* ECMA_OBJECT_LAST ////////////////////////////////////////////////////////////////////////////// */\ 198 \ 199 HCLASS, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 200 LINE_STRING, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */\ 201 CONSTANT_STRING, /* ///////////////////////////////////////////////////////////////////////////////-PADDING */\ 202 SLICED_STRING, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 203 TREE_STRING, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 204 BIGINT, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 205 TAGGED_ARRAY, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 206 MUTANT_TAGGED_ARRAY, /* ///////////////////////////////////////////////////////////////////////////-PADDING */ \ 207 BYTE_ARRAY, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 208 LEXICAL_ENV, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 209 TAGGED_DICTIONARY, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 210 CONSTANT_POOL, /* /////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 211 PROFILE_TYPE_INFO, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 212 COW_MUTANT_TAGGED_ARRAY, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 213 COW_TAGGED_ARRAY, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 214 LINKED_NODE, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 215 RB_TREENODE, /* //////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 216 FREE_OBJECT_WITH_ONE_FIELD, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 217 FREE_OBJECT_WITH_NONE_FIELD, /* ///////////////////////////////////////////////////////////////////-PADDING */ \ 218 FREE_OBJECT_WITH_TWO_FIELD, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 219 JS_NATIVE_POINTER, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 220 GLOBAL_ENV, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 221 ACCESSOR_DATA, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 222 INTERNAL_ACCESSOR, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 223 SYMBOL, /* ////////////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 224 JS_GENERATOR_CONTEXT, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 225 PROTOTYPE_HANDLER, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 226 TRANSITION_HANDLER, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 227 TRANS_WITH_PROTO_HANDLER, /* ///////////////////////////////////////////////////////////////////-PADDING */ \ 228 STORE_TS_HANDLER, /* ////////////////////////////////////////////////////////////////////////-PADDING */ \ 229 PROPERTY_BOX, /* /////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 230 PROTO_CHANGE_MARKER, /* ///////////////////////////////////////////////////////////////////////////-PADDING */ \ 231 MARKER_CELL, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 232 TRACK_INFO, /* ///////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 233 PROTOTYPE_INFO, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 234 TEMPLATE_MAP, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 235 PROGRAM, /* /////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 236 METHOD, /* ////////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 237 CLASS_LITERAL, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 238 \ 239 PROMISE_CAPABILITY, /* JS_RECORD_FIRST //////////////////////////////////////////////////////////////////// */ \ 240 PROMISE_RECORD, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 241 RESOLVING_FUNCTIONS_RECORD, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 242 PROMISE_REACTIONS, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 243 ASYNC_GENERATOR_REQUEST, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 244 ASYNC_ITERATOR_RECORD, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 245 PROMISE_ITERATOR_RECORD, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 246 MICRO_JOB_QUEUE, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 247 PENDING_JOB, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 248 MODULE_RECORD, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 249 SOURCE_TEXT_MODULE_RECORD, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 250 IMPORTENTRY_RECORD, /* /////////////////////////////////////////////////////////////////////////-PADDING */ \ 251 LOCAL_EXPORTENTRY_RECORD, /* ///////////////////////////////////////////////////////////////////-PADDING */ \ 252 INDIRECT_EXPORTENTRY_RECORD, /* ////////////////////////////////////////////////////////////////-PADDING */ \ 253 STAR_EXPORTENTRY_RECORD, /* ////////////////////////////////////////////////////////////////////-PADDING */ \ 254 RESOLVEDBINDING_RECORD, /* /////////////////////////////////////////////////////////////////////-PADDING */ \ 255 RESOLVEDINDEXBINDING_RECORD, /* ////////////////////////////////////////////////////////////////-PADDING */ \ 256 CELL_RECORD, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 257 COMPLETION_RECORD, /* JS_RECORD_LAST /////////////////////////////////////////////////////////////////////// */\ 258 MACHINE_CODE_OBJECT, \ 259 CLASS_INFO_EXTRACTOR, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 260 TS_ARRAY_TYPE, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 261 TS_UNION_TYPE, /* ////////////////////////////////////////////////////////////////////////////////-PADDING */ \ 262 TS_FUNCTION_TYPE, /* /////////////////////////////////////////////////////////////////////////////-PADDING */ \ 263 TS_OBJECT_TYPE, /* ///////////////////////////////////////////////////////////////////////////////-PADDING */ \ 264 TS_CLASS_TYPE, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 265 TS_CLASS_INSTANCE_TYPE, /* ///////////////////////////////////////////////////////////////////////-PADDING */ \ 266 TS_INTERFACE_TYPE, /* //////////////////////////////////////////////////////////////////////////-PADDING */ \ 267 TS_ITERATOR_INSTANCE_TYPE, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 268 TS_NAMESPACE_TYPE, /* ////////////////////////////////////////////////////////////////////////////-PADDING */ \ 269 \ 270 VTABLE, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 271 AOT_LITERAL_INFO, /* //////////////////////////////////////////////////////////////////////////////-PADDING */ \ 272 TYPE_LAST = AOT_LITERAL_INFO, /* //////////////////////////////////////////////////////////////////-PADDING */ \ 273 \ 274 JS_FUNCTION_FIRST = JS_FUNCTION, /* ///////////////////////////////////////////////////////////////-PADDING */ \ 275 JS_FUNCTION_LAST = JS_ASYNC_AWAIT_STATUS_FUNCTION, /* //////////////////////////////////////////////-PADDING */\ 276 \ 277 JS_OBJECT_FIRST = JS_OBJECT, /* ///////////////////////////////////////////////////////////////////-PADDING */ \ 278 JS_OBJECT_LAST = JS_GLOBAL_OBJECT, /* //////////////////////////////////////////////////////////////-PADDING */\ 279 \ 280 ECMA_OBJECT_FIRST = JS_OBJECT, /* /////////////////////////////////////////////////////////////////-PADDING */ \ 281 ECMA_OBJECT_LAST = JS_PROXY, /* /////////////////////////////////////////////////////////////////-PADDING */\ 282 \ 283 JS_ERROR_FIRST = JS_ERROR, /* ////////////////////////////////////////////////////////////////-PADDING */ \ 284 JS_ERROR_LAST = JS_TERMINATION_ERROR, /* ////////////////////////////////////////////////////////-PADDING */\ 285 \ 286 JS_ITERATOR_FIRST = JS_ITERATOR, /* //////////////////////////////////////////////////////////-PADDING */ \ 287 JS_ITERATOR_LAST = JS_STRING_ITERATOR, /* //////////////////////////////////////////////////////////-PADDING */\ 288 \ 289 JS_RECORD_FIRST = PROMISE_CAPABILITY, /* //////////////////////////////////////////////////////////-PADDING */ \ 290 JS_RECORD_LAST = COMPLETION_RECORD, /* ///////////////////////////////////////////////////////-PADDING */ \ 291 \ 292 JS_TYPED_ARRAY_FIRST = JS_TYPED_ARRAY, /* /////////////////////////////////////////////////////////-PADDING */ \ 293 JS_TYPED_ARRAY_LAST = JS_BIGUINT64_ARRAY, /* ///////////////////////////////////////////////////////-PADDING */\ 294 \ 295 MODULE_RECORD_FIRST = MODULE_RECORD, /* ///////////////////////////////////////////////////////////-PADDING */ \ 296 MODULE_RECORD_LAST = SOURCE_TEXT_MODULE_RECORD, /* ////////////////////////////////////////////////-PADDING */ \ 297 \ 298 TS_TYPE_FIRST = TS_ARRAY_TYPE, /* /////////////////////////////////////////////////////////////////-PADDING */ \ 299 TS_TYPE_LAST = TS_NAMESPACE_TYPE, /* ///////////////////////////////////////////////////////////////-PADDING */\ 300 \ 301 STRING_FIRST = LINE_STRING, /* /////////////////////////////////////////////////////////////////////-PADDING */\ 302 STRING_LAST = TREE_STRING /* /////////////////////////////////////////////////////////////////////-PADDING */ 303 304 enum class JSType : uint8_t { 305 JSTYPE_DECL, 306 }; 307 308 // EnumCache: 309 // +-----------------+----------------------+ 310 // | value | status | 311 // +-----------------+----------------------+ 312 // | null | uninitialized | 313 // ------------------------------------------ 314 // | undefined | a fast path to check | 315 // | | simple enum cache | 316 // ------------------------------------------ 317 // | empty array | enum keys is empty | 318 // ------------------------------------------ 319 // | non-empty array | non-empty enum keys | 320 // +----------------------------------------+ 321 // structure of non-empty array of EnumCache: 322 // 0: an int value indicating enum cache kind 323 // 1-n: enum keys 324 namespace EnumCache { 325 static constexpr uint32_t ENUM_CACHE_HEADER_SIZE = 1; 326 static constexpr uint32_t ENUM_CACHE_KIND_OFFSET = 0; 327 enum class EnumCacheKind : uint8_t { 328 NONE = 0, 329 SIMPLE, // simple enum cache(used in for-in) 330 // make sure EnumCache is empty array only for SIMPLE 331 PROTOCHAIN, // enum cache with prototype chain info(used in for-in) 332 ONLY_OWN_KEYS // enum cache with only own enum keys(used in Json.stringify and Object.keys) 333 }; 334 335 } // namespace EnumCache 336 337 namespace JSShared { 338 // check mode for js shared 339 enum SCheckMode: uint8_t { 340 SKIP = 0, 341 CHECK 342 }; 343 } // namespace JSShared 344 345 class JSHClass : public TaggedObject { 346 public: 347 static constexpr int TYPE_BITFIELD_NUM = 8; 348 static constexpr int LEVEL_BTTFIELD_NUM = 5; 349 static constexpr int ELEMENTS_KIND_BITFIELD_NUM = 5; 350 static constexpr unsigned BITS_PER_BYTE = 8; 351 using ObjectTypeBits = BitField<JSType, 0, TYPE_BITFIELD_NUM>; // 8 352 using CallableBit = ObjectTypeBits::NextFlag; // 9 353 using ConstructorBit = CallableBit::NextFlag; // 10 354 using ExtensibleBit = ConstructorBit::NextFlag; // 11 355 using IsPrototypeBit = ExtensibleBit::NextFlag; // 12 356 using ElementsKindBits = IsPrototypeBit::NextField<ElementsKind, ELEMENTS_KIND_BITFIELD_NUM>; // 13-17 357 using DictionaryElementBits = ElementsKindBits::NextFlag; // 18 358 using IsDictionaryBit = DictionaryElementBits::NextFlag; // 19 359 using IsStableElementsBit = IsDictionaryBit::NextFlag; // 20 360 using HasConstructorBits = IsStableElementsBit::NextFlag; // 21 361 using IsClassConstructorOrPrototypeBit = HasConstructorBits::NextFlag; // 22 362 using IsNativeBindingObjectBit = IsClassConstructorOrPrototypeBit::NextFlag; // 23 363 using IsTSBit = IsNativeBindingObjectBit::NextFlag; // 24 364 using LevelBit = IsTSBit::NextField<uint32_t, LEVEL_BTTFIELD_NUM>; // 25-29 365 using IsJSFunctionBit = LevelBit::NextFlag; // 30 366 using IsOnHeap = IsJSFunctionBit::NextFlag; // 31 367 using BitFieldLastBit = IsOnHeap; 368 static_assert(BitFieldLastBit::START_BIT + BitFieldLastBit::SIZE <= sizeof(uint32_t) * BITS_PER_BYTE, "Invalid"); 369 370 static constexpr int DEFAULT_CAPACITY_OF_IN_OBJECTS = 4; 371 static constexpr int OFFSET_MAX_OBJECT_SIZE_IN_WORDS_WITHOUT_INLINED = 5; 372 static constexpr int OFFSET_MAX_OBJECT_SIZE_IN_WORDS = 373 PropertyAttributes::OFFSET_BITFIELD_NUM + OFFSET_MAX_OBJECT_SIZE_IN_WORDS_WITHOUT_INLINED; 374 static constexpr int MAX_OBJECT_SIZE_IN_WORDS = (1U << OFFSET_MAX_OBJECT_SIZE_IN_WORDS) - 1; 375 376 using NumberOfPropsBits = BitField<uint32_t, 0, PropertyAttributes::OFFSET_BITFIELD_NUM>; // 10 377 using InlinedPropsStartBits = NumberOfPropsBits::NextField<uint32_t, 378 OFFSET_MAX_OBJECT_SIZE_IN_WORDS_WITHOUT_INLINED>; // 15 379 using ObjectSizeInWordsBits = InlinedPropsStartBits::NextField<uint32_t, OFFSET_MAX_OBJECT_SIZE_IN_WORDS>; // 30 380 using HasDeletePropertyBit = ObjectSizeInWordsBits::NextFlag; // 381 using IsAllTaggedPropBit = HasDeletePropertyBit::NextFlag; // 32 382 using BitField1LastBit = IsAllTaggedPropBit; 383 static_assert(BitField1LastBit::START_BIT + BitField1LastBit::SIZE <= sizeof(uint32_t) * BITS_PER_BYTE, "Invalid"); 384 385 static JSHClass *Cast(const TaggedObject *object); 386 387 inline size_t SizeFromJSHClass(TaggedObject *header); 388 inline bool HasReferenceField(); 389 390 // size need to add inlined property numbers 391 void Initialize(const JSThread *thread, uint32_t size, JSType type, uint32_t inlinedProps); 392 393 static JSHandle<JSHClass> Clone(const JSThread *thread, const JSHandle<JSHClass> &jshclass, 394 bool withoutInlinedProperties = false, uint32_t incInlinedProperties = 0); 395 static JSHandle<JSHClass> CloneWithoutInlinedProperties(const JSThread *thread, const JSHandle<JSHClass> &jshclass); 396 397 static void TransitionElementsToDictionary(const JSThread *thread, const JSHandle<JSObject> &obj); 398 static void OptimizeAsFastElements(const JSThread *thread, JSHandle<JSObject> obj); 399 static void OptimizeAsFastProperties(const JSThread *thread, const JSHandle<JSObject> &obj, 400 const std::vector<int> &indexArray = {}, bool isDictionary = false); 401 template<bool checkDuplicateKeys = false> 402 static JSHandle<JSHClass> SetPropertyOfObjHClass(const JSThread *thread, JSHandle<JSHClass> &jshclass, 403 const JSHandle<JSTaggedValue> &key, 404 const PropertyAttributes &attr); 405 static void AddProperty(const JSThread *thread, const JSHandle<JSObject> &obj, const JSHandle<JSTaggedValue> &key, 406 const PropertyAttributes &attr); 407 408 static void TryRestoreElementsKind(const JSThread *thread, JSHandle<JSHClass> newJsHClass, 409 const JSHandle<JSObject> &obj); 410 static JSHandle<JSHClass> TransitionExtension(const JSThread *thread, const JSHandle<JSHClass> &jshclass); 411 static JSHandle<JSHClass> TransitionProto(const JSThread *thread, const JSHandle<JSHClass> &jshclass, 412 const JSHandle<JSTaggedValue> &proto); 413 static JSHandle<JSHClass> TransProtoWithoutLayout(const JSThread *thread, const JSHandle<JSHClass> &jshclass, 414 const JSHandle<JSTaggedValue> &proto); 415 static JSHandle<JSHClass> CloneWithAddProto(const JSThread *thread, const JSHandle<JSHClass> &jshclass, 416 const JSHandle<JSTaggedValue> &key, 417 const JSHandle<JSTaggedValue> &proto); 418 static void TransitionToDictionary(const JSThread *thread, const JSHandle<JSObject> &obj); 419 static void TransitionForRepChange(const JSThread *thread, const JSHandle<JSObject> &receiver, 420 const JSHandle<JSTaggedValue> &key, PropertyAttributes attr); 421 static void TransitionForElementsKindChange(const JSThread *thread, const JSHandle<JSObject> &receiver, 422 const ElementsKind newKind); 423 static JSHClass* GetInitialArrayHClassWithElementsKind(const JSThread *thread, const ElementsKind kind); 424 static void TransitToElementsKind(const JSThread *thread, const JSHandle<JSArray> &array, 425 ElementsKind newKind = ElementsKind::NONE); 426 static bool TransitToElementsKind(const JSThread *thread, const JSHandle<JSObject> &object, 427 const JSHandle<JSTaggedValue> &value, ElementsKind kind = ElementsKind::NONE); 428 static std::tuple<bool, bool, JSTaggedValue> ConvertOrTransitionWithRep(const JSThread *thread, 429 const JSHandle<JSObject> &receiver, const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value, 430 PropertyAttributes &attr); 431 432 static JSHandle<JSTaggedValue> EnableProtoChangeMarker(const JSThread *thread, const JSHandle<JSHClass> &jshclass); 433 static JSHandle<JSTaggedValue> EnablePHCProtoChangeMarker( 434 const JSThread *thread, const JSHandle<JSHClass> &protoClass); 435 436 static void NotifyHclassChanged(const JSThread *thread, JSHandle<JSHClass> oldHclass, JSHandle<JSHClass> newHclass, 437 JSTaggedValue addedKey = JSTaggedValue::Undefined()); 438 439 static void NotifyAccessorChanged(const JSThread *thread, JSHandle<JSHClass> hclass); 440 441 static void RegisterOnProtoChain(const JSThread *thread, const JSHandle<JSHClass> &jshclass); 442 443 static bool UnregisterOnProtoChain(const JSThread *thread, const JSHandle<JSHClass> &jshclass); 444 445 static JSHandle<ProtoChangeDetails> GetProtoChangeDetails(const JSThread *thread, 446 const JSHandle<JSHClass> &jshclass); 447 448 static JSHandle<ProtoChangeDetails> GetProtoChangeDetails(const JSThread *thread, const JSHandle<JSObject> &obj); 449 450 inline void UpdatePropertyMetaData(const JSThread *thread, const JSTaggedValue &key, 451 const PropertyAttributes &metaData); 452 453 static void MarkProtoChanged(const JSThread *thread, const JSHandle<JSHClass> &jshclass, 454 JSTaggedValue addedKey = JSTaggedValue::Undefined()); 455 456 static void NoticeThroughChain(const JSThread *thread, const JSHandle<JSHClass> &jshclass, 457 JSTaggedValue addedKey = JSTaggedValue::Undefined()); 458 459 static void RefreshUsers(const JSThread *thread, const JSHandle<JSHClass> &oldHclass, 460 const JSHandle<JSHClass> &newHclass); 461 462 void InitTSInheritInfo(const JSThread *thread); 463 464 bool HasTSSubtyping() const; 465 466 bool IsTSIHCWithInheritInfo() const; 467 468 static void CopyTSInheritInfo(const JSThread *thread, const JSHandle<JSHClass> &oldHClass, 469 JSHandle<JSHClass> &newHClass); 470 ClearBitField()471 inline void ClearBitField() 472 { 473 SetBitField(0UL); 474 SetBitField1(0UL); 475 } 476 GetObjectType()477 inline JSType GetObjectType() const 478 { 479 uint32_t bits = GetBitField(); 480 return ObjectTypeBits::Decode(bits); 481 } 482 SetObjectType(JSType type)483 inline void SetObjectType(JSType type) 484 { 485 uint32_t bits = GetBitField(); 486 uint32_t newVal = ObjectTypeBits::Update(bits, type); 487 SetBitField(newVal); 488 } 489 SetCallable(bool flag)490 inline void SetCallable(bool flag) 491 { 492 CallableBit::Set<uint32_t>(flag, GetBitFieldAddr()); 493 } 494 SetConstructor(bool flag)495 inline void SetConstructor(bool flag) const 496 { 497 ConstructorBit::Set<uint32_t>(flag, GetBitFieldAddr()); 498 } 499 SetExtensible(bool flag)500 inline void SetExtensible(bool flag) const 501 { 502 ExtensibleBit::Set<uint32_t>(flag, GetBitFieldAddr()); 503 } 504 SetIsPrototype(bool flag)505 inline void SetIsPrototype(bool flag) const 506 { 507 IsPrototypeBit::Set<uint32_t>(flag, GetBitFieldAddr()); 508 } 509 SetClassConstructor(bool flag)510 inline void SetClassConstructor(bool flag) const 511 { 512 IsClassConstructorOrPrototypeBit::Set<uint32_t>(flag, GetBitFieldAddr()); 513 SetConstructor(flag); 514 } 515 SetClassPrototype(bool flag)516 inline void SetClassPrototype(bool flag) const 517 { 518 IsClassConstructorOrPrototypeBit::Set<uint32_t>(flag, GetBitFieldAddr()); 519 SetIsPrototype(flag); 520 } 521 SetIsNativeBindingObject(bool flag)522 inline void SetIsNativeBindingObject(bool flag) const 523 { 524 IsNativeBindingObjectBit::Set<uint32_t>(flag, GetBitFieldAddr()); 525 } 526 SetIsDictionaryMode(bool flag)527 inline void SetIsDictionaryMode(bool flag) const 528 { 529 IsDictionaryBit::Set<uint32_t>(flag, GetBitFieldAddr()); 530 } 531 SetTS(bool flag)532 inline void SetTS(bool flag) const 533 { 534 IsTSBit::Set<uint32_t>(flag, GetBitFieldAddr()); 535 } 536 SetIsJSFunction(bool flag)537 inline void SetIsJSFunction(bool flag) const 538 { 539 IsJSFunctionBit::Set<uint32_t>(flag, GetBitFieldAddr()); 540 } 541 SetIsOnHeap(bool flag)542 inline void SetIsOnHeap(bool flag) const 543 { 544 IsOnHeap::Set<uint32_t>(flag, GetBitFieldAddr()); 545 } 546 IsJSObject()547 inline bool IsJSObject() const 548 { 549 JSType jsType = GetObjectType(); 550 return (JSType::JS_OBJECT_FIRST <= jsType && jsType <= JSType::JS_OBJECT_LAST); 551 } 552 IsOnlyJSObject()553 inline bool IsOnlyJSObject() const 554 { 555 return GetObjectType() == JSType::JS_OBJECT; 556 } 557 IsECMAObject()558 inline bool IsECMAObject() const 559 { 560 JSType jsType = GetObjectType(); 561 return (JSType::ECMA_OBJECT_FIRST <= jsType && jsType <= JSType::ECMA_OBJECT_LAST); 562 } 563 ShouldSetDefaultSupers()564 inline bool ShouldSetDefaultSupers() const 565 { 566 return IsECMAObject() || IsStringOrSymbol(); 567 } 568 IsRealm()569 inline bool IsRealm() const 570 { 571 return GetObjectType() == JSType::JS_REALM; 572 } 573 IsHClass()574 inline bool IsHClass() const 575 { 576 return GetObjectType() == JSType::HCLASS; 577 } 578 IsString()579 inline bool IsString() const 580 { 581 JSType jsType = GetObjectType(); 582 return (JSType::STRING_FIRST <= jsType && jsType <= JSType::STRING_LAST); 583 } 584 IsLineString()585 inline bool IsLineString() const 586 { 587 return GetObjectType() == JSType::LINE_STRING; 588 } 589 IsConstantString()590 inline bool IsConstantString() const 591 { 592 return GetObjectType() == JSType::CONSTANT_STRING; 593 } 594 IsSlicedString()595 inline bool IsSlicedString() const 596 { 597 return GetObjectType() == JSType::SLICED_STRING; 598 } 599 IsTreeString()600 inline bool IsTreeString() const 601 { 602 return GetObjectType() == JSType::TREE_STRING; 603 } 604 IsBigInt()605 inline bool IsBigInt() const 606 { 607 return GetObjectType() == JSType::BIGINT; 608 } 609 IsSymbol()610 inline bool IsSymbol() const 611 { 612 return GetObjectType() == JSType::SYMBOL; 613 } 614 IsStringOrSymbol()615 inline bool IsStringOrSymbol() const 616 { 617 JSType jsType = GetObjectType(); 618 return (JSType::STRING_FIRST <= jsType && jsType <= JSType::STRING_LAST) || (jsType == JSType::SYMBOL); 619 } 620 IsTaggedArray()621 inline bool IsTaggedArray() const 622 { 623 JSType jsType = GetObjectType(); 624 switch (jsType) { 625 case JSType::TAGGED_ARRAY: 626 case JSType::TAGGED_DICTIONARY: 627 case JSType::LEXICAL_ENV: 628 case JSType::CONSTANT_POOL: 629 case JSType::PROFILE_TYPE_INFO: 630 case JSType::AOT_LITERAL_INFO: 631 case JSType::VTABLE: 632 case JSType::COW_TAGGED_ARRAY: 633 case JSType::MUTANT_TAGGED_ARRAY: 634 case JSType::COW_MUTANT_TAGGED_ARRAY: 635 return true; 636 default: 637 return false; 638 } 639 } 640 IsLexicalEnv()641 inline bool IsLexicalEnv() const 642 { 643 return GetObjectType() == JSType::LEXICAL_ENV; 644 } IsByteArray()645 inline bool IsByteArray() const 646 { 647 return GetObjectType() == JSType::BYTE_ARRAY; 648 } 649 IsConstantPool()650 inline bool IsConstantPool() const 651 { 652 return GetObjectType() == JSType::CONSTANT_POOL; 653 } 654 IsDictionary()655 inline bool IsDictionary() const 656 { 657 return GetObjectType() == JSType::TAGGED_DICTIONARY; 658 } 659 IsCOWArray()660 inline bool IsCOWArray() const 661 { 662 // Copy On Write ARRAY. 663 return GetObjectType() == JSType::COW_TAGGED_ARRAY || 664 GetObjectType() == JSType::COW_MUTANT_TAGGED_ARRAY; 665 } 666 IsMutantTaggedArray()667 inline bool IsMutantTaggedArray() const 668 { 669 return GetObjectType() == JSType::MUTANT_TAGGED_ARRAY || 670 GetObjectType() == JSType::COW_MUTANT_TAGGED_ARRAY; 671 } 672 IsJSNativePointer()673 inline bool IsJSNativePointer() const 674 { 675 return GetObjectType() == JSType::JS_NATIVE_POINTER; 676 } 677 IsJSSymbol()678 inline bool IsJSSymbol() const 679 { 680 return GetObjectType() == JSType::SYMBOL; 681 } 682 IsJSArray()683 inline bool IsJSArray() const 684 { 685 return GetObjectType() == JSType::JS_ARRAY; 686 } 687 IsTypedArray()688 inline bool IsTypedArray() const 689 { 690 JSType jsType = GetObjectType(); 691 return (JSType::JS_TYPED_ARRAY_FIRST < jsType && jsType <= JSType::JS_TYPED_ARRAY_LAST); 692 } 693 HasOrdinaryGet()694 inline bool HasOrdinaryGet() const 695 { 696 return (IsSpecialContainer() || IsModuleNamespace() || IsJSBigInt64Array() || IsJSBigUint64Array()); 697 } 698 IsJSTypedArray()699 inline bool IsJSTypedArray() const 700 { 701 return GetObjectType() == JSType::JS_TYPED_ARRAY; 702 } 703 IsJSInt8Array()704 inline bool IsJSInt8Array() const 705 { 706 return GetObjectType() == JSType::JS_INT8_ARRAY; 707 } 708 IsJSUint8Array()709 inline bool IsJSUint8Array() const 710 { 711 return GetObjectType() == JSType::JS_UINT8_ARRAY; 712 } 713 IsJSUint8ClampedArray()714 inline bool IsJSUint8ClampedArray() const 715 { 716 return GetObjectType() == JSType::JS_UINT8_CLAMPED_ARRAY; 717 } 718 IsJSInt16Array()719 inline bool IsJSInt16Array() const 720 { 721 return GetObjectType() == JSType::JS_INT16_ARRAY; 722 } 723 IsJSUint16Array()724 inline bool IsJSUint16Array() const 725 { 726 return GetObjectType() == JSType::JS_UINT16_ARRAY; 727 } 728 IsJSInt32Array()729 inline bool IsJSInt32Array() const 730 { 731 return GetObjectType() == JSType::JS_INT32_ARRAY; 732 } 733 IsJSUint32Array()734 inline bool IsJSUint32Array() const 735 { 736 return GetObjectType() == JSType::JS_UINT32_ARRAY; 737 } 738 IsJSFloat32Array()739 inline bool IsJSFloat32Array() const 740 { 741 return GetObjectType() == JSType::JS_FLOAT32_ARRAY; 742 } 743 IsJSFloat64Array()744 inline bool IsJSFloat64Array() const 745 { 746 return GetObjectType() == JSType::JS_FLOAT64_ARRAY; 747 } 748 IsJSBigInt64Array()749 inline bool IsJSBigInt64Array() const 750 { 751 return GetObjectType() == JSType::JS_BIGINT64_ARRAY; 752 } 753 IsJSBigUint64Array()754 inline bool IsJSBigUint64Array() const 755 { 756 return GetObjectType() == JSType::JS_BIGUINT64_ARRAY; 757 } 758 IsJsGlobalEnv()759 inline bool IsJsGlobalEnv() const 760 { 761 return GetObjectType() == JSType::GLOBAL_ENV; 762 } 763 IsJSFunctionBase()764 inline bool IsJSFunctionBase() const 765 { 766 JSType jsType = GetObjectType(); 767 return jsType >= JSType::JS_FUNCTION_BASE && jsType <= JSType::JS_BOUND_FUNCTION; 768 } 769 IsJsBoundFunction()770 inline bool IsJsBoundFunction() const 771 { 772 return GetObjectType() == JSType::JS_BOUND_FUNCTION; 773 } 774 IsJSIntlBoundFunction()775 inline bool IsJSIntlBoundFunction() const 776 { 777 return GetObjectType() == JSType::JS_INTL_BOUND_FUNCTION; 778 } 779 IsJSProxyRevocFunction()780 inline bool IsJSProxyRevocFunction() const 781 { 782 return GetObjectType() == JSType::JS_PROXY_REVOC_FUNCTION; 783 } 784 IsJSAsyncFunction()785 inline bool IsJSAsyncFunction() const 786 { 787 return GetObjectType() == JSType::JS_ASYNC_FUNCTION; 788 } 789 IsJSAsyncAwaitStatusFunction()790 inline bool IsJSAsyncAwaitStatusFunction() const 791 { 792 return GetObjectType() == JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION; 793 } 794 IsJSPromiseReactionFunction()795 inline bool IsJSPromiseReactionFunction() const 796 { 797 return GetObjectType() == JSType::JS_PROMISE_REACTIONS_FUNCTION; 798 } 799 IsJSPromiseExecutorFunction()800 inline bool IsJSPromiseExecutorFunction() const 801 { 802 return GetObjectType() == JSType::JS_PROMISE_EXECUTOR_FUNCTION; 803 } 804 IsJSAsyncModuleFulfilledFunction()805 inline bool IsJSAsyncModuleFulfilledFunction() const 806 { 807 return GetObjectType() == JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION; 808 } 809 IsJSAsyncModuleRejectedFunction()810 inline bool IsJSAsyncModuleRejectedFunction() const 811 { 812 return GetObjectType() == JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION; 813 } 814 IsJSAsyncFromSyncIterUnwarpFunction()815 inline bool IsJSAsyncFromSyncIterUnwarpFunction() const 816 { 817 return GetObjectType() == JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION; 818 } 819 IsJSPromiseAllResolveElementFunction()820 inline bool IsJSPromiseAllResolveElementFunction() const 821 { 822 return GetObjectType() == JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION; 823 } 824 IsJSAsyncGeneratorResNextRetProRstFtn()825 inline bool IsJSAsyncGeneratorResNextRetProRstFtn() const 826 { 827 return GetObjectType() == JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN; 828 } 829 IsJSPromiseAnyRejectElementFunction()830 inline bool IsJSPromiseAnyRejectElementFunction() const 831 { 832 return GetObjectType() == JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION; 833 } 834 IsJSPromiseAllSettledElementFunction()835 inline bool IsJSPromiseAllSettledElementFunction() const 836 { 837 return GetObjectType() == JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION; 838 } 839 IsJSPromiseFinallyFunction()840 inline bool IsJSPromiseFinallyFunction() const 841 { 842 return GetObjectType() == JSType::JS_PROMISE_FINALLY_FUNCTION; 843 } 844 IsJSPromiseValueThunkOrThrowerFunction()845 inline bool IsJSPromiseValueThunkOrThrowerFunction() const 846 { 847 return GetObjectType() == JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION; 848 } 849 IsMicroJobQueue()850 inline bool IsMicroJobQueue() const 851 { 852 return GetObjectType() == JSType::MICRO_JOB_QUEUE; 853 } 854 IsPendingJob()855 inline bool IsPendingJob() const 856 { 857 return GetObjectType() == JSType::PENDING_JOB; 858 } 859 IsJsPrimitiveRef()860 inline bool IsJsPrimitiveRef() const 861 { 862 return GetObjectType() == JSType::JS_PRIMITIVE_REF; 863 } 864 IsJSSet()865 bool IsJSSet() const 866 { 867 return GetObjectType() == JSType::JS_SET; 868 } 869 IsJSMap()870 bool IsJSMap() const 871 { 872 return GetObjectType() == JSType::JS_MAP; 873 } 874 IsJSWeakMap()875 bool IsJSWeakMap() const 876 { 877 return GetObjectType() == JSType::JS_WEAK_MAP; 878 } 879 IsJSWeakSet()880 bool IsJSWeakSet() const 881 { 882 return GetObjectType() == JSType::JS_WEAK_SET; 883 } 884 IsJSWeakRef()885 bool IsJSWeakRef() const 886 { 887 return GetObjectType() == JSType::JS_WEAK_REF; 888 } 889 IsJSFinalizationRegistry()890 bool IsJSFinalizationRegistry() const 891 { 892 return GetObjectType() == JSType::JS_FINALIZATION_REGISTRY; 893 } 894 IsJSFunction()895 bool IsJSFunction() const 896 { 897 return GetObjectType() >= JSType::JS_FUNCTION_FIRST && GetObjectType() <= JSType::JS_FUNCTION_LAST; 898 } 899 IsJSSharedFunction()900 bool IsJSSharedFunction() const 901 { 902 return GetObjectType() == JSType::JS_SHARED_FUNCTION; 903 } 904 IsJSShared()905 bool IsJSShared() const 906 { 907 return IsJSSharedType(GetObjectType()); 908 } 909 IsJSSharedType(JSType jsType)910 static inline bool IsJSSharedType(JSType jsType) 911 { 912 return (jsType == JSType::JS_SHARED_OBJECT || jsType == JSType::JS_SHARED_FUNCTION); 913 } 914 IsJSError()915 inline bool IsJSError() const 916 { 917 JSType jsType = GetObjectType(); 918 return jsType >= JSType::JS_ERROR_FIRST && jsType <= JSType::JS_ERROR_LAST; 919 } 920 IsArguments()921 inline bool IsArguments() const 922 { 923 return GetObjectType() == JSType::JS_ARGUMENTS; 924 } 925 IsDate()926 inline bool IsDate() const 927 { 928 return GetObjectType() == JSType::JS_DATE; 929 } 930 IsJSRegExp()931 inline bool IsJSRegExp() const 932 { 933 return GetObjectType() == JSType::JS_REG_EXP; 934 } 935 IsJSProxy()936 inline bool IsJSProxy() const 937 { 938 return GetObjectType() == JSType::JS_PROXY; 939 } 940 IsJSLocale()941 inline bool IsJSLocale() const 942 { 943 return GetObjectType() == JSType::JS_LOCALE; 944 } 945 IsJSIntl()946 inline bool IsJSIntl() const 947 { 948 return GetObjectType() == JSType::JS_INTL; 949 } 950 IsJSDateTimeFormat()951 inline bool IsJSDateTimeFormat() const 952 { 953 return GetObjectType() == JSType::JS_DATE_TIME_FORMAT; 954 } 955 IsJSRelativeTimeFormat()956 inline bool IsJSRelativeTimeFormat() const 957 { 958 return GetObjectType() == JSType::JS_RELATIVE_TIME_FORMAT; 959 } 960 IsJSNumberFormat()961 inline bool IsJSNumberFormat() const 962 { 963 return GetObjectType() == JSType::JS_NUMBER_FORMAT; 964 } 965 IsJSCollator()966 inline bool IsJSCollator() const 967 { 968 return GetObjectType() == JSType::JS_COLLATOR; 969 } 970 IsJSPluralRules()971 inline bool IsJSPluralRules() const 972 { 973 return GetObjectType() == JSType::JS_PLURAL_RULES; 974 } 975 IsJSDisplayNames()976 inline bool IsJSDisplayNames() const 977 { 978 return GetObjectType() == JSType::JS_DISPLAYNAMES; 979 } 980 IsJSListFormat()981 inline bool IsJSListFormat() const 982 { 983 return GetObjectType() == JSType::JS_LIST_FORMAT; 984 } 985 IsMethod()986 inline bool IsMethod() const 987 { 988 return GetObjectType() == JSType::METHOD; 989 } 990 IsClassLiteral()991 inline bool IsClassLiteral() const 992 { 993 return GetObjectType() == JSType::CLASS_LITERAL; 994 } 995 996 // non ECMA standard jsapi containers. IsSpecialContainer()997 inline bool IsSpecialContainer() const 998 { 999 return GetObjectType() >= JSType::JS_API_ARRAY_LIST && GetObjectType() <= JSType::JS_API_QUEUE; 1000 } 1001 IsRegularObject()1002 inline bool IsRegularObject() const 1003 { 1004 return GetObjectType() < JSType::JS_API_ARRAY_LIST; 1005 } 1006 IsJSAPIArrayList()1007 inline bool IsJSAPIArrayList() const 1008 { 1009 return GetObjectType() == JSType::JS_API_ARRAY_LIST; 1010 } 1011 IsJSAPIArrayListIterator()1012 inline bool IsJSAPIArrayListIterator() const 1013 { 1014 return GetObjectType() == JSType::JS_API_ARRAYLIST_ITERATOR; 1015 } IsJSAPILightWeightMap()1016 inline bool IsJSAPILightWeightMap() const 1017 { 1018 return GetObjectType() == JSType::JS_API_LIGHT_WEIGHT_MAP; 1019 } IsJSAPILightWeightMapIterator()1020 inline bool IsJSAPILightWeightMapIterator() const 1021 { 1022 return GetObjectType() == JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR; 1023 } IsJSAPILightWeightSet()1024 inline bool IsJSAPILightWeightSet() const 1025 { 1026 return GetObjectType() == JSType::JS_API_LIGHT_WEIGHT_SET; 1027 } IsJSAPILightWeightSetIterator()1028 inline bool IsJSAPILightWeightSetIterator() const 1029 { 1030 return GetObjectType() == JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR; 1031 } IsJSAPIStack()1032 inline bool IsJSAPIStack() const 1033 { 1034 return GetObjectType() == JSType::JS_API_STACK; 1035 } IsJSAPIDeque()1036 inline bool IsJSAPIDeque() const 1037 { 1038 return GetObjectType() == JSType::JS_API_DEQUE; 1039 } IsLinkedNode()1040 inline bool IsLinkedNode() const 1041 { 1042 return GetObjectType() == JSType::LINKED_NODE; 1043 } 1044 IsRBTreeNode()1045 inline bool IsRBTreeNode() const 1046 { 1047 return GetObjectType() == JSType::RB_TREENODE; 1048 } 1049 IsJSAPIHashMap()1050 inline bool IsJSAPIHashMap() const 1051 { 1052 return GetObjectType() == JSType::JS_API_HASH_MAP; 1053 } 1054 IsJSAPIHashSet()1055 inline bool IsJSAPIHashSet() const 1056 { 1057 return GetObjectType() == JSType::JS_API_HASH_SET; 1058 } 1059 IsJSAPIHashMapIterator()1060 inline bool IsJSAPIHashMapIterator() const 1061 { 1062 return GetObjectType() == JSType::JS_API_HASHMAP_ITERATOR; 1063 } 1064 IsJSAPIHashSetIterator()1065 inline bool IsJSAPIHashSetIterator() const 1066 { 1067 return GetObjectType() == JSType::JS_API_HASHSET_ITERATOR; 1068 } IsJSAPIQueue()1069 inline bool IsJSAPIQueue() const 1070 { 1071 return GetObjectType() == JSType::JS_API_QUEUE; 1072 } 1073 IsJSAPIPlainArray()1074 inline bool IsJSAPIPlainArray() const 1075 { 1076 return GetObjectType() == JSType::JS_API_PLAIN_ARRAY; 1077 } 1078 IsJSAPIQueueIterator()1079 inline bool IsJSAPIQueueIterator() const 1080 { 1081 return GetObjectType() == JSType::JS_API_QUEUE_ITERATOR; 1082 } IsJSAPIList()1083 inline bool IsJSAPIList() const 1084 { 1085 return GetObjectType() == JSType::JS_API_LIST; 1086 } IsJSAPILinkedList()1087 inline bool IsJSAPILinkedList() const 1088 { 1089 return GetObjectType() == JSType::JS_API_LINKED_LIST; 1090 } IsJSAPITreeMap()1091 inline bool IsJSAPITreeMap() const 1092 { 1093 return GetObjectType() == JSType::JS_API_TREE_MAP; 1094 } 1095 IsJSAPITreeSet()1096 inline bool IsJSAPITreeSet() const 1097 { 1098 return GetObjectType() == JSType::JS_API_TREE_SET; 1099 } 1100 IsJSAPITreeMapIterator()1101 inline bool IsJSAPITreeMapIterator() const 1102 { 1103 return GetObjectType() == JSType::JS_API_TREEMAP_ITERATOR; 1104 } 1105 IsJSAPITreeSetIterator()1106 inline bool IsJSAPITreeSetIterator() const 1107 { 1108 return GetObjectType() == JSType::JS_API_TREESET_ITERATOR; 1109 } IsJSAPIVector()1110 inline bool IsJSAPIVector() const 1111 { 1112 return GetObjectType() == JSType::JS_API_VECTOR; 1113 } IsJSAPIVectorIterator()1114 inline bool IsJSAPIVectorIterator() const 1115 { 1116 return GetObjectType() == JSType::JS_API_VECTOR_ITERATOR; 1117 } 1118 IsAccessorData()1119 inline bool IsAccessorData() const 1120 { 1121 return GetObjectType() == JSType::ACCESSOR_DATA; 1122 } 1123 IsInternalAccessor()1124 inline bool IsInternalAccessor() const 1125 { 1126 return GetObjectType() == JSType::INTERNAL_ACCESSOR; 1127 } 1128 IsIterator()1129 inline bool IsIterator() const 1130 { 1131 JSType jsType = GetObjectType(); 1132 return jsType >= JSType::JS_ITERATOR_FIRST && jsType <= JSType::JS_ITERATOR_LAST; 1133 } 1134 IsAsyncIterator()1135 inline bool IsAsyncIterator() const 1136 { 1137 return GetObjectType() == JSType::JS_ASYNCITERATOR; 1138 } 1139 IsAsyncFromSyncIterator()1140 inline bool IsAsyncFromSyncIterator() const 1141 { 1142 return GetObjectType() == JSType::JS_ASYNC_FROM_SYNC_ITERATOR; 1143 } 1144 IsForinIterator()1145 inline bool IsForinIterator() const 1146 { 1147 return GetObjectType() == JSType::JS_FORIN_ITERATOR; 1148 } 1149 IsStringIterator()1150 inline bool IsStringIterator() const 1151 { 1152 return GetObjectType() == JSType::JS_STRING_ITERATOR; 1153 } 1154 IsArrayBuffer()1155 inline bool IsArrayBuffer() const 1156 { 1157 return GetObjectType() == JSType::JS_ARRAY_BUFFER; 1158 } 1159 IsSharedArrayBuffer()1160 inline bool IsSharedArrayBuffer() const 1161 { 1162 return GetObjectType() == JSType::JS_SHARED_ARRAY_BUFFER; 1163 } 1164 IsDataView()1165 inline bool IsDataView() const 1166 { 1167 return GetObjectType() == JSType::JS_DATA_VIEW; 1168 } 1169 IsJSSetIterator()1170 inline bool IsJSSetIterator() const 1171 { 1172 return GetObjectType() == JSType::JS_SET_ITERATOR; 1173 } 1174 IsJSRegExpIterator()1175 inline bool IsJSRegExpIterator() const 1176 { 1177 return GetObjectType() == JSType::JS_REG_EXP_ITERATOR; 1178 } 1179 IsJSMapIterator()1180 inline bool IsJSMapIterator() const 1181 { 1182 return GetObjectType() == JSType::JS_MAP_ITERATOR; 1183 } 1184 IsJSArrayIterator()1185 inline bool IsJSArrayIterator() const 1186 { 1187 return GetObjectType() == JSType::JS_ARRAY_ITERATOR; 1188 } 1189 IsJSAPIPlainArrayIterator()1190 inline bool IsJSAPIPlainArrayIterator() const 1191 { 1192 return GetObjectType() == JSType::JS_API_PLAIN_ARRAY_ITERATOR; 1193 } 1194 IsJSAPIDequeIterator()1195 inline bool IsJSAPIDequeIterator() const 1196 { 1197 return GetObjectType() == JSType::JS_API_DEQUE_ITERATOR; 1198 } 1199 IsJSAPIStackIterator()1200 inline bool IsJSAPIStackIterator() const 1201 { 1202 return GetObjectType() == JSType::JS_API_STACK_ITERATOR; 1203 } 1204 IsJSAPILinkedListIterator()1205 inline bool IsJSAPILinkedListIterator() const 1206 { 1207 return GetObjectType() == JSType::JS_API_LINKED_LIST_ITERATOR; 1208 } 1209 IsJSAPIListIterator()1210 inline bool IsJSAPIListIterator() const 1211 { 1212 return GetObjectType() == JSType::JS_API_LIST_ITERATOR; 1213 } 1214 IsPrototypeHandler()1215 inline bool IsPrototypeHandler() const 1216 { 1217 return GetObjectType() == JSType::PROTOTYPE_HANDLER; 1218 } 1219 IsTransitionHandler()1220 inline bool IsTransitionHandler() const 1221 { 1222 return GetObjectType() == JSType::TRANSITION_HANDLER; 1223 } 1224 IsTransWithProtoHandler()1225 inline bool IsTransWithProtoHandler() const 1226 { 1227 return GetObjectType() == JSType::TRANS_WITH_PROTO_HANDLER; 1228 } 1229 IsStoreTSHandler()1230 inline bool IsStoreTSHandler() const 1231 { 1232 return GetObjectType() == JSType::STORE_TS_HANDLER; 1233 } 1234 IsPropertyBox()1235 inline bool IsPropertyBox() const 1236 { 1237 return GetObjectType() == JSType::PROPERTY_BOX; 1238 } IsProtoChangeMarker()1239 inline bool IsProtoChangeMarker() const 1240 { 1241 return GetObjectType() == JSType::PROTO_CHANGE_MARKER; 1242 } 1243 IsMarkerCell()1244 inline bool IsMarkerCell() const 1245 { 1246 return GetObjectType() == JSType::MARKER_CELL; 1247 } 1248 IsTrackInfoObject()1249 inline bool IsTrackInfoObject() const 1250 { 1251 return GetObjectType() == JSType::TRACK_INFO; 1252 } 1253 IsProtoChangeDetails()1254 inline bool IsProtoChangeDetails() const 1255 { 1256 return GetObjectType() == JSType::PROTOTYPE_INFO; 1257 } 1258 IsProgram()1259 inline bool IsProgram() const 1260 { 1261 return GetObjectType() == JSType::PROGRAM; 1262 } 1263 IsClassInfoExtractor()1264 inline bool IsClassInfoExtractor() const 1265 { 1266 return GetObjectType() == JSType::CLASS_INFO_EXTRACTOR; 1267 } 1268 IsCallable()1269 inline bool IsCallable() const 1270 { 1271 uint32_t bits = GetBitField(); 1272 return CallableBit::Decode(bits); 1273 } 1274 IsConstructor()1275 inline bool IsConstructor() const 1276 { 1277 uint32_t bits = GetBitField(); 1278 return ConstructorBit::Decode(bits); 1279 } 1280 IsExtensible()1281 inline bool IsExtensible() const 1282 { 1283 uint32_t bits = GetBitField(); 1284 return ExtensibleBit::Decode(bits); 1285 } 1286 IsPrototype()1287 inline bool IsPrototype() const 1288 { 1289 uint32_t bits = GetBitField(); 1290 return IsPrototypeBit::Decode(bits); 1291 } 1292 IsClassConstructor()1293 inline bool IsClassConstructor() const 1294 { 1295 uint32_t bits = GetBitField(); 1296 return IsClassConstructorOrPrototypeBit::Decode(bits) && IsConstructor(); 1297 } 1298 IsJSGlobalObject()1299 inline bool IsJSGlobalObject() const 1300 { 1301 return GetObjectType() == JSType::JS_GLOBAL_OBJECT; 1302 } 1303 IsClassPrototype()1304 inline bool IsClassPrototype() const 1305 { 1306 uint32_t bits = GetBitField(); 1307 return IsClassConstructorOrPrototypeBit::Decode(bits) && IsPrototype(); 1308 } 1309 IsNativeBindingObject()1310 inline bool IsNativeBindingObject() const 1311 { 1312 uint32_t bits = GetBitField(); 1313 return IsNativeBindingObjectBit::Decode(bits); 1314 } 1315 IsDictionaryMode()1316 inline bool IsDictionaryMode() const 1317 { 1318 uint32_t bits = GetBitField(); 1319 return IsDictionaryBit::Decode(bits); 1320 } 1321 1322 // created from TypeScript Types IsTS()1323 inline bool IsTS() const 1324 { 1325 uint32_t bits = GetBitField(); 1326 return IsTSBit::Decode(bits); 1327 } 1328 IsJSFunctionFromBitField()1329 inline bool IsJSFunctionFromBitField() const 1330 { 1331 uint32_t bits = GetBitField(); 1332 return IsJSFunctionBit::Decode(bits); 1333 } 1334 IsOnHeapFromBitField()1335 inline bool IsOnHeapFromBitField() const 1336 { 1337 uint32_t bits = GetBitField(); 1338 return IsOnHeap::Decode(bits); 1339 } 1340 IsGeneratorFunction()1341 inline bool IsGeneratorFunction() const 1342 { 1343 return GetObjectType() == JSType::JS_GENERATOR_FUNCTION; 1344 } 1345 IsAsyncGeneratorFunction()1346 inline bool IsAsyncGeneratorFunction() const 1347 { 1348 return GetObjectType() == JSType::JS_ASYNC_GENERATOR_FUNCTION; 1349 } 1350 IsGeneratorObject()1351 inline bool IsGeneratorObject() const 1352 { 1353 JSType jsType = GetObjectType(); 1354 return jsType == JSType::JS_GENERATOR_OBJECT || jsType == JSType::JS_ASYNC_FUNC_OBJECT; 1355 } 1356 IsAsyncGeneratorObject()1357 inline bool IsAsyncGeneratorObject() const 1358 { 1359 JSType jsType = GetObjectType(); 1360 return jsType == JSType::JS_ASYNC_GENERATOR_OBJECT; 1361 } 1362 IsGeneratorContext()1363 inline bool IsGeneratorContext() const 1364 { 1365 return GetObjectType() == JSType::JS_GENERATOR_CONTEXT; 1366 } 1367 IsAsyncGeneratorRequest()1368 inline bool IsAsyncGeneratorRequest() const 1369 { 1370 JSType jsType = GetObjectType(); 1371 return jsType == JSType::ASYNC_GENERATOR_REQUEST; 1372 } 1373 IsAsyncIteratorRecord()1374 inline bool IsAsyncIteratorRecord() const 1375 { 1376 JSType jsType = GetObjectType(); 1377 return jsType == JSType::ASYNC_ITERATOR_RECORD; 1378 } 1379 IsAsyncFuncObject()1380 inline bool IsAsyncFuncObject() const 1381 { 1382 return GetObjectType() == JSType::JS_ASYNC_FUNC_OBJECT; 1383 } 1384 IsJSPromise()1385 inline bool IsJSPromise() const 1386 { 1387 return GetObjectType() == JSType::JS_PROMISE; 1388 } 1389 IsResolvingFunctionsRecord()1390 inline bool IsResolvingFunctionsRecord() const 1391 { 1392 return GetObjectType() == JSType::RESOLVING_FUNCTIONS_RECORD; 1393 } 1394 IsPromiseRecord()1395 inline bool IsPromiseRecord() const 1396 { 1397 return GetObjectType() == JSType::PROMISE_RECORD; 1398 } 1399 IsPromiseIteratorRecord()1400 inline bool IsPromiseIteratorRecord() const 1401 { 1402 return GetObjectType() == JSType::PROMISE_ITERATOR_RECORD; 1403 } 1404 IsPromiseCapability()1405 inline bool IsPromiseCapability() const 1406 { 1407 return GetObjectType() == JSType::PROMISE_CAPABILITY; 1408 } 1409 IsPromiseReaction()1410 inline bool IsPromiseReaction() const 1411 { 1412 return GetObjectType() == JSType::PROMISE_REACTIONS; 1413 } 1414 IsCellRecord()1415 inline bool IsCellRecord() const 1416 { 1417 return GetObjectType() == JSType::CELL_RECORD; 1418 } 1419 IsCompletionRecord()1420 inline bool IsCompletionRecord() const 1421 { 1422 return GetObjectType() == JSType::COMPLETION_RECORD; 1423 } 1424 IsRecord()1425 inline bool IsRecord() const 1426 { 1427 JSType jsType = GetObjectType(); 1428 return jsType >= JSType::JS_RECORD_FIRST && jsType <= JSType::JS_RECORD_LAST; 1429 } 1430 IsTemplateMap()1431 inline bool IsTemplateMap() const 1432 { 1433 return GetObjectType() == JSType::TEMPLATE_MAP; 1434 } 1435 IsFreeObject()1436 inline bool IsFreeObject() const 1437 { 1438 JSType t = GetObjectType(); 1439 return (t >= JSType::FREE_OBJECT_WITH_ONE_FIELD) && (t <= JSType::FREE_OBJECT_WITH_TWO_FIELD); 1440 } 1441 IsFreeObjectWithShortField()1442 inline bool IsFreeObjectWithShortField() const 1443 { 1444 switch (GetObjectType()) { 1445 case JSType::FREE_OBJECT_WITH_ONE_FIELD: 1446 case JSType::FREE_OBJECT_WITH_NONE_FIELD: 1447 return true; 1448 default: 1449 return false; 1450 } 1451 } 1452 IsFreeObjectWithOneField()1453 inline bool IsFreeObjectWithOneField() const 1454 { 1455 return GetObjectType() == JSType::FREE_OBJECT_WITH_ONE_FIELD; 1456 } 1457 IsFreeObjectWithNoneField()1458 inline bool IsFreeObjectWithNoneField() const 1459 { 1460 return GetObjectType() == JSType::FREE_OBJECT_WITH_NONE_FIELD; 1461 } 1462 IsFreeObjectWithTwoField()1463 inline bool IsFreeObjectWithTwoField() const 1464 { 1465 return GetObjectType() == JSType::FREE_OBJECT_WITH_TWO_FIELD; 1466 } 1467 IsMachineCodeObject()1468 inline bool IsMachineCodeObject() const 1469 { 1470 return GetObjectType() == JSType::MACHINE_CODE_OBJECT; 1471 } 1472 IsTSType()1473 inline bool IsTSType() const 1474 { 1475 JSType jsType = GetObjectType(); 1476 return jsType >= JSType::TS_TYPE_FIRST && jsType <= JSType::TS_TYPE_LAST; 1477 } 1478 IsTSObjectType()1479 inline bool IsTSObjectType() const 1480 { 1481 return GetObjectType() == JSType::TS_OBJECT_TYPE; 1482 } 1483 IsTSClassType()1484 inline bool IsTSClassType() const 1485 { 1486 return GetObjectType() == JSType::TS_CLASS_TYPE; 1487 } 1488 IsTSInterfaceType()1489 inline bool IsTSInterfaceType() const 1490 { 1491 return GetObjectType() == JSType::TS_INTERFACE_TYPE; 1492 } 1493 IsTSUnionType()1494 inline bool IsTSUnionType() const 1495 { 1496 return GetObjectType() == JSType::TS_UNION_TYPE; 1497 } 1498 IsTSClassInstanceType()1499 inline bool IsTSClassInstanceType() const 1500 { 1501 return GetObjectType() == JSType::TS_CLASS_INSTANCE_TYPE; 1502 } 1503 IsTSFunctionType()1504 inline bool IsTSFunctionType() const 1505 { 1506 return GetObjectType() == JSType::TS_FUNCTION_TYPE; 1507 } 1508 IsTSArrayType()1509 inline bool IsTSArrayType() const 1510 { 1511 return GetObjectType() == JSType::TS_ARRAY_TYPE; 1512 } 1513 IsTSIteratorInstanceType()1514 inline bool IsTSIteratorInstanceType() const 1515 { 1516 return GetObjectType() == JSType::TS_ITERATOR_INSTANCE_TYPE; 1517 } 1518 IsTSNamespaceType()1519 inline bool IsTSNamespaceType() const 1520 { 1521 return GetObjectType() == JSType::TS_NAMESPACE_TYPE; 1522 } 1523 IsAOTLiteralInfo()1524 inline bool IsAOTLiteralInfo() const 1525 { 1526 return GetObjectType() == JSType::AOT_LITERAL_INFO; 1527 } 1528 IsVTable()1529 inline bool IsVTable() const 1530 { 1531 return GetObjectType() == JSType::VTABLE; 1532 } 1533 IsModuleRecord()1534 inline bool IsModuleRecord() const 1535 { 1536 JSType jsType = GetObjectType(); 1537 return jsType >= JSType::MODULE_RECORD_FIRST && jsType <= JSType::MODULE_RECORD_LAST; 1538 } 1539 IsSourceTextModule()1540 inline bool IsSourceTextModule() const 1541 { 1542 return GetObjectType() == JSType::SOURCE_TEXT_MODULE_RECORD; 1543 } 1544 IsCjsExports()1545 inline bool IsCjsExports() const 1546 { 1547 return GetObjectType() == JSType::JS_CJS_EXPORTS; 1548 } 1549 IsCjsModule()1550 inline bool IsCjsModule() const 1551 { 1552 return GetObjectType() == JSType::JS_CJS_MODULE; 1553 } 1554 IsCjsRequire()1555 inline bool IsCjsRequire() const 1556 { 1557 return GetObjectType() == JSType::JS_CJS_REQUIRE; 1558 } 1559 IsImportEntry()1560 inline bool IsImportEntry() const 1561 { 1562 return GetObjectType() == JSType::IMPORTENTRY_RECORD; 1563 } 1564 IsLocalExportEntry()1565 inline bool IsLocalExportEntry() const 1566 { 1567 return GetObjectType() == JSType::LOCAL_EXPORTENTRY_RECORD; 1568 } 1569 IsIndirectExportEntry()1570 inline bool IsIndirectExportEntry() const 1571 { 1572 return GetObjectType() == JSType::INDIRECT_EXPORTENTRY_RECORD; 1573 } 1574 IsStarExportEntry()1575 inline bool IsStarExportEntry() const 1576 { 1577 return GetObjectType() == JSType::STAR_EXPORTENTRY_RECORD; 1578 } 1579 IsResolvedBinding()1580 inline bool IsResolvedBinding() const 1581 { 1582 return GetObjectType() == JSType::RESOLVEDBINDING_RECORD; 1583 } 1584 IsResolvedIndexBinding()1585 inline bool IsResolvedIndexBinding() const 1586 { 1587 return GetObjectType() == JSType::RESOLVEDINDEXBINDING_RECORD; 1588 } 1589 IsModuleNamespace()1590 inline bool IsModuleNamespace() const 1591 { 1592 return GetObjectType() == JSType::JS_MODULE_NAMESPACE; 1593 } 1594 IsJSSharedObject()1595 inline bool IsJSSharedObject() const 1596 { 1597 return GetObjectType() == JSType::JS_SHARED_OBJECT; 1598 } 1599 SetElementsKind(ElementsKind kind)1600 inline void SetElementsKind(ElementsKind kind) 1601 { 1602 uint32_t bits = GetBitField(); 1603 uint32_t newVal = ElementsKindBits::Update(bits, kind); 1604 SetBitField(newVal); 1605 } 1606 GetElementsKind()1607 inline ElementsKind GetElementsKind() const 1608 { 1609 uint32_t bits = GetBitField(); 1610 return ElementsKindBits::Decode(bits); 1611 } 1612 SetLevel(uint8_t level)1613 inline void SetLevel(uint8_t level) 1614 { 1615 uint32_t bits = GetBitField(); 1616 uint32_t newVal = LevelBit::Update(bits, level); 1617 SetBitField(newVal); 1618 } 1619 GetLevel()1620 inline uint8_t GetLevel() const 1621 { 1622 uint32_t bits = GetBitField(); 1623 return LevelBit::Decode(bits); 1624 } 1625 SetIsDictionaryElement(bool value)1626 inline void SetIsDictionaryElement(bool value) 1627 { 1628 uint32_t newVal = DictionaryElementBits::Update(GetBitField(), value); 1629 SetBitField(newVal); 1630 } IsDictionaryElement()1631 inline bool IsDictionaryElement() const 1632 { 1633 return DictionaryElementBits::Decode(GetBitField()); 1634 } SetIsStableElements(bool value)1635 inline void SetIsStableElements(bool value) 1636 { 1637 uint32_t newVal = IsStableElementsBit::Update(GetBitField(), value); 1638 SetBitField(newVal); 1639 } IsStableElements()1640 inline bool IsStableElements() const 1641 { 1642 return IsStableElementsBit::Decode(GetBitField()); 1643 } IsStableJSArguments()1644 inline bool IsStableJSArguments() const 1645 { 1646 uint32_t bits = GetBitField(); 1647 auto type = ObjectTypeBits::Decode(bits); 1648 return IsStableElementsBit::Decode(bits) && (type == JSType::JS_ARGUMENTS); 1649 } IsStableJSArray()1650 inline bool IsStableJSArray() const 1651 { 1652 uint32_t bits = GetBitField(); 1653 auto type = ObjectTypeBits::Decode(bits); 1654 return IsStableElementsBit::Decode(bits) && (type == JSType::JS_ARRAY); 1655 } SetHasConstructor(bool value)1656 inline void SetHasConstructor(bool value) 1657 { 1658 JSTaggedType newVal = HasConstructorBits::Update(GetBitField(), value); 1659 SetBitField(newVal); 1660 } HasConstructor()1661 inline bool HasConstructor() const 1662 { 1663 return HasConstructorBits::Decode(GetBitField()); 1664 } 1665 SetNumberOfProps(uint32_t num)1666 inline void SetNumberOfProps(uint32_t num) 1667 { 1668 uint32_t bits = GetBitField1(); 1669 uint32_t newVal = NumberOfPropsBits::Update(bits, num); 1670 SetBitField1(newVal); 1671 } 1672 IncNumberOfProps()1673 inline void IncNumberOfProps() 1674 { 1675 ASSERT(NumberOfProps() < PropertyAttributes::MAX_FAST_PROPS_CAPACITY); 1676 SetNumberOfProps(NumberOfProps() + 1); 1677 } 1678 NumberOfProps()1679 inline uint32_t NumberOfProps() const 1680 { 1681 uint32_t bits = GetBitField1(); 1682 return NumberOfPropsBits::Decode(bits); 1683 } 1684 GetNextInlinedPropsIndex()1685 inline int32_t GetNextInlinedPropsIndex() const 1686 { 1687 uint32_t inlinedProperties = GetInlinedProperties(); 1688 uint32_t numberOfProps = NumberOfProps(); 1689 if (numberOfProps < inlinedProperties) { 1690 return numberOfProps; 1691 } 1692 return -1; 1693 } 1694 GetNextNonInlinedPropsIndex()1695 inline int32_t GetNextNonInlinedPropsIndex() const 1696 { 1697 uint32_t inlinedProperties = GetInlinedProperties(); 1698 uint32_t numberOfProps = NumberOfProps(); 1699 if (numberOfProps >= inlinedProperties) { 1700 return numberOfProps - inlinedProperties; 1701 } 1702 return -1; 1703 } 1704 GetObjectSize()1705 inline uint32_t GetObjectSize() const 1706 { 1707 uint32_t bits = GetBitField1(); 1708 return ObjectSizeInWordsBits::Decode(bits) * JSTaggedValue::TaggedTypeSize(); 1709 } 1710 GetObjectSizeExcludeInlinedProps()1711 inline uint32_t GetObjectSizeExcludeInlinedProps() const 1712 { 1713 return GetObjectSize() - GetInlinedProperties() * JSTaggedValue::TaggedTypeSize(); 1714 } 1715 SetObjectSize(uint32_t num)1716 inline void SetObjectSize(uint32_t num) 1717 { 1718 ASSERT((num / JSTaggedValue::TaggedTypeSize()) <= MAX_OBJECT_SIZE_IN_WORDS); 1719 uint32_t bits = GetBitField1(); 1720 uint32_t newVal = ObjectSizeInWordsBits::Update(bits, num / JSTaggedValue::TaggedTypeSize()); 1721 SetBitField1(newVal); 1722 } 1723 GetInlinedPropertiesOffset(uint32_t index)1724 inline uint32_t GetInlinedPropertiesOffset(uint32_t index) const 1725 { 1726 ASSERT(index < GetInlinedProperties()); 1727 return GetInlinedPropertiesIndex(index) * JSTaggedValue::TaggedTypeSize(); 1728 } 1729 GetInlinedPropertiesIndex(uint32_t index)1730 inline uint32_t GetInlinedPropertiesIndex(uint32_t index) const 1731 { 1732 ASSERT(index < GetInlinedProperties()); 1733 uint32_t bits = GetBitField1(); 1734 return InlinedPropsStartBits::Decode(bits) + index; 1735 } 1736 SetInlinedPropsStart(uint32_t num)1737 inline void SetInlinedPropsStart(uint32_t num) 1738 { 1739 uint32_t bits = GetBitField1(); 1740 uint32_t newVal = InlinedPropsStartBits::Update(bits, num / JSTaggedValue::TaggedTypeSize()); 1741 SetBitField1(newVal); 1742 } 1743 GetInlinedPropsStartSize()1744 inline uint32_t GetInlinedPropsStartSize() const 1745 { 1746 uint32_t bits = GetBitField1(); 1747 return InlinedPropsStartBits::Decode(bits) * JSTaggedValue::TaggedTypeSize(); 1748 } 1749 GetInlinedProperties()1750 inline uint32_t GetInlinedProperties() const 1751 { 1752 JSType type = GetObjectType(); 1753 if (JSType::JS_OBJECT_FIRST <= type && type <= JSType::JS_OBJECT_LAST) { 1754 uint32_t bits = GetBitField1(); 1755 return static_cast<uint32_t>(ObjectSizeInWordsBits::Decode(bits) - InlinedPropsStartBits::Decode(bits)); 1756 } else { 1757 return 0; 1758 } 1759 } 1760 SetHasDeleteProperty(bool flag)1761 inline void SetHasDeleteProperty(bool flag) const 1762 { 1763 HasDeletePropertyBit::Set<uint32_t>(flag, GetBitField1Addr()); 1764 } 1765 HasDeleteProperty()1766 inline bool HasDeleteProperty() const 1767 { 1768 uint32_t bits = GetBitField1(); 1769 return HasDeletePropertyBit::Decode(bits); 1770 } 1771 SetIsAllTaggedProp(bool flag)1772 inline void SetIsAllTaggedProp(bool flag) const 1773 { 1774 IsAllTaggedPropBit::Set<uint32_t>(flag, GetBitField1Addr()); 1775 } 1776 IsAllTaggedProp()1777 inline bool IsAllTaggedProp() const 1778 { 1779 uint32_t bits = GetBitField1(); 1780 return IsAllTaggedPropBit::Decode(bits); 1781 } 1782 1783 inline static JSHClass *FindRootHClass(JSHClass *hclass); 1784 inline static JSTaggedValue FindProtoHClass(JSHClass *hclass); 1785 inline static JSTaggedValue FindProtoRootHClass(JSHClass *hclass); 1786 inline static void UpdateRootHClass(const JSThread *thread, const JSHandle<JSHClass> &parent, 1787 const JSHandle<JSHClass> &child); 1788 1789 inline static int FindPropertyEntry(const JSThread *thread, JSHClass *hclass, JSTaggedValue key); 1790 1791 static PropertyLookupResult LookupPropertyInAotHClass(const JSThread *thread, JSHClass *hclass, JSTaggedValue key); 1792 static PropertyLookupResult LookupPropertyInPGOHClass(const JSThread *thread, JSHClass *hclass, JSTaggedValue key); 1793 static PropertyLookupResult LookupPropertyInBuiltinPrototypeHClass(const JSThread *thread, JSHClass *hclass, 1794 JSTaggedValue key); 1795 static PropertyLookupResult LookupPropertyInBuiltinHClass(const JSThread *thread, JSHClass *hclass, 1796 JSTaggedValue key); 1797 1798 static constexpr size_t PROTOTYPE_OFFSET = TaggedObjectSize(); 1799 ACCESSORS(Proto, PROTOTYPE_OFFSET, LAYOUT_OFFSET); 1800 ACCESSORS_SYNCHRONIZED(Layout, LAYOUT_OFFSET, TRANSTIONS_OFFSET); 1801 ACCESSORS(Transitions, TRANSTIONS_OFFSET, PARENT_OFFSET); 1802 ACCESSORS(Parent, PARENT_OFFSET, PROTO_CHANGE_MARKER_OFFSET); 1803 ACCESSORS(ProtoChangeMarker, PROTO_CHANGE_MARKER_OFFSET, PROTO_CHANGE_DETAILS_OFFSET); 1804 ACCESSORS(ProtoChangeDetails, PROTO_CHANGE_DETAILS_OFFSET, ENUM_CACHE_OFFSET); 1805 ACCESSORS(EnumCache, ENUM_CACHE_OFFSET, SUPERS_OFFSET); 1806 ACCESSORS(Supers, SUPERS_OFFSET, VTABLE_OFFSET); 1807 ACCESSORS(VTable, VTABLE_OFFSET, BIT_FIELD_OFFSET); 1808 ACCESSORS_PRIMITIVE_FIELD(BitField, uint32_t, BIT_FIELD_OFFSET, BIT_FIELD1_OFFSET); 1809 ACCESSORS_PRIMITIVE_FIELD(BitField1, uint32_t, BIT_FIELD1_OFFSET, LAST_OFFSET); 1810 DEFINE_ALIGN_SIZE(LAST_OFFSET); 1811 1812 static JSHandle<JSTaggedValue> SetPrototypeWithNotification(const JSThread *thread, 1813 const JSHandle<JSTaggedValue> &hclass, 1814 const JSHandle<JSTaggedValue> &proto); 1815 void SetPrototype(const JSThread *thread, JSTaggedValue proto); 1816 void SetPrototype(const JSThread *thread, const JSHandle<JSTaggedValue> &proto); 1817 static void OptimizePrototypeForIC(const JSThread *thread, const JSHandle<JSTaggedValue> &proto); GetPrototype()1818 inline JSTaggedValue GetPrototype() const 1819 { 1820 return GetProto(); 1821 } 1822 1823 inline JSHClass *FindTransitions(const JSTaggedValue &key, const JSTaggedValue &attributes); 1824 1825 DECL_DUMP() 1826 1827 static CString DumpJSType(JSType type); 1828 1829 static JSHandle<JSHClass> CreateRootHClass(const JSThread *thread, const HClassLayoutDesc *desc, uint32_t maxNum); 1830 static JSHandle<JSHClass> CreateChildHClass( 1831 const JSThread *thread, const JSHandle<JSHClass> &parent, const HClassLayoutDesc *desc); 1832 static bool DumpForRootHClass(const JSHClass *hclass, HClassLayoutDesc *desc); 1833 static bool DumpForChildHClass(const JSHClass *hclass, HClassLayoutDesc *desc); 1834 static bool UpdateRootLayoutDesc( 1835 const JSHClass *hclass, const PGOHClassTreeDesc *treeDesc, HClassLayoutDesc *rootDesc); 1836 static bool UpdateChildLayoutDesc(const JSHClass *hclass, HClassLayoutDesc *childDesc); 1837 static CString DumpToString(JSTaggedType hclassVal); 1838 1839 DECL_VISIT_OBJECT(PROTOTYPE_OFFSET, BIT_FIELD_OFFSET); 1840 inline JSHClass *FindProtoTransitions(const JSTaggedValue &key, const JSTaggedValue &proto); 1841 1842 private: 1843 static inline void AddTransitions(const JSThread *thread, const JSHandle<JSHClass> &parent, 1844 const JSHandle<JSHClass> &child, const JSHandle<JSTaggedValue> &key, 1845 PropertyAttributes attr); 1846 static inline void AddExtensionTransitions(const JSThread *thread, const JSHandle<JSHClass> &parent, 1847 const JSHandle<JSHClass> &child, const JSHandle<JSTaggedValue> &key); 1848 static inline void AddProtoTransitions(const JSThread *thread, const JSHandle<JSHClass> &parent, 1849 const JSHandle<JSHClass> &child, const JSHandle<JSTaggedValue> &key, 1850 const JSHandle<JSTaggedValue> &proto); 1851 template<bool checkDuplicateKeys = false> 1852 static inline void AddPropertyToNewHClass(const JSThread *thread, JSHandle<JSHClass> &jshclass, 1853 JSHandle<JSHClass> &newJsHClass, const JSHandle<JSTaggedValue> &key, 1854 const PropertyAttributes &attr); 1855 1856 inline void Copy(const JSThread *thread, const JSHClass *jshclass); 1857 GetBitFieldAddr()1858 uint32_t *GetBitFieldAddr() const 1859 { 1860 return reinterpret_cast<uint32_t *>(ToUintPtr(this) + BIT_FIELD_OFFSET); 1861 } 1862 GetBitField1Addr()1863 uint32_t *GetBitField1Addr() const 1864 { 1865 return reinterpret_cast<uint32_t *>(ToUintPtr(this) + BIT_FIELD1_OFFSET); 1866 } 1867 friend class RuntimeStubs; 1868 }; 1869 static_assert(JSHClass::BIT_FIELD_OFFSET % static_cast<uint8_t>(MemAlignment::MEM_ALIGN_OBJECT) == 0); 1870 1871 // record property look up info in local and vtable 1872 class PropertyLookupResult { 1873 public: 1874 static constexpr uint32_t OFFSET_BITFIELD_NUM = 14; 1875 using IsFoundBit = BitField<bool, 0, 1>; 1876 using IsLocalBit = IsFoundBit::NextFlag; 1877 using IsNotHoleBit = IsLocalBit::NextFlag; 1878 using IsAccessorBit = IsNotHoleBit::NextFlag; 1879 using OffsetBits = IsAccessorBit::NextField<uint32_t, OFFSET_BITFIELD_NUM>; 1880 using WritableField = OffsetBits::NextFlag; 1881 using RepresentationBits = WritableField::NextField<Representation, PropertyAttributes::REPRESENTATION_NUM>; 1882 using IsInlinedPropsBits = RepresentationBits::NextFlag; 1883 data_(data)1884 explicit PropertyLookupResult(uint32_t data = 0) : data_(data) {} 1885 ~PropertyLookupResult() = default; 1886 DEFAULT_NOEXCEPT_MOVE_SEMANTIC(PropertyLookupResult); 1887 DEFAULT_COPY_SEMANTIC(PropertyLookupResult); 1888 IsFound()1889 inline bool IsFound() const 1890 { 1891 return IsFoundBit::Get(data_); 1892 } 1893 SetIsFound(bool flag)1894 inline void SetIsFound(bool flag) 1895 { 1896 IsFoundBit::Set(flag, &data_); 1897 } 1898 IsWritable()1899 inline bool IsWritable() const 1900 { 1901 return WritableField::Get(data_); 1902 } 1903 SetIsWritable(bool flag)1904 inline void SetIsWritable(bool flag) 1905 { 1906 WritableField::Set(flag, &data_); 1907 } 1908 IsLocal()1909 inline bool IsLocal() const 1910 { 1911 return IsLocalBit::Get(data_); 1912 } 1913 SetIsLocal(bool flag)1914 inline void SetIsLocal(bool flag) 1915 { 1916 IsLocalBit::Set(flag, &data_); 1917 } 1918 IsNotHole()1919 inline bool IsNotHole() const 1920 { 1921 return IsNotHoleBit::Get(data_); 1922 } 1923 SetIsNotHole(bool flag)1924 inline void SetIsNotHole(bool flag) 1925 { 1926 IsNotHoleBit::Set(flag, &data_); 1927 } 1928 IsVtable()1929 inline bool IsVtable() const 1930 { 1931 return IsFound() && !IsLocal(); 1932 } 1933 SetIsVtable()1934 inline void SetIsVtable() 1935 { 1936 SetIsFound(true); 1937 SetIsLocal(false); 1938 } 1939 IsAccessor()1940 inline bool IsAccessor() const 1941 { 1942 return IsAccessorBit::Get(data_); 1943 } 1944 SetIsAccessor(bool flag)1945 inline void SetIsAccessor(bool flag) 1946 { 1947 IsAccessorBit::Set(flag, &data_); 1948 } 1949 IsFunction()1950 inline bool IsFunction() const 1951 { 1952 return IsVtable() && !IsAccessor(); 1953 } 1954 GetOffset()1955 inline uint32_t GetOffset() const 1956 { 1957 return OffsetBits::Get(data_); 1958 } 1959 SetOffset(uint32_t offset)1960 inline void SetOffset(uint32_t offset) 1961 { 1962 OffsetBits::Set<uint32_t>(offset, &data_); 1963 } 1964 SetRepresentation(Representation rep)1965 inline void SetRepresentation(Representation rep) 1966 { 1967 RepresentationBits::Set(rep, &data_); 1968 } 1969 GetRepresentation()1970 inline Representation GetRepresentation() 1971 { 1972 return RepresentationBits::Get(data_); 1973 } 1974 SetIsInlinedProps(bool flag)1975 inline void SetIsInlinedProps(bool flag) 1976 { 1977 IsInlinedPropsBits::Set(flag, &data_); 1978 } 1979 IsInlinedProps()1980 inline bool IsInlinedProps() 1981 { 1982 return IsInlinedPropsBits::Get(data_); 1983 } 1984 GetData()1985 inline uint32_t GetData() const 1986 { 1987 return data_; 1988 } 1989 1990 private: 1991 uint32_t data_ {0}; 1992 }; 1993 static_assert(PropertyLookupResult::OffsetBits::MaxValue() > 1994 (PropertyAttributes::MAX_FAST_PROPS_CAPACITY * JSTaggedValue::TaggedTypeSize())); 1995 } // namespace panda::ecmascript 1996 1997 #endif // ECMASCRIPT_JS_HCLASS_H 1998