From 6351d7dd0171e606dfab58e22b590a9db1d06b08 Mon Sep 17 00:00:00 2001 From: Vsevolod Pukhov Date: Mon, 10 Oct 2022 20:26:36 +0300 Subject: [PATCH 1/2] Improve ECMAScript field accessors, compute NativeFields * Compute GC NativeFields mask in compile-time, add alignment checks * Remove manual offset calculations, make accessors safe Signed-off-by: Vsevolod Pukhov --- runtime/accessor_data.h | 17 +- runtime/asm_defines/asm_defines.def | 42 +-- runtime/builtins.cpp | 255 ++++++++---------- runtime/class_info_extractor.cpp | 11 +- runtime/class_info_extractor.h | 26 +- runtime/class_linker/program_object.h | 26 +- runtime/containers/containers_private.cpp | 2 +- runtime/ecma_macro_accessors.h | 172 ++++++++++++ runtime/ecma_macros.h | 125 +-------- runtime/ecma_module.h | 6 +- runtime/ecma_string.h | 9 +- runtime/ecma_vm.cpp | 4 +- runtime/free_object.h | 15 +- runtime/global_env.h | 3 +- runtime/global_env_constants.cpp | 129 ++++----- runtime/ic/ic_handler.h | 22 +- runtime/ic/property_box.h | 6 +- runtime/ic/proto_change_details.h | 13 +- runtime/jobs/micro_job_queue.h | 9 +- runtime/jobs/pending_job.h | 9 +- runtime/js_arguments.h | 7 +- runtime/js_array.h | 9 +- runtime/js_array_iterator.h | 11 +- runtime/js_arraybuffer.h | 10 +- runtime/js_arraylist.h | 6 +- runtime/js_async_from_sync_iterator_object.h | 16 +- runtime/js_async_function.h | 14 +- runtime/js_async_generator_object.h | 14 +- runtime/js_bigint.h | 8 +- runtime/js_collator.h | 25 +- runtime/js_dataview.h | 13 +- runtime/js_date.h | 9 +- runtime/js_date_time_format.h | 29 +- runtime/js_finalization_registry.h | 10 +- runtime/js_for_in_iterator.h | 19 +- runtime/js_function.cpp | 2 +- runtime/js_function.h | 102 +++----- runtime/js_function_extra_info.h | 10 +- runtime/js_generator_object.h | 34 +-- runtime/js_global_object.h | 2 - runtime/js_hclass.h | 26 +- runtime/js_intl.h | 7 +- runtime/js_locale.h | 7 +- runtime/js_map.h | 7 +- runtime/js_map_iterator.h | 11 +- runtime/js_native_pointer.h | 9 +- runtime/js_number_format.h | 49 ++-- runtime/js_object.h | 19 +- runtime/js_plural_rules.h | 29 +- runtime/js_primitive_ref.h | 7 +- runtime/js_promise.h | 63 ++--- runtime/js_proxy.h | 11 +- runtime/js_realm.h | 8 +- runtime/js_regexp.h | 17 +- runtime/js_regexp_iterator.h | 12 +- runtime/js_relative_time_format.h | 21 +- runtime/js_set.h | 6 +- runtime/js_set_iterator.h | 11 +- runtime/js_string_iterator.h | 8 +- runtime/js_symbol.h | 11 +- runtime/js_typed_array.h | 16 +- runtime/js_weak_container.h | 19 +- runtime/mem/ecma_reference_processor.cpp | 2 +- runtime/mem/object_xray-inl.h | 262 ------------------- runtime/mem/object_xray.h | 2 - runtime/object_factory.cpp | 45 ++-- runtime/object_factory.h | 44 +++- runtime/object_wrapper.h | 7 +- runtime/record.h | 2 + runtime/tagged_array.h | 14 +- tests/runtime/mem/object_helpers_test.cpp | 17 +- tests/runtime/napi/jsnapi_tests.cpp | 4 +- 72 files changed, 865 insertions(+), 1159 deletions(-) create mode 100644 runtime/ecma_macro_accessors.h diff --git a/runtime/accessor_data.h b/runtime/accessor_data.h index c03eb1e11..de0b0424d 100644 --- a/runtime/accessor_data.h +++ b/runtime/accessor_data.h @@ -61,12 +61,12 @@ public: return set_func(thread, obj, value, may_throw); } - static constexpr size_t GETTER_OFFSET = Record::SIZE; - ACCESSORS(Getter, GETTER_OFFSET, SETTER_OFFSET); - ACCESSORS(Setter, SETTER_OFFSET, SIZE); + ACCESSORS_BASE(Record) + ACCESSORS(0, Getter) + ACCESSORS(1, Setter) + ACCESSORS_FINISH(2) DECL_DUMP() - DECL_VISIT_OBJECT(GETTER_OFFSET, SIZE) }; class CompletionRecord final : public Record { @@ -94,13 +94,12 @@ public: return !JSTaggedValue::SameValue(this->GetType(), JSTaggedValue(static_cast(NORMAL))); } - static constexpr size_t TYPE_OFFSET = Record::SIZE; - ACCESSORS(Type, TYPE_OFFSET, VALUE_OFFSET); - ACCESSORS(Value, VALUE_OFFSET, SIZE); + ACCESSORS_BASE(Record) + ACCESSORS(0, Type) + ACCESSORS(1, Value) + ACCESSORS_FINISH(2) DECL_DUMP() - - DECL_VISIT_OBJECT(TYPE_OFFSET, SIZE) }; } // namespace panda::ecmascript #endif // ECMASCRIPT_ACCESSOR_DATA_H diff --git a/runtime/asm_defines/asm_defines.def b/runtime/asm_defines/asm_defines.def index 4c79c9bb3..8b943fa1a 100644 --- a/runtime/asm_defines/asm_defines.def +++ b/runtime/asm_defines/asm_defines.def @@ -16,11 +16,11 @@ DEFINE_VALUE(JSTYPE_JS_ARRAY, static_cast(panda::ecmascript::JSType::JS DEFINE_VALUE(JSTYPE_PROTOTYPE_HANDLER, static_cast(panda::ecmascript::JSType::PROTOTYPE_HANDLER)) DEFINE_VALUE(JSTYPE_TRANSITION_HANDLER, static_cast(panda::ecmascript::JSType::TRANSITION_HANDLER)) DEFINE_VALUE(JSTYPE_JS_FUNCTION, static_cast(panda::ecmascript::JSType::JS_FUNCTION)) -DEFINE_VALUE(ECMASTRING_MIX_LENGTH_OFFSET, panda::ecmascript::EcmaString::MIX_LENGTH_OFFSET) +DEFINE_VALUE(ECMASTRING_MIX_LENGTH_OFFSET, panda::ecmascript::EcmaString::GetMixLengthOffset()) DEFINE_VALUE(ECMASTRING_DATA_OFFSET, panda::ecmascript::EcmaString::DATA_OFFSET) DEFINE_VALUE(ECMASTRING_STRING_COMPRESSED_MASK, panda::ecmascript::EcmaString::GetStringCompressionMask()) -DEFINE_VALUE(JSFORINITERATOR_FAST_REMAINING_INDEX_OFFSET, panda::ecmascript::JSForInIterator::FAST_REMAINING_INDEX_OFFSET) -DEFINE_VALUE(JSFORINITERATOR_REMAINING_KEYS_OFFSET, panda::ecmascript::JSForInIterator::REMAINING_KEYS_OFFSET) +DEFINE_VALUE(JSFORINITERATOR_FAST_REMAINING_INDEX_OFFSET, panda::ecmascript::JSForInIterator::GetFastRemainingIndexOffset()) +DEFINE_VALUE(JSFORINITERATOR_REMAINING_KEYS_OFFSET, panda::ecmascript::JSForInIterator::GetRemainingKeysOffset()) DEFINE_VALUE(TAGGEDARRAY_DATA_OFFSET, panda::ecmascript::TaggedArray::DATA_OFFSET) DEFINE_VALUE(TAGGEDQUEUE_START_INDEX, panda::ecmascript::TaggedQueue::START_INDEX) DEFINE_VALUE(TAGGEDQUEUE_END_INDEX, panda::ecmascript::TaggedQueue::END_INDEX) @@ -34,7 +34,7 @@ DEFINE_VALUE(JSHCLASS_BITFIELD_EXTENSIBLE_START_BIT, panda::ecmascript::JSHClass DEFINE_VALUE(JSHCLASS_BITFIELD_INLINED_PROPS_START_BITS_START_BIT, panda::ecmascript::JSHClass::InlinedPropsStartBits::START_BIT) DEFINE_VALUE(JSHCLASS_BITFIELD_INLINED_PROPS_START_BITS_MASK, panda::ecmascript::JSHClass::InlinedPropsStartBits::MaxValue()) DEFINE_VALUE(JSHCLASS_HCLASS_OFFSET, panda::ecmascript::JSHClass::GetHClassOffset()) -DEFINE_VALUE(JSHCLASS_LAYOUT_OFFSET, panda::ecmascript::JSHClass::LAYOUT_OFFSET) +DEFINE_VALUE(JSHCLASS_LAYOUT_OFFSET, panda::ecmascript::JSHClass::GetLayoutOffset()) DEFINE_VALUE(JSHCLASS_BITFIELD1_OFFSET, panda::ecmascript::JSHClass::BIT_FIELD1_OFFSET) DEFINE_VALUE(JSHCLASS_BITFIELD1_NUMBER_OF_PROPS_BITS_START_BIT, panda::ecmascript::JSHClass::NumberOfPropsBits::START_BIT) DEFINE_VALUE(JSHCLASS_BITFIELD1_NUMBER_OF_PROPS_BITS_MASK, panda::ecmascript::JSHClass::NumberOfPropsBits::MaxValue()) @@ -44,25 +44,25 @@ DEFINE_VALUE(JSHCLASS_LAYOUT_PROPERTIES_SIZE, sizeof(panda::ecmascript::Properti DEFINE_VALUE(JSHCLASS_LAYOUT_PROPERTIES_KEY_OFFSET, panda::ecmascript::Properties::GetKeyOffset()) DEFINE_VALUE(JSHCLASS_LAYOUT_PROPERTIES_ATTR_OFFSET, panda::ecmascript::Properties::GetAttrOffset()) DEFINE_VALUE(JSHCLASS_LAYOUT_INFO_NUMBER_OF_PROPERTIES_INDEX, panda::ecmascript::LayoutInfo::NUMBER_OF_PROPERTIES_INDEX) -DEFINE_VALUE(JSOBJECT_PROPERTIES_OFFSET, panda::ecmascript::JSObject::PROPERTIES_OFFSET) -DEFINE_VALUE(JSOBJECT_ELEMENTS_OFFSET, panda::ecmascript::JSObject::ELEMENTS_OFFSET) +DEFINE_VALUE(JSOBJECT_PROPERTIES_OFFSET, panda::ecmascript::JSObject::GetPropertiesOffset()) +DEFINE_VALUE(JSOBJECT_ELEMENTS_OFFSET, panda::ecmascript::JSObject::GetElementsOffset()) DEFINE_VALUE(JSOBJECT_MAX_ELEMENT_INDEX, static_cast(panda::ecmascript::JSObject::MAX_ELEMENT_INDEX)) -DEFINE_VALUE(JSARRAY_LENGTH_OFFSET, panda::ecmascript::JSArray::LENGTH_OFFSET) -DEFINE_VALUE(JSFUNCTION_METHOD_OFFSET, panda::ecmascript::JSFunction::METHOD_OFFSET) -DEFINE_VALUE(JSFUNCTION_PROFILE_TYPE_INFO_OFFSET, panda::ecmascript::JSFunction::PROFILE_TYPE_INFO_OFFSET) -DEFINE_VALUE(JSFUNCTION_CONSTANT_POOL_OFFSET, panda::ecmascript::JSFunction::CONSTANT_POOL_OFFSET) -DEFINE_VALUE(JSFUNCTION_LEXICAL_ENV_OFFSET, panda::ecmascript::JSFunction::LEXICAL_ENV_OFFSET) -DEFINE_VALUE(JSFUNCTION_FUNCTION_INFO_FLAG_OFFSET, panda::ecmascript::JSFunction::FUNCTION_INFO_FLAG_OFFSET) +DEFINE_VALUE(JSARRAY_LENGTH_OFFSET, panda::ecmascript::JSArray::GetLengthOffset()) +DEFINE_VALUE(JSFUNCTION_METHOD_OFFSET, panda::ecmascript::JSFunction::GetMethodOffset()) +DEFINE_VALUE(JSFUNCTION_PROFILE_TYPE_INFO_OFFSET, panda::ecmascript::JSFunction::GetProfileTypeInfoOffset()) +DEFINE_VALUE(JSFUNCTION_CONSTANT_POOL_OFFSET, panda::ecmascript::JSFunction::GetConstantPoolOffset()) +DEFINE_VALUE(JSFUNCTION_LEXICAL_ENV_OFFSET, panda::ecmascript::JSFunction::GetLexicalEnvOffset()) +DEFINE_VALUE(JSFUNCTION_FUNCTION_INFO_FLAG_OFFSET, panda::ecmascript::JSFunction::GetFunctionInfoFlagOffset()) DEFINE_VALUE(JSFUNCTION_FUNCTION_INFO_FLAG_IS_STRICT_START_BIT, panda::ecmascript::JSFunction::StrictBit::START_BIT) -DEFINE_VALUE(JSPROPERTY_BOX_VALUE_OFFSET, panda::ecmascript::PropertyBox::VALUE_OFFSET) -DEFINE_VALUE(JSTRANSITION_HANDLER_HANDLER_INFO_OFFSET, panda::ecmascript::TransitionHandler::HANDLER_INFO_OFFSET) -DEFINE_VALUE(JSTRANSITION_HANDLER_HCLASS_OFFSET, panda::ecmascript::TransitionHandler::TRANSITION_HCLASS_OFFSET) -DEFINE_VALUE(JSPROTOTYPE_HANDLER_HANDLER_INFO_OFFSET, panda::ecmascript::PrototypeHandler::HANDLER_INFO_OFFSET) -DEFINE_VALUE(JSPROTOTYPE_HANDLER_PROTO_CELL_OFFSET, panda::ecmascript::PrototypeHandler::PROTO_CELL_OFFSET) -DEFINE_VALUE(JSPROTOTYPE_HANDLER_HOLDER_OFFSET, panda::ecmascript::PrototypeHandler::HOLDER_OFFSET) -DEFINE_VALUE(JSPROTO_CHANGE_MARKER_HAS_CHANGED_OFFSET, panda::ecmascript::ProtoChangeMarker::HAS_CHANGED_OFFSET) -DEFINE_VALUE(JS_STRING_HASHCODE_OFFSET, panda::ecmascript::EcmaString::HASHCODE_OFFSET) -DEFINE_VALUE(JS_SYMBOL_HASHFIELD_OFFSET, panda::ecmascript::JSSymbol::HASHFIELD_OFFSET) +DEFINE_VALUE(JSPROPERTY_BOX_VALUE_OFFSET, panda::ecmascript::PropertyBox::GetValueOffset()) +DEFINE_VALUE(JSTRANSITION_HANDLER_HANDLER_INFO_OFFSET, panda::ecmascript::TransitionHandler::GetHandlerInfoOffset()) +DEFINE_VALUE(JSTRANSITION_HANDLER_HCLASS_OFFSET, panda::ecmascript::TransitionHandler::GetTransitionHClassOffset()) +DEFINE_VALUE(JSPROTOTYPE_HANDLER_HANDLER_INFO_OFFSET, panda::ecmascript::PrototypeHandler::GetHandlerInfoOffset()) +DEFINE_VALUE(JSPROTOTYPE_HANDLER_PROTO_CELL_OFFSET, panda::ecmascript::PrototypeHandler::GetProtoCellOffset()) +DEFINE_VALUE(JSPROTOTYPE_HANDLER_HOLDER_OFFSET, panda::ecmascript::PrototypeHandler::GetHolderOffset()) +DEFINE_VALUE(JSPROTO_CHANGE_MARKER_HAS_CHANGED_OFFSET, panda::ecmascript::ProtoChangeMarker::GetHasChangedOffset()) +DEFINE_VALUE(JS_STRING_HASHCODE_OFFSET, panda::ecmascript::EcmaString::GetRawHashcodeOffset()) +DEFINE_VALUE(JS_SYMBOL_HASHFIELD_OFFSET, panda::ecmascript::JSSymbol::GetHashFieldOffset()) DEFINE_VALUE(IC_HANDLER_KIND_BIT_START_BIT, panda::ecmascript::HandlerBase::KindBit::START_BIT) DEFINE_VALUE(IC_HANDLER_KIND_BIT_MASK, panda::ecmascript::HandlerBase::KindBit::MaxValue()) DEFINE_VALUE(IC_HANDLER_OFFSET_BIT_START_BIT, panda::ecmascript::HandlerBase::OffsetBit::START_BIT) diff --git a/runtime/builtins.cpp b/runtime/builtins.cpp index 52cefc0a0..5294de92e 100644 --- a/runtime/builtins.cpp +++ b/runtime/builtins.cpp @@ -162,29 +162,27 @@ void Builtins::Initialize(const JSHandle &env, JSThread *thread) JSHandle nullHandle(thread, JSTaggedValue::Null()); // Object.prototype[dynclass] - JSHandle objPrototypeDynclass = factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, nullHandle); + JSHandle objPrototypeDynclass = factory_->CreateDynClass(JSType::JS_OBJECT, nullHandle); // Object.prototype JSHandle objFuncPrototype = factory_->NewJSObject(objPrototypeDynclass); JSHandle objFuncPrototypeVal(objFuncPrototype); // Object.prototype_or_dynclass - JSHandle objFuncDynclass = - factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, objFuncPrototypeVal); + JSHandle objFuncDynclass = factory_->CreateDynClass(JSType::JS_OBJECT, objFuncPrototypeVal); // GLobalObject.prototype_or_dynclass - JSHandle globalObjFuncDynclass = factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_GLOBAL_OBJECT, 0); + JSHandle globalObjFuncDynclass = factory_->CreateDynClass(JSType::JS_GLOBAL_OBJECT, 0); globalObjFuncDynclass->SetPrototype(thread_, objFuncPrototypeVal.GetTaggedValue()); globalObjFuncDynclass->SetIsDictionaryMode(true); // Function.prototype_or_dynclass JSHandle emptyFuncDynclass( - factory_->NewEcmaDynClass(JSFunction::SIZE, JSType::JS_FUNCTION, objFuncPrototypeVal, HClass::IS_CALLABLE)); - emptyFuncDynclass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); + factory_->CreateDynClass(JSType::JS_FUNCTION, objFuncPrototypeVal, HClass::IS_CALLABLE)); emptyFuncDynclass->SetExtensible(true); // PrimitiveRef.prototype_or_dynclass JSHandle primRefObjDynclass = - factory_->NewEcmaDynClass(JSPrimitiveRef::SIZE, JSType::JS_PRIMITIVE_REF, objFuncPrototypeVal); + factory_->CreateDynClass(JSType::JS_PRIMITIVE_REF, objFuncPrototypeVal); // init global object JSHandle globalObject = factory_->NewNonMovableJSObject(globalObjFuncDynclass); @@ -197,58 +195,47 @@ void Builtins::Initialize(const JSHandle &env, JSThread *thread) JSHandle objFuncInstancePrototype = factory_->NewJSObject(objFuncDynclass); JSHandle objFuncInstancePrototypeValue(objFuncInstancePrototype); - JSHandle asyncFuncClass = factory_->CreateFunctionClass( - FunctionKind::ASYNC_FUNCTION, JSAsyncFunction::SIZE, JSType::JS_ASYNC_FUNCTION, objFuncInstancePrototypeValue); + JSHandle asyncFuncClass = factory_->CreateFunctionClass( + FunctionKind::ASYNC_FUNCTION, JSType::JS_ASYNC_FUNCTION, objFuncInstancePrototypeValue); asyncFuncClass->SetExtensible(true); env->SetAsyncFunctionClass(thread_, asyncFuncClass); - JSHandle asyncAwaitStatusFuncClass = - factory_->CreateFunctionClass(FunctionKind::NORMAL_FUNCTION, JSAsyncAwaitStatusFunction::SIZE, - JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION, env->GetFunctionPrototype()); + JSHandle asyncAwaitStatusFuncClass = factory_->CreateFunctionClass( + FunctionKind::NORMAL_FUNCTION, JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION, env->GetFunctionPrototype()); env->SetAsyncAwaitStatusFunctionClass(thread_, asyncAwaitStatusFuncClass); - JSHandle asyncGeneratorResolveNextFuncClass = factory_->NewEcmaDynClass( - JSAsyncGeneratorResolveNextFunction::SIZE, JSType::JS_ASYNC_GENERATOR_RESOLVE_NEXT_FUNCTION, - env->GetFunctionPrototype(), HClass::IS_CALLABLE); + JSHandle asyncGeneratorResolveNextFuncClass = + factory_->CreateDynClass(JSType::JS_ASYNC_GENERATOR_RESOLVE_NEXT_FUNCTION, + env->GetFunctionPrototype(), HClass::IS_CALLABLE); asyncGeneratorResolveNextFuncClass->SetExtensible(true); - asyncGeneratorResolveNextFuncClass->GetHClass()->MarkFieldAsNative( - JSAsyncGeneratorResolveNextFunction::METHOD_OFFSET); env->SetAsyncGeneratorResolveNextFunctionClass(thread_, asyncGeneratorResolveNextFuncClass); - JSHandle asyncFromSyncIteratorValueUnwrapFuncClass = factory_->NewEcmaDynClass( - JSAsyncFromSyncIteratorValueUnwrapFunction::SIZE, JSType::JS_ASYNC_FROM_SYNC_ITERATOR_VALUE_UNWRAP_FUNCTION, - env->GetFunctionPrototype(), HClass::IS_CALLABLE); + JSHandle asyncFromSyncIteratorValueUnwrapFuncClass = + factory_->CreateDynClass( + JSType::JS_ASYNC_FROM_SYNC_ITERATOR_VALUE_UNWRAP_FUNCTION, env->GetFunctionPrototype(), + HClass::IS_CALLABLE); asyncFromSyncIteratorValueUnwrapFuncClass->SetExtensible(true); - asyncFromSyncIteratorValueUnwrapFuncClass->GetHClass()->MarkFieldAsNative( - JSAsyncFromSyncIteratorValueUnwrapFunction::METHOD_OFFSET); env->SetAsyncFromSyncIteratorValueUnwrapFunctionClass(thread_, asyncFromSyncIteratorValueUnwrapFuncClass); - JSHandle promiseReactionFuncClass = - factory_->NewEcmaDynClass(JSPromiseReactionsFunction::SIZE, JSType::JS_PROMISE_REACTIONS_FUNCTION, - env->GetFunctionPrototype(), HClass::IS_CALLABLE); + JSHandle promiseReactionFuncClass = factory_->CreateDynClass( + JSType::JS_PROMISE_REACTIONS_FUNCTION, env->GetFunctionPrototype(), HClass::IS_CALLABLE); promiseReactionFuncClass->SetExtensible(true); - promiseReactionFuncClass->GetHClass()->MarkFieldAsNative(JSPromiseReactionsFunction::METHOD_OFFSET); env->SetPromiseReactionFunctionClass(thread_, promiseReactionFuncClass); - JSHandle promiseExecutorFuncClass = - factory_->NewEcmaDynClass(JSPromiseExecutorFunction::SIZE, JSType::JS_PROMISE_EXECUTOR_FUNCTION, - env->GetFunctionPrototype(), HClass::IS_CALLABLE); + JSHandle promiseExecutorFuncClass = factory_->CreateDynClass( + JSType::JS_PROMISE_EXECUTOR_FUNCTION, env->GetFunctionPrototype(), HClass::IS_CALLABLE); promiseExecutorFuncClass->SetExtensible(true); - promiseExecutorFuncClass->GetHClass()->MarkFieldAsNative(JSPromiseExecutorFunction::METHOD_OFFSET); env->SetPromiseExecutorFunctionClass(thread_, promiseExecutorFuncClass); - JSHandle promiseAllResolveElementFunctionClass = factory_->NewEcmaDynClass( - JSPromiseAllResolveElementFunction::SIZE, JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION, - env->GetFunctionPrototype(), HClass::IS_CALLABLE); + JSHandle promiseAllResolveElementFunctionClass = + factory_->CreateDynClass(JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION, + env->GetFunctionPrototype(), HClass::IS_CALLABLE); promiseAllResolveElementFunctionClass->SetExtensible(true); - promiseAllResolveElementFunctionClass->GetHClass()->MarkFieldAsNative( - JSPromiseAllResolveElementFunction::METHOD_OFFSET); env->SetPromiseAllResolveElementFunctionClass(thread_, promiseAllResolveElementFunctionClass); - JSHandle proxyRevocFuncClass = factory_->NewEcmaDynClass( - JSProxyRevocFunction::SIZE, JSType::JS_PROXY_REVOC_FUNCTION, env->GetFunctionPrototype(), HClass::IS_CALLABLE); + JSHandle proxyRevocFuncClass = factory_->CreateDynClass( + JSType::JS_PROXY_REVOC_FUNCTION, env->GetFunctionPrototype(), HClass::IS_CALLABLE); proxyRevocFuncClass->SetExtensible(true); - proxyRevocFuncClass->GetHClass()->MarkFieldAsNative(JSProxyRevocFunction::METHOD_OFFSET); env->SetProxyRevocFunctionClass(thread_, proxyRevocFuncClass); // Object = new Function() @@ -260,14 +247,14 @@ void Builtins::Initialize(const JSHandle &env, JSThread *thread) env->SetObjectFunction(thread_, objectFunction); env->SetObjectFunctionPrototype(thread_, objFuncPrototype); - JSHandle functionClass = factory_->CreateFunctionClass(FunctionKind::BASE_CONSTRUCTOR, JSFunction::SIZE, - JSType::JS_FUNCTION, env->GetFunctionPrototype()); + JSHandle functionClass = factory_->CreateFunctionClass( + FunctionKind::BASE_CONSTRUCTOR, JSType::JS_FUNCTION, env->GetFunctionPrototype()); env->SetFunctionClassWithProto(thread_, functionClass); - functionClass = factory_->CreateFunctionClass(FunctionKind::NORMAL_FUNCTION, JSFunction::SIZE, JSType::JS_FUNCTION, - env->GetFunctionPrototype()); + functionClass = factory_->CreateFunctionClass(FunctionKind::NORMAL_FUNCTION, JSType::JS_FUNCTION, + env->GetFunctionPrototype()); env->SetFunctionClassWithoutProto(thread_, functionClass); - functionClass = factory_->CreateFunctionClass(FunctionKind::CLASS_CONSTRUCTOR, JSFunction::SIZE, - JSType::JS_FUNCTION, env->GetFunctionPrototype()); + functionClass = factory_->CreateFunctionClass(FunctionKind::CLASS_CONSTRUCTOR, JSType::JS_FUNCTION, + env->GetFunctionPrototype()); env->SetFunctionClassWithoutName(thread_, functionClass); if (env == vm_->GetGlobalEnv()) { @@ -333,14 +320,13 @@ void Builtins::Initialize(const JSHandle &env, JSThread *thread) InitializeCollator(env); InitializePluralRules(env); - JSHandle generatorFuncClass = - factory_->CreateFunctionClass(FunctionKind::GENERATOR_FUNCTION, JSFunction::SIZE, JSType::JS_GENERATOR_FUNCTION, - env->GetGeneratorFunctionPrototype()); + JSHandle generatorFuncClass = factory_->CreateFunctionClass( + FunctionKind::GENERATOR_FUNCTION, JSType::JS_GENERATOR_FUNCTION, env->GetGeneratorFunctionPrototype()); env->SetGeneratorFunctionClass(thread_, generatorFuncClass); - JSHandle asyncGeneratorFuncClass = - factory_->CreateFunctionClass(FunctionKind::ASYNC_GENERATOR_FUNCTION, JSFunction::SIZE, - JSType::JS_ASYNC_GENERATOR_FUNCTION, env->GetAsyncGeneratorFunctionPrototype()); + JSHandle asyncGeneratorFuncClass = factory_->CreateFunctionClass( + FunctionKind::ASYNC_GENERATOR_FUNCTION, JSType::JS_ASYNC_GENERATOR_FUNCTION, + env->GetAsyncGeneratorFunctionPrototype()); env->SetAsyncGeneratorFunctionClass(thread_, asyncGeneratorFuncClass); env->SetObjectFunctionPrototypeClass(thread_, JSTaggedValue(objFuncPrototype->GetClass())); @@ -414,10 +400,9 @@ void Builtins::InitializeFunction(const JSHandle &env, const JSHandle JSHandle funcFuncPrototypeValue(funcFuncPrototype); // Function.prototype_or_dynclass - JSHandle funcFuncIntanceDynclass = factory_->NewEcmaDynClass( - JSFunction::SIZE, JSType::JS_FUNCTION, funcFuncPrototypeValue, HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); + JSHandle funcFuncIntanceDynclass = factory_->CreateDynClass( + JSType::JS_FUNCTION, funcFuncPrototypeValue, HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); funcFuncIntanceDynclass->SetConstructor(true); - funcFuncIntanceDynclass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); // Function = new Function() (forbidden use NewBuiltinConstructor) JSMethod *ctor = vm_->GetMethodForNativeFunction(reinterpret_cast(Function::FunctionConstructor)); @@ -431,22 +416,17 @@ void Builtins::InitializeFunction(const JSHandle &env, const JSHandle env->SetFunctionFunction(thread_, funcFunc); env->SetFunctionPrototype(thread_, funcFuncPrototype); - JSHandle normalFuncClass = factory_->NewEcmaDynClass(JSFunction::SIZE, JSType::JS_FUNCTION, - env->GetFunctionPrototype(), HClass::IS_CALLABLE); - normalFuncClass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); + JSHandle normalFuncClass = + factory_->CreateDynClass(JSType::JS_FUNCTION, env->GetFunctionPrototype(), HClass::IS_CALLABLE); env->SetNormalFunctionClass(thread_, normalFuncClass); - JSHandle jSIntlBoundFunctionClass = - factory_->CreateFunctionClass(FunctionKind::NORMAL_FUNCTION, JSIntlBoundFunction::SIZE, - JSType::JS_INTL_BOUND_FUNCTION, env->GetFunctionPrototype()); - jSIntlBoundFunctionClass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); + JSHandle jSIntlBoundFunctionClass = factory_->CreateFunctionClass( + FunctionKind::NORMAL_FUNCTION, JSType::JS_INTL_BOUND_FUNCTION, env->GetFunctionPrototype()); env->SetJSIntlBoundFunctionClass(thread_, jSIntlBoundFunctionClass); - JSHandle constructorFunctionClass = - factory_->NewEcmaDynClass(JSFunction::SIZE, JSType::JS_FUNCTION, env->GetFunctionPrototype(), - HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); + JSHandle constructorFunctionClass = factory_->CreateDynClass( + JSType::JS_FUNCTION, env->GetFunctionPrototype(), HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); constructorFunctionClass->SetConstructor(true); - constructorFunctionClass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); env->SetConstructorFunctionClass(thread_, constructorFunctionClass); StrictModeForbiddenAccessCallerArguments(env, funcFuncPrototypeObj); @@ -554,7 +534,7 @@ void Builtins::InitializeSymbol(const JSHandle &env, const JSHandle symbolFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSPrimitiveRef::SIZE, JSType::JS_PRIMITIVE_REF, symbolFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_PRIMITIVE_REF, symbolFuncPrototypeValue); // Symbol = new Function() JSHandle symbolFunction( @@ -653,7 +633,7 @@ void Builtins::InitializeSymbolWithRealm(const JSHandle &realm, // Symbol.prototype_or_dynclass JSHandle symbolFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSPrimitiveRef::SIZE, JSType::JS_PRIMITIVE_REF, symbolFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_PRIMITIVE_REF, symbolFuncPrototypeValue); // Symbol = new Function() JSHandle symbolFunction( @@ -741,7 +721,7 @@ void Builtins::InitializeNumber(const JSHandle &env, const JSHandle numFuncInstanceClass = - factory_->NewEcmaDynClass(JSPrimitiveRef::SIZE, JSType::JS_PRIMITIVE_REF, numFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_PRIMITIVE_REF, numFuncPrototypeValue); // Number = new Function() JSHandle numFunction( @@ -793,7 +773,7 @@ void Builtins::InitializeBigInt(const JSHandle &env, const JSHandle bigIntFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSPrimitiveRef::SIZE, JSType::JS_PRIMITIVE_REF, bigIntFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_PRIMITIVE_REF, bigIntFuncPrototypeValue); // BigInt = new Function() JSHandle bigIntFunction(NewBuiltinConstructor(env, bigIntFuncPrototype, BuiltinsBigInt::BigIntConstructor, "BigInt", FunctionLength::ONE)); @@ -823,7 +803,7 @@ void Builtins::InitializeDate(const JSHandle &env, const JSHandle dateFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSDate::SIZE, JSType::JS_DATE, dateFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_DATE, dateFuncPrototypeValue); // Date = new Function() JSHandle dateFunction( @@ -904,7 +884,7 @@ void Builtins::InitializeBoolean(const JSHandle &env, const JSHandle< // Boolean.prototype_or_dynclass JSHandle booleanFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSPrimitiveRef::SIZE, JSType::JS_PRIMITIVE_REF, booleanFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_PRIMITIVE_REF, booleanFuncPrototypeValue); // new Boolean Function() JSHandle booleanFunction( @@ -957,8 +937,7 @@ void Builtins::InitializeAsyncFunction(const JSHandle &env, const JSH // AsyncFunction.prototype_or_dynclass JSHandle asyncFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSAsyncFunction::SIZE, JSType::JS_ASYNC_FUNCTION, async_func_prototype_value); - asyncFuncInstanceDynclass->GetHClass()->MarkFieldAsNative(JSAsyncFunction::METHOD_OFFSET); + factory_->CreateDynClass(JSType::JS_ASYNC_FUNCTION, async_func_prototype_value); // AsyncFunction = new Function() JSHandle asyncFunction = NewBuiltinConstructor( @@ -982,7 +961,7 @@ void Builtins::InitializeAllTypeError(const JSHandle &env, const JSHa JSHandle errorFuncPrototypeValue(errorFuncPrototype); // Error.prototype_or_dynclass JSHandle errorFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_ERROR, errorFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_ERROR, errorFuncPrototypeValue); // Error() = new Function() JSHandle errorFunction( NewBuiltinConstructor(env, errorFuncPrototype, Error::ErrorConstructor, "Error", FunctionLength::ONE)); @@ -997,14 +976,13 @@ void Builtins::InitializeAllTypeError(const JSHandle &env, const JSHa SetAttribute(errorFuncPrototype, "message", ""); env->SetErrorFunction(thread_, errorFunction); - JSHandle nativeErrorFuncClass = factory_->NewEcmaDynClass( - JSFunction::SIZE, JSType::JS_FUNCTION, env->GetErrorFunction(), HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); + JSHandle nativeErrorFuncClass = factory_->CreateDynClass( + JSType::JS_FUNCTION, env->GetErrorFunction(), HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); nativeErrorFuncClass->SetConstructor(true); - nativeErrorFuncClass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); env->SetNativeErrorFunctionClass(thread_, nativeErrorFuncClass); JSHandle errorNativeFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, errorFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_OBJECT, errorFuncPrototypeValue); InitializeError(env, errorNativeFuncInstanceDynclass, JSType::JS_RANGE_ERROR); InitializeError(env, errorNativeFuncInstanceDynclass, JSType::JS_REFERENCE_ERROR); InitializeError(env, errorNativeFuncInstanceDynclass, JSType::JS_TYPE_ERROR); @@ -1122,7 +1100,7 @@ void Builtins::InitializeError(const JSHandle &env, const JSHandle nativeErrorFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSObject::SIZE, errorParameter.nativeJstype, nativeErrorFuncPrototypeValue); + factory_->CreateDynClass(errorParameter.nativeJstype, nativeErrorFuncPrototypeValue); // NativeError() = new Error() JSHandle nativeErrorFunction = @@ -1190,8 +1168,7 @@ void Builtins::InitializeSet(const JSHandle &env, const JSHandle setFuncPrototype = factory_->NewJSObject(objFuncDynclass); JSHandle setFuncPrototypeValue(setFuncPrototype); // Set.prototype_or_dynclass - JSHandle setFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSSet::SIZE, JSType::JS_SET, setFuncPrototypeValue); + JSHandle setFuncInstanceDynclass = factory_->CreateDynClass(JSType::JS_SET, setFuncPrototypeValue); // Set() = new Function() JSHandle setFunction( NewBuiltinConstructor(env, setFuncPrototype, BuiltinsSet::SetConstructor, "Set", FunctionLength::ZERO)); @@ -1251,8 +1228,7 @@ void Builtins::InitializeMap(const JSHandle &env, const JSHandle mapFuncPrototype = factory_->NewJSObject(objFuncDynclass); JSHandle mapFuncPrototypeValue(mapFuncPrototype); // Map.prototype_or_dynclass - JSHandle mapFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSMap::SIZE, JSType::JS_MAP, mapFuncPrototypeValue); + JSHandle mapFuncInstanceDynclass = factory_->CreateDynClass(JSType::JS_MAP, mapFuncPrototypeValue); // Map() = new Function() JSHandle mapFunction( NewBuiltinConstructor(env, mapFuncPrototype, BuiltinsMap::MapConstructor, "Map", FunctionLength::ZERO)); @@ -1317,7 +1293,7 @@ void Builtins::InitializeWeakRef(const JSHandle &env, const JSHandle< JSHandle weakRefFuncPrototypeValue(weakRefFuncPrototype); // WeakRef.prototype_or_dynclass JSHandle weakRefFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSWeakRef::SIZE, JSType::JS_WEAK_REF, weakRefFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_WEAK_REF, weakRefFuncPrototypeValue); weakRefFuncInstanceDynclass->SetWeakContainer(true); // WeakRef() = new Function() JSHandle weakRefFunction( @@ -1344,7 +1320,7 @@ void Builtins::InitializeWeakMap(const JSHandle &env, const JSHandle< JSHandle weakMapFuncPrototypeValue(weakMapFuncPrototype); // WeakMap.prototype_or_dynclass JSHandle weakMapFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSWeakMap::SIZE, JSType::JS_WEAK_MAP, weakMapFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_WEAK_MAP, weakMapFuncPrototypeValue); // WeakMap() = new Function() JSHandle weakMapFunction(NewBuiltinConstructor( env, weakMapFuncPrototype, BuiltinsWeakMap::WeakMapConstructor, "WeakMap", FunctionLength::ZERO)); @@ -1380,7 +1356,7 @@ void Builtins::InitializeWeakSet(const JSHandle &env, const JSHandle< JSHandle weakSetFuncPrototypeValue(weakSetFuncPrototype); // Set.prototype_or_dynclass JSHandle weakSetFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSWeakSet::SIZE, JSType::JS_WEAK_SET, weakSetFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_WEAK_SET, weakSetFuncPrototypeValue); // Set() = new Function() JSHandle weakSetFunction(NewBuiltinConstructor( env, weakSetFuncPrototype, BuiltinsWeakSet::WeakSetConstructor, "WeakSet", FunctionLength::ZERO)); @@ -1405,7 +1381,7 @@ void Builtins::InitializeWeakSet(const JSHandle &env, const JSHandle< void Builtins::InitializeMath(const JSHandle &env, const JSHandle &objFuncPrototypeVal) const { [[maybe_unused]] EcmaHandleScope scope(thread_); - JSHandle mathDynclass = factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, objFuncPrototypeVal); + JSHandle mathDynclass = factory_->CreateDynClass(JSType::JS_OBJECT, objFuncPrototypeVal); JSHandle mathObject = factory_->NewJSObject(mathDynclass); SetFunction(env, mathObject, "abs", Math::Abs, FunctionLength::ONE); SetFunction(env, mathObject, "acos", Math::Acos, FunctionLength::ONE); @@ -1464,7 +1440,7 @@ void Builtins::InitializeMath(const JSHandle &env, const JSHandle &env, const JSHandle &objFuncPrototypeVal) const { [[maybe_unused]] EcmaHandleScope scope(thread_); - JSHandle jsonDynclass = factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, objFuncPrototypeVal); + JSHandle jsonDynclass = factory_->CreateDynClass(JSType::JS_OBJECT, objFuncPrototypeVal); JSHandle jsonObject = factory_->NewJSObject(jsonDynclass); SetFunction(env, jsonObject, "parse", Json::Parse, FunctionLength::TWO); @@ -1490,7 +1466,7 @@ void Builtins::InitializeString(const JSHandle &env, const JSHandle stringFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSPrimitiveRef::SIZE, JSType::JS_PRIMITIVE_REF, stringFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_PRIMITIVE_REF, stringFuncPrototypeValue); // String = new Function() JSHandle stringFunction(NewBuiltinConstructor(env, stringFuncPrototype, BuiltinsString::StringConstructor, @@ -1572,8 +1548,8 @@ void Builtins::InitializeStringIterator(const JSHandle &env, JSHandle strIterPrototype(factory_->NewJSObject(iteratorFuncDynclass)); // StringIterator.prototype_or_dynclass - JSHandle strIterFuncInstanceDynclass = factory_->NewEcmaDynClass( - JSStringIterator::SIZE, JSType::JS_STRING_ITERATOR, JSHandle(strIterPrototype)); + JSHandle strIterFuncInstanceDynclass = factory_->CreateDynClass( + JSType::JS_STRING_ITERATOR, JSHandle(strIterPrototype)); JSHandle strIterFunction( factory_->NewJSFunction(env, static_cast(nullptr), FunctionKind::BASE_CONSTRUCTOR)); @@ -1604,7 +1580,7 @@ void Builtins::InitializeIterator(const JSHandle &env, const JSHandle // Iterator.dynclass JSHandle iteratorFuncDynclass = - factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_ITERATOR, JSHandle(iteratorPrototype)); + factory_->CreateDynClass(JSType::JS_ITERATOR, JSHandle(iteratorPrototype)); InitializeForinIterator(env, iteratorFuncDynclass); InitializeSetIterator(env, iteratorFuncDynclass); @@ -1631,8 +1607,8 @@ void Builtins::InitializeForinIterator(const JSHandle &env, [[maybe_unused]] EcmaHandleScope scope(thread_); // Iterator.prototype JSHandle forinIteratorPrototype = factory_->NewJSObject(iteratorFuncDynclass); - JSHandle dynclass = factory_->NewEcmaDynClass(JSForInIterator::SIZE, JSType::JS_FORIN_ITERATOR, - JSHandle(forinIteratorPrototype)); + JSHandle dynclass = factory_->CreateDynClass( + JSType::JS_FORIN_ITERATOR, JSHandle(forinIteratorPrototype)); // Iterator.prototype.next() SetFunction(env, forinIteratorPrototype, "next", JSForInIterator::Next, FunctionLength::ONE); @@ -1877,8 +1853,8 @@ void Builtins::InitializeTypedArray(const JSHandle &env, const JSHand JSHandle typedArrFuncPrototypeValue(typedArrFuncPrototype); // TypedArray.prototype_or_dynclass - JSHandle typedArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_TYPED_ARRAY, typedArrFuncPrototypeValue); + JSHandle typedArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_TYPED_ARRAY, typedArrFuncPrototypeValue); // TypedArray = new Function() JSHandle typedArrayFunction(NewBuiltinConstructor( @@ -1969,11 +1945,9 @@ void Builtins::InitializeTypedArray(const JSHandle &env, const JSHand env->SetTypedArrayFunction(thread_, typedArrayFunction.GetTaggedValue()); env->SetTypedArrayPrototype(thread_, typedArrFuncPrototype); - JSHandle specificTypedArrayFuncClass = - factory_->NewEcmaDynClass(JSFunction::SIZE, JSType::JS_FUNCTION, env->GetTypedArrayFunction(), - HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); + JSHandle specificTypedArrayFuncClass = factory_->CreateDynClass( + JSType::JS_FUNCTION, env->GetTypedArrayFunction(), HClass::IS_CALLABLE | HClass::IS_BUILTINS_CTOR); specificTypedArrayFuncClass->SetConstructor(true); - specificTypedArrayFuncClass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); env->SetSpecificTypedArrayFunctionClass(thread_, specificTypedArrayFuncClass); InitializeInt8Array(env, typedArrFuncInstanceDynclass); @@ -1997,8 +1971,8 @@ void Builtins::InitializeInt8Array(const JSHandle &env, const JSHandl JSHandle int8ArrFuncPrototypeValue(int8ArrFuncPrototype); // Int8Array.prototype_or_dynclass - JSHandle int8ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_INT8_ARRAY, int8ArrFuncPrototypeValue); + JSHandle int8ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_INT8_ARRAY, int8ArrFuncPrototypeValue); // Int8Array = new Function() JSHandle int8ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2021,8 +1995,8 @@ void Builtins::InitializeUint8Array(const JSHandle &env, const JSHand JSHandle uint8ArrFuncPrototypeValue(uint8ArrFuncPrototype); // Uint8Array.prototype_or_dynclass - JSHandle uint8ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_UINT8_ARRAY, uint8ArrFuncPrototypeValue); + JSHandle uint8ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_UINT8_ARRAY, uint8ArrFuncPrototypeValue); // Uint8Array = new Function() JSHandle uint8ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2046,8 +2020,8 @@ void Builtins::InitializeUint8ClampedArray(const JSHandle &env, JSHandle uint8ClampedArrFuncPrototypeValue(uint8ClampedArrFuncPrototype); // Uint8ClampedArray.prototype_or_dynclass - JSHandle uint8ClampedArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_UINT8_CLAMPED_ARRAY, uint8ClampedArrFuncPrototypeValue); + JSHandle uint8ClampedArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_UINT8_CLAMPED_ARRAY, uint8ClampedArrFuncPrototypeValue); // Uint8ClampedArray = new Function() JSHandle uint8ClampedArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2071,8 +2045,8 @@ void Builtins::InitializeInt16Array(const JSHandle &env, const JSHand JSHandle int16ArrFuncPrototypeValue(int16ArrFuncPrototype); // Int16Array.prototype_or_dynclass - JSHandle int16ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_INT16_ARRAY, int16ArrFuncPrototypeValue); + JSHandle int16ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_INT16_ARRAY, int16ArrFuncPrototypeValue); // Int16Array = new Function() JSHandle int16ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2095,8 +2069,8 @@ void Builtins::InitializeUint16Array(const JSHandle &env, const JSHan JSHandle uint16ArrFuncPrototypeValue(uint16ArrFuncPrototype); // Uint16Array.prototype_or_dynclass - JSHandle uint16ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_UINT16_ARRAY, uint16ArrFuncPrototypeValue); + JSHandle uint16ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_UINT16_ARRAY, uint16ArrFuncPrototypeValue); // Uint16Array = new Function() JSHandle uint16ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2119,8 +2093,8 @@ void Builtins::InitializeInt32Array(const JSHandle &env, const JSHand JSHandle int32ArrFuncPrototypeValue(int32ArrFuncPrototype); // Int32Array.prototype_or_dynclass - JSHandle int32ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_INT32_ARRAY, int32ArrFuncPrototypeValue); + JSHandle int32ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_INT32_ARRAY, int32ArrFuncPrototypeValue); // Int32Array = new Function() JSHandle int32ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2143,8 +2117,8 @@ void Builtins::InitializeUint32Array(const JSHandle &env, const JSHan JSHandle uint32ArrFuncPrototypeValue(uint32ArrFuncPrototype); // Uint32Array.prototype_or_dynclass - JSHandle uint32ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_UINT32_ARRAY, uint32ArrFuncPrototypeValue); + JSHandle uint32ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_UINT32_ARRAY, uint32ArrFuncPrototypeValue); // Uint32Array = new Function() JSHandle uint32ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2167,8 +2141,8 @@ void Builtins::InitializeFloat32Array(const JSHandle &env, const JSHa JSHandle float32ArrFuncPrototypeValue(float32ArrFuncPrototype); // Float32Array.prototype_or_dynclass - JSHandle float32ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_FLOAT32_ARRAY, float32ArrFuncPrototypeValue); + JSHandle float32ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_FLOAT32_ARRAY, float32ArrFuncPrototypeValue); // Float32Array = new Function() JSHandle float32ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2191,8 +2165,8 @@ void Builtins::InitializeFloat64Array(const JSHandle &env, const JSHa JSHandle float64ArrFuncPrototypeValue(float64ArrFuncPrototype); // Float64Array.prototype_or_dynclass - JSHandle float64ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_FLOAT64_ARRAY, float64ArrFuncPrototypeValue); + JSHandle float64ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_FLOAT64_ARRAY, float64ArrFuncPrototypeValue); // Float64Array = new Function() JSHandle float64ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2215,8 +2189,8 @@ void Builtins::InitializeBigInt64Array(const JSHandle &env, const JSH JSHandle bigInt64ArrFuncPrototypeValue(bigInt64ArrFuncPrototype); // BigInt64Array.prototype_or_dynclass - JSHandle bigInt64ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_BIGINT64_ARRAY, bigInt64ArrFuncPrototypeValue); + JSHandle bigInt64ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_BIGINT64_ARRAY, bigInt64ArrFuncPrototypeValue); // BigInt64Array = new Function() JSHandle bigInt64ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2239,8 +2213,8 @@ void Builtins::InitializeBigUint64Array(const JSHandle &env, const JS JSHandle bigUint64ArrFuncPrototypeValue(bigUint64ArrFuncPrototype); // BigUint64Array.prototype_or_dynclass - JSHandle bigUint64ArrFuncInstanceDynclass = factory_->NewEcmaDynClass( - panda::ecmascript::JSTypedArray::SIZE, JSType::JS_BIGUINT64_ARRAY, bigUint64ArrFuncPrototypeValue); + JSHandle bigUint64ArrFuncInstanceDynclass = + factory_->CreateDynClass(JSType::JS_BIGUINT64_ARRAY, bigUint64ArrFuncPrototypeValue); // BigUint64Array = new Function() JSHandle bigUint64ArrayFunction = factory_->NewSpecificTypedArrayFunction( @@ -2264,7 +2238,7 @@ void Builtins::InitializeArrayBuffer(const JSHandle &env, const JSHan // ArrayBuffer.prototype_or_dynclass JSHandle arrayBufferFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSArrayBuffer::SIZE, JSType::JS_ARRAY_BUFFER, arrayBufferFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_ARRAY_BUFFER, arrayBufferFuncPrototypeValue); // ArrayBuffer = new Function() JSHandle arrayBufferFunction(NewBuiltinConstructor( @@ -2301,8 +2275,7 @@ void Builtins::InitializeReflect(const JSHandle &env, const JSHandle &objFuncPrototypeVal) const { [[maybe_unused]] EcmaHandleScope scope(thread_); - JSHandle reflectDynclass = - factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, objFuncPrototypeVal); + JSHandle reflectDynclass = factory_->CreateDynClass(JSType::JS_OBJECT, objFuncPrototypeVal); JSHandle reflectObject = factory_->NewJSObject(reflectDynclass); SetFunction(env, reflectObject, "apply", Reflect::ReflectApply, FunctionLength::THREE); @@ -2339,7 +2312,7 @@ void Builtins::InitializePromise(const JSHandle &env, const JSHandle< JSHandle promiseFuncPrototypeValue(promiseFuncPrototype); // Promise.prototype_or_dynclass JSHandle promiseFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSPromise::SIZE, JSType::JS_PROMISE, promiseFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_PROMISE, promiseFuncPrototypeValue); // Promise() = new Function() JSHandle promiseFunction( NewBuiltinConstructor(env, promiseFuncPrototype, Promise::PromiseConstructor, "Promise", FunctionLength::ONE)); @@ -2385,8 +2358,8 @@ void Builtins::InitializeFinalizationRegistry(const JSHandle &env, JSHandle registryFuncPrototype = factory_->NewJSObject(objFuncDynclass); JSHandle registryFuncPrototypeValue(registryFuncPrototype); // FinalizationRegistry.prototype_or_dynclass - JSHandle registryFuncInstanceDynclass = factory_->NewEcmaDynClass( - JSFinalizationRegistry::SIZE, JSType::FINALIZATION_REGISTRY, registryFuncPrototypeValue); + JSHandle registryFuncInstanceDynclass = + factory_->CreateDynClass(JSType::FINALIZATION_REGISTRY, registryFuncPrototypeValue); // FinalizationRegistry() = new Function() JSHandle registryFunction(NewBuiltinConstructor(env, registryFuncPrototype, BuiltinsFinalizationRegistry::Constructor, @@ -2420,7 +2393,7 @@ void Builtins::InitializeDataView(const JSHandle &env, const JSHandle // ArrayBuffer.prototype_or_dynclass JSHandle dataViewFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSDataView::SIZE, JSType::JS_DATA_VIEW, dataViewFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_DATA_VIEW, dataViewFuncPrototypeValue); // ArrayBuffer = new Function() JSHandle dataViewFunction(NewBuiltinConstructor(env, dataViewFuncPrototype, DataView::DataViewConstructor, @@ -2643,10 +2616,9 @@ void Builtins::InitializeGeneratorFunction(const JSHandle &env, // 26.3.3.1 GeneratorFunction.prototype.constructor // GeneratorFunction.prototype_or_dynclass - JSHandle generatorFuncInstanceDynclass = factory_->NewEcmaDynClass( - JSFunction::SIZE, JSType::JS_GENERATOR_FUNCTION, generatorFuncPrototypeValue, HClass::IS_CALLABLE); + JSHandle generatorFuncInstanceDynclass = factory_->CreateDynClass( + JSType::JS_GENERATOR_FUNCTION, generatorFuncPrototypeValue, HClass::IS_CALLABLE); generatorFuncInstanceDynclass->SetExtensible(true); - generatorFuncInstanceDynclass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); // GeneratorFunction = new GeneratorFunction() JSHandle generator_function = NewBuiltinConstructor(env, generatorFuncPrototype, GeneratorObject::GeneratorFunctionConstructor, @@ -2719,10 +2691,9 @@ void Builtins::InitializeAsyncGeneratorFunction(const JSHandle &env, // 26.3.3.1 AsyncGeneratorFunction.prototype.constructor // AsyncGeneratorFunction.prototype_or_dynclass - JSHandle asyncGeneratorFuncInstanceDynclass = factory_->NewEcmaDynClass( - JSFunction::SIZE, JSType::JS_ASYNC_GENERATOR_FUNCTION, asyncGeneratorFuncPrototypeValue, HClass::IS_CALLABLE); + JSHandle asyncGeneratorFuncInstanceDynclass = factory_->CreateDynClass( + JSType::JS_ASYNC_GENERATOR_FUNCTION, asyncGeneratorFuncPrototypeValue, HClass::IS_CALLABLE); asyncGeneratorFuncInstanceDynclass->SetExtensible(true); - asyncGeneratorFuncInstanceDynclass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); // AsyncGeneratorFunction = new AsyncGeneratorFunction() JSHandle asyncGeneratorFunction = @@ -2880,7 +2851,7 @@ void Builtins::InitializeIntlCtor(const JSHandle &env, const JSHandle void Builtins::InitializeIntl(const JSHandle &env, const JSHandle &objFuncPrototypeValue) { [[maybe_unused]] EcmaHandleScope scope(thread_); - JSHandle intlDynclass = factory_->NewEcmaDynClass(JSObject::SIZE, JSType::JS_INTL, objFuncPrototypeValue); + JSHandle intlDynclass = factory_->CreateDynClass(JSType::JS_INTL, objFuncPrototypeValue); JSHandle intlObject = factory_->NewJSObject(intlDynclass); JSHandle initIntlSymbol(factory_->NewPublicSymbolWithChar("Symbol.IntlLegacyConstructedSymbol")); @@ -2909,7 +2880,7 @@ void Builtins::InitializeDateTimeFormat(const JSHandle &env) // DateTimeFormat.prototype_or_dynclass JSHandle dtfFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSDateTimeFormat::SIZE, JSType::JS_DATE_TIME_FORMAT, dtfPrototypeValue); + factory_->CreateDynClass(JSType::JS_DATE_TIME_FORMAT, dtfPrototypeValue); // DateTimeFormat = new Function() // 13.4.1 Intl.DateTimeFormat.prototype.constructor @@ -2951,7 +2922,7 @@ void Builtins::InitializeRelativeTimeFormat(const JSHandle &env) // RelativeTimeFormat.prototype_or_dynclass JSHandle rtfFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSRelativeTimeFormat::SIZE, JSType::JS_RELATIVE_TIME_FORMAT, rtfPrototypeValue); + factory_->CreateDynClass(JSType::JS_RELATIVE_TIME_FORMAT, rtfPrototypeValue); // RelativeTimeFormat = new Function() // 14.2.1 Intl.RelativeTimeFormat.prototype.constructor @@ -2988,7 +2959,7 @@ void Builtins::InitializeNumberFormat(const JSHandle &env) // NumberFormat.prototype_or_dynclass JSHandle nfFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSNumberFormat::SIZE, JSType::JS_NUMBER_FORMAT, nfPrototypeValue); + factory_->CreateDynClass(JSType::JS_NUMBER_FORMAT, nfPrototypeValue); // NumberFormat = new Function() // 12.4.1 Intl.NumberFormat.prototype.constructor @@ -3026,7 +2997,7 @@ void Builtins::InitializeLocale(const JSHandle &env) // Locale.prototype_or_dynclass JSHandle localeFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSLocale::SIZE, JSType::JS_LOCALE, localePrototypeValue); + factory_->CreateDynClass(JSType::JS_LOCALE, localePrototypeValue); // Locale = new Function() JSHandle localeFunction( @@ -3087,7 +3058,7 @@ void Builtins::InitializeCollator(const JSHandle &env) // Collator.prototype_or_dynclass JSHandle collatorFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSCollator::SIZE, JSType::JS_COLLATOR, collatorPrototypeValue); + factory_->CreateDynClass(JSType::JS_COLLATOR, collatorPrototypeValue); // Collator = new Function() // 11.1.2 Intl.Collator.prototype.constructor @@ -3122,7 +3093,7 @@ void Builtins::InitializePluralRules(const JSHandle &env) // PluralRules.prototype_or_dynclass JSHandle prFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSPluralRules::SIZE, JSType::JS_PLURAL_RULES, prPrototypeValue); + factory_->CreateDynClass(JSType::JS_PLURAL_RULES, prPrototypeValue); // PluralRules = new Function() // 15.2.1 Intl.PluralRules.prototype.constructor @@ -3225,7 +3196,7 @@ void Builtins::InitializeFuzzilli(const JSHandle &env, const JSHandle JSHandle fuzzilliFuncPrototypeValue(fuzzilliFuncPrototype); JSHandle fuzzilliFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSDate::SIZE, JSType::JS_FUNCTION, fuzzilliFuncPrototypeValue); + factory_->CreateDynClass(JSType::JS_FUNCTION, fuzzilliFuncPrototypeValue); JSHandle fuzzilliFunction(NewBuiltinConstructor( env, fuzzilliFuncPrototype, BuiltinsFuzzilli::FuzzilliConstructor, "fuzzilli", FunctionLength::THREE)); diff --git a/runtime/class_info_extractor.cpp b/runtime/class_info_extractor.cpp index 76ab56c7a..45b1942c7 100644 --- a/runtime/class_info_extractor.cpp +++ b/runtime/class_info_extractor.cpp @@ -191,13 +191,13 @@ JSHandle ClassInfoExtractor::CreatePrototypeHClass(JSThread *thread, J layout->AddKey(thread, index, key.GetTaggedValue(), attributes); } - hclass = factory->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, length); + hclass = factory->CreateDynClass(JSType::JS_OBJECT, length); // Not need set proto here hclass->SetLayout(thread, layout); hclass->SetNumberOfProps(length); } else { // dictionary mode - hclass = factory->NewEcmaDynClass(JSObject::SIZE, JSType::JS_OBJECT, 0); // without in-obj + hclass = factory->CreateDynClass(JSType::JS_OBJECT, 0); // without in-obj hclass->SetIsDictionaryMode(true); hclass->SetNumberOfProps(0); } @@ -251,21 +251,20 @@ JSHandle ClassInfoExtractor::CreateConstructorHClass(JSThread *thread, layout->AddKey(thread, index, key.GetTaggedValue(), attributes); } - hclass = factory->NewEcmaDynClass(factory->hclass_class_, JSConstructorFunction::SIZE, JSType::JS_FUNCTION, - HClass::IS_CALLABLE, length); + hclass = factory->CreateDynClass(factory->hclass_class_, JSType::JS_FUNCTION, + HClass::IS_CALLABLE, length); // Not need set proto here hclass->SetLayout(thread, layout); hclass->SetNumberOfProps(length); } else { // dictionary mode - hclass = factory->NewEcmaDynClass(JSConstructorFunction::SIZE, JSType::JS_FUNCTION, 0); // without in-obj + hclass = factory->CreateDynClass(JSType::JS_FUNCTION, 0); // without in-obj hclass->SetIsDictionaryMode(true); hclass->SetNumberOfProps(0); } hclass->SetClassConstructor(true); hclass->SetConstructor(true); - hclass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); return hclass; } diff --git a/runtime/class_info_extractor.h b/runtime/class_info_extractor.h index e120419b1..8937f5187 100644 --- a/runtime/class_info_extractor.h +++ b/runtime/class_info_extractor.h @@ -77,19 +77,19 @@ public: return StaticWithElementsBit::Decode(GetBitField()); } - static constexpr size_t BIT_FIELD_OFFSET = TaggedObjectSize(); - SET_GET_PRIMITIVE_FIELD(BitField, uint8_t, BIT_FIELD_OFFSET, CONSTRUCTOR_METHOD_OFFSET) - SET_GET_NATIVE_FIELD(ConstructorMethod, JSMethod, CONSTRUCTOR_METHOD_OFFSET, PROTOTYPE_HCLASS_OFFSET) - ACCESSORS(PrototypeHClass, PROTOTYPE_HCLASS_OFFSET, NON_STATIC_KEYS_OFFSET) - ACCESSORS(NonStaticKeys, NON_STATIC_KEYS_OFFSET, NON_STATIC_PROPERTIES_OFFSET) - ACCESSORS(NonStaticProperties, NON_STATIC_PROPERTIES_OFFSET, NON_STATIC_ELEMENTS_OFFSET) - ACCESSORS(NonStaticElements, NON_STATIC_ELEMENTS_OFFSET, CONSTRUCTOR_HCLASS_OFFSET) - ACCESSORS(ConstructorHClass, CONSTRUCTOR_HCLASS_OFFSET, STATIC_KEYS_OFFSET) - ACCESSORS(StaticKeys, STATIC_KEYS_OFFSET, STATIC_PROPERTIES_OFFSET) - ACCESSORS(StaticProperties, STATIC_PROPERTIES_OFFSET, STATIC_ELEMENTS_OFFSET) - ACCESSORS(StaticElements, STATIC_ELEMENTS_OFFSET, SIZE) - - DECL_VISIT_OBJECT(PROTOTYPE_HCLASS_OFFSET, SIZE) + ACCESSORS_START(TaggedObjectSize()) + ACCESSORS(0, PrototypeHClass) + ACCESSORS(1, NonStaticKeys) + ACCESSORS(2, NonStaticProperties) + ACCESSORS(3, NonStaticElements) + ACCESSORS(4, ConstructorHClass) + ACCESSORS(5, StaticKeys) + ACCESSORS(6, StaticProperties) + ACCESSORS(7, StaticElements); + ACCESSORS_NATIVE_FIELD(8, ConstructorMethod, JSMethod) + ACCESSORS_BIT_FIELD(9, BitField) + ACCESSORS_FINISH(10) + DECL_DUMP() private: diff --git a/runtime/class_linker/program_object.h b/runtime/class_linker/program_object.h index a6fe0c1de..56b389e6e 100644 --- a/runtime/class_linker/program_object.h +++ b/runtime/class_linker/program_object.h @@ -26,15 +26,15 @@ class Program : public ECMAObject { public: DECL_CAST(Program) - static constexpr size_t LOCATION_OFFSET = ECMAObject::SIZE; - ACCESSORS(Location, LOCATION_OFFSET, CONSTANT_POOL_OFFSET) - ACCESSORS(ConstantPool, CONSTANT_POOL_OFFSET, MAIN_FUNCTION_OFFSET) - ACCESSORS(MainFunction, MAIN_FUNCTION_OFFSET, METHODS_DATA_OFFSET) - SET_GET_NATIVE_FIELD(MethodsData, PandaList, METHODS_DATA_OFFSET, SIZE) + ACCESSORS_BASE(ECMAObject) + ACCESSORS(0, Location) + ACCESSORS(1, ConstantPool) + ACCESSORS(2, MainFunction) + ACCESSORS_NATIVE_FIELD(3, MethodsData, PandaList) + ACCESSORS_FINISH(4) inline void FreeMethodData(); - DECL_VISIT_OBJECT(LOCATION_OFFSET, METHODS_DATA_OFFSET) DECL_DUMP() }; @@ -54,14 +54,14 @@ public: inline const uint8_t *GetInstructions() const; - static constexpr size_t NAME_OFFSET = ECMAObject::SIZE; - ACCESSORS(Name, NAME_OFFSET, NUMBER_VREGS_OFFSET) - ACCESSORS(NumberVRegs, NUMBER_VREGS_OFFSET, NUMBER_IC_SLOTS_OFFSET) - ACCESSORS(NumberICSlots, NUMBER_IC_SLOTS_OFFSET, BYTECODE_OFFSET) - ACCESSORS(Bytecode, BYTECODE_OFFSET, PROGRAM_OFFSET) - ACCESSORS(Program, PROGRAM_OFFSET, SIZE) + ACCESSORS_BASE(ECMAObject) + ACCESSORS(0, Name) + ACCESSORS(1, NumberVRegs) + ACCESSORS(2, NumberICSlots) + ACCESSORS(3, Bytecode) + ACCESSORS(4, Program) + ACCESSORS_FINISH(5) - DECL_VISIT_OBJECT(NAME_OFFSET, SIZE) DECL_DUMP() }; diff --git a/runtime/containers/containers_private.cpp b/runtime/containers/containers_private.cpp index 4cc3e7b34..fe3ab2b0b 100644 --- a/runtime/containers/containers_private.cpp +++ b/runtime/containers/containers_private.cpp @@ -173,7 +173,7 @@ JSHandle ContainersPrivate::InitializeArrayList(JSThread *thread) JSHandle arrayListFuncPrototypeValue(arrayListFuncPrototype); // ArrayList.prototype_or_dynclass JSHandle arrayListInstanceDynclass = - factory->NewEcmaDynClass(JSArrayList::SIZE, JSType::JS_ARRAY_LIST, arrayListFuncPrototypeValue); + factory->CreateDynClass(JSType::JS_ARRAY_LIST, arrayListFuncPrototypeValue); // ArrayList() = new Function() JSHandle arrayListFunction(NewContainerConstructor( thread, arrayListFuncPrototype, ContainersArrayList::ArrayListConstructor, "ArrayList", FuncLength::ZERO)); diff --git a/runtime/ecma_macro_accessors.h b/runtime/ecma_macro_accessors.h new file mode 100644 index 000000000..add45a97f --- /dev/null +++ b/runtime/ecma_macro_accessors.h @@ -0,0 +1,172 @@ +#ifndef ECMASCRIPT_ECMA_MACRO_ACCESSORS_H +#define ECMASCRIPT_ECMA_MACRO_ACCESSORS_H + +#include "runtime/include/hclass.h" +#include "plugins/ecmascript/runtime/common.h" +#include "plugins/ecmascript/runtime/js_tagged_value.h" +#include "plugins/ecmascript/runtime/js_thread.h" +#include "plugins/ecmascript/runtime/mem/barriers-inl.h" +#include "utils/logger.h" + +namespace panda::ecmascript { + +using JSAccessorsMaskType = uint32_t; + +template +struct JSAccessorsOffs { + static constexpr size_t END = OFFS_; +}; + +template