diff --git a/BUILD.gn b/BUILD.gn index 9988b3a57e2a4e587009a07a429f2e13b4137b99..4bd019e84bac037e0f2b5bede45af69e41933508 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -137,7 +137,6 @@ config("ark_jsruntime_public_config") { "$js_root", # Dependent on runtime_core include - "$ark_root/runtime", "$ark_root", ] } diff --git a/docs/development-example-zh.md b/docs/development-example-zh.md index 8a4fbf2d2bddb178f86846d23796fa0d8d9c1d8c..bdebde868d86ab6881f72ea5a0a309cbf1902655 100644 --- a/docs/development-example-zh.md +++ b/docs/development-example-zh.md @@ -31,7 +31,7 @@ 编译arm32版本: ``` - ./build.sh --product-name rk3568 --build-target libarkruntime --build-target ark_js_runtime --build-target ld-musl-arm.so.1 + ./build.sh --product-name rk3568 --build-target ark_js_runtime --build-target ld-musl-arm.so.1 ``` 2. 编译方舟前端,编译命令: diff --git a/docs/development-example.md b/docs/development-example.md index c601fb5d7d32e14e861e437a27a0eba4991b4ec6..ef262d35b77d7d9ec84d6ec3313aaf977105c445 100644 --- a/docs/development-example.md +++ b/docs/development-example.md @@ -29,7 +29,7 @@ This section describes how to develop and test ARK runtime. arm32: ``` - ./build.sh --product-name rk3568 --build-target libarkruntime --build-target ark_js_runtime --build-target ld-musl-arm.so.1 + ./build.sh --product-name rk3568 --build-target ark_js_runtime --build-target ld-musl-arm.so.1 ``` **NOTE**: Run the compilation commands in the project root directory. diff --git a/docs/environment-setup-and-compilation-zh.md b/docs/environment-setup-and-compilation-zh.md index 4247a6efda3cbadf89fed947d1bf2cad08fd6ed0..fea4f238a4d03719af47b44d6ae1c7685ed3afdd 100644 --- a/docs/environment-setup-and-compilation-zh.md +++ b/docs/environment-setup-and-compilation-zh.md @@ -31,7 +31,7 @@ Ubuntu版本要求18.04或20.04,详细环境搭建参考: 编译arm32版本: ``` - ./build.sh --product-name rk3568 --build-target libarkruntime --build-target ark_js_runtime --build-target ld-musl-arm.so.1 + ./build.sh --product-name rk3568 --build-target ark_js_runtime --build-target ld-musl-arm.so.1 ``` 3. 首次编译后增量编译方舟前端: diff --git a/docs/environment-setup-and-compilation.md b/docs/environment-setup-and-compilation.md index 51c94e61c4838b49a63ed184e38e0f756ed02dbd..5c73a9fe42c644e99cddc6053aecdef007e582cd 100644 --- a/docs/environment-setup-and-compilation.md +++ b/docs/environment-setup-and-compilation.md @@ -28,7 +28,7 @@ Use Ubuntu 18.04 or 20.04. For details about how to set up the environment, see: arm32: ``` - ./build.sh --product-name rk3568 --build-target libarkruntime --build-target ark_js_runtime --build-target ld-musl-arm.so.1 + ./build.sh --product-name rk3568 --build-target ark_js_runtime --build-target ld-musl-arm.so.1 ``` 3. Compile the ARK frontend after the first compilation: diff --git a/ecmascript/accessor_data.h b/ecmascript/accessor_data.h index 4e132fecc420f480be218b0e1a10a44d93e6ed45..4d9e876e5bf0f6ed2d89a3eede68d7ef8904a934 100644 --- a/ecmascript/accessor_data.h +++ b/ecmascript/accessor_data.h @@ -30,7 +30,7 @@ public: using InternalGetFunc = JSTaggedValue (*)(JSThread *, const JSHandle &); using InternalSetFunc = bool (*)(JSThread *, const JSHandle &, const JSHandle &, bool); - static AccessorData *Cast(ObjectHeader *object) + static AccessorData *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsAccessorData() || JSTaggedValue(object).IsInternalAccessor()); return static_cast(object); @@ -81,7 +81,7 @@ enum class CompletionRecordType : uint8_t { class CompletionRecord final : public Record { public: - static CompletionRecord *Cast(ObjectHeader *object) + static CompletionRecord *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsCompletionRecord()); return static_cast(object); diff --git a/ecmascript/base/string_helper.h b/ecmascript/base/string_helper.h index b12404b061d31e5d360e7dfc78ceba439bb41c79..1bf2d44542f66c19f15a4940da758f3a8345879b 100644 --- a/ecmascript/base/string_helper.h +++ b/ecmascript/base/string_helper.h @@ -30,7 +30,6 @@ #include "ecmascript/js_thread.h" #include "ecmascript/mem/assert_scope.h" #include "ecmascript/object_factory.h" -#include "libpandafile/file_items.h" #include "unicode/unistr.h" namespace panda::ecmascript::base { diff --git a/ecmascript/base/tests/builtins_base_test.cpp b/ecmascript/base/tests/builtins_base_test.cpp index d9c678c5adb8c7033a65bfe2be3f40e38aa9bbbc..020afa461ca4d616daedea94e68946b0486a8309 100644 --- a/ecmascript/base/tests/builtins_base_test.cpp +++ b/ecmascript/base/tests/builtins_base_test.cpp @@ -59,7 +59,7 @@ public: */ HWTEST_F_L0(BuiltinsBaseTest, GetArgsArray) { - array_size_t argvLength = 10; + uint32_t argvLength = 10; auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), argvLength); ecmaRuntimeCallInfo->SetCallArg(0, JSTaggedValue(1)); ecmaRuntimeCallInfo->SetCallArg(1, JSTaggedValue(2)); diff --git a/ecmascript/builtins/builtins_array.cpp b/ecmascript/builtins/builtins_array.cpp index 1a16af2b19727e2cc2e939b8000e347c499d38ce..13f51d58c264322ebf4887d529c6c8dc9cc15c1e 100644 --- a/ecmascript/builtins/builtins_array.cpp +++ b/ecmascript/builtins/builtins_array.cpp @@ -2682,7 +2682,7 @@ JSTaggedValue BuiltinsArray::Flat(EcmaRuntimeCallInfo *argv) JSHandle thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - array_size_t argc = argv->GetArgsNumber(); + uint32_t argc = argv->GetArgsNumber(); JSHandle thisObjVal(thisObjHandle); // 2. Let sourceLen be ? LengthOfArrayLike(O). @@ -2769,7 +2769,7 @@ JSTaggedValue BuiltinsArray::Includes(EcmaRuntimeCallInfo *argv) JSHandle thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - array_size_t argc = argv->GetArgsNumber(); + uint32_t argc = argv->GetArgsNumber(); JSHandle thisObjVal(thisObjHandle); JSHandle searchElement = GetCallArg(argv, 0); diff --git a/ecmascript/builtins/builtins_regexp.cpp b/ecmascript/builtins/builtins_regexp.cpp index de0950b7f262596bf4259821dadb2642a86a258f..2f25d6f0db15fc8d34be841321ad464ed0cee841 100644 --- a/ecmascript/builtins/builtins_regexp.cpp +++ b/ecmascript/builtins/builtins_regexp.cpp @@ -65,7 +65,7 @@ JSTaggedValue BuiltinsRegExp::RegExpConstructor(EcmaRuntimeCallInfo *argv) // 4.b If patternIsRegExp is true and flags is undefined if (patternIsRegExp && flags->IsUndefined()) { // 4.b.i Let patternConstructor be Get(pattern, "constructor"). - JSTaggedValue patternConstructor = FastRuntimeStub::FastGetPropertyByName( + JSTaggedValue patternConstructor = FastRuntimeStub::FastGetPropertyByValue( thread, pattern.GetTaggedValue(), constructorString.GetTaggedValue()); // 4.b.ii ReturnIfAbrupt(patternConstructor). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -384,7 +384,7 @@ JSTaggedValue BuiltinsRegExp::Match(EcmaRuntimeCallInfo *argv) const GlobalEnvConstants *globalConst = thread->GlobalConstants(); JSHandle global = globalConst->GetHandledGlobalString(); JSTaggedValue globalValue = - FastRuntimeStub::FastGetPropertyByName(thread, thisObj.GetTaggedValue(), global.GetTaggedValue()); + FastRuntimeStub::FastGetPropertyByValue(thread, thisObj.GetTaggedValue(), global.GetTaggedValue()); // 6. ReturnIfAbrupt(global). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -422,15 +422,15 @@ JSTaggedValue BuiltinsRegExp::Match(EcmaRuntimeCallInfo *argv) // a. Let fullUnicode be ToBoolean(Get(rx, "unicode")). JSHandle unicode = globalConst->GetHandledUnicodeString(); JSTaggedValue uincodeValue = - FastRuntimeStub::FastGetProperty(thread, thisObj.GetTaggedValue(), unicode.GetTaggedValue()); + FastRuntimeStub::FastGetPropertyByValue(thread, thisObj.GetTaggedValue(), unicode.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); bool fullUnicode = uincodeValue.ToBoolean(); // b. ReturnIfAbrupt(fullUnicode) RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // c. Let setStatus be Set(rx, "lastIndex", 0, true). JSHandle lastIndexString(globalConst->GetHandledLastIndexString()); - FastRuntimeStub::FastSetProperty(thread, thisObj.GetTaggedValue(), lastIndexString.GetTaggedValue(), - JSTaggedValue(0), true); + FastRuntimeStub::FastSetPropertyByValue(thread, thisObj.GetTaggedValue(), lastIndexString.GetTaggedValue(), + JSTaggedValue(0)); // d. ReturnIfAbrupt(setStatus). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // e. Let A be ArrayCreate(0). @@ -462,8 +462,9 @@ JSTaggedValue BuiltinsRegExp::Match(EcmaRuntimeCallInfo *argv) // iv. Else result is not null, // 1. Let matchStr be ToString(Get(result, "0")). JSHandle zeroString = globalConst->GetHandledZeroString(); - JSHandle matchStr( - thread, FastRuntimeStub::FastGetProperty(thread, result.GetTaggedValue(), zeroString.GetTaggedValue())); + JSTaggedValue matchVal = FastRuntimeStub::FastGetPropertyByValue( + thread, result.GetTaggedValue(), zeroString.GetTaggedValue()); + JSHandle matchStr(thread, matchVal); JSHandle matchString = JSTaggedValue::ToString(thread, matchStr); // 2. ReturnIfAbrupt(matchStr). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -473,9 +474,9 @@ JSTaggedValue BuiltinsRegExp::Match(EcmaRuntimeCallInfo *argv) // 5. If matchStr is the empty String, then if (JSTaggedValue::ToString(thread, matchValue)->GetLength() == 0) { // a. Let thisIndex be ToLength(Get(rx, "lastIndex")). - JSHandle lastIndexHandle( - thread, - FastRuntimeStub::FastGetProperty(thread, thisObj.GetTaggedValue(), lastIndexString.GetTaggedValue())); + JSTaggedValue lastIndex = FastRuntimeStub::FastGetPropertyByValue(thread, thisObj.GetTaggedValue(), + lastIndexString.GetTaggedValue()); + JSHandle lastIndexHandle(thread, lastIndex); JSTaggedNumber thisIndex = JSTaggedValue::ToLength(thread, lastIndexHandle); // b. ReturnIfAbrupt(thisIndex). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -483,8 +484,8 @@ JSTaggedValue BuiltinsRegExp::Match(EcmaRuntimeCallInfo *argv) // d. Let setStatus be Set(rx, "lastIndex", nextIndex, true). JSTaggedValue nextIndex = JSTaggedValue(AdvanceStringIndex(string, thisIndex.GetNumber(), fullUnicode)); - FastRuntimeStub::FastSetProperty(thread, thisObj.GetTaggedValue(), lastIndexString.GetTaggedValue(), - nextIndex, true); + FastRuntimeStub::FastSetPropertyByValue(thread, thisObj.GetTaggedValue(), lastIndexString.GetTaggedValue(), + nextIndex); // e. ReturnIfAbrupt(setStatus). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); } @@ -542,8 +543,8 @@ JSTaggedValue BuiltinsRegExp::MatchAll(EcmaRuntimeCallInfo *argv) RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 8. Perform ? Set(matcher, "lastIndex", lastIndex, true). - FastRuntimeStub::FastSetProperty(thread, matcherHandle.GetTaggedValue(), lastIndexString.GetTaggedValue(), - thisLastIndex, true); + FastRuntimeStub::FastSetPropertyByValue(thread, matcherHandle.GetTaggedValue(), lastIndexString.GetTaggedValue(), + thisLastIndex); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 9. If flags contains "g", let global be true. @@ -586,7 +587,7 @@ JSTaggedValue BuiltinsRegExp::RegExpReplaceFast(JSThread *thread, JSHandle(thisIndex.GetInt()); } else { @@ -651,8 +652,8 @@ JSTaggedValue BuiltinsRegExp::RegExpReplaceFast(JSThread *thread, JSHandleGetEcmaVM()->GetFactory(); JSHandle global = globalConst->GetHandledGlobalString(); JSTaggedValue globalValue = - FastRuntimeStub::FastGetProperty(thread, thisObj.GetTaggedValue(), global.GetTaggedValue()); + FastRuntimeStub::FastGetPropertyByValue(thread, thisObj.GetTaggedValue(), global.GetTaggedValue()); // 9. ReturnIfAbrupt(global). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); bool isGlobal = globalValue.ToBoolean(); @@ -737,14 +738,14 @@ JSTaggedValue BuiltinsRegExp::Replace(EcmaRuntimeCallInfo *argv) // a. Let fullUnicode be ToBoolean(Get(rx, "unicode")). JSHandle unicode = globalConst->GetHandledUnicodeString(); JSTaggedValue fullUnicodeTag = - FastRuntimeStub::FastGetProperty(thread, thisObj.GetTaggedValue(), unicode.GetTaggedValue()); + FastRuntimeStub::FastGetPropertyByValue(thread, thisObj.GetTaggedValue(), unicode.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); fullUnicode = fullUnicodeTag.ToBoolean(); // b. ReturnIfAbrupt(fullUnicode). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // c. Let setStatus be Set(rx, "lastIndex", 0, true). - FastRuntimeStub::FastSetProperty(thread, thisObj.GetTaggedValue(), lastIndex.GetTaggedValue(), JSTaggedValue(0), - true); + FastRuntimeStub::FastSetPropertyByValue(thread, thisObj.GetTaggedValue(), + lastIndex.GetTaggedValue(), JSTaggedValue(0)); // d. ReturnIfAbrupt(setStatus). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); } @@ -814,16 +815,18 @@ JSTaggedValue BuiltinsRegExp::Replace(EcmaRuntimeCallInfo *argv) break; } // iii. Else, 1. Let matchStr be ToString(Get(result, "0")). - JSHandle getMatch( - thread, FastRuntimeStub::FastGetProperty(thread, execResult.GetTaggedValue(), matchedStr.GetTaggedValue())); + JSTaggedValue getMatchVal = FastRuntimeStub::FastGetPropertyByValue( + thread, execResult.GetTaggedValue(), matchedStr.GetTaggedValue()); + JSHandle getMatch(thread, getMatchVal); JSHandle matchString = JSTaggedValue::ToString(thread, getMatch); // 2. ReturnIfAbrupt(matchStr). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 3. If matchStr is the empty String, then if (matchString->GetLength() == 0) { // a. Let thisIndex be ToLength(Get(rx, "lastIndex")). - JSHandle thisIndexHandle( - thread, FastRuntimeStub::FastGetProperty(thread, thisObj.GetTaggedValue(), lastIndex.GetTaggedValue())); + JSTaggedValue thisIndexVal = FastRuntimeStub::FastGetPropertyByValue( + thread, thisObj.GetTaggedValue(), lastIndex.GetTaggedValue()); + JSHandle thisIndexHandle(thread, thisIndexVal); uint32_t thisIndex = 0; if (thisIndexHandle->IsInt()) { thisIndex = static_cast(thisIndexHandle->GetInt()); @@ -836,8 +839,8 @@ JSTaggedValue BuiltinsRegExp::Replace(EcmaRuntimeCallInfo *argv) uint32_t nextIndex = AdvanceStringIndex(inputStr, thisIndex, fullUnicode); nextIndexHandle.Update(JSTaggedValue(nextIndex)); // d. Let setStatus be Set(rx, "lastIndex", nextIndex, true). - FastRuntimeStub::FastSetProperty(thread, thisObj.GetTaggedValue(), lastIndex.GetTaggedValue(), - nextIndexHandle.GetTaggedValue(), true); + FastRuntimeStub::FastSetPropertyByValue(thread, thisObj.GetTaggedValue(), lastIndex.GetTaggedValue(), + nextIndexHandle.GetTaggedValue()); // e. ReturnIfAbrupt(setStatus). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); } @@ -855,8 +858,8 @@ JSTaggedValue BuiltinsRegExp::Replace(EcmaRuntimeCallInfo *argv) resultValues.Update(FastRuntimeStub::FastGetPropertyByIndex(thread, resultsList.GetTaggedValue(), i)); // a. Let nCaptures be ToLength(Get(result, "length")). JSHandle lengthHandle = globalConst->GetHandledLengthString(); - ncapturesHandle.Update( - FastRuntimeStub::FastGetProperty(thread, resultValues.GetTaggedValue(), lengthHandle.GetTaggedValue())); + ncapturesHandle.Update(FastRuntimeStub::FastGetPropertyByValue( + thread, resultValues.GetTaggedValue(), lengthHandle.GetTaggedValue())); uint32_t ncaptures = JSTaggedValue::ToUint32(thread, ncapturesHandle); // b. ReturnIfAbrupt(nCaptures). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -872,8 +875,8 @@ JSTaggedValue BuiltinsRegExp::Replace(EcmaRuntimeCallInfo *argv) uint32_t matchLength = matchString->GetLength(); // g. Let position be ToInteger(Get(result, "index")). JSHandle resultIndex = globalConst->GetHandledIndexString(); - JSTaggedValue positionTag = - FastRuntimeStub::FastGetPropertyByName(thread, resultValues.GetTaggedValue(), resultIndex.GetTaggedValue()); + JSTaggedValue positionTag = FastRuntimeStub::FastGetPropertyByValue( + thread, resultValues.GetTaggedValue(), resultIndex.GetTaggedValue()); JSHandle positionHandle(thread, positionTag); uint32_t position = 0; if (positionHandle->IsInt()) { @@ -1358,7 +1361,7 @@ JSTaggedValue BuiltinsRegExp::RegExpBuiltinExec(JSThread *thread, const JSHandle const GlobalEnvConstants *globalConst = thread->GlobalConstants(); JSHandle lastIndexHandle = globalConst->GetHandledLastIndexString(); JSTaggedValue result = - FastRuntimeStub::FastGetProperty(thread, regexp.GetTaggedValue(), lastIndexHandle.GetTaggedValue()); + FastRuntimeStub::FastGetPropertyByValue(thread, regexp.GetTaggedValue(), lastIndexHandle.GetTaggedValue()); int32_t lastIndex = 0; if (result.IsInt()) { lastIndex = result.GetInt(); @@ -1370,12 +1373,12 @@ JSTaggedValue BuiltinsRegExp::RegExpBuiltinExec(JSThread *thread, const JSHandle } JSHandle globalHandle = globalConst->GetHandledGlobalString(); - bool global = - FastRuntimeStub::FastGetProperty(thread, regexp.GetTaggedValue(), globalHandle.GetTaggedValue()).ToBoolean(); + bool global = FastRuntimeStub::FastGetPropertyByValue( + thread, regexp.GetTaggedValue(), globalHandle.GetTaggedValue()).ToBoolean(); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); JSHandle stickyHandle = globalConst->GetHandledStickyString(); - bool sticky = - FastRuntimeStub::FastGetProperty(thread, regexp.GetTaggedValue(), stickyHandle.GetTaggedValue()).ToBoolean(); + bool sticky = FastRuntimeStub::FastGetPropertyByValue( + thread, regexp.GetTaggedValue(), stickyHandle.GetTaggedValue()).ToBoolean(); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (!global && !sticky) { lastIndex = 0; @@ -1488,8 +1491,9 @@ JSTaggedValue BuiltinsRegExp::RegExpExec(JSThread *thread, const JSHandleGlobalConstants(); JSHandle execHandle = globalConst->GetHandledExecString(); - JSHandle exec( - thread, FastRuntimeStub::FastGetProperty(thread, regexp.GetTaggedValue(), execHandle.GetTaggedValue())); + JSTaggedValue execVal = FastRuntimeStub::FastGetPropertyByValue(thread, regexp.GetTaggedValue(), + execHandle.GetTaggedValue()); + JSHandle exec(thread, execVal); // 4. ReturnIfAbrupt(exec). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 5. If IsCallable(exec) is true, then @@ -1680,8 +1684,8 @@ JSTaggedValue BuiltinsRegExp::RegExpInitialize(JSThread *thread, const JSHandle< } // 14. Let setStatus be Set(obj, "lastIndex", 0, true). JSHandle lastIndexString = thread->GlobalConstants()->GetHandledLastIndexString(); - FastRuntimeStub::FastSetProperty(thread, obj.GetTaggedValue(), lastIndexString.GetTaggedValue(), JSTaggedValue(0), - true); + FastRuntimeStub::FastSetPropertyByValue(thread, obj.GetTaggedValue(), + lastIndexString.GetTaggedValue(), JSTaggedValue(0)); // 15. ReturnIfAbrupt(setStatus). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 16. Return obj. diff --git a/ecmascript/builtins/tests/builtins_object_test.cpp b/ecmascript/builtins/tests/builtins_object_test.cpp index 8a0f1852a21362a40370c64121e7abb8122006be..416ccfbd34c05ca2d75400279b72ce26e1e88ac6 100644 --- a/ecmascript/builtins/tests/builtins_object_test.cpp +++ b/ecmascript/builtins/tests/builtins_object_test.cpp @@ -26,7 +26,6 @@ #include "ecmascript/js_thread.h" #include "ecmascript/object_factory.h" #include "ecmascript/tests/test_helper.h" -#include "file_items.h" #include "utils/bit_utils.h" using namespace panda::ecmascript; diff --git a/ecmascript/builtins/tests/builtins_proxy_test.cpp b/ecmascript/builtins/tests/builtins_proxy_test.cpp index 37448823a41f3dfc3ff43d0cf07c4a594df45a73..c410e3cbb2a4dd2892775f8f8c1f252c0d625fef 100644 --- a/ecmascript/builtins/tests/builtins_proxy_test.cpp +++ b/ecmascript/builtins/tests/builtins_proxy_test.cpp @@ -24,7 +24,6 @@ #include "ecmascript/js_thread.h" #include "ecmascript/object_factory.h" #include "ecmascript/tests/test_helper.h" -#include "file_items.h" #include "utils/bit_utils.h" using namespace panda::ecmascript; diff --git a/ecmascript/compiler/circuit_builder.h b/ecmascript/compiler/circuit_builder.h index f33911def039ad89f885bfb93071beef7f8d24d7..177e1d0c016d81dbb4a9dd3850e1ed567e8336e0 100644 --- a/ecmascript/compiler/circuit_builder.h +++ b/ecmascript/compiler/circuit_builder.h @@ -16,6 +16,8 @@ #ifndef ECMASCRIPT_COMPILER_CIRCUIT_BUILDER_H #define ECMASCRIPT_COMPILER_CIRCUIT_BUILDER_H +#include + #include "ecmascript/compiler/circuit.h" #include "ecmascript/compiler/gate.h" #include "ecmascript/compiler/gate_accessor.h" diff --git a/ecmascript/compiler/llvm_codegen.h b/ecmascript/compiler/llvm_codegen.h index 52fb8ae988a8d48457f28265204c52f5a4d60eca..def798f656e04fb0e8eb74a78a4b2f3784183c96 100644 --- a/ecmascript/compiler/llvm_codegen.h +++ b/ecmascript/compiler/llvm_codegen.h @@ -40,6 +40,7 @@ #include "ecmascript/mem/machine_code.h" #include "ecmascript/mem/region.h" +#include "libpandabase/utils/asan_interface.h" #include "llvm-c/Analysis.h" #include "llvm-c/Core.h" #include "llvm-c/ExecutionEngine.h" diff --git a/ecmascript/compiler/stub-inl.h b/ecmascript/compiler/stub-inl.h index 41d1b91696f6be19a76c0ed5bec92b04064dbb5b..0a8c7cc003e0bded95d0f75d42d18844f93fafa1 100644 --- a/ecmascript/compiler/stub-inl.h +++ b/ecmascript/compiler/stub-inl.h @@ -33,7 +33,6 @@ #include "ecmascript/message_string.h" #include "ecmascript/mem/slots.h" #include "ecmascript/mem/visitor.h" -#include "mem/region_space.h" namespace panda::ecmascript::kungfu { using JSFunction = panda::ecmascript::JSFunction; diff --git a/ecmascript/compiler/tests/stub_tests.cpp b/ecmascript/compiler/tests/stub_tests.cpp index f322e37a3de83a38023f9e419cd960d73b9221e2..c9952e393e1f4d3eff1cbdab903f9a29662d9935 100644 --- a/ecmascript/compiler/tests/stub_tests.cpp +++ b/ecmascript/compiler/tests/stub_tests.cpp @@ -39,7 +39,6 @@ #include "ecmascript/compiler/assembler_module.h" namespace panda::test { -using namespace panda::coretypes; using namespace panda::ecmascript; using namespace panda::ecmascript::kungfu; using BuiltinsPromiseHandler = builtins::BuiltinsPromiseHandler; @@ -127,7 +126,7 @@ HWTEST_F_L0(StubTest, FastAddTest) int x1 = 2147483647; int y1 = 15; auto resG = fn(thread->GetGlueAddr(), JSTaggedValue(x1).GetRawData(), JSTaggedValue(y1).GetRawData()); - auto expectedG = FastRuntimeStub::FastAdd(JSTaggedValue(x1), JSTaggedValue(y1)); + auto expectedG = SlowRuntimeStub::Add2Dyn(thread, JSTaggedValue(x1), JSTaggedValue(y1)); EXPECT_EQ(resG, expectedG); } @@ -860,8 +859,8 @@ HWTEST_F_L0(StubTest, GetPropertyByIndexStub) JSHandle obj = factory->NewEmptyJSObject(); int x = 213; int y = 10; - FastRuntimeStub::SetOwnElement(thread, obj.GetTaggedValue(), 1, JSTaggedValue(x)); - FastRuntimeStub::SetOwnElement(thread, obj.GetTaggedValue(), 10250, JSTaggedValue(y)); + FastRuntimeStub::SetPropertyByIndex(thread, obj.GetTaggedValue(), 1, JSTaggedValue(x)); + FastRuntimeStub::SetPropertyByIndex(thread, obj.GetTaggedValue(), 10250, JSTaggedValue(y)); JSTaggedValue resVal = getpropertyByIndex(thread->GetGlueAddr(), obj.GetTaggedValue(), 1); EXPECT_EQ(resVal.GetNumber(), x); resVal = getpropertyByIndex(thread->GetGlueAddr(), obj.GetTaggedValue(), 10250); @@ -1025,8 +1024,8 @@ HWTEST_F_L0(StubTest, GetPropertyByValueStub) int x = 213; int y = 10; auto sp = const_cast(thread->GetCurrentSPFrame()); - FastRuntimeStub::SetOwnElement(thread, obj.GetTaggedValue(), 1, JSTaggedValue(x)); - FastRuntimeStub::SetOwnElement(thread, obj.GetTaggedValue(), 10250, JSTaggedValue(y)); + FastRuntimeStub::SetPropertyByIndex(thread, obj.GetTaggedValue(), 1, JSTaggedValue(x)); + FastRuntimeStub::SetPropertyByIndex(thread, obj.GetTaggedValue(), 10250, JSTaggedValue(y)); JSHandle strA(factory->NewFromASCII("a")); JSHandle strBig(factory->NewFromASCII("biggest")); @@ -1209,8 +1208,8 @@ HWTEST_F_L0(StubTest, FastEqualTest) // test for obj == obj JSHandle obj1 = factory->NewEmptyJSObject(); JSHandle obj2 = factory->NewEmptyJSObject(); - FastRuntimeStub::SetOwnElement(thread, obj1.GetTaggedValue(), 1, JSTaggedValue(1)); - FastRuntimeStub::SetOwnElement(thread, obj2.GetTaggedValue(), 1, JSTaggedValue(1)); + FastRuntimeStub::SetPropertyByIndex(thread, obj1.GetTaggedValue(), 1, JSTaggedValue(1)); + FastRuntimeStub::SetPropertyByIndex(thread, obj2.GetTaggedValue(), 1, JSTaggedValue(1)); auto resI = fn(thread->GetGlueAddr(), obj1.GetTaggedValue().GetRawData(), obj2.GetTaggedValue().GetRawData()); auto expectI = FastRuntimeStub::FastEqual(obj1.GetTaggedValue(), obj2.GetTaggedValue()); EXPECT_EQ(resI, expectI); diff --git a/ecmascript/dfx/hprof/heap_snapshot.cpp b/ecmascript/dfx/hprof/heap_snapshot.cpp index 5925e57c154acad417a7cbdb3f3b44d211c507aa..c9a88af0ab42a49694139f6cfa9e49459fa15603 100644 --- a/ecmascript/dfx/hprof/heap_snapshot.cpp +++ b/ecmascript/dfx/hprof/heap_snapshot.cpp @@ -663,7 +663,7 @@ void HeapSnapshot::FillEdges() toValue.RemoveWeakTag(); } if (toValue.IsHeapObject()) { - auto *to = reinterpret_cast(toValue.GetHeapObject()); + auto *to = reinterpret_cast(toValue.GetTaggedObject()); entryTo = entryMap_.FindEntry(Node::NewAddress(to)); } if (entryTo == nullptr) { diff --git a/ecmascript/dump.cpp b/ecmascript/dump.cpp index 3b54a4fecdabe2f7cd8ea9678ac10c49f1c3fd7d..c9a7ec0ac02715e2bf5717ea90394ca9c787118f 100644 --- a/ecmascript/dump.cpp +++ b/ecmascript/dump.cpp @@ -3263,7 +3263,7 @@ static void DumpObject(TaggedObject *obj, JSCjsExports::Cast(obj)->DumpForSnapshot(vec); return; case JSType::JS_CJS_REQUIRE: - JSCjsExports::Cast(obj)->DumpForSnapshot(vec); + JSCjsRequire::Cast(obj)->DumpForSnapshot(vec); return; case JSType::JS_COLLATOR: JSCollator::Cast(obj)->DumpForSnapshot(vec); diff --git a/ecmascript/ecma_macros.h b/ecmascript/ecma_macros.h index c96755861d3a2e99afc3b2234b950d831885171a..1a478d0e988b054d2ab9229aa848e31aad8ba165 100644 --- a/ecmascript/ecma_macros.h +++ b/ecmascript/ecma_macros.h @@ -405,7 +405,7 @@ // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DECL_CAST(TYPE) \ - static TYPE *Cast(ObjectHeader *object) \ + static TYPE *Cast(TaggedObject *object) \ { \ ASSERT(JSTaggedValue(object).Is##TYPE()); \ return reinterpret_cast(object); \ @@ -457,14 +457,14 @@ #if ECMASCRIPT_ENABLE_CAST_CHECK #define CAST_CHECK(CAST_TYPE, CHECK_METHOD) \ - static inline CAST_TYPE *Cast(ObjectHeader *object) \ + static inline CAST_TYPE *Cast(TaggedObject *object) \ { \ if (!JSTaggedValue(object).CHECK_METHOD()) { \ std::abort(); \ } \ return static_cast(object); \ } \ - static inline const CAST_TYPE *ConstCast(const ObjectHeader *object) \ + static inline const CAST_TYPE *ConstCast(const TaggedObject *object) \ { \ if (!JSTaggedValue(object).CHECK_METHOD()) { \ std::abort(); \ @@ -473,23 +473,23 @@ } # else #define CAST_CHECK(CAST_TYPE, CHECK_METHOD) \ - static inline CAST_TYPE *Cast(ObjectHeader *object) \ + static inline CAST_TYPE *Cast(TaggedObject *object) \ { \ ASSERT(JSTaggedValue(object).CHECK_METHOD()); \ return static_cast(object); \ } \ - static const inline CAST_TYPE *ConstCast(const ObjectHeader *object) \ + static const inline CAST_TYPE *ConstCast(const TaggedObject *object) \ { \ ASSERT(JSTaggedValue(object).CHECK_METHOD()); \ return static_cast(object); \ } #define CAST_NO_CHECK(CAST_TYPE) \ - static inline CAST_TYPE *Cast(ObjectHeader *object) \ + static inline CAST_TYPE *Cast(TaggedObject *object) \ { \ return static_cast(object); \ } \ - static const inline CAST_TYPE *ConstCast(const ObjectHeader *object) \ + static const inline CAST_TYPE *ConstCast(const TaggedObject *object) \ { \ return static_cast(object); \ } diff --git a/ecmascript/ecma_string-inl.h b/ecmascript/ecma_string-inl.h index 099eb51aedcbdf01186d25369c69e4f5e7a21b07..82a5623e6f9ae8a053d136b749ff1cab56b000a8 100644 --- a/ecmascript/ecma_string-inl.h +++ b/ecmascript/ecma_string-inl.h @@ -24,7 +24,7 @@ namespace panda::ecmascript { /* static */ -inline EcmaString *EcmaString::Cast(ObjectHeader *object) +inline EcmaString *EcmaString::Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsString()); return static_cast(object); diff --git a/ecmascript/ecma_string.h b/ecmascript/ecma_string.h index ee6ef7e3ef739e12440e37e7aee75d5a9e78c0c2..09734409b0eac7f26b0345b8faa7ff723f66aafe 100644 --- a/ecmascript/ecma_string.h +++ b/ecmascript/ecma_string.h @@ -26,6 +26,7 @@ #include "ecmascript/mem/tagged_object.h" #include "ecmascript/mem/barriers.h" #include "macros.h" +#include "securec.h" namespace panda { namespace ecmascript { @@ -35,7 +36,7 @@ class EcmaVM; class EcmaString : public TaggedObject { public: - static EcmaString *Cast(ObjectHeader *object); + static EcmaString *Cast(TaggedObject *object); static const EcmaString *ConstCast(const TaggedObject *object); static EcmaString *CreateEmptyString(const EcmaVM *vm); diff --git a/ecmascript/ecma_vm.cpp b/ecmascript/ecma_vm.cpp index 30ddaa12181a994444378da73af13c644b1dd52b..20da3358e168e8d0320ea8663267fee0db9103cf 100644 --- a/ecmascript/ecma_vm.cpp +++ b/ecmascript/ecma_vm.cpp @@ -491,7 +491,7 @@ void EcmaVM::EnableUserUncaughtErrorHandler() isUncaughtExceptionRegistered_ = true; } -void EcmaVM::HandleUncaughtException(ObjectHeader *exception) +void EcmaVM::HandleUncaughtException(TaggedObject *exception) { if (isUncaughtExceptionRegistered_) { return; diff --git a/ecmascript/ecma_vm.h b/ecmascript/ecma_vm.h index 13677dedcaddaebd2a569b38496ccd4e52f45d8d..10f019bc3008eb65793a3304bf0178e52ae84ae4 100644 --- a/ecmascript/ecma_vm.h +++ b/ecmascript/ecma_vm.h @@ -350,7 +350,7 @@ public: protected: - void HandleUncaughtException(ObjectHeader *exception); + void HandleUncaughtException(TaggedObject *exception); void PrintJSErrorInfo(const JSHandle &exceptionInfo); diff --git a/ecmascript/global_env.h b/ecmascript/global_env.h index 0b58dbe4041d126ee13dd93c5925e14a1c72658c..84958f3f19e7f1b5beff578946ccc40b4bf1f693 100644 --- a/ecmascript/global_env.h +++ b/ecmascript/global_env.h @@ -185,7 +185,7 @@ public: void Init(JSThread *thread); void InitGlobalObject(); - static GlobalEnv *Cast(ObjectHeader *object) + static GlobalEnv *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSGlobalEnv()); return reinterpret_cast(object); diff --git a/ecmascript/ic/ic_handler.h b/ecmascript/ic/ic_handler.h index 5e200ecfcde93535a944673eb7ee22cb8866aa50..f4e43ac9d64e698e511f8afe2e85566f2dbff36c 100644 --- a/ecmascript/ic/ic_handler.h +++ b/ecmascript/ic/ic_handler.h @@ -193,7 +193,7 @@ public: JSHandle handler = factory->NewTransitionHandler(); JSHandle handlerInfo = StoreHandler::StoreProperty(thread, op); handler->SetHandlerInfo(thread, handlerInfo); - auto hclass = JSObject::Cast(op.GetReceiver()->GetHeapObject())->GetJSHClass(); + auto hclass = JSObject::Cast(op.GetReceiver()->GetTaggedObject())->GetJSHClass(); handler->SetTransitionHClass(thread, JSTaggedValue(hclass)); return JSHandle::Cast(handler); } diff --git a/ecmascript/ic/ic_runtime_stub-inl.h b/ecmascript/ic/ic_runtime_stub-inl.h index 72b048628cc822e9c52492323df9153481507fcf..c1f9606bda1da19078ac1bb83e5981879ab1e4f3 100644 --- a/ecmascript/ic/ic_runtime_stub-inl.h +++ b/ecmascript/ic/ic_runtime_stub-inl.h @@ -68,7 +68,7 @@ JSTaggedValue ICRuntimeStub::CheckPolyHClass(JSTaggedValue cachedValue, JSHClass { if (!cachedValue.IsWeak()) { ASSERT(cachedValue.IsTaggedArray()); - TaggedArray *array = TaggedArray::Cast(cachedValue.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(cachedValue.GetTaggedObject()); uint32_t length = array->GetLength(); for (uint32_t i = 0; i < length; i += 2) { // 2 means one ic, two slot auto result = array->Get(i); @@ -112,7 +112,7 @@ ARK_INLINE JSTaggedValue ICRuntimeStub::TryLoadICByValue(JSThread *thread, JSTag auto hclass = receiver.GetTaggedObject()->GetClass(); if (firstValue.GetWeakReferentUnChecked() == hclass) { ASSERT(HandlerBase::IsElement(secondValue.GetInt())); - return LoadElement(JSObject::Cast(receiver.GetHeapObject()), key); + return LoadElement(JSObject::Cast(receiver.GetTaggedObject()), key); } // Check key if (firstValue == key) { @@ -140,7 +140,7 @@ ARK_INLINE JSTaggedValue ICRuntimeStub::TryStoreICByValue(JSThread *thread, JSTa if (receiver.IsHeapObject()) { auto hclass = receiver.GetTaggedObject()->GetClass(); if (firstValue.GetWeakReferentUnChecked() == hclass) { - return StoreElement(thread, JSObject::Cast(receiver.GetHeapObject()), key, value, secondValue); + return StoreElement(thread, JSObject::Cast(receiver.GetTaggedObject()), key, value, secondValue); } // Check key if (firstValue == key) { @@ -196,15 +196,15 @@ ARK_INLINE JSTaggedValue ICRuntimeStub::StoreICWithHandler(JSThread *thread, JST if (handler.IsInt()) { auto handlerInfo = static_cast(handler.GetInt()); if (HandlerBase::IsField(handlerInfo)) { - StoreField(thread, JSObject::Cast(receiver.GetHeapObject()), value, handlerInfo); + StoreField(thread, JSObject::Cast(receiver.GetTaggedObject()), value, handlerInfo); return JSTaggedValue::Undefined(); } ASSERT(HandlerBase::IsAccessor(handlerInfo) || HandlerBase::IsInternalAccessor(handlerInfo)); - auto accessor = LoadFromField(JSObject::Cast(holder.GetHeapObject()), handlerInfo); + auto accessor = LoadFromField(JSObject::Cast(holder.GetTaggedObject()), handlerInfo); return FastRuntimeStub::CallSetter(thread, JSTaggedValue(receiver), value, accessor); } if (handler.IsTransitionHandler()) { - StoreWithTransition(thread, JSObject::Cast(receiver.GetHeapObject()), value, handler); + StoreWithTransition(thread, JSObject::Cast(receiver.GetTaggedObject()), value, handler); return JSTaggedValue::Undefined(); } if (handler.IsPrototypeHandler()) { @@ -224,7 +224,7 @@ JSTaggedValue ICRuntimeStub::StorePrototype(JSThread *thread, JSTaggedValue rece PrototypeHandler *prototypeHandler = PrototypeHandler::Cast(handler.GetTaggedObject()); auto cellValue = prototypeHandler->GetProtoCell(); ASSERT(cellValue.IsProtoChangeMarker()); - ProtoChangeMarker *cell = ProtoChangeMarker::Cast(cellValue.GetHeapObject()); + ProtoChangeMarker *cell = ProtoChangeMarker::Cast(cellValue.GetTaggedObject()); if (cell->GetHasChanged()) { return JSTaggedValue::Hole(); } @@ -244,7 +244,7 @@ void ICRuntimeStub::StoreWithTransition(JSThread *thread, JSObject *receiver, JS ASSERT(HandlerBase::IsField(handlerInfo)); if (!HandlerBase::IsInlinedProps(handlerInfo)) { - TaggedArray *array = TaggedArray::Cast(receiver->GetProperties().GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(receiver->GetProperties().GetTaggedObject()); int capacity = static_cast(array->GetLength()); int index = HandlerBase::GetOffset(handlerInfo); if (index >= capacity) { @@ -278,7 +278,7 @@ ARK_INLINE void ICRuntimeStub::StoreField(JSThread *thread, JSObject *receiver, SET_VALUE_WITH_BARRIER(thread, receiver, static_cast(index) * JSTaggedValue::TaggedTypeSize(), value); return; } - TaggedArray *array = TaggedArray::Cast(receiver->GetProperties().GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(receiver->GetProperties().GetTaggedObject()); ASSERT(index < static_cast(array->GetLength())); array->Set(thread, index, value); } @@ -289,13 +289,13 @@ ARK_INLINE JSTaggedValue ICRuntimeStub::LoadFromField(JSObject *receiver, uint32 if (HandlerBase::IsInlinedProps(handlerInfo)) { return JSTaggedValue(GET_VALUE(receiver, static_cast(index) * JSTaggedValue::TaggedTypeSize())); } - return TaggedArray::Cast(receiver->GetProperties().GetHeapObject())->Get(index); + return TaggedArray::Cast(receiver->GetProperties().GetTaggedObject())->Get(index); } ARK_INLINE JSTaggedValue ICRuntimeStub::LoadGlobal(JSTaggedValue handler) { ASSERT(handler.IsPropertyBox()); - PropertyBox *cell = PropertyBox::Cast(handler.GetHeapObject()); + PropertyBox *cell = PropertyBox::Cast(handler.GetTaggedObject()); if (cell->IsInvalid()) { return JSTaggedValue::Hole(); } @@ -308,7 +308,7 @@ ARK_INLINE JSTaggedValue ICRuntimeStub::StoreGlobal(JSThread *thread, JSTaggedVa { INTERPRETER_TRACE(thread, StoreGlobal); ASSERT(handler.IsPropertyBox()); - PropertyBox *cell = PropertyBox::Cast(handler.GetHeapObject()); + PropertyBox *cell = PropertyBox::Cast(handler.GetTaggedObject()); if (cell->IsInvalid()) { return JSTaggedValue::Hole(); } @@ -324,7 +324,7 @@ JSTaggedValue ICRuntimeStub::LoadPrototype(JSThread *thread, JSTaggedValue recei PrototypeHandler *prototypeHandler = PrototypeHandler::Cast(handler.GetTaggedObject()); auto cellValue = prototypeHandler->GetProtoCell(); ASSERT(cellValue.IsProtoChangeMarker()); - ProtoChangeMarker *cell = ProtoChangeMarker::Cast(cellValue.GetHeapObject()); + ProtoChangeMarker *cell = ProtoChangeMarker::Cast(cellValue.GetTaggedObject()); if (cell->GetHasChanged()) { return JSTaggedValue::Hole(); } @@ -340,13 +340,13 @@ ARK_INLINE JSTaggedValue ICRuntimeStub::LoadICWithHandler(JSThread *thread, JSTa if (LIKELY(handler.IsInt())) { auto handlerInfo = static_cast(handler.GetInt()); if (LIKELY(HandlerBase::IsField(handlerInfo))) { - return LoadFromField(JSObject::Cast(holder.GetHeapObject()), handlerInfo); + return LoadFromField(JSObject::Cast(holder.GetTaggedObject()), handlerInfo); } if (HandlerBase::IsNonExist(handlerInfo)) { return JSTaggedValue::Undefined(); } ASSERT(HandlerBase::IsAccessor(handlerInfo) || HandlerBase::IsInternalAccessor(handlerInfo)); - auto accessor = LoadFromField(JSObject::Cast(holder.GetHeapObject()), handlerInfo); + auto accessor = LoadFromField(JSObject::Cast(holder.GetTaggedObject()), handlerInfo); return FastRuntimeStub::CallGetter(thread, receiver, holder, accessor); } @@ -364,7 +364,7 @@ ARK_INLINE JSTaggedValue ICRuntimeStub::LoadElement(JSObject *receiver, JSTagged return JSTaggedValue::Hole(); } uint32_t elementIndex = static_cast(index); - TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetHeapObject()); + TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetTaggedObject()); if (elements->GetLength() <= elementIndex) { return JSTaggedValue::Hole(); } @@ -392,7 +392,7 @@ JSTaggedValue ICRuntimeStub::StoreElement(JSThread *thread, JSObject *receiver, arr->SetArrayLength(thread, elementIndex + 1); } } - TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetHeapObject()); + TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetTaggedObject()); uint32_t capacity = elements->GetLength(); if (elementIndex >= capacity) { if (JSObject::ShouldTransToDict(capacity, elementIndex)) { @@ -413,7 +413,7 @@ JSTaggedValue ICRuntimeStub::StoreElement(JSThread *thread, JSObject *receiver, PrototypeHandler *prototypeHandler = PrototypeHandler::Cast(handler.GetTaggedObject()); auto cellValue = prototypeHandler->GetProtoCell(); ASSERT(cellValue.IsProtoChangeMarker()); - ProtoChangeMarker *cell = ProtoChangeMarker::Cast(cellValue.GetHeapObject()); + ProtoChangeMarker *cell = ProtoChangeMarker::Cast(cellValue.GetTaggedObject()); if (cell->GetHasChanged()) { return JSTaggedValue::Hole(); } diff --git a/ecmascript/ic/invoke_cache.cpp b/ecmascript/ic/invoke_cache.cpp index d8ee49029e31dc6ed087b08106a58fa679f9001d..9e99826295c8e3827fb74e3e9631a4509f450f6c 100644 --- a/ecmascript/ic/invoke_cache.cpp +++ b/ecmascript/ic/invoke_cache.cpp @@ -62,7 +62,7 @@ bool InvokeCache::SetPolyConstuctCacheSlot(JSThread *thread, ProfileTypeInfo *pr JSTaggedValue InvokeCache::CheckPolyInvokeCache(JSTaggedValue cachedArray, JSTaggedValue func) { ASSERT(cachedArray.IsTaggedArray()); - TaggedArray *array = TaggedArray::Cast(cachedArray.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(cachedArray.GetTaggedObject()); uint32_t length = array->GetLength(); for (uint32_t index = 0; index < length; index += 2) { // 2: means one ic, two slot auto result = array->Get(index); diff --git a/ecmascript/ic/profile_type_info.cpp b/ecmascript/ic/profile_type_info.cpp index cafcd559aa34650c664e5d7065f726c8f96b96b8..c5c3ef1253a5ba64275c380b0e45744310334aa6 100644 --- a/ecmascript/ic/profile_type_info.cpp +++ b/ecmascript/ic/profile_type_info.cpp @@ -259,11 +259,11 @@ ProfileTypeAccessor::ICState ProfileTypeAccessor::GetICState() const return ICState::MONO; } if (profileData.IsTaggedArray()) { - TaggedArray *array = TaggedArray::Cast(profileData.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(profileData.GetTaggedObject()); return array->GetLength() == MONO_CASE_NUM ? ICState::MONO : ICState::POLY; // 2 : test case } profileData = profileTypeInfo_->Get(slotId_ + 1); - TaggedArray *array = TaggedArray::Cast(profileData.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(profileData.GetTaggedObject()); return array->GetLength() == MONO_CASE_NUM ? ICState::MONO : ICState::POLY; // 2 : test case } case ICKind::NamedGlobalLoadIC: @@ -273,7 +273,7 @@ ProfileTypeAccessor::ICState ProfileTypeAccessor::GetICState() const case ICKind::GlobalLoadIC: case ICKind::GlobalStoreIC: { ASSERT(profileData.IsTaggedArray()); - TaggedArray *array = TaggedArray::Cast(profileData.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(profileData.GetTaggedObject()); return array->GetLength() == MONO_CASE_NUM ? ICState::MONO : ICState::POLY; // 2 : test case } default: diff --git a/ecmascript/ic/property_box.h b/ecmascript/ic/property_box.h index 9472e285d7fd2a8ac0f87450fbb5e627586bf85f..532e29ca146d41a8762d75da1cfc35c2e10a7c4a 100644 --- a/ecmascript/ic/property_box.h +++ b/ecmascript/ic/property_box.h @@ -27,7 +27,7 @@ namespace panda { namespace ecmascript { class PropertyBox : public TaggedObject { public: - static PropertyBox *Cast(ObjectHeader *object) + static PropertyBox *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsPropertyBox()); return static_cast(object); diff --git a/ecmascript/ic/proto_change_details.h b/ecmascript/ic/proto_change_details.h index 8ce9905be165eeb448a7cd0f50bdeb9fc83bda1d..a75fb39c8f76565da6e2b70f647bf231e7a2d6e7 100644 --- a/ecmascript/ic/proto_change_details.h +++ b/ecmascript/ic/proto_change_details.h @@ -25,7 +25,7 @@ namespace panda { namespace ecmascript { class ProtoChangeMarker : public TaggedObject { public: - static ProtoChangeMarker *Cast(ObjectHeader *object) + static ProtoChangeMarker *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsProtoChangeMarker()); return static_cast(object); @@ -45,7 +45,7 @@ public: class ProtoChangeDetails : public TaggedObject { public: static constexpr int UNREGISTERED = -1; - static ProtoChangeDetails *Cast(ObjectHeader *object) + static ProtoChangeDetails *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsProtoChangeDetails()); return static_cast(object); @@ -62,7 +62,7 @@ public: class ChangeListener : public WeakVector { public: - static ChangeListener *Cast(ObjectHeader *object) + static ChangeListener *Cast(TaggedObject *object) { return static_cast(object); } diff --git a/ecmascript/ic/tests/ic_runtime_stub_test.cpp b/ecmascript/ic/tests/ic_runtime_stub_test.cpp index 6de3e636dbc5b4c25219aa121bbb1408efb774cc..125152205e3dfb1b57a8900d9011ec3370378973 100644 --- a/ecmascript/ic/tests/ic_runtime_stub_test.cpp +++ b/ecmascript/ic/tests/ic_runtime_stub_test.cpp @@ -331,7 +331,7 @@ HWTEST_F_L0(ICRuntimeStubTest, StoreICWithHandler) OffsetBit::Set(bitOffset, &handler); AccessorBit::Set(true, &handler); - array_size_t arrayLength = bitOffset + 1U; + uint32_t arrayLength = bitOffset + 1U; JSHandle handleHolder = factory->NewJSObjectByConstructor(JSHandle(objFun), objFun); JSHandle handleTaggedArr = factory->NewTaggedArray(arrayLength); handleTaggedArr->Set(thread, bitOffset, handleAccessor.GetTaggedValue()); @@ -389,7 +389,7 @@ HWTEST_F_L0(ICRuntimeStubTest, LoadICWithHandler) OffsetBit::Set(bitOffset, &handler); AccessorBit::Set(true, &handler); - array_size_t arrayLength = bitOffset + 1U; + uint32_t arrayLength = bitOffset + 1U; JSHandle handleHolder = factory->NewJSObjectByConstructor(JSHandle(objFun), objFun); JSHandle handleTaggedArr = factory->NewTaggedArray(arrayLength); handleTaggedArr->Set(thread, bitOffset, handleAccessor.GetTaggedValue()); @@ -428,7 +428,7 @@ HWTEST_F_L0(ICRuntimeStubTest, Prototype_StoreAndLoad) OffsetBit::Set(bitOffset, &handler); KindBit::Set(HandlerKind::FIELD, &handler); // test filed - array_size_t arrayLength = bitOffset + 1U; + uint32_t arrayLength = bitOffset + 1U; JSHandle handleObj = factory->NewJSObjectByConstructor(JSHandle(objFun), objFun); JSHandle handleTaggedArr = factory->NewTaggedArray(arrayLength); handleObj->SetProperties(thread, handleTaggedArr.GetTaggedValue()); @@ -462,7 +462,7 @@ HWTEST_F_L0(ICRuntimeStubTest, StoreWithTransition_In_Filed) OffsetBit::Set(bitOffset, &handler); KindBit::Set(HandlerKind::FIELD, &handler); - array_size_t arrayLength = bitOffset + 1U; + uint32_t arrayLength = bitOffset + 1U; JSHandle handleTaggedArr = factory->NewTaggedArray(arrayLength); handleObj->SetProperties(thread, handleTaggedArr.GetTaggedValue()); @@ -487,7 +487,7 @@ HWTEST_F_L0(ICRuntimeStubTest, Field_StoreAndLoad) uint32_t bitOffset = 2U; OffsetBit::Set(bitOffset, &handler); - array_size_t arrayLength = bitOffset + 1U; + uint32_t arrayLength = bitOffset + 1U; JSHandle handleTaggedArr = factory->NewTaggedArray(arrayLength); handleTaggedArr->Set(thread, bitOffset, JSTaggedValue::Undefined()); @@ -533,7 +533,7 @@ HWTEST_F_L0(ICRuntimeStubTest, Element_StoreAndLoad) KindBit::Set(HandlerKind::ELEMENT, &handlerInfo); IsJSArrayBit::Set(true, &handlerInfo); - array_size_t arrayLength = 3U; + uint32_t arrayLength = 3U; JSArray *handleArr = JSArray::ArrayCreate(thread, JSTaggedNumber(arrayLength)).GetObject(); JSHandle handleArrObj(thread, handleArr); JSHandle handleTaggedArr = factory->NewTaggedArray(arrayLength); diff --git a/ecmascript/ic/tests/properties_cache_test.cpp b/ecmascript/ic/tests/properties_cache_test.cpp index aeba3058d0af613cc4a92c08e11a66a4ad2e46b2..720f652118a76f99c166e68ef05927a75b78fb4e 100644 --- a/ecmascript/ic/tests/properties_cache_test.cpp +++ b/ecmascript/ic/tests/properties_cache_test.cpp @@ -62,7 +62,7 @@ HWTEST_F_L0(PropertiesCacheTest, SetAndGet) JSHandle handleFunction(factory->NewJSFunction(env)); JSHandle handleSymbol(factory->NewJSSymbol()); JSHandle handleKey10(factory->NewFromASCII("10")); - JSHClass *FuncClass = JSObject::Cast(handleFunction->GetHeapObject())->GetJSHClass(); + JSHClass *FuncClass = JSObject::Cast(handleFunction->GetTaggedObject())->GetJSHClass(); PropertiesCache *handleProCache = thread->GetPropertiesCache(); // key is string @@ -98,7 +98,7 @@ HWTEST_F_L0(PropertiesCacheTest, Clear) JSHandle handleKey(factory->NewFromASCII("10")); JSHandle handleFunction(factory->NewJSFunction(env)); - JSHClass *FuncClass = JSObject::Cast(handleFunction->GetHeapObject())->GetJSHClass(); + JSHClass *FuncClass = JSObject::Cast(handleFunction->GetTaggedObject())->GetJSHClass(); PropertiesCache *handleProCache = thread->GetPropertiesCache(); handleProCache->Set(FuncClass, handleKey.GetTaggedValue(), 10); diff --git a/ecmascript/ic/tests/proto_change_details_test.cpp b/ecmascript/ic/tests/proto_change_details_test.cpp index 06234b933111e70800b91957c930a57e38723183..cec855986c312c716b507f725cd61e96fbb3f805 100644 --- a/ecmascript/ic/tests/proto_change_details_test.cpp +++ b/ecmascript/ic/tests/proto_change_details_test.cpp @@ -96,7 +96,7 @@ HWTEST_F_L0(ProtoChangeDetailsTest, SetChangeListener) ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle handleValue(thread, JSTaggedValue(1)); - array_size_t weakVectorCapacity = 100; + uint32_t weakVectorCapacity = 100; JSHandle weakVector = WeakVector::Create(thread, weakVectorCapacity); JSHandle handleChangeListener = JSHandle::Cast(weakVector); JSHandle handleChangeDetails = factory->NewProtoChangeDetails(); @@ -138,8 +138,8 @@ HWTEST_F_L0(ProtoChangeDetailsTest, Add_001) JSHandle objFun = env->GetObjectFunction(); JSHandle handleObj = factory->NewJSObjectByConstructor(JSHandle(objFun), objFun); JSHandle objDynclassVal(thread, handleObj->GetJSHClass()); - array_size_t weakVectorCapacity = 10; - array_size_t index = 2; + uint32_t weakVectorCapacity = 10; + uint32_t index = 2; JSHandle weakVector = WeakVector::Create(thread, weakVectorCapacity); for (int i = 0; i < 9; i++) { weakVector->PushBack(thread, JSTaggedValue(i)); @@ -169,8 +169,8 @@ HWTEST_F_L0(ProtoChangeDetailsTest, Add_002) JSHandle objFun = env->GetObjectFunction(); JSHandle handleObj = factory->NewJSObjectByConstructor(JSHandle(objFun), objFun); JSHandle objDynclassVal(thread, handleObj->GetJSHClass()); - array_size_t weakVectorCapacity = 10; - array_size_t index = 2; + uint32_t weakVectorCapacity = 10; + uint32_t index = 2; JSHandle weakVector = WeakVector::Create(thread, weakVectorCapacity); for (int i = 0; i < 10; i++) { weakVector->PushBack(thread, JSTaggedValue(i)); @@ -202,8 +202,8 @@ HWTEST_F_L0(ProtoChangeDetailsTest, Add_003) JSHandle objFun = env->GetObjectFunction(); JSHandle handleObj = factory->NewJSObjectByConstructor(JSHandle(objFun), objFun); JSHandle objDynclassVal(thread, handleObj->GetJSHClass()); - array_size_t weakVectorCapacity = 10; - array_size_t index = 2; + uint32_t weakVectorCapacity = 10; + uint32_t index = 2; JSHandle weakVector = WeakVector::Create(thread, weakVectorCapacity); for (int i = 0; i < 10; i++) { weakVector->PushBack(thread, JSTaggedValue(i)); @@ -229,7 +229,7 @@ HWTEST_F_L0(ProtoChangeDetailsTest, Add_003) */ HWTEST_F_L0(ProtoChangeDetailsTest, CheckHole) { - array_size_t weakVectorCapacity = 10; + uint32_t weakVectorCapacity = 10; JSHandle weakVector = WeakVector::Create(thread, weakVectorCapacity); for (int i = 0; i < 10; i++) { weakVector->PushBack(thread, JSTaggedValue(i)); // Set Value and End @@ -250,7 +250,7 @@ HWTEST_F_L0(ProtoChangeDetailsTest, CheckHole) */ HWTEST_F_L0(ProtoChangeDetailsTest, Get) { - array_size_t weakVectorCapacity = 3; + uint32_t weakVectorCapacity = 3; ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle objFun = env->GetObjectFunction(); diff --git a/ecmascript/interpreter/fast_runtime_stub-inl.h b/ecmascript/interpreter/fast_runtime_stub-inl.h index ccf68f35d0dabb9c43f8f4e913e180b88b4e972b..f6bcbe688fa4960f40eeb3f9df3189986c8242e4 100644 --- a/ecmascript/interpreter/fast_runtime_stub-inl.h +++ b/ecmascript/interpreter/fast_runtime_stub-inl.h @@ -45,24 +45,6 @@ namespace panda::ecmascript { return JSTaggedValue::Hole(); \ } -JSTaggedValue FastRuntimeStub::FastAdd(JSTaggedValue left, JSTaggedValue right) -{ - if (left.IsNumber() && right.IsNumber()) { - return JSTaggedValue(left.GetNumber() + right.GetNumber()); - } - - return JSTaggedValue::Hole(); -} - -JSTaggedValue FastRuntimeStub::FastSub(JSTaggedValue left, JSTaggedValue right) -{ - if (left.IsNumber() && right.IsNumber()) { - return JSTaggedValue(left.GetNumber() - right.GetNumber()); - } - - return JSTaggedValue::Hole(); -} - JSTaggedValue FastRuntimeStub::FastMul(JSTaggedValue left, JSTaggedValue right) { if (left.IsNumber() && right.IsNumber()) { @@ -801,593 +783,6 @@ JSTaggedValue FastRuntimeStub::NewLexicalEnvDyn(JSThread *thread, ObjectFactory return JSTaggedValue(newEnv); } -// Those interface below is discarded -bool FastRuntimeStub::IsSpecialIndexedObjForGet(JSTaggedValue obj) -{ - JSType jsType = obj.GetTaggedObject()->GetClass()->GetObjectType(); - return jsType > JSType::JS_ARRAY && jsType <= JSType::JS_PRIMITIVE_REF; -} - -bool FastRuntimeStub::IsSpecialIndexedObjForSet(JSTaggedValue obj) -{ - JSType jsType = obj.GetTaggedObject()->GetClass()->GetObjectType(); - return jsType >= JSType::JS_ARRAY && jsType <= JSType::JS_PRIMITIVE_REF; -} - -JSTaggedValue FastRuntimeStub::GetElement(JSTaggedValue receiver, uint32_t index) -{ - JSTaggedValue holder = receiver; - while (true) { - JSTaggedValue val = FindOwnElement(JSObject::Cast(holder), index); - if (!val.IsHole()) { - return val; - } - - holder = JSObject::Cast(holder)->GetJSHClass()->GetPrototype(); - if (!holder.IsHeapObject()) { - return JSTaggedValue::Undefined(); - } - } -} - -JSTaggedValue FastRuntimeStub::GetElementWithArray(JSTaggedValue receiver, uint32_t index) -{ - DISALLOW_GARBAGE_COLLECTION; - JSTaggedValue holder = receiver; - while (true) { - JSTaggedValue val = FindOwnElement(JSObject::Cast(holder), index); - if (!val.IsHole()) { - return val; - } - - holder = JSObject::Cast(holder)->GetJSHClass()->GetPrototype(); - if (!holder.IsHeapObject()) { - return val; - } - } -} - -bool FastRuntimeStub::SetElement(JSThread *thread, JSTaggedValue receiver, uint32_t index, JSTaggedValue value, - bool mayThrow) -{ - INTERPRETER_TRACE(thread, SetElement); - JSTaggedValue holder = receiver; - bool onPrototype = false; - - while (true) { - PropertyAttributes attr; - uint32_t indexOrEntry = 0; - TaggedArray *elements = TaggedArray::Cast(JSObject::Cast(holder)->GetElements().GetHeapObject()); - bool isDict = elements->IsDictionaryMode(); - JSTaggedValue val = FindOwnElement(elements, index, isDict, &attr, &indexOrEntry); - if (!val.IsHole()) { - if (UNLIKELY(onPrototype)) { - if (UNLIKELY(!JSObject::Cast(receiver)->IsExtensible())) { - if (mayThrow) { - THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot add property in prevent extensions ", false); - } - return false; - } - - return JSObject::AddElementInternal(thread, JSHandle(thread, receiver), index, - JSHandle(thread, value), - PropertyAttributes::Default()); - } - if (!attr.IsAccessor()) { - if (attr.IsWritable()) { - elements = TaggedArray::Cast(JSObject::Cast(receiver)->GetElements().GetHeapObject()); - if (!isDict) { - elements->Set(thread, indexOrEntry, value); - JSObject::Cast(receiver)->GetJSHClass()->UpdateRepresentation(value); - return true; - } - NumberDictionary::Cast(elements)->UpdateValueAndAttributes(thread, indexOrEntry, value, attr); - return true; - } - - if (mayThrow) { - THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot set readonly property", false); - } - return false; - } - - // Accessor - [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle objHandle(thread, receiver); - JSHandle valueHandle(thread, value); - AccessorData *access = AccessorData::Cast(val.GetHeapObject()); - return JSObject::CallSetter(thread, *access, objHandle, valueHandle, mayThrow); - } - - holder = JSObject::Cast(holder)->GetJSHClass()->GetPrototype(); - if (!holder.IsHeapObject()) { - if (UNLIKELY(!JSObject::Cast(receiver)->IsExtensible())) { - if (mayThrow) { - THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot add property in prevent extensions ", false); - } - return false; - } - - return JSObject::AddElementInternal(thread, JSHandle(thread, receiver), index, - JSHandle(thread, value), PropertyAttributes::Default()); - } - if (holder.IsJSProxy()) { - return JSProxy::SetProperty( - thread, JSHandle(thread, holder), JSHandle(thread, JSTaggedValue(index)), - JSHandle(thread, value), JSHandle(thread, receiver), mayThrow); - } - onPrototype = true; - } -} - -bool FastRuntimeStub::SetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, - JSTaggedValue value, bool mayThrow) -{ - INTERPRETER_TRACE(thread, SetPropertyByName); - // property - JSTaggedValue holder = receiver; - bool onPrototype = false; - - while (true) { - TaggedArray *properties = TaggedArray::Cast(JSObject::Cast(holder)->GetProperties().GetHeapObject()); - PropertyAttributes attr; - uint32_t indexOrEntry = 0; - JSTaggedValue val = FindOwnProperty(thread, JSObject::Cast(holder), properties, key, &attr, &indexOrEntry); - if (!val.IsHole()) { - if (!attr.IsAccessor()) { - if (UNLIKELY(onPrototype)) { - if (UNLIKELY(!JSObject::Cast(receiver)->IsExtensible() || !attr.IsWritable())) { - if (mayThrow) { - THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot add property in prevent extensions ", false); - } - return false; - } - [[maybe_unused]] EcmaHandleScope handleScope(thread); - ObjectOperator::FastAdd(thread, receiver, key, JSHandle(thread, value), - PropertyAttributes::Default()); - - return true; - } - - if (attr.IsWritable()) { - properties = TaggedArray::Cast(JSObject::Cast(receiver)->GetProperties().GetHeapObject()); - if (!properties->IsDictionaryMode()) { - Representation representation = - PropertyAttributes::UpdateRepresentation(attr.GetRepresentation(), value); - if (attr.GetRepresentation() != representation) { - attr.SetRepresentation(representation); - } - - JSObject::Cast(receiver)->GetJSHClass()->UpdatePropertyMetaData(thread, key, attr); - if (UNLIKELY(val.IsInternalAccessor())) { - [[maybe_unused]] EcmaHandleScope handleScope(thread); - AccessorData::Cast(val.GetHeapObject()) - ->CallInternalSet(thread, JSHandle(thread, receiver), - JSHandle(thread, value), mayThrow); - RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); - return true; - } - - if (attr.IsInlinedProps()) { - JSObject::Cast(receiver)->SetPropertyInlinedProps(thread, indexOrEntry, value); - } else { - properties->Set(thread, indexOrEntry, value); - } - return true; - } - - if (receiver.IsJSGlobalObject()) { - [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle dictHandle(thread, properties); - // globalobj have no internal accessor - GlobalDictionary::InvalidatePropertyBox(thread, dictHandle, indexOrEntry, attr); - return true; - } - - if (UNLIKELY(val.IsInternalAccessor())) { - [[maybe_unused]] EcmaHandleScope handleScope(thread); - AccessorData::Cast(val.GetHeapObject()) - ->CallInternalSet(thread, JSHandle(thread, receiver), - JSHandle(thread, value), mayThrow); - RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); - return true; - } - - NameDictionary::Cast(properties)->UpdateValueAndAttributes(thread, indexOrEntry, value, attr); - return true; - } - - if (mayThrow) { - THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot set readonly property", false); - } - return false; - } - - // Accessor - [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle objHandle(thread, receiver); - JSHandle valueHandle(thread, value); - AccessorData *access = AccessorData::Cast(val.GetHeapObject()); - return JSObject::CallSetter(thread, *access, objHandle, valueHandle, mayThrow); - } - - if (holder.IsTypedArray()) { - [[maybe_unused]] EcmaHandleScope handleScope(thread); - return JSTypedArray::SetProperty(thread, JSHandle(thread, holder), - JSTypedArray::ToPropKey(thread, JSHandle(thread, key)), - JSHandle(thread, value), - JSHandle(thread, receiver), mayThrow); - } - - holder = JSObject::Cast(holder)->GetJSHClass()->GetPrototype(); - if (!holder.IsHeapObject()) { - if (UNLIKELY(!JSObject::Cast(receiver)->IsExtensible())) { - if (mayThrow) { - THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot add property in prevent extensions ", false); - } - return false; - } - [[maybe_unused]] EcmaHandleScope handleScope(thread); - ObjectOperator::FastAdd(thread, receiver, key, JSHandle(thread, value), - PropertyAttributes::Default()); - - return true; - } - if (holder.IsJSProxy()) { - [[maybe_unused]] EcmaHandleScope handleScope(thread); - return JSProxy::SetProperty(thread, JSHandle(thread, holder), JSHandle(thread, key), - JSHandle(thread, value), - JSHandle(thread, receiver), mayThrow); - } - onPrototype = true; - } -} - -bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, - JSTaggedValue value, bool mayThrow) -{ - INTERPRETER_TRACE(thread, SetGlobalOwnProperty); - uint32_t index = 0; - if (JSTaggedValue::ToElementIndex(key, &index)) { - return SetElement(thread, receiver, index, value, mayThrow); - } - - JSObject *obj = JSObject::Cast(receiver); - GlobalDictionary *dict = GlobalDictionary::Cast(obj->GetProperties().GetTaggedObject()); - PropertyAttributes attr = PropertyAttributes::Default(); - if (UNLIKELY(dict->GetLength() == 0)) { - JSHandle keyHandle(thread, key); - JSHandle valHandle(thread, value); - JSHandle objHandle(thread, obj); - JSHandle dictHandle(GlobalDictionary::Create(thread)); - - // Add PropertyBox to global dictionary - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle boxHandle = factory->NewPropertyBox(valHandle); - boxHandle->SetValue(thread, valHandle.GetTaggedValue()); - PropertyBoxType boxType = valHandle->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT; - attr.SetBoxType(boxType); - - JSHandle properties = - GlobalDictionary::PutIfAbsent(thread, dictHandle, keyHandle, JSHandle(boxHandle), attr); - objHandle->SetProperties(thread, properties); - return true; - } - - int entry = dict->FindEntry(key); - if (entry != -1) { - attr = dict->GetAttributes(entry); - JSTaggedValue val = dict->GetValue(entry); - if (!attr.IsAccessor()) { - if (attr.IsWritable()) { - // globalobj have no internal accessor - JSHandle dictHandle(thread, dict); - GlobalDictionary::InvalidatePropertyBox(thread, dictHandle, entry, attr); - return true; - } - } - - // Accessor - JSTaggedValue setter = AccessorData::Cast(val.GetHeapObject())->GetSetter(); - if (setter.IsUndefined()) { - if (mayThrow) { - THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot set property when setter is undefined", false); - } - return false; - } - - JSHandle objHandle(thread, receiver); - JSHandle setFunc(thread, setter); - JSHandle undefined = thread->GlobalConstants()->GetHandledUndefined(); - EcmaRuntimeCallInfo info = EcmaInterpreter::NewRuntimeCallInfo(thread, setFunc, objHandle, undefined, 1); - info.SetCallArg(value); - JSFunction::Call(&info); - // 10. ReturnIfAbrupt(setterResult). - RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); - return true; - } - - JSHandle keyHandle(thread, key); - JSHandle valHandle(thread, value); - JSHandle objHandle(thread, obj); - JSHandle dictHandle(thread, dict); - - // Add PropertyBox to global dictionary - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle boxHandle = factory->NewPropertyBox(keyHandle); - boxHandle->SetValue(thread, valHandle.GetTaggedValue()); - PropertyBoxType boxType = valHandle->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT; - attr.SetBoxType(boxType); - - JSHandle properties = - GlobalDictionary::PutIfAbsent(thread, dictHandle, keyHandle, JSHandle(boxHandle), attr); - objHandle->SetProperties(thread, properties); - return true; -} - -// set property that is not accessor and is writable -void FastRuntimeStub::SetOwnPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, - JSTaggedValue value) -{ - INTERPRETER_TRACE(thread, SetOwnPropertyByName); - TaggedArray *properties = TaggedArray::Cast(JSObject::Cast(receiver)->GetProperties().GetHeapObject()); - PropertyAttributes attr; - uint32_t indexOrEntry; - JSTaggedValue val = FindOwnProperty(thread, JSObject::Cast(receiver), properties, key, &attr, &indexOrEntry); - if (!val.IsHole()) { - ASSERT(!attr.IsAccessor() && attr.IsWritable()); - if (!properties->IsDictionaryMode()) { - Representation representation = PropertyAttributes::UpdateRepresentation(attr.GetRepresentation(), value); - if (attr.GetRepresentation() != representation) { - attr.SetRepresentation(representation); - } - - JSObject::Cast(receiver)->GetJSHClass()->UpdatePropertyMetaData(thread, key, attr); - - if (attr.IsInlinedProps()) { - JSObject::Cast(receiver)->SetPropertyInlinedProps(thread, indexOrEntry, value); - } else { - properties->Set(thread, indexOrEntry, value); - } - return; - } - - NameDictionary::Cast(properties)->UpdateValueAndAttributes(thread, indexOrEntry, value, attr); - return; - } - [[maybe_unused]] EcmaHandleScope handleScope(thread); - - ObjectOperator::FastAdd(thread, receiver, key, JSHandle(thread, value), - PropertyAttributes::Default()); -} - -// set element that is not accessor and is writable -bool FastRuntimeStub::SetOwnElement(JSThread *thread, JSTaggedValue receiver, uint32_t index, JSTaggedValue value) -{ - INTERPRETER_TRACE(thread, SetOwnElement); - PropertyAttributes attr; - uint32_t indexOrEntry; - TaggedArray *elements = TaggedArray::Cast(JSObject::Cast(receiver)->GetElements().GetHeapObject()); - bool isDict = elements->IsDictionaryMode(); - [[maybe_unused]] JSTaggedValue val = FindOwnElement(elements, index, isDict, &attr, &indexOrEntry); - if (!val.IsHole()) { - ASSERT(!attr.IsAccessor() && attr.IsWritable()); - if (!isDict) { - elements->Set(thread, indexOrEntry, value); - JSObject::Cast(receiver)->GetJSHClass()->UpdateRepresentation(value); - return true; - } - NumberDictionary::Cast(elements)->UpdateValueAndAttributes(thread, indexOrEntry, value, attr); - return true; - } - - return JSObject::AddElementInternal(thread, JSHandle(thread, receiver), index, - JSHandle(thread, value), PropertyAttributes::Default()); -} - -bool FastRuntimeStub::FastSetProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, JSTaggedValue value, - bool mayThrow) -{ - INTERPRETER_TRACE(thread, FastSetProperty); - if (receiver.IsJSObject() && !receiver.IsTypedArray() && (key.IsStringOrSymbol())) { - uint32_t index = 0; - if (UNLIKELY(JSTaggedValue::ToElementIndex(key, &index))) { - if (!FastRuntimeStub::IsSpecialIndexedObjForSet(receiver)) { - return FastRuntimeStub::SetElement(thread, receiver, index, value, true); - } - return JSTaggedValue::SetProperty(thread, JSHandle(thread, receiver), - JSHandle(thread, key), - JSHandle(thread, value), mayThrow); - } - if (key.IsString()) { - key = JSTaggedValue(thread->GetEcmaVM()->GetFactory()->InternString(JSHandle(thread, key))); - } - return FastRuntimeStub::SetPropertyByName(thread, receiver, key, value, mayThrow); - } - return JSTaggedValue::SetProperty(thread, JSHandle(thread, receiver), - JSHandle(thread, key), JSHandle(thread, value), - mayThrow); -} - -JSTaggedValue FastRuntimeStub::FastGetProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key) -{ - INTERPRETER_TRACE(thread, FastGetProperty); - JSTaggedValue result = JSTaggedValue::Hole(); - if (receiver.IsJSObject() && !receiver.IsTypedArray() && (key.IsStringOrSymbol())) { - uint32_t index = 0; - if (UNLIKELY(JSTaggedValue::ToElementIndex(key, &index))) { - if (FastRuntimeStub::IsSpecialIndexedObjForSet(receiver)) { - result = JSTaggedValue::Hole(); - } else { - result = FastRuntimeStub::GetElement(receiver, index); - } - } else { - if (key.IsString()) { - key = JSTaggedValue( - thread->GetEcmaVM()->GetFactory()->InternString(JSHandle(thread, key))); - } - result = FastRuntimeStub::GetPropertyByName(thread, receiver, key); - } - } - if (!result.IsHole()) { - if (UNLIKELY(result.IsAccessor())) { - return JSObject::CallGetter(thread, AccessorData::Cast(result.GetHeapObject()), - JSHandle(thread, receiver)); - } - return result; - } - return JSTaggedValue::GetProperty(thread, JSHandle(thread, receiver), - JSHandle(thread, key)) - .GetValue() - .GetTaggedValue(); -} - -JSTaggedValue FastRuntimeStub::FindOwnProperty(JSThread *thread, JSObject *obj, TaggedArray *properties, - JSTaggedValue key, PropertyAttributes *attr, uint32_t *indexOrEntry) -{ - INTERPRETER_TRACE(thread, FindOwnProperty); - if (!properties->IsDictionaryMode()) { - JSHClass *cls = obj->GetJSHClass(); - JSTaggedValue attrs = cls->GetLayout(); - if (!attrs.IsNull()) { - LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetHeapObject()); - uint32_t propNumber = cls->NumberOfProps(); - int entry = layoutInfo->FindElementWithCache(thread, cls, key, propNumber); - if (entry != -1) { - *attr = layoutInfo->GetAttr(entry); - ASSERT(entry == static_cast(attr->GetOffset())); - *indexOrEntry = entry; - if (attr->IsInlinedProps()) { - return obj->GetPropertyInlinedProps(entry); - } - *indexOrEntry -= cls->GetInlinedProperties(); - return properties->Get(*indexOrEntry); - } - } - return JSTaggedValue::Hole(); // properties == empty properties will return here. - } - - if (obj->IsJSGlobalObject()) { - GlobalDictionary *dict = GlobalDictionary::Cast(properties); - int entry = dict->FindEntry(key); - if (entry != -1) { - *indexOrEntry = entry; - *attr = dict->GetAttributes(entry); - return dict->GetValue(entry); - } - return JSTaggedValue::Hole(); - } - - NameDictionary *dict = NameDictionary::Cast(properties); - int entry = dict->FindEntry(key); - if (entry != -1) { - *indexOrEntry = entry; - *attr = dict->GetAttributes(entry); - return dict->GetValue(entry); - } - - return JSTaggedValue::Hole(); -} - -JSTaggedValue FastRuntimeStub::FindOwnElement(TaggedArray *elements, uint32_t index, bool isDict, - PropertyAttributes *attr, uint32_t *indexOrEntry) -{ - if (!isDict) { - if (elements->GetLength() <= index) { - return JSTaggedValue::Hole(); - } - - JSTaggedValue value = elements->Get(index); - if (!value.IsHole()) { - *attr = PropertyAttributes::Default(); - *indexOrEntry = index; - return value; - } - } else { - NumberDictionary *dict = NumberDictionary::Cast(elements); - int entry = dict->FindEntry(JSTaggedValue(static_cast(index))); - if (entry != -1) { - *indexOrEntry = entry; - *attr = dict->GetAttributes(entry); - return dict->GetValue(entry); - } - } - return JSTaggedValue::Hole(); -} - -JSTaggedValue FastRuntimeStub::FindOwnProperty(JSThread *thread, JSObject *obj, JSTaggedValue key) -{ - INTERPRETER_TRACE(thread, FindOwnProperty); - TaggedArray *array = TaggedArray::Cast(obj->GetProperties().GetHeapObject()); - if (!array->IsDictionaryMode()) { - JSHClass *cls = obj->GetJSHClass(); - JSTaggedValue attrs = cls->GetLayout(); - if (!attrs.IsNull()) { - LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetHeapObject()); - uint32_t propsNumber = cls->NumberOfProps(); - int entry = layoutInfo->FindElementWithCache(thread, cls, key, propsNumber); - if (entry != -1) { - PropertyAttributes attr(layoutInfo->GetAttr(entry)); - ASSERT(static_cast(attr.GetOffset()) == entry); - return attr.IsInlinedProps() ? obj->GetPropertyInlinedProps(entry) - : array->Get(static_cast(entry) - cls->GetInlinedProperties()); - } - } - return JSTaggedValue::Hole(); // array == empty array will return here. - } - - if (obj->IsJSGlobalObject()) { - GlobalDictionary *dict = GlobalDictionary::Cast(array); - int entry = dict->FindEntry(key); - if (entry != -1) { - return dict->GetValue(entry); - } - return JSTaggedValue::Hole(); - } - - NameDictionary *dict = NameDictionary::Cast(array); - int entry = dict->FindEntry(key); - if (entry != -1) { - return dict->GetValue(entry); - } - - return JSTaggedValue::Hole(); -} - -JSTaggedValue FastRuntimeStub::FindOwnElement(JSObject *obj, uint32_t index) -{ - TaggedArray *elements = TaggedArray::Cast(JSObject::Cast(obj)->GetElements().GetHeapObject()); - - if (!elements->IsDictionaryMode()) { - if (elements->GetLength() <= index) { - return JSTaggedValue::Hole(); - } - - JSTaggedValue value = elements->Get(index); - if (!value.IsHole()) { - return value; - } - } else { - NumberDictionary *dict = NumberDictionary::Cast(elements); - int entry = dict->FindEntry(JSTaggedValue(static_cast(index))); - if (entry != -1) { - return dict->GetValue(entry); - } - } - return JSTaggedValue::Hole(); -} - -JSTaggedValue FastRuntimeStub::HasOwnProperty(JSThread *thread, JSObject *obj, JSTaggedValue key) -{ - INTERPRETER_TRACE(thread, HasOwnProperty); - uint32_t index = 0; - if (UNLIKELY(JSTaggedValue::ToElementIndex(key, &index))) { - return FastRuntimeStub::FindOwnElement(obj, index); - } - - return FastRuntimeStub::FindOwnProperty(thread, obj, key); -} - JSTaggedValue FastRuntimeStub::GetContainerProperty(JSThread *thread, JSTaggedValue receiver, uint32_t index, JSType jsType) { @@ -1487,23 +882,6 @@ JSTaggedValue FastRuntimeStub::NewThisObject(JSThread *thread, JSTaggedValue cto return obj.GetTaggedValue(); } -JSTaggedValue FastRuntimeStub::NewThisObject(JSThread *thread, JSTaggedValue ctor, JSTaggedValue newTarget, - AsmInterpretedFrame *state) -{ - [[maybe_unused]] EcmaHandleScope handleScope(thread); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - - JSHandle ctorHandle(thread, ctor); - JSHandle newTargetHandle(thread, newTarget); - JSHandle obj = factory->NewJSObjectByConstructor(ctorHandle, newTargetHandle); - RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception()); - - state->function = ctorHandle.GetTaggedValue(); - state->env = ctorHandle->GetLexicalEnv(); - - return obj.GetTaggedValue(); -} - bool FastRuntimeStub::TryStringOrSymbolToIndex(JSTaggedValue key, uint32_t *output) { if (key.IsSymbol()) { diff --git a/ecmascript/interpreter/fast_runtime_stub.h b/ecmascript/interpreter/fast_runtime_stub.h index 1d8a4b3dd0de60bae407d8de7e5e01fc11a99dc6..879a0d235a997ab6145bb13dee014ca449221ead 100644 --- a/ecmascript/interpreter/fast_runtime_stub.h +++ b/ecmascript/interpreter/fast_runtime_stub.h @@ -26,9 +26,6 @@ class PropertyAttributes; class FastRuntimeStub { public: - /* -------------- Common API Begin, Don't change those interface!!! ----------------- */ - static inline JSTaggedValue FastAdd(JSTaggedValue left, JSTaggedValue right); - static inline JSTaggedValue FastSub(JSTaggedValue left, JSTaggedValue right); static inline JSTaggedValue FastMul(JSTaggedValue left, JSTaggedValue right); static inline JSTaggedValue FastDiv(JSTaggedValue left, JSTaggedValue right); static inline JSTaggedValue FastMod(JSTaggedValue left, JSTaggedValue right); @@ -37,38 +34,6 @@ public: static inline bool FastStrictEqual(JSTaggedValue left, JSTaggedValue right); static inline JSTaggedValue NewLexicalEnvDyn(JSThread *thread, ObjectFactory *factory, uint16_t numVars); static inline JSTaggedValue GetGlobalOwnProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); - /* -------------- Special API For Multi-Language VM Begin ----------------- */ - static inline bool IsSpecialIndexedObjForGet(JSTaggedValue obj); - static inline bool IsSpecialIndexedObjForSet(JSTaggedValue obj); - static inline JSTaggedValue GetElement(JSTaggedValue receiver, uint32_t index); - static inline JSTaggedValue GetElementWithArray(JSTaggedValue receiver, uint32_t index); - static inline bool SetElement(JSThread *thread, JSTaggedValue receiver, uint32_t index, JSTaggedValue value, - bool mayThrow); - static inline bool SetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, - JSTaggedValue value, bool mayThrow); - static inline bool SetGlobalOwnProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, - JSTaggedValue value, bool mayThrow); - - // set property that is not accessor and is writable - static inline void SetOwnPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, - JSTaggedValue value); - // set element that is not accessor and is writable - static inline bool SetOwnElement(JSThread *thread, JSTaggedValue receiver, uint32_t index, JSTaggedValue value); - static inline bool FastSetProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, JSTaggedValue value, - bool mayThrow); - static inline JSTaggedValue FastGetProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); - static inline JSTaggedValue FindOwnProperty(JSThread *thread, JSObject *obj, TaggedArray *properties, - JSTaggedValue key, PropertyAttributes *attr, uint32_t *indexOrEntry); - static inline JSTaggedValue FindOwnElement(TaggedArray *elements, uint32_t index, bool isDict, - PropertyAttributes *attr, uint32_t *indexOrEntry); - static inline JSTaggedValue FindOwnProperty(JSThread *thread, JSObject *obj, JSTaggedValue key); - - static inline JSTaggedValue FindOwnElement(JSObject *obj, uint32_t index); - - static inline JSTaggedValue HasOwnProperty(JSThread *thread, JSObject *obj, JSTaggedValue key); - /* -------------- Special API For Multi-Language VM End ----------------- */ - /* -------------- Common API End, Don't change those interface!!! ----------------- */ - template static inline JSTaggedValue GetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); template @@ -100,8 +65,6 @@ public: static inline JSTaggedValue NewThisObject(JSThread *thread, JSTaggedValue ctor, JSTaggedValue newTarget, InterpretedFrame* state); - static inline JSTaggedValue NewThisObject(JSThread *thread, JSTaggedValue ctor, JSTaggedValue newTarget, - AsmInterpretedFrame* state); private: friend class ICRuntimeStub; diff --git a/ecmascript/interpreter/interpreter-inl.h b/ecmascript/interpreter/interpreter-inl.h index fb70ca6dade7922b851fac1861ed64c152b4ebb5..60e436928a9a6c5ce3ddd503fe7c3fc12ce1d105 100644 --- a/ecmascript/interpreter/interpreter-inl.h +++ b/ecmascript/interpreter/interpreter-inl.h @@ -3843,7 +3843,7 @@ bool EcmaInterpreter::UpdateHotnessCounter(JSThread* thread, JSTaggedType *sp, J // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto thisFunc = state->function; auto res = SlowRuntimeStub::NotifyInlineCache( - thread, JSFunction::Cast(thisFunc.GetHeapObject()), method); + thread, JSFunction::Cast(thisFunc.GetTaggedObject()), method); state->profileTypeInfo = res; method->SetHotnessCounter(EcmaInterpreter::METHOD_HOTNESS_THRESHOLD); return true; diff --git a/ecmascript/interpreter/slow_runtime_stub.h b/ecmascript/interpreter/slow_runtime_stub.h index 1b7380c8ae0fd3eb063eeed6b574eb0a1e456a8d..93efa8c815387dc38343d10fbb38306455b6760e 100644 --- a/ecmascript/interpreter/slow_runtime_stub.h +++ b/ecmascript/interpreter/slow_runtime_stub.h @@ -26,7 +26,6 @@ class JSArray; class SlowRuntimeStub { public: - /* -------------- Common API Begin, Don't change those interface!!! ----------------- */ static JSTaggedValue CallSpreadDyn(JSThread *thread, JSTaggedValue func, JSTaggedValue obj, JSTaggedValue array); static JSTaggedValue NegDyn(JSThread *thread, JSTaggedValue value); static JSTaggedValue AsyncFunctionEnter(JSThread *thread); @@ -161,7 +160,6 @@ public: static JSTaggedValue GetModuleNamespace(JSThread *thread, JSTaggedValue localName); static JSTaggedValue LdBigInt(JSThread *thread, JSTaggedValue numberBigInt); static JSTaggedValue ThrowTypeError(JSThread *thread, const char *message); - /* -------------- Common API End, Don't change those interface!!! ----------------- */ private: static JSTaggedValue ThrowSyntaxError(JSThread *thread, const char *message); diff --git a/ecmascript/jobs/micro_job_queue.h b/ecmascript/jobs/micro_job_queue.h index d675f6c7d4f6db970e5d7d7d7de55525d2bc24bf..76ba9f7a40158afb940194d8900166cf74327001 100644 --- a/ecmascript/jobs/micro_job_queue.h +++ b/ecmascript/jobs/micro_job_queue.h @@ -33,7 +33,7 @@ enum class QueueType : uint8_t { class MicroJobQueue final : public Record { public: - static MicroJobQueue *Cast(ObjectHeader *object) + static MicroJobQueue *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsMicroJobQueue()); return static_cast(object); diff --git a/ecmascript/jobs/pending_job.h b/ecmascript/jobs/pending_job.h index 78dadfeb605ca243dba5b74428e2bc62ab8d6118..3940e46a02e287ac5f6f23ede0ac244f32e8ea37 100644 --- a/ecmascript/jobs/pending_job.h +++ b/ecmascript/jobs/pending_job.h @@ -29,7 +29,7 @@ namespace panda::ecmascript::job { class PendingJob final : public Record { public: - static PendingJob *Cast(ObjectHeader *object) + static PendingJob *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsPendingJob()); return static_cast(object); diff --git a/ecmascript/jobs/tests/micro_job_queue_test.cpp b/ecmascript/jobs/tests/micro_job_queue_test.cpp index c4ec66aeabf6f43c762ff9e633c35c7147c821e9..a12a67fc23a45eeef310a0699eb4fc9ff181a9b8 100644 --- a/ecmascript/jobs/tests/micro_job_queue_test.cpp +++ b/ecmascript/jobs/tests/micro_job_queue_test.cpp @@ -62,7 +62,7 @@ public: HWTEST_F_L0(MicroJobQueueTest, GetJobQueue) { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - array_size_t capacity = 4; + uint32_t capacity = 4; JSHandle handleValue(thread, JSTaggedValue(123)); JSHandle handlePromiseQueue = factory->NewTaggedQueue(capacity); diff --git a/ecmascript/js_api_arraylist.h b/ecmascript/js_api_arraylist.h index 25610621298b0a54a6d5191dc06ab02a5b974974..8a5005b3f0bc8bcfbac833d2732b18198eca2fb8 100644 --- a/ecmascript/js_api_arraylist.h +++ b/ecmascript/js_api_arraylist.h @@ -27,7 +27,7 @@ namespace panda::ecmascript { class JSAPIArrayList : public JSObject { public: static constexpr uint32_t DEFAULT_CAPACITY_LENGTH = 10; - static JSAPIArrayList *Cast(ObjectHeader *object) + static JSAPIArrayList *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPIArrayList()); return static_cast(object); diff --git a/ecmascript/js_api_arraylist_iterator.h b/ecmascript/js_api_arraylist_iterator.h index 377ff00c27b16976d87bafcfe5dfd93053f7dc5d..90c5d62b6014639ab7e7037845cdaf981e78fdec 100644 --- a/ecmascript/js_api_arraylist_iterator.h +++ b/ecmascript/js_api_arraylist_iterator.h @@ -26,7 +26,7 @@ namespace panda::ecmascript { * */ class JSAPIArrayListIterator : public JSObject { public: - static JSAPIArrayListIterator *Cast(ObjectHeader *obj) + static JSAPIArrayListIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPIArrayListIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_deque.h b/ecmascript/js_api_deque.h index ed56b1bea011a6e6e55847a23dab23dd444c4e6b..ace225d8b88b3e222c95932132c8d312bcddeeaa 100644 --- a/ecmascript/js_api_deque.h +++ b/ecmascript/js_api_deque.h @@ -23,7 +23,7 @@ namespace panda::ecmascript { class JSAPIDeque : public JSObject { public: static constexpr int DEFAULT_CAPACITY_LENGTH = 8; - static JSAPIDeque *Cast(ObjectHeader *object) + static JSAPIDeque *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPIDeque()); return static_cast(object); diff --git a/ecmascript/js_api_deque_iterator.cpp b/ecmascript/js_api_deque_iterator.cpp index ab77f9179a70312be0324c4a4106ec981b3c581a..a4a6f0ffe28d66c69d62d4eef10571806bda7c76 100644 --- a/ecmascript/js_api_deque_iterator.cpp +++ b/ecmascript/js_api_deque_iterator.cpp @@ -44,7 +44,7 @@ JSTaggedValue JSAPIDequeIterator::Next(EcmaRuntimeCallInfo *argv) uint32_t index = iter->GetNextIndex(); JSHandle elements(thread, deque->GetElements()); - array_size_t capacity = elements->GetLength(); + uint32_t capacity = elements->GetLength(); uint32_t first = deque->GetFirst(); uint32_t last = deque->GetLast(); if (index == last) { diff --git a/ecmascript/js_api_deque_iterator.h b/ecmascript/js_api_deque_iterator.h index eee3639184c3e2f3ca9fd3bfd4221e6b7c07163f..43249062f912c61e818cc3bb2d054c2950876a65 100644 --- a/ecmascript/js_api_deque_iterator.h +++ b/ecmascript/js_api_deque_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSAPIDequeIterator : public JSObject { public: - static JSAPIDequeIterator *Cast(ObjectHeader *obj) + static JSAPIDequeIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPIDequeIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_linked_list.h b/ecmascript/js_api_linked_list.h index c317f5f18e0a28d615d6be3b9ec904007baaeeab..3ce6e9b3b514066af658c3e74a6f3e3624d78453 100644 --- a/ecmascript/js_api_linked_list.h +++ b/ecmascript/js_api_linked_list.h @@ -24,7 +24,7 @@ namespace panda::ecmascript { class JSAPILinkedList : public JSObject { public: static constexpr int DEFAULT_CAPACITY_LENGTH = 10; - static JSAPILinkedList *Cast(ObjectHeader *object) + static JSAPILinkedList *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPILinkedList()); return static_cast(object); diff --git a/ecmascript/js_api_linked_list_iterator.h b/ecmascript/js_api_linked_list_iterator.h index ae3fddd12e8b5a22fd3e6421be48d85654d214ed..000ad4cd43bdc2c5d834dd4dd19422ec9515ab60 100644 --- a/ecmascript/js_api_linked_list_iterator.h +++ b/ecmascript/js_api_linked_list_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSAPILinkedListIterator : public JSObject { public: - static JSAPILinkedListIterator *Cast(ObjectHeader *obj) + static JSAPILinkedListIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPILinkedListIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_list.h b/ecmascript/js_api_list.h index 6655f17e49bccff21ebe413f5071ac59c2bacdff..51ddb767887a341e48382aa5495ba1f8e29a4d63 100644 --- a/ecmascript/js_api_list.h +++ b/ecmascript/js_api_list.h @@ -24,7 +24,7 @@ namespace panda::ecmascript { class JSAPIList : public JSObject { public: static constexpr int DEFAULT_CAPACITY_LENGTH = 10; - static JSAPIList *Cast(ObjectHeader *object) + static JSAPIList *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPIList()); return static_cast(object); diff --git a/ecmascript/js_api_list_iterator.h b/ecmascript/js_api_list_iterator.h index 82bbe56377c5ddfa4d1bb6b04eca6d5b7a213c6d..1884285ae0ffa6a8c9c70c2822dfd3d350f30e0a 100644 --- a/ecmascript/js_api_list_iterator.h +++ b/ecmascript/js_api_list_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSAPIListIterator : public JSObject { public: - static JSAPIListIterator *Cast(ObjectHeader *obj) + static JSAPIListIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPIListIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_plain_array.h b/ecmascript/js_api_plain_array.h index 89f1ee48b44192205ef042749c6034afdcecde85..8f06d66b68bd9d65d285b030bd4db9fe979f4029 100644 --- a/ecmascript/js_api_plain_array.h +++ b/ecmascript/js_api_plain_array.h @@ -23,7 +23,7 @@ namespace panda::ecmascript { class JSAPIPlainArray : public JSObject { public: static constexpr int DEFAULT_CAPACITY_LENGTH = 8; - static JSAPIPlainArray *Cast(ObjectHeader *object) + static JSAPIPlainArray *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPIPlainArray()); return static_cast(object); diff --git a/ecmascript/js_api_plain_array_iterator.h b/ecmascript/js_api_plain_array_iterator.h index 413813bf50a5fcfc553e71cd6868e7cfeb99af8e..b2a6217d59cb4105392dbad839fe7930da0e74fd 100644 --- a/ecmascript/js_api_plain_array_iterator.h +++ b/ecmascript/js_api_plain_array_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSAPIPlainArrayIterator : public JSObject { public: - static JSAPIPlainArrayIterator *Cast(ObjectHeader *obj) + static JSAPIPlainArrayIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPIPlainArrayIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_queue.h b/ecmascript/js_api_queue.h index 0df8f3c35d061fa23c99b272346c6e83916028ce..fe46a13187247b2314affbd2e207dbf6d504cdb7 100644 --- a/ecmascript/js_api_queue.h +++ b/ecmascript/js_api_queue.h @@ -23,7 +23,7 @@ namespace panda::ecmascript { class JSAPIQueue : public JSObject { public: static constexpr int DEFAULT_CAPACITY_LENGTH = 8; - static JSAPIQueue *Cast(ObjectHeader *object) + static JSAPIQueue *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPIQueue()); return static_cast(object); diff --git a/ecmascript/js_api_queue_iterator.h b/ecmascript/js_api_queue_iterator.h index 470dd451060e6bbf4b5968c131c30054f9e9b23b..f105926a31989f393b805ca194c164a6b0c3412f 100644 --- a/ecmascript/js_api_queue_iterator.h +++ b/ecmascript/js_api_queue_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSAPIQueueIterator : public JSObject { public: - static JSAPIQueueIterator *Cast(ObjectHeader *obj) + static JSAPIQueueIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPIQueueIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_stack.h b/ecmascript/js_api_stack.h index 74a92c70d8f8caad17240d6b058456ef948bfada..66a0f0c78a44f9f6092e2aacaf006b7e68359c34 100644 --- a/ecmascript/js_api_stack.h +++ b/ecmascript/js_api_stack.h @@ -23,7 +23,7 @@ namespace panda::ecmascript { class JSAPIStack : public JSObject { public: static constexpr int DEFAULT_CAPACITY_LENGTH = 10; - static JSAPIStack *Cast(ObjectHeader *object) + static JSAPIStack *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPIStack()); return static_cast(object); diff --git a/ecmascript/js_api_stack_iterator.h b/ecmascript/js_api_stack_iterator.h index 2aa68e87565f0cb241302afb107e642cb166d6a4..8faa44cf13409989d62445e560b7aec31317ed85 100644 --- a/ecmascript/js_api_stack_iterator.h +++ b/ecmascript/js_api_stack_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSAPIStackIterator : public JSObject { public: - static JSAPIStackIterator *Cast(ObjectHeader *obj) + static JSAPIStackIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPIStackIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_tree_map.h b/ecmascript/js_api_tree_map.h index 2e948deb0b30fad7524a476f30498010e685eb23..dcab7bb1bb39b7320952bca41cad600763870440 100644 --- a/ecmascript/js_api_tree_map.h +++ b/ecmascript/js_api_tree_map.h @@ -26,7 +26,7 @@ namespace panda::ecmascript { * */ class JSAPITreeMap : public JSObject { public: - static JSAPITreeMap *Cast(ObjectHeader *object) + static JSAPITreeMap *Cast(TaggedObject *object) { return static_cast(object); } diff --git a/ecmascript/js_api_tree_map_iterator.h b/ecmascript/js_api_tree_map_iterator.h index dc950c50c01d9937350367af5e2c1be32717f187..6addee7e77c8de9b2c58bf725b92be37d394a150 100644 --- a/ecmascript/js_api_tree_map_iterator.h +++ b/ecmascript/js_api_tree_map_iterator.h @@ -26,7 +26,7 @@ namespace panda::ecmascript { * */ class JSAPITreeMapIterator : public JSObject { public: - static JSAPITreeMapIterator *Cast(ObjectHeader *obj) + static JSAPITreeMapIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPITreeMapIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_tree_set.h b/ecmascript/js_api_tree_set.h index 83d5e3653fcca872eb37502d2af864dc7b3123a8..807c66ffff537c66a13c8fd8afb30b1220d1dff0 100644 --- a/ecmascript/js_api_tree_set.h +++ b/ecmascript/js_api_tree_set.h @@ -26,7 +26,7 @@ namespace panda::ecmascript { * */ class JSAPITreeSet : public JSObject { public: - static JSAPITreeSet *Cast(ObjectHeader *object) + static JSAPITreeSet *Cast(TaggedObject *object) { return static_cast(object); } diff --git a/ecmascript/js_api_tree_set_iterator.h b/ecmascript/js_api_tree_set_iterator.h index ed25ee7cba7f7017d489b38f807a1ffb0696b5c4..d0487a82be257613f563540e4f09e4d4105fcc86 100644 --- a/ecmascript/js_api_tree_set_iterator.h +++ b/ecmascript/js_api_tree_set_iterator.h @@ -26,7 +26,7 @@ namespace panda::ecmascript { * */ class JSAPITreeSetIterator : public JSObject { public: - static JSAPITreeSetIterator *Cast(ObjectHeader *obj) + static JSAPITreeSetIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPITreeSetIterator()); return static_cast(obj); diff --git a/ecmascript/js_api_vector.h b/ecmascript/js_api_vector.h index ce19d96fc5eb5fe635bb9a2715c55ed761e14d16..41bc290659d467efa42699378225b702d59d4564 100644 --- a/ecmascript/js_api_vector.h +++ b/ecmascript/js_api_vector.h @@ -23,7 +23,7 @@ namespace panda::ecmascript { class JSAPIVector : public JSObject { public: static constexpr int32_t DEFAULT_CAPACITY_LENGTH = 10; - static JSAPIVector *Cast(ObjectHeader *object) + static JSAPIVector *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAPIVector()); return static_cast(object); diff --git a/ecmascript/js_api_vector_iterator.h b/ecmascript/js_api_vector_iterator.h index 253b8ef9e3f73486bdc1a193b1428f25699d4a3a..c63ff066a394395b49241bcb1ea5ae7a9c64468f 100644 --- a/ecmascript/js_api_vector_iterator.h +++ b/ecmascript/js_api_vector_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSAPIVectorIterator : public JSObject { public: - static JSAPIVectorIterator *Cast(ObjectHeader *obj) + static JSAPIVectorIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSAPIVectorIterator()); return static_cast(obj); diff --git a/ecmascript/js_async_function.h b/ecmascript/js_async_function.h index 7e94d15bb9e174ee9e2855cb105f619d9707e314..74d9a8976a8c84a0a23ec9b992ac90874a934d6a 100644 --- a/ecmascript/js_async_function.h +++ b/ecmascript/js_async_function.h @@ -43,7 +43,7 @@ public: class JSAsyncFunction : public JSFunction { public: - static JSAsyncFunction *Cast(ObjectHeader *object) + static JSAsyncFunction *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSAsyncFunction()); return static_cast(object); diff --git a/ecmascript/js_finalization_registry.h b/ecmascript/js_finalization_registry.h index df9b7d13279fa1e44b9626ceda858cdc4c729c21..541ad6b629e32be0584c249f4858fc8b9f4ecf22 100644 --- a/ecmascript/js_finalization_registry.h +++ b/ecmascript/js_finalization_registry.h @@ -49,7 +49,7 @@ public: class CellRecordVector : public WeakVector { public: - static CellRecordVector *Cast(ObjectHeader *object) + static CellRecordVector *Cast(TaggedObject *object) { return static_cast(object); } diff --git a/ecmascript/js_function.cpp b/ecmascript/js_function.cpp index 82e7a581f7885ea4b46139c8fd856de748dc4db3..9e4925f7c8889168d5c790632acbb74a15fe3c27 100644 --- a/ecmascript/js_function.cpp +++ b/ecmascript/js_function.cpp @@ -510,7 +510,7 @@ void JSFunction::SetFunctionNameNoPrefix(JSThread *thread, JSFunction *func, JST GetHandledRightSquareBracketString()); concatName = factory->ConcatFromString( leftBrackets, - JSHandle(thread, JSSymbol::Cast(nameBegin->GetHeapObject())->GetDescription())); + JSHandle(thread, JSSymbol::Cast(nameBegin->GetTaggedObject())->GetDescription())); concatName = factory->ConcatFromString(concatName, rightBrackets); nameHandle.Update(concatName.GetTaggedValue()); } diff --git a/ecmascript/js_function.h b/ecmascript/js_function.h index 83d81f9d9eea18c0ed004909d95decf562a29561..ca66315b8bd8500298afc8f39c0aebf56d4b714c 100644 --- a/ecmascript/js_function.h +++ b/ecmascript/js_function.h @@ -58,7 +58,6 @@ public: static constexpr int PROTOTYPE_INLINE_PROPERTY_INDEX = 2; static constexpr int CLASS_PROTOTYPE_INLINE_PROPERTY_INDEX = 1; - /* -------------- Common API Begin, Don't change those interface!!! ----------------- */ CAST_CHECK(JSFunction, IsJSFunction); static void InitializeJSFunction(JSThread *thread, const JSHandle &env, const JSHandle &func, @@ -191,7 +190,6 @@ public: GetClass()->SetClassConstructor(flag); } - /* -------------- Common API End, Don't change those interface!!! ----------------- */ static void InitializeJSFunction(JSThread *thread, const JSHandle &func, FunctionKind kind = FunctionKind::NORMAL_FUNCTION, bool strict = true); static JSHClass *GetOrCreateInitialJSHClass(JSThread *thread, const JSHandle &fun); diff --git a/ecmascript/js_global_object.h b/ecmascript/js_global_object.h index 7fdbb07a1dafca5424149ddf8d08828a35ead044..bd9a3a288f40e7e0c4c43fc6e1bde2eabd4bf512 100644 --- a/ecmascript/js_global_object.h +++ b/ecmascript/js_global_object.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSGlobalObject : public JSObject { public: - static JSGlobalObject *Cast(ObjectHeader *object) + static JSGlobalObject *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsECMAObject()); return static_cast(object); diff --git a/ecmascript/js_handle.h b/ecmascript/js_handle.h index 86506c349492690801504f1f8212cdf8037b1e2a..a463e4dcb82a4fe64130d51f55e566d07ee42cc8 100644 --- a/ecmascript/js_handle.h +++ b/ecmascript/js_handle.h @@ -85,11 +85,6 @@ public: address_ = EcmaHandleScope::NewHandle(const_cast(thread), value.GetRawData()); } - explicit JSHandle(const JSThread *thread, const ObjectHeader *value) - { - address_ = EcmaHandleScope::NewHandle(const_cast(thread), JSTaggedValue(value).GetRawData()); - } - explicit JSHandle(const JSThread *thread, const TaggedObject *value) { address_ = EcmaHandleScope::NewHandle(const_cast(thread), JSTaggedValue(value).GetRawData()); diff --git a/ecmascript/js_intl.h b/ecmascript/js_intl.h index 2b1de0b626ea6eb68b226dcdf6a3800ba5f96eae..7ae82587d0a8083184e901455a236e444cef2ccc 100644 --- a/ecmascript/js_intl.h +++ b/ecmascript/js_intl.h @@ -21,7 +21,7 @@ namespace panda::ecmascript { class JSIntl : public JSObject { public: - static JSIntl *Cast(ObjectHeader *object) + static JSIntl *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSIntl()); return static_cast(object); diff --git a/ecmascript/js_locale.h b/ecmascript/js_locale.h index 58da78739f1aab69efc0e80b1b725403ca191f99..2ce3266f0beb644c86b014133fe6aa6cdb423972 100644 --- a/ecmascript/js_locale.h +++ b/ecmascript/js_locale.h @@ -150,7 +150,7 @@ public: std::string extension; }; - static JSLocale *Cast(ObjectHeader *object) + static JSLocale *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSLocale()); return static_cast(object); diff --git a/ecmascript/js_map_iterator.h b/ecmascript/js_map_iterator.h index 8a11bb6e3a8b5ad32bce27c57108ce1f345cdefa..9e39ee68ad7b582a2581911f0991aac14fb9d64b 100644 --- a/ecmascript/js_map_iterator.h +++ b/ecmascript/js_map_iterator.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSMapIterator : public JSObject { public: - static JSMapIterator *Cast(ObjectHeader *obj) + static JSMapIterator *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsJSMapIterator()); return static_cast(obj); diff --git a/ecmascript/js_native_pointer.h b/ecmascript/js_native_pointer.h index 7f71413d9252b7ba9f1d1cc2438d2aca65155be7..a842bcb431cb7e74aa4453f5acd50452ade264ee 100644 --- a/ecmascript/js_native_pointer.h +++ b/ecmascript/js_native_pointer.h @@ -25,7 +25,7 @@ using DeleteEntryPoint = void (*)(void *, void *); // Used for the requirement of ACE that wants to associated a registered C++ resource with a JSObject. class JSNativePointer : public TaggedObject { public: - static JSNativePointer *Cast(ObjectHeader *object) + static JSNativePointer *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSNativePointer()); return reinterpret_cast(object); diff --git a/ecmascript/js_object.cpp b/ecmascript/js_object.cpp index 62c6ddb671cec5d991e474e75e75972e2b09b7bd..3ec86077f4e7b2f2c13cb3de8712d2032f009f00 100644 --- a/ecmascript/js_object.cpp +++ b/ecmascript/js_object.cpp @@ -1156,16 +1156,16 @@ bool JSObject::CreateMethodProperty(JSThread *thread, const JSHandle & JSHandle JSObject::GetMethod(JSThread *thread, const JSHandle &obj, const JSHandle &key) { - JSTaggedValue func = FastRuntimeStub::FastGetProperty(thread, obj.GetTaggedValue(), key.GetTaggedValue()); - if (func.IsUndefined() || func.IsNull()) { + JSHandle func = GetProperty(thread, obj, key).GetValue(); + RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread); + if (func->IsUndefined() || func->IsNull()) { return JSHandle(thread, JSTaggedValue::Undefined()); } - JSHandle result(thread, func); - if (!result->IsCallable()) { - THROW_TYPE_ERROR_AND_RETURN(thread, "obj is not Callable", result); + if (!func->IsCallable()) { + THROW_TYPE_ERROR_AND_RETURN(thread, "obj is not Callable", func); } - return result; + return func; } // 7.3.14 SetIntegrityLevel (O, level) @@ -1866,7 +1866,7 @@ void ECMAObject::SetHash(int32_t hash) if (value.IsHeapObject()) { JSThread *thread = this->GetJSThread(); ASSERT(value.IsTaggedArray()); - TaggedArray *array = TaggedArray::Cast(value.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(value.GetTaggedObject()); array->Set(thread, 0, JSTaggedValue(hash)); } else { Barriers::SetDynPrimitive(this, HASH_OFFSET, JSTaggedValue(hash).GetRawData()); @@ -1878,7 +1878,7 @@ int32_t ECMAObject::GetHash() const JSTaggedType hashField = Barriers::GetDynValue(this, HASH_OFFSET); JSTaggedValue value(hashField); if (value.IsHeapObject()) { - TaggedArray *array = TaggedArray::Cast(value.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(value.GetTaggedObject()); return array->Get(0).GetInt(); } JSThread *thread = this->GetJSThread(); @@ -1931,7 +1931,7 @@ int32_t ECMAObject::GetNativePointerFieldCount() const JSTaggedType hashField = Barriers::GetDynValue(this, HASH_OFFSET); JSTaggedValue value(hashField); if (value.IsHeapObject()) { - TaggedArray *array = TaggedArray::Cast(value.GetHeapObject()); + TaggedArray *array = TaggedArray::Cast(value.GetTaggedObject()); len = static_cast(array->GetLength() - 1); } return len; diff --git a/ecmascript/js_realm.h b/ecmascript/js_realm.h index 6d201190f26a908f086f31bc6504c83f8be0a415..56273c2e9663747e45abb83f714c73a196dbddc4 100644 --- a/ecmascript/js_realm.h +++ b/ecmascript/js_realm.h @@ -21,7 +21,7 @@ namespace panda::ecmascript { class JSRealm : public JSObject { public: - static JSRealm *Cast(ObjectHeader *object) + static JSRealm *Cast(TaggedObject *object) { return static_cast(object); } diff --git a/ecmascript/js_regexp_iterator.cpp b/ecmascript/js_regexp_iterator.cpp index 69d6a6c3f00c8229c05a1fb0ccd62624e6c606f0..a988d56a7cd86de44bc51a03b8bf48a2fcf1f104 100644 --- a/ecmascript/js_regexp_iterator.cpp +++ b/ecmascript/js_regexp_iterator.cpp @@ -90,9 +90,9 @@ JSTaggedValue JSRegExpIterator::Next(EcmaRuntimeCallInfo *argv) RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); uint32_t nextIndex = BuiltinsRegExp::AdvanceStringIndex(inputStr, thisIndex.ToUint32(), fullUnicode); - FastRuntimeStub::FastSetProperty(thread, regexHandle.GetTaggedValue(), - lastIndexString.GetTaggedValue(), - JSTaggedValue(nextIndex), true); + FastRuntimeStub::FastSetPropertyByValue(thread, regexHandle.GetTaggedValue(), + lastIndexString.GetTaggedValue(), + JSTaggedValue(nextIndex)); } // iii. Return ! CreateIterResultObject(match, false). return JSIterator::CreateIterResultObject(thread, matchHandle, false).GetTaggedValue(); diff --git a/ecmascript/js_serializer.cpp b/ecmascript/js_serializer.cpp index c7f01e9b2ea78ab85677ba61d099ec732a6a849c..44439984473c805111bb05427e556578589b2f5d 100644 --- a/ecmascript/js_serializer.cpp +++ b/ecmascript/js_serializer.cpp @@ -1639,7 +1639,7 @@ bool Serializer::FinalizeTransfer(JSThread *thread, const JSHandle element = JSArray::FastGetPropertyByValue(thread, transfer, idx); - JSArrayBuffer::Cast(element->GetHeapObject())->Detach(thread); + JSArrayBuffer::Cast(element->GetTaggedObject())->Detach(thread); } return true; } diff --git a/ecmascript/js_tagged_value.h b/ecmascript/js_tagged_value.h index f013b8393a0593b192c106e0348840faf1b22a45..6d8b0fbe820ddfdc62f921ad44af86e4aa0460e8 100644 --- a/ecmascript/js_tagged_value.h +++ b/ecmascript/js_tagged_value.h @@ -113,7 +113,7 @@ public: static constexpr size_t DOUBLE_ENCODE_OFFSET_BIT = 48; static constexpr JSTaggedType DOUBLE_ENCODE_OFFSET = 1ULL << DOUBLE_ENCODE_OFFSET_BIT; - static JSTaggedValue Cast(ObjectHeader *object) + static JSTaggedValue Cast(TaggedObject *object) { return JSTaggedValue(object); } @@ -156,8 +156,6 @@ public: value_ = ReinterpretDoubleToTaggedType(v) + DOUBLE_ENCODE_OFFSET; } - explicit JSTaggedValue(const ObjectHeader *v) : value_(static_cast(ToUintPtr(v))) {} - explicit JSTaggedValue(const TaggedObject *v) : value_(static_cast(ToUintPtr(v))) {} explicit JSTaggedValue(int64_t v) @@ -245,24 +243,17 @@ public: return value_; } - inline ObjectHeader *GetHeapObject() const - { - ASSERT_PRINT(IsHeapObject() && ((value_ & TAG_WEAK_FILTER) == 0U), - "can not convert JSTaggedValue to HeapObject :" << std::hex << value_); - return reinterpret_cast(value_); - } - // This function returns the heap object pointer which may have the weak tag. - inline ObjectHeader *GetRawHeapObject() const + inline TaggedObject *GetRawHeapObject() const { ASSERT_PRINT(IsHeapObject(), "can not convert JSTaggedValue to HeapObject :" << std::hex << value_); - return reinterpret_cast(value_); + return reinterpret_cast(value_); } - inline ObjectHeader *GetWeakReferent() const + inline TaggedObject *GetWeakReferent() const { ASSERT_PRINT(IsWeak(), "can not convert JSTaggedValue to WeakRef HeapObject :" << std::hex << value_); - return reinterpret_cast(value_ & (~TAG_WEAK_MASK)); + return reinterpret_cast(value_ & (~TAG_WEAK_MASK)); } static inline JSTaggedType Cast(void *ptr) @@ -364,7 +355,9 @@ public: inline TaggedObject *GetTaggedObject() const { - return reinterpret_cast(GetHeapObject()); + ASSERT_PRINT(IsHeapObject() && ((value_ & TAG_WEAK_FILTER) == 0U), + "can not convert JSTaggedValue to HeapObject :" << std::hex << value_); + return reinterpret_cast(value_); } inline TaggedObject *GetRawTaggedObject() const diff --git a/ecmascript/js_thread.h b/ecmascript/js_thread.h index 295a175e87b91c1684608e0d45669777d16e3c80..fcc066889509a4acabe6cafb2255a88276477378 100644 --- a/ecmascript/js_thread.h +++ b/ecmascript/js_thread.h @@ -27,6 +27,7 @@ #include "ecmascript/frames.h" #include "ecmascript/global_env_constants.h" #include "ecmascript/mem/visitor.h" +#include "libpandabase/os/thread.h" namespace panda::ecmascript { class EcmaHandleScope; diff --git a/ecmascript/js_typed_array.h b/ecmascript/js_typed_array.h index b422d096efa5a5d705753b7e861c9f3b2cc96657..fbfc27b76db47cde39a6308792a673263ba64d67 100644 --- a/ecmascript/js_typed_array.h +++ b/ecmascript/js_typed_array.h @@ -24,7 +24,7 @@ namespace panda::ecmascript { enum class ContentType : uint8_t { None = 1, Number, BigInt }; class JSTypedArray : public JSObject { public: - static JSTypedArray *Cast(ObjectHeader *object) + static JSTypedArray *Cast(TaggedObject *object) { #if ECMASCRIPT_ENABLE_CAST_CHECK if (!(JSTaggedValue(object).IsTypedArray() || JSTaggedValue(object).IsJSTypedArray())) { diff --git a/ecmascript/js_vm/main.cpp b/ecmascript/js_vm/main.cpp index 5b33dd1e4e9b8a418302fac110a179b066d898b0..cc2638510c5fe76c1f7ba4e29ec6ba59d59df096 100644 --- a/ecmascript/js_vm/main.cpp +++ b/ecmascript/js_vm/main.cpp @@ -27,7 +27,6 @@ #include "ecmascript/mem/mem_controller.h" #include "ecmascript/napi/include/jsnapi.h" #include "generated/base_options.h" -#include "handle_scope.h" #include "libpandabase/os/native_stack.h" #include "libpandabase/utils/pandargs.h" #include "libpandabase/utils/span.h" diff --git a/ecmascript/js_weak_container.h b/ecmascript/js_weak_container.h index e7f276c78226d43f1d9263cd18e78627855254d0..3e32375944b9cf9c02514aef54f1c0ed326cbdcb 100644 --- a/ecmascript/js_weak_container.h +++ b/ecmascript/js_weak_container.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { class JSWeakMap : public JSObject { public: - static JSWeakMap *Cast(ObjectHeader *object) + static JSWeakMap *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSWeakMap()); return static_cast(object); @@ -48,7 +48,7 @@ public: class JSWeakSet : public JSObject { public: - static JSWeakSet *Cast(ObjectHeader *object) + static JSWeakSet *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSWeakSet()); return static_cast(object); diff --git a/ecmascript/js_weak_ref.h b/ecmascript/js_weak_ref.h index 493766c117121c26e53c2bc19964d0cca46ac737..16d87cf4eb87e93cf707468893f5e2acd792a801 100644 --- a/ecmascript/js_weak_ref.h +++ b/ecmascript/js_weak_ref.h @@ -21,7 +21,7 @@ namespace panda::ecmascript { class JSWeakRef : public JSObject { public: - static JSWeakRef *Cast(ObjectHeader *object) + static JSWeakRef *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsJSWeakRef()); return static_cast(object); diff --git a/ecmascript/jspandafile/accessor/module_data_accessor.cpp b/ecmascript/jspandafile/accessor/module_data_accessor.cpp index 01c15fd36f6118f148ac02530e4f793b50150762..0b551bdf1cbc7caaa79a6715a97e848359b2c486 100644 --- a/ecmascript/jspandafile/accessor/module_data_accessor.cpp +++ b/ecmascript/jspandafile/accessor/module_data_accessor.cpp @@ -14,7 +14,6 @@ */ #include "ecmascript/jspandafile/accessor/module_data_accessor.h" -#include "libpandafile/file_items.h" #include "libpandafile/helpers.h" namespace panda::ecmascript::jspandafile { diff --git a/ecmascript/jspandafile/program_object.h b/ecmascript/jspandafile/program_object.h index 4b8a79dc6a4207510ffd172e03c73d06f01e9b99..54f365d2473f57db3c869cfadef9e792aee3847a 100644 --- a/ecmascript/jspandafile/program_object.h +++ b/ecmascript/jspandafile/program_object.h @@ -37,7 +37,7 @@ public: class ConstantPool : public TaggedArray { public: - static ConstantPool *Cast(ObjectHeader *object) + static ConstantPool *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsTaggedArray()); return static_cast(object); diff --git a/ecmascript/layout_info.h b/ecmascript/layout_info.h index 8696cf39d5f6fc74491b97c10dda08e28e4274ff..635ca776bd10735c2e09c295b1d40bcd6b2d5220 100644 --- a/ecmascript/layout_info.h +++ b/ecmascript/layout_info.h @@ -33,7 +33,7 @@ public: static constexpr int NUMBER_OF_PROPERTIES_INDEX = 0; static constexpr int ELEMENTS_START_INDEX = 1; - inline static LayoutInfo *Cast(ObjectHeader *obj) + inline static LayoutInfo *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsTaggedArray()); return reinterpret_cast(obj); diff --git a/ecmascript/lexical_env.h b/ecmascript/lexical_env.h index 4aa0ff4b71617548228fdfc731b890ea8d6f2b65..57cbc3d8aeb354145b9a7503ea355208def1b858 100644 --- a/ecmascript/lexical_env.h +++ b/ecmascript/lexical_env.h @@ -25,7 +25,7 @@ public: static constexpr uint32_t SCOPE_INFO_INDEX = 1; static constexpr uint32_t RESERVED_ENV_LENGTH = 2; - static LexicalEnv *Cast(ObjectHeader *object) + static LexicalEnv *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsTaggedArray()); return static_cast(object); diff --git a/ecmascript/linked_hash_table.cpp b/ecmascript/linked_hash_table.cpp index 1c86cebf4130cc3bf00c226d5f63f575ad036929..87d8a9097a46f236497abb15b0e7574dbd39a4fb 100644 --- a/ecmascript/linked_hash_table.cpp +++ b/ecmascript/linked_hash_table.cpp @@ -273,20 +273,20 @@ int LinkedHash::Hash(JSTaggedValue key) key = JSTaggedValue(0); } if (key.IsSymbol()) { - auto symbolString = JSSymbol::Cast(key.GetHeapObject()); + auto symbolString = JSSymbol::Cast(key.GetTaggedObject()); return symbolString->GetHashField(); } if (key.IsString()) { - auto keyString = reinterpret_cast(key.GetHeapObject()); + auto keyString = reinterpret_cast(key.GetTaggedObject()); return keyString->GetHashcode(); } if (key.IsECMAObject()) { - int32_t hash = ECMAObject::Cast(key.GetHeapObject())->GetHash(); + int32_t hash = ECMAObject::Cast(key.GetTaggedObject())->GetHash(); if (hash == 0) { uint64_t keyValue = key.GetRawData(); hash = static_cast( GetHash32(reinterpret_cast(&keyValue), sizeof(keyValue) / sizeof(uint8_t))); - ECMAObject::Cast(key.GetHeapObject())->SetHash(hash); + ECMAObject::Cast(key.GetTaggedObject())->SetHash(hash); } return hash; } diff --git a/ecmascript/linked_hash_table.h b/ecmascript/linked_hash_table.h index 882bd806ff96c54a9f79dc799eee398ff3e5ab3f..32dea40ee524ae1bc64d9a9bfad6571fe944c2b5 100644 --- a/ecmascript/linked_hash_table.h +++ b/ecmascript/linked_hash_table.h @@ -302,7 +302,7 @@ public: class LinkedHashMap : public LinkedHashTable { public: - static LinkedHashMap *Cast(ObjectHeader *obj) + static LinkedHashMap *Cast(TaggedObject *obj) { return static_cast(obj); } @@ -342,7 +342,7 @@ public: class LinkedHashSet : public LinkedHashTable { public: - static LinkedHashSet *Cast(ObjectHeader *obj) + static LinkedHashSet *Cast(TaggedObject *obj) { return static_cast(obj); } diff --git a/ecmascript/mem/heap.cpp b/ecmascript/mem/heap.cpp index 7cf3dcf45850dfe9e487fcd45b1c5d809227567d..bb6d4c113a7ac583082a8dc32c5db969f6330140 100644 --- a/ecmascript/mem/heap.cpp +++ b/ecmascript/mem/heap.cpp @@ -597,10 +597,10 @@ void Heap::UpdateDerivedObjectInStack() " derived:" << derivedAddr << " old Value: " << *derivedAddr << std::endl; #endif // derived is always bigger than base - *derivedAddr = reinterpret_cast(base.GetHeapObject()) + (*derivedAddr - baseOldObject); + *derivedAddr = reinterpret_cast(base.GetTaggedObject()) + (*derivedAddr - baseOldObject); #ifndef NDEBUG LOG_ECMA(DEBUG) << std::hex << "fix base after:" << baseAddr << - " base New Value: " << base.GetHeapObject() << + " base New Value: " << base.GetTaggedObject() << " derived:" << derivedAddr << " New Value: " << *derivedAddr << std::endl; #endif } diff --git a/ecmascript/mem/machine_code.h b/ecmascript/mem/machine_code.h index ad4bf55eda9d7f2c8605a20828af22b880ba852b..58b3eb5bd645795ced09df56076a574ebace3a55 100644 --- a/ecmascript/mem/machine_code.h +++ b/ecmascript/mem/machine_code.h @@ -27,7 +27,7 @@ class MachineCode : public TaggedObject { public: NO_COPY_SEMANTIC(MachineCode); NO_MOVE_SEMANTIC(MachineCode); - static MachineCode *Cast(ObjectHeader *object) + static MachineCode *Cast(TaggedObject *object) { ASSERT(JSTaggedValue(object).IsMachineCodeObject()); return static_cast(object); diff --git a/ecmascript/mem/mem.h b/ecmascript/mem/mem.h index d10da9d629385d395dcee896f238e0b3da33b8bf..25c47b288fadbb8a97f8d3b367bff7279191a1fa 100644 --- a/ecmascript/mem/mem.h +++ b/ecmascript/mem/mem.h @@ -18,6 +18,10 @@ #include +#ifndef PANDA_TARGET_WINDOWS +#include +#endif + #include "ecmascript/ecma_param_configuration.h" #include "ecmascript/mem/tagged_object.h" #include "libpandabase/mem/mem.h" diff --git a/ecmascript/mem/mem_map_allocator.cpp b/ecmascript/mem/mem_map_allocator.cpp index a61173a7cd243c5169910e9843c39ef5ece8d319..adaaaee3fde60293088ef053c57e7adcf0a06990 100644 --- a/ecmascript/mem/mem_map_allocator.cpp +++ b/ecmascript/mem/mem_map_allocator.cpp @@ -14,8 +14,8 @@ */ #include "ecmascript/mem/mem_map_allocator.h" -#include "mem/runslots.h" #if defined(PANDA_TARGET_WINDOWS) +#include #include #elif defined(PANDA_TARGET_MACOS) #include "sys/sysctl.h" diff --git a/ecmascript/mem/mem_map_allocator.h b/ecmascript/mem/mem_map_allocator.h index 36dd9f18c6658465e5d645aa63ca5604bba2c0c5..3393c3b0e9b43f0b0dfab4da3407ef6dd39affa6 100644 --- a/ecmascript/mem/mem_map_allocator.h +++ b/ecmascript/mem/mem_map_allocator.h @@ -48,6 +48,9 @@ #undef STRICT #endif +#ifdef VOID +#undef VOID +#endif #endif namespace panda::ecmascript { diff --git a/ecmascript/mem/parallel_evacuator.cpp b/ecmascript/mem/parallel_evacuator.cpp index 3fc375e246c352a6f9ca90f9614d24331a51e941..8483e810f5712b5cb0d3b9f7ec24daa545419fb8 100644 --- a/ecmascript/mem/parallel_evacuator.cpp +++ b/ecmascript/mem/parallel_evacuator.cpp @@ -290,7 +290,7 @@ void ParallelEvacuator::UpdateRSet(Region *region) auto cb = [this](void *mem) -> bool { ObjectSlot slot(ToUintPtr(mem)); if (UpdateObjectSlot(slot)) { - Region *valueRegion = Region::ObjectAddressToRange(slot.GetTaggedObjectHeader()); + Region *valueRegion = Region::ObjectAddressToRange(slot.GetTaggedObject()); if (!valueRegion->InYoungSpace()) { return false; } diff --git a/ecmascript/mem/slots.h b/ecmascript/mem/slots.h index faa359edc02b72a5cff95ad0a47552c3287a74c2..ec2755a1910964b3954808e336b6ff511a5d522d 100644 --- a/ecmascript/mem/slots.h +++ b/ecmascript/mem/slots.h @@ -44,7 +44,7 @@ public: *reinterpret_cast(slotAddress_) = value; } - TaggedObject *GetTaggedObjectHeader() const + TaggedObject *GetTaggedObject() const { return reinterpret_cast(GetTaggedType()); } diff --git a/ecmascript/mem/tagged_object-inl.h b/ecmascript/mem/tagged_object-inl.h index 7cef1cf6c2b807e12c0f465c53dc6c649539f3e9..af5ca884b9174e71f0430d408014d57a1af199a5 100644 --- a/ecmascript/mem/tagged_object-inl.h +++ b/ecmascript/mem/tagged_object-inl.h @@ -27,7 +27,7 @@ namespace panda::ecmascript { inline void TaggedObject::SetClassWithoutBarrier(JSHClass *hclass) { - *reinterpret_cast(ToUintPtr(this)) = reinterpret_cast(hclass); + class_ = reinterpret_cast(hclass); } inline void TaggedObject::SetClass(JSHClass *hclass) @@ -42,7 +42,7 @@ inline void TaggedObject::SetClass(JSHandle hclass) inline JSHClass *TaggedObject::GetClass() const { - return reinterpret_cast(*reinterpret_cast(ToUintPtr(this))); + return reinterpret_cast(class_); } inline void TaggedObject::SynchronizedSetClass(JSHClass *hclass) diff --git a/ecmascript/mem/tagged_object.h b/ecmascript/mem/tagged_object.h index 2fcc35079e486b7b31ee37786deabd0bf97b1790..89c901875461153dc5c2fdb313591168afa36b12 100644 --- a/ecmascript/mem/tagged_object.h +++ b/ecmascript/mem/tagged_object.h @@ -17,7 +17,6 @@ #define ECMASCRIPT_TAGGED_OBJECT_HEADER_H #include "ecmascript/mem/mark_word.h" -#include "include/object_header.h" namespace panda::ecmascript { class JSHClass; @@ -25,9 +24,9 @@ template class JSHandle; class JSThread; -class TaggedObject : public ObjectHeader { +class TaggedObject { public: - static TaggedObject *Cast(ObjectHeader *header) + static TaggedObject *Cast(TaggedObject *header) { return static_cast(header); } @@ -47,6 +46,9 @@ public: } JSThread* GetJSThread() const; + +private: + MarkWordType class_; }; static_assert(TaggedObject::TaggedObjectSize() == sizeof(MarkWordType)); } // namespace panda::ecmascript diff --git a/ecmascript/module/js_module_manager.cpp b/ecmascript/module/js_module_manager.cpp index ec22610a71d70c42174d67fd5db41b2ccb2742bb..d5b899716688f5f1e7861b17577911b79da6f2d0 100644 --- a/ecmascript/module/js_module_manager.cpp +++ b/ecmascript/module/js_module_manager.cpp @@ -45,7 +45,7 @@ JSTaggedValue ModuleManager::GetModuleValueInner(JSTaggedValue key) if (currentModule.IsUndefined()) { LOG_ECMA(FATAL) << "GetModuleValueInner currentModule failed"; } - return SourceTextModule::Cast(currentModule.GetHeapObject())->GetModuleValue(vm_->GetJSThread(), key, false); + return SourceTextModule::Cast(currentModule.GetTaggedObject())->GetModuleValue(vm_->GetJSThread(), key, false); } JSTaggedValue ModuleManager::GetModuleValueOutter(JSTaggedValue key) @@ -55,7 +55,7 @@ JSTaggedValue ModuleManager::GetModuleValueOutter(JSTaggedValue key) if (currentModule.IsUndefined()) { LOG_ECMA(FATAL) << "GetModuleValueOutter currentModule failed"; } - JSTaggedValue moduleEnvironment = SourceTextModule::Cast(currentModule.GetHeapObject())->GetEnvironment(); + JSTaggedValue moduleEnvironment = SourceTextModule::Cast(currentModule.GetTaggedObject())->GetEnvironment(); ASSERT(!moduleEnvironment.IsUndefined()); JSTaggedValue resolvedBinding = LinkedHashMap::Cast(moduleEnvironment.GetTaggedObject())->Get(key); if (resolvedBinding.IsUndefined()) { @@ -65,13 +65,13 @@ JSTaggedValue ModuleManager::GetModuleValueOutter(JSTaggedValue key) ResolvedBinding *binding = ResolvedBinding::Cast(resolvedBinding.GetTaggedObject()); JSTaggedValue resolvedModule = binding->GetModule(); ASSERT(resolvedModule.IsSourceTextModule()); - SourceTextModule *module = SourceTextModule::Cast(resolvedModule.GetHeapObject()); + SourceTextModule *module = SourceTextModule::Cast(resolvedModule.GetTaggedObject()); if (module->GetTypes() == ModuleTypes::CJSMODULE) { JSHandle cjsModuleName(thread, module->GetEcmaModuleFilename()); return JSCjsModule::SearchFromModuleCache(thread, cjsModuleName).GetTaggedValue(); } - return SourceTextModule::Cast(resolvedModule.GetHeapObject())->GetModuleValue(thread, binding->GetBindingName(), - false); + return SourceTextModule::Cast(resolvedModule.GetTaggedObject())->GetModuleValue(thread, + binding->GetBindingName(), false); } void ModuleManager::StoreModuleValue(JSTaggedValue key, JSTaggedValue value) @@ -165,7 +165,7 @@ JSTaggedValue ModuleManager::GetModuleNamespace(JSTaggedValue localName) if (currentModule.IsUndefined()) { LOG_ECMA(FATAL) << "GetModuleNamespace currentModule failed"; } - JSTaggedValue moduleEnvironment = SourceTextModule::Cast(currentModule.GetHeapObject())->GetEnvironment(); + JSTaggedValue moduleEnvironment = SourceTextModule::Cast(currentModule.GetTaggedObject())->GetEnvironment(); ASSERT(!moduleEnvironment.IsUndefined()); JSTaggedValue moduleNamespace = LinkedHashMap::Cast(moduleEnvironment.GetTaggedObject())->Get(localName); if (moduleNamespace.IsUndefined()) { diff --git a/ecmascript/module/js_module_namespace.cpp b/ecmascript/module/js_module_namespace.cpp index 58d29c73a7582b5191af337db32d5d999c43074f..a3eb1485b42195aa764c2763a484af9d390e8a7a 100644 --- a/ecmascript/module/js_module_namespace.cpp +++ b/ecmascript/module/js_module_namespace.cpp @@ -92,7 +92,7 @@ OperationResult ModuleNamespace::GetProperty(JSThread *thread, const JSHandleGetModule(); // 9. Assert: targetModule is not undefined. ASSERT(!targetModule.IsUndefined()); - JSTaggedValue result = SourceTextModule::Cast(targetModule.GetHeapObject())-> + JSTaggedValue result = SourceTextModule::Cast(targetModule.GetTaggedObject())-> GetModuleValue(thread, resolvedBind->GetBindingName(), true); return OperationResult(thread, result, PropertyMetaData(true)); } @@ -238,7 +238,7 @@ bool ModuleNamespace::ValidateKeysAvailable(JSThread *thread, const JSHandleIsResolvedBinding()); JSTaggedValue targetModule = JSHandle::Cast(binding)->GetModule(); ASSERT(!targetModule.IsUndefined()); - JSTaggedValue dictionary = SourceTextModule::Cast(targetModule.GetHeapObject())->GetNameDictionary(); + JSTaggedValue dictionary = SourceTextModule::Cast(targetModule.GetTaggedObject())->GetNameDictionary(); if (dictionary.IsUndefined()) { THROW_REFERENCE_ERROR_AND_RETURN(thread, "module environment is undefined", false); } diff --git a/ecmascript/module/js_module_record.cpp b/ecmascript/module/js_module_record.cpp index 38910f0524000df7172adc5222774e55658155f5..da9f0b7a49f71294775921b026cccdf286b1ce80 100644 --- a/ecmascript/module/js_module_record.cpp +++ b/ecmascript/module/js_module_record.cpp @@ -38,7 +38,7 @@ int32_t ModuleRecord::Evaluate(JSThread *thread, const JSHandle & JSTaggedValue ModuleRecord::GetNamespace(JSTaggedValue module) { if (module.IsSourceTextModule()) { - return SourceTextModule::Cast(module.GetHeapObject())->GetNamespace(); + return SourceTextModule::Cast(module.GetTaggedObject())->GetNamespace(); } UNREACHABLE(); } @@ -46,7 +46,7 @@ JSTaggedValue ModuleRecord::GetNamespace(JSTaggedValue module) void ModuleRecord::SetNamespace(JSThread *thread, JSTaggedValue module, JSTaggedValue value) { if (module.IsSourceTextModule()) { - SourceTextModule::Cast(module.GetHeapObject())->SetNamespace(thread, value); + SourceTextModule::Cast(module.GetTaggedObject())->SetNamespace(thread, value); } else { UNREACHABLE(); } diff --git a/ecmascript/module/js_module_source_text.cpp b/ecmascript/module/js_module_source_text.cpp index fa5fc238e4aec59143380576db8dfdf348bd5c9d..658e6341f4f3714839ef8cf836fee3cd8cdd5bcb 100644 --- a/ecmascript/module/js_module_source_text.cpp +++ b/ecmascript/module/js_module_source_text.cpp @@ -54,7 +54,7 @@ CVector SourceTextModule::GetExportedNames(JSThread *thread, const // a. Assert: module provides the direct binding for this export. // b. Append e.[[ExportName]] to exportedNames. std::string exportName = - base::StringHelper::ToStdString(EcmaString::Cast(ee->GetExportName().GetHeapObject())); + base::StringHelper::ToStdString(EcmaString::Cast(ee->GetExportName().GetTaggedObject())); exportedNames.emplace_back(exportName); } } @@ -70,7 +70,7 @@ CVector SourceTextModule::GetExportedNames(JSThread *thread, const // a. Assert: module imports a specific binding for this export. // b. Append e.[[ExportName]] to exportedNames. std::string exportName = - base::StringHelper::ToStdString(EcmaString::Cast(ee->GetExportName().GetHeapObject())); + base::StringHelper::ToStdString(EcmaString::Cast(ee->GetExportName().GetTaggedObject())); exportedNames.emplace_back(exportName); } } @@ -112,10 +112,10 @@ JSHandle SourceTextModule::HostResolveImportedModule(JSThread const JSHandle &module, const JSHandle &moduleRequest) { - CString moduleFilename = ConvertToString(EcmaString::Cast(moduleRequest->GetHeapObject())); + CString moduleFilename = ConvertToString(EcmaString::Cast(moduleRequest->GetTaggedObject())); ASSERT(module->GetEcmaModuleFilename().IsHeapObject()); CString baseFilename = - ConvertToString(EcmaString::Cast(module->GetEcmaModuleFilename().GetHeapObject())); + ConvertToString(EcmaString::Cast(module->GetEcmaModuleFilename().GetTaggedObject())); int suffixEnd = static_cast(moduleFilename.find_last_of('.')); if (suffixEnd == -1) { RETURN_HANDLE_IF_ABRUPT_COMPLETION(SourceTextModule, thread); @@ -664,7 +664,7 @@ void SourceTextModule::ModuleExecution(JSThread *thread, const JSHandleGetEcmaModuleFilename(); ASSERT(moduleFileName.IsString()); - CString moduleFilenameStr = ConvertToString(EcmaString::Cast(moduleFileName.GetHeapObject())); + CString moduleFilenameStr = ConvertToString(EcmaString::Cast(moduleFileName.GetTaggedObject())); const JSPandaFile *jsPandaFile = JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, moduleFilenameStr, JSPandaFile::ENTRY_MAIN_FUNCTION); if (jsPandaFile == nullptr) { diff --git a/ecmascript/napi/jsnapi.cpp b/ecmascript/napi/jsnapi.cpp index 205a5417d8bbfc089becb52abacafd347c33dcbc..4d329d8294032c148ec9971428109c1754b11799 100644 --- a/ecmascript/napi/jsnapi.cpp +++ b/ecmascript/napi/jsnapi.cpp @@ -1889,31 +1889,31 @@ bool JSValueRef::IsJSPrimitiveRef() bool JSValueRef::IsJSPrimitiveNumber() { JSHandle obj = JSNApiHelper::ToJSHandle(this); - return JSPrimitiveRef::Cast(obj->GetHeapObject())->IsNumber(); + return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsNumber(); } bool JSValueRef::IsJSPrimitiveInt() { JSHandle obj = JSNApiHelper::ToJSHandle(this); - return JSPrimitiveRef::Cast(obj->GetHeapObject())->IsInt(); + return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsInt(); } bool JSValueRef::IsJSPrimitiveBoolean() { JSHandle obj = JSNApiHelper::ToJSHandle(this); - return JSPrimitiveRef::Cast(obj->GetHeapObject())->IsBoolean(); + return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsBoolean(); } bool JSValueRef::IsJSPrimitiveString() { JSHandle obj = JSNApiHelper::ToJSHandle(this); - return JSPrimitiveRef::Cast(obj->GetHeapObject())->IsString(); + return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsString(); } bool JSValueRef::IsJSPrimitiveSymbol() { JSHandle obj = JSNApiHelper::ToJSHandle(this); - return JSPrimitiveRef::Cast(obj->GetHeapObject())->IsSymbol(); + return JSPrimitiveRef::Cast(obj->GetTaggedObject())->IsSymbol(); } bool JSValueRef::IsGeneratorObject() diff --git a/ecmascript/object_factory.cpp b/ecmascript/object_factory.cpp index 9b7f14f64d065781fada66ce1634e40b0095ea6e..48a99e80c94e78c0b8b48d63685243eb3ea37647 100644 --- a/ecmascript/object_factory.cpp +++ b/ecmascript/object_factory.cpp @@ -2912,7 +2912,7 @@ JSHandle ObjectFactory::NewJSAPIArrayListIterator(const return iter; } -JSHandle ObjectFactory::NewJSAPIPlainArray(array_size_t capacity) +JSHandle ObjectFactory::NewJSAPIPlainArray(uint32_t capacity) { NewObjectHook(); JSHandle builtinObj(thread_, thread_->GlobalConstants()->GetPlainArrayFunction()); diff --git a/ecmascript/object_factory.h b/ecmascript/object_factory.h index 9cc5f185c29c71b88d0ca33f9f234fe784960b9c..3e577f9ef8ef3b2be0a18f4d915b2f4f50919c9e 100644 --- a/ecmascript/object_factory.h +++ b/ecmascript/object_factory.h @@ -447,7 +447,7 @@ public: JSHandle NewEcmaDynClass(uint32_t size, JSType type, const JSHandle &prototype); // It is used to provide iterators for non ECMA standard jsapi containers. - JSHandle NewJSAPIPlainArray(array_size_t capacity); + JSHandle NewJSAPIPlainArray(uint32_t capacity); JSHandle NewJSAPIPlainArrayIterator(const JSHandle &plainarray, IterationKind kind); JSHandle NewJSAPIArrayList(uint32_t capacity); diff --git a/ecmascript/object_operator.cpp b/ecmascript/object_operator.cpp index a4e3d6ae2954a359841b964a876677b1d2e18f4b..4434533be1f18b8640cfb2317786b2a12b2face3 100644 --- a/ecmascript/object_operator.cpp +++ b/ecmascript/object_operator.cpp @@ -392,7 +392,7 @@ void ObjectOperator::TransitionForAttributeChanged(const JSHandle &rec bool ObjectOperator::UpdateValueAndDetails(const JSHandle &receiver, const JSHandle &value, PropertyAttributes attr, bool attrChanged) { - bool isInternalAccessor = IsAccessorDescriptor() && AccessorData::Cast(GetValue().GetHeapObject())->IsInternal(); + bool isInternalAccessor = IsAccessorDescriptor() && AccessorData::Cast(GetValue().GetTaggedObject())->IsInternal(); if (attrChanged) { TransitionForAttributeChanged(receiver, attr); } @@ -423,7 +423,7 @@ bool ObjectOperator::UpdateDataValue(const JSHandle &receiver, const J } if (isInternalAccessor) { - auto accessor = AccessorData::Cast(GetValue().GetHeapObject()); + auto accessor = AccessorData::Cast(GetValue().GetTaggedObject()); if (accessor->HasSetter()) { return accessor->CallInternalSet(thread_, JSHandle(receiver), value, mayThrow); } @@ -471,7 +471,7 @@ bool ObjectOperator::WriteDataProperty(const JSHandle &receiver, const } if (IsAccessorDescriptor()) { - auto accessor = AccessorData::Cast(GetValue().GetHeapObject()); + auto accessor = AccessorData::Cast(GetValue().GetTaggedObject()); if (!accessor->IsInternal() || !accessor->HasSetter()) { attr.SetIsAccessor(false); attrChanged = true; diff --git a/ecmascript/require/js_cjs_exports.h b/ecmascript/require/js_cjs_exports.h index 524080ac22d6c3153a16fec2d8092128071dfed9..9724cd84650b0dde435e4b4b5b4a23a7edc1809d 100644 --- a/ecmascript/require/js_cjs_exports.h +++ b/ecmascript/require/js_cjs_exports.h @@ -24,11 +24,6 @@ class JSCjsExports final : public JSObject { public: CAST_CHECK(JSCjsExports, IsJSCjsExports); - inline static JSCjsExports *Cast(const TaggedObject *object) - { - return static_cast(const_cast(object)); - } - static constexpr size_t JS_CJS_EXPORTS_OFFSET = JSObject::SIZE; ACCESSORS(Exports, JS_CJS_EXPORTS_OFFSET, SIZE) diff --git a/ecmascript/require/js_cjs_module.cpp b/ecmascript/require/js_cjs_module.cpp index 7f5921758a3851d593b2a52e54778ac66826c425..400a31130927db5f1af389994ecaba6e3ff69197 100644 --- a/ecmascript/require/js_cjs_module.cpp +++ b/ecmascript/require/js_cjs_module.cpp @@ -145,8 +145,8 @@ JSHandle JSCjsModule::ResolveFilename(JSThread *thread, JSTaggedValu JSHandle nativeRequireName = ResolveFilenameFromNative(thread, dirname, request); return nativeRequireName; } - std::string modDirname = std::string(ConvertToString(EcmaString::Cast(dirname.GetHeapObject()))); - std::string modFile = std::string(ConvertToString(EcmaString::Cast(request.GetHeapObject()))); + std::string modDirname = std::string(ConvertToString(EcmaString::Cast(dirname.GetTaggedObject()))); + std::string modFile = std::string(ConvertToString(EcmaString::Cast(request.GetTaggedObject()))); std::string callbackRequireName = resolvePathCallback(modDirname, modFile); CString fullname = callbackRequireName.c_str(); return factory->NewFromUtf8(fullname); @@ -157,8 +157,8 @@ JSHandle JSCjsModule::ResolveFilenameFromNative(JSThread *thread, JS { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - CString dirnameStr = ConvertToString(EcmaString::Cast(dirname.GetHeapObject())); - CString requestStr = ConvertToString(EcmaString::Cast(request.GetHeapObject())); + CString dirnameStr = ConvertToString(EcmaString::Cast(dirname.GetTaggedObject())); + CString requestStr = ConvertToString(EcmaString::Cast(request.GetTaggedObject())); if (requestStr.find("./") == 0) { requestStr = requestStr.substr(2); // 2 : delete './' } diff --git a/ecmascript/require/js_cjs_module.h b/ecmascript/require/js_cjs_module.h index 739993eeded1d5af3d3d0d87bee06b81c3b8f8b6..3e9d667d219c49ebf361b85558f08d48f320cb50 100644 --- a/ecmascript/require/js_cjs_module.h +++ b/ecmascript/require/js_cjs_module.h @@ -27,11 +27,6 @@ class JSCjsModule final : public JSObject { public: CAST_CHECK(JSCjsModule, IsJSCjsModule); - inline static JSCjsModule *Cast(const TaggedObject *object) - { - return static_cast(const_cast(object)); - } - // Instantiate member static constexpr size_t JS_CJS_MODULE_OFFSET = JSObject::SIZE; ACCESSORS(Id, JS_CJS_MODULE_OFFSET, ID_OFFSET) diff --git a/ecmascript/require/js_cjs_module_cache.h b/ecmascript/require/js_cjs_module_cache.h index 882106212c7908479581894a5199a98914168d20..f1a894cf2c8b1fb93791bb940cdc6ea0b6c69794 100644 --- a/ecmascript/require/js_cjs_module_cache.h +++ b/ecmascript/require/js_cjs_module_cache.h @@ -28,8 +28,9 @@ class CjsModuleCache : public TaggedHashTable { public: using HashTable = TaggedHashTable; - static CjsModuleCache *Cast(ObjectHeader *object) + static CjsModuleCache *Cast(TaggedObject *object) { + ASSERT(JSTaggedValue(object).IsTaggedArray()); return reinterpret_cast(object); } diff --git a/ecmascript/require/js_cjs_require.h b/ecmascript/require/js_cjs_require.h index b03569cb2fe4c0c570d35bfaa497f65c85c70b76..02efcdae6ff891a6b91dd4a61f6f784b9cdca4d8 100644 --- a/ecmascript/require/js_cjs_require.h +++ b/ecmascript/require/js_cjs_require.h @@ -25,11 +25,6 @@ class JSCjsRequire final : public JSObject { public: CAST_CHECK(JSCjsRequire, IsJSCjsRequire); - inline static JSCjsRequire *Cast(const TaggedObject *object) - { - return static_cast(const_cast(object)); - } - // Instantiate member static constexpr size_t JS_CJS_REQUIRE_OFFSET = JSObject::SIZE; ACCESSORS(Cache, JS_CJS_REQUIRE_OFFSET, CACHE_OFFSET) diff --git a/ecmascript/runtime_call_id.h b/ecmascript/runtime_call_id.h index bff01d68627068f651dae0fa4d79a5f79043154d..28f0ba92eacf618d4dde425c8f3eca75174a8814 100644 --- a/ecmascript/runtime_call_id.h +++ b/ecmascript/runtime_call_id.h @@ -162,14 +162,6 @@ namespace panda::ecmascript { V(FastGetPropertyByValue) \ V(FastGetPropertyByIndex) \ V(NewLexicalEnvDyn) \ - V(SetElement) \ - V(SetGlobalOwnProperty) \ - V(SetOwnPropertyByName) \ - V(SetOwnElement) \ - V(FastSetProperty) \ - V(FastGetProperty) \ - V(FindOwnProperty) \ - V(HasOwnProperty) \ V(ExecuteNative) \ V(Execute) \ V(ToJSTaggedValueWithInt32) \ diff --git a/ecmascript/snapshot/mem/snapshot_env.h b/ecmascript/snapshot/mem/snapshot_env.h index 6c509fceace2a66898cc9dcfdad14d0ebbf7d7e1..b52e775f1e70d18dbbd9e753832ac1890bea6729 100644 --- a/ecmascript/snapshot/mem/snapshot_env.h +++ b/ecmascript/snapshot/mem/snapshot_env.h @@ -16,6 +16,8 @@ #ifndef ECMASCRIPT_SNAPSHOT_MEM_SNAPSHOT_ENV_H #define ECMASCRIPT_SNAPSHOT_MEM_SNAPSHOT_ENV_H +#include + #include "ecmascript/mem/object_xray.h" #include "ecmascript/mem/visitor.h" #include "libpandabase/macros.h" diff --git a/ecmascript/symbol_table.h b/ecmascript/symbol_table.h index 3f9b0eb2979ea088d00a1b6bbc0ce53b59fc5318..5681c4a91ea22067b5f5da9e22e7e3ac8b93cdc9 100644 --- a/ecmascript/symbol_table.h +++ b/ecmascript/symbol_table.h @@ -27,7 +27,7 @@ namespace panda::ecmascript { class SymbolTable : public TaggedHashTable { public: using HashTable = TaggedHashTable; - static SymbolTable *Cast(ObjectHeader *object) + static SymbolTable *Cast(TaggedObject *object) { return reinterpret_cast(object); } diff --git a/ecmascript/tagged_array.h b/ecmascript/tagged_array.h index c2d4a85ef0e2434e735fa0b678f62f1287d994f5..8a4f3f825346d691f19118233592cf41166c1e76 100644 --- a/ecmascript/tagged_array.h +++ b/ecmascript/tagged_array.h @@ -28,7 +28,7 @@ public: static constexpr uint32_t MAX_ARRAY_INDEX = std::numeric_limits::max(); static constexpr uint32_t MAX_END_UNUSED = 4; - inline static TaggedArray *Cast(ObjectHeader *obj) + inline static TaggedArray *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsTaggedArray()); return static_cast(obj); diff --git a/ecmascript/tagged_list.h b/ecmascript/tagged_list.h index e508a94fb39b4fd297723fbc7b579a5d8d199721..c1307f31955ec13a3718ed64f360255c19bba18e 100644 --- a/ecmascript/tagged_list.h +++ b/ecmascript/tagged_list.h @@ -113,7 +113,7 @@ public: class TaggedSingleList : public TaggedList { public: static const int ENTRY_SIZE = 2; - static TaggedSingleList *Cast(ObjectHeader *obj) + static TaggedSingleList *Cast(TaggedObject *obj) { return static_cast(obj); } @@ -152,7 +152,7 @@ public: class TaggedDoubleList : public TaggedList { public: static const int ENTRY_SIZE = 3; - static TaggedDoubleList *Cast(ObjectHeader *obj) + static TaggedDoubleList *Cast(TaggedObject *obj) { return static_cast(obj); } diff --git a/ecmascript/tagged_queue.h b/ecmascript/tagged_queue.h index f880bb517aab36e72b803556af38bb6372848a8d..e21f71309043986d1022e42ed976b145d26b7965 100644 --- a/ecmascript/tagged_queue.h +++ b/ecmascript/tagged_queue.h @@ -24,7 +24,7 @@ namespace panda::ecmascript { class TaggedQueue : public TaggedArray { public: - static TaggedQueue *Cast(ObjectHeader *object) + static TaggedQueue *Cast(TaggedObject *object) { return reinterpret_cast(object); } diff --git a/ecmascript/tagged_tree.h b/ecmascript/tagged_tree.h index 5c2722a1ec4591aeb993be4f7a1d34821a9db3f5..931eb5cf01d3ec15fd341ec5d51e5085895a2a91 100644 --- a/ecmascript/tagged_tree.h +++ b/ecmascript/tagged_tree.h @@ -453,7 +453,7 @@ protected: class TaggedTreeMap : public TaggedTree { public: using RBTree = TaggedTree; - static TaggedTreeMap *Cast(ObjectHeader *obj) + static TaggedTreeMap *Cast(TaggedObject *obj) { return static_cast(obj); } @@ -521,7 +521,7 @@ public: class TaggedTreeSet : public TaggedTree { public: using RBTree = TaggedTree; - static TaggedTreeSet *Cast(ObjectHeader *obj) + static TaggedTreeSet *Cast(TaggedObject *obj) { return static_cast(obj); } diff --git a/ecmascript/template_map.h b/ecmascript/template_map.h index c40ed4da1f4a503a407a0a5733e6b8fccb90df69..c0309bbbc5c73393aaaefcd584f939e48af8fedf 100644 --- a/ecmascript/template_map.h +++ b/ecmascript/template_map.h @@ -30,7 +30,7 @@ public: static inline int Hash(const JSTaggedValue &obj) { ASSERT(obj.IsJSArray()); - JSArray *array = JSArray::Cast(obj.GetHeapObject()); + JSArray *array = JSArray::Cast(obj.GetTaggedObject()); uint32_t len = array->GetArrayLength(); return len; } @@ -50,7 +50,7 @@ public: { return ENTRY_SIZE; } - static TemplateMap *Cast(ObjectHeader *object) + static TemplateMap *Cast(TaggedObject *object) { return reinterpret_cast(object); } diff --git a/ecmascript/tests/accessor_data_test.cpp b/ecmascript/tests/accessor_data_test.cpp index df8cfb90ae027a296c14ae6cc3bb562bd2914d34..555cff45e9d92984f1736809e456742389a4a5b4 100644 --- a/ecmascript/tests/accessor_data_test.cpp +++ b/ecmascript/tests/accessor_data_test.cpp @@ -51,7 +51,7 @@ public: /** * @tc.name: Cast - * @tc.desc: Convert an object of type ObjectHeader to type AccessorData object. + * @tc.desc: Convert an object of type TaggedObject to type AccessorData object. * @tc.type: FUNC * @tc.require: */ @@ -62,7 +62,7 @@ HWTEST_F_L0(AccessorDataTest, AccessorData_Cast) JSHandle accDynclassHandle = factory->NewEcmaDynClass(JSObject::SIZE, JSType::ACCESSOR_DATA, nullHandle); - ObjectHeader *accObject = factory->NewDynObject(accDynclassHandle); + TaggedObject *accObject = factory->NewDynObject(accDynclassHandle); AccessorData::Cast(accObject)->SetGetter(thread, JSTaggedValue::Undefined()); AccessorData::Cast(accObject)->SetSetter(thread, JSTaggedValue::Undefined()); EXPECT_TRUE(JSTaggedValue(accObject).IsAccessorData()); @@ -71,7 +71,7 @@ HWTEST_F_L0(AccessorDataTest, AccessorData_Cast) JSHandle internalAccDynClassHandle = factory->NewEcmaDynClass(JSObject::SIZE, JSType::INTERNAL_ACCESSOR, nullHandle); - ObjectHeader *internalAccObject = factory->NewDynObject(internalAccDynClassHandle); + TaggedObject *internalAccObject = factory->NewDynObject(internalAccDynClassHandle); EXPECT_TRUE(JSTaggedValue(internalAccObject).IsInternalAccessor()); AccessorData *internalAcc = AccessorData::Cast(internalAccObject); EXPECT_TRUE(JSTaggedValue(internalAcc).IsInternalAccessor()); @@ -96,7 +96,7 @@ HWTEST_F_L0(AccessorDataTest, IsInternal) JSHandle nullHandle(thread, JSTaggedValue::Null()); JSHandle accDynclass = factory->NewEcmaDynClass(JSObject::SIZE, JSType::ACCESSOR_DATA, nullHandle); - ObjectHeader *accObject = factory->NewDynObject(accDynclass); + TaggedObject *accObject = factory->NewDynObject(accDynclass); AccessorData *acc = AccessorData::Cast(accObject); acc->SetGetter(thread, JSTaggedValue::Undefined()); acc->SetSetter(thread, JSTaggedValue::Undefined()); @@ -104,7 +104,7 @@ HWTEST_F_L0(AccessorDataTest, IsInternal) JSHandle internalAccDynClass = factory->NewEcmaDynClass(JSObject::SIZE, JSType::INTERNAL_ACCESSOR, nullHandle); - ObjectHeader *internalAccObject = factory->NewDynObject(internalAccDynClass); + TaggedObject *internalAccObject = factory->NewDynObject(internalAccDynClass); AccessorData *internalAcc = AccessorData::Cast(internalAccObject); EXPECT_EQ(internalAcc->IsInternal(), true); } @@ -142,7 +142,7 @@ HWTEST_F_L0(AccessorDataTest, HasSetter) // 3.Create normal AccessorData object from dynamic class. JSHandle nullHandle(thread, JSTaggedValue::Null()); JSHandle accDynclass = factory->NewEcmaDynClass(JSObject::SIZE, JSType::ACCESSOR_DATA, nullHandle); - ObjectHeader *accObject = factory->NewDynObject(accDynclass); + TaggedObject *accObject = factory->NewDynObject(accDynclass); AccessorData *acc = AccessorData::Cast(accObject); acc->SetGetter(thread, JSTaggedValue::Undefined()); EXPECT_EQ(acc->HasSetter(), true); @@ -154,7 +154,7 @@ HWTEST_F_L0(AccessorDataTest, HasSetter) // 4.Create internal AccessorData object from dynamic class. JSHandle internalAccDynClass = factory->NewEcmaDynClass(JSObject::SIZE, JSType::INTERNAL_ACCESSOR, nullHandle); - ObjectHeader *internalAccObject = factory->NewDynObject(internalAccDynClass); + TaggedObject *internalAccObject = factory->NewDynObject(internalAccDynClass); AccessorData *internalAcc = AccessorData::Cast(internalAccObject); EXPECT_EQ(internalAcc->HasSetter(), true); internalAcc->SetSetter(thread, JSTaggedValue::Undefined()); @@ -208,7 +208,7 @@ HWTEST_F_L0(AccessorDataTest, CallInternalSet) /** * @tc.name: Cast - * @tc.desc: Convert an object of type ObjectHeader to type CompletionRecord object. + * @tc.desc: Convert an object of type TaggedObject to type CompletionRecord object. * @tc.type: FUNC * @tc.require: */ @@ -219,7 +219,7 @@ HWTEST_F_L0(AccessorDataTest, CompletionRecord_Cast) JSHandle comRecordDynclassHandle = factory->NewEcmaDynClass(JSObject::SIZE, JSType::COMPLETION_RECORD, nullHandle); - ObjectHeader *comRecordObject = factory->NewDynObject(comRecordDynclassHandle); + TaggedObject *comRecordObject = factory->NewDynObject(comRecordDynclassHandle); EXPECT_TRUE(JSTaggedValue(comRecordObject).IsCompletionRecord()); CompletionRecord *comRecord = CompletionRecord::Cast(comRecordObject); EXPECT_TRUE(JSTaggedValue(comRecord).IsCompletionRecord()); diff --git a/ecmascript/tests/concurrent_sweep_test.cpp b/ecmascript/tests/concurrent_sweep_test.cpp index fa404f1b098056236afe051b6cba830c1131bcc9..3f64f3dc702b3fa71a872536053618b160cbd7c3 100644 --- a/ecmascript/tests/concurrent_sweep_test.cpp +++ b/ecmascript/tests/concurrent_sweep_test.cpp @@ -58,6 +58,6 @@ TEST_F(ConcurrentSweepTest, ConcurrentSweep) } JSHandle test2(thread, EcmaString::CreateFromUtf8(utf8, 4, vm, true)); ASSERT_EQ(test1->GetLength(), 4U); - ASSERT_NE(test1.GetTaggedValue().GetHeapObject(), test2.GetTaggedValue().GetHeapObject()); + ASSERT_NE(test1.GetTaggedValue().GetTaggedObject(), test2.GetTaggedValue().GetTaggedObject()); } } // namespace panda::test diff --git a/ecmascript/tests/ecma_module_test.cpp b/ecmascript/tests/ecma_module_test.cpp index 104d99bf3f13de5c75af0bef0b5c0c3062139da4..57a8cabe13025a326c4a19b2d0c15e42621794ae 100644 --- a/ecmascript/tests/ecma_module_test.cpp +++ b/ecmascript/tests/ecma_module_test.cpp @@ -268,8 +268,8 @@ HWTEST_F_L0(EcmaModuleTest, ParseCjsModule) JSTaggedValue resolvedModule2 = binding2->GetModule(); JSTaggedValue resolvedModule1 = binding1->GetModule(); - SourceTextModule *module1 = SourceTextModule::Cast(resolvedModule1.GetHeapObject()); - SourceTextModule *module2 = SourceTextModule::Cast(resolvedModule2.GetHeapObject()); + SourceTextModule *module1 = SourceTextModule::Cast(resolvedModule1.GetTaggedObject()); + SourceTextModule *module2 = SourceTextModule::Cast(resolvedModule2.GetTaggedObject()); CString bindingName1 = ConvertToString(binding1->GetBindingName()); CString bindingName2 = ConvertToString(binding2->GetBindingName()); diff --git a/ecmascript/tests/js_api_arraylist_iterator_test.cpp b/ecmascript/tests/js_api_arraylist_iterator_test.cpp index 63c307cd544dd1a78744295d051be0d1e314eca8..77c29ed06b7a2a5ea222a0e21ca0f19448d5406b 100644 --- a/ecmascript/tests/js_api_arraylist_iterator_test.cpp +++ b/ecmascript/tests/js_api_arraylist_iterator_test.cpp @@ -25,7 +25,6 @@ using namespace panda; using namespace panda::ecmascript; -using namespace coretypes; namespace panda::test { class JSAPIArrayListIteratorTest : public testing::Test { diff --git a/ecmascript/tests/js_api_arraylist_test.cpp b/ecmascript/tests/js_api_arraylist_test.cpp index 4a7216f76f7f581103e7c009283e0a2585de7488..94eed3eccc09ee44beb5787ee33087665c0aee12 100644 --- a/ecmascript/tests/js_api_arraylist_test.cpp +++ b/ecmascript/tests/js_api_arraylist_test.cpp @@ -24,7 +24,6 @@ using namespace panda; using namespace panda::ecmascript; -using namespace coretypes; namespace panda::test { class JSAPIArrayListTest : public testing::Test { diff --git a/ecmascript/tests/js_typed_array_test.cpp b/ecmascript/tests/js_typed_array_test.cpp index 684b76c77c48a0d0c73ea14149e5394efde916bb..232e7e4e967f8e254f5279219b79fc7aaedc8784 100644 --- a/ecmascript/tests/js_typed_array_test.cpp +++ b/ecmascript/tests/js_typed_array_test.cpp @@ -52,7 +52,7 @@ public: // CVector pushed with JSTaggedValue made from compatible input value for the JSType const CVector cVecHandleTagValValueForTypedArray { - // Use "(S)(...)" cast to make v in "JSTaggedValue(T v) : coretypes::TaggedValue(v) {}" compatible with S + // Use "(S)(...)" cast to make v in "JSTaggedValue(T v) {}" compatible with S JSTaggedValue((int8_t)(-111)), JSTaggedValue((uint8_t)(222)), JSTaggedValue((uint8_t)(222)), JSTaggedValue((int16_t)(-31111)), JSTaggedValue((uint16_t)(61111)), // int32 : -2147483648->2147483647, uint32 : 0->4294967295 diff --git a/ecmascript/tooling/backend/js_pt_location.h b/ecmascript/tooling/backend/js_pt_location.h index b5e6207d902e7aea3932419eb4aa4f0b8c6d7d60..434372fa5296b3eb915cd50638487a9a42228499 100644 --- a/ecmascript/tooling/backend/js_pt_location.h +++ b/ecmascript/tooling/backend/js_pt_location.h @@ -18,7 +18,7 @@ #include -#include "libpandafile/file_items.h" +#include "libpandafile/file.h" #include "libpandabase/macros.h" namespace panda::ecmascript::tooling { diff --git a/ecmascript/tooling/test/utils/testcases/test_list.h b/ecmascript/tooling/test/utils/testcases/test_list.h index 0409f3897f74f25d6260b4220a268850523408e9..0f208fe16353fb3d89ca5f7a8df36765dd7177c0 100644 --- a/ecmascript/tooling/test/utils/testcases/test_list.h +++ b/ecmascript/tooling/test/utils/testcases/test_list.h @@ -21,7 +21,6 @@ #include "ecmascript/mem/c_containers.h" #include "ecmascript/mem/c_string.h" -#include "libpandafile/file_items.h" namespace panda::ecmascript::tooling::test { std::vector GetTestList(); diff --git a/ecmascript/ts_types/ts_obj_layout_info.h b/ecmascript/ts_types/ts_obj_layout_info.h index d3d48b24f391cfd410d662c55e22a3bf64850d02..3f530534fe312558a8406f671cf672bf0cb34f41 100644 --- a/ecmascript/ts_types/ts_obj_layout_info.h +++ b/ecmascript/ts_types/ts_obj_layout_info.h @@ -32,7 +32,7 @@ public: static constexpr int ENTRY_TYPE_OFFSET = 1; static constexpr int ENTRY_KEY_OFFSET = 0; - inline static TSObjLayoutInfo *Cast(ObjectHeader *obj) + inline static TSObjLayoutInfo *Cast(TaggedObject *obj) { ASSERT(JSTaggedValue(obj).IsTaggedArray()); return reinterpret_cast(obj); diff --git a/ecmascript/ts_types/ts_type_table.cpp b/ecmascript/ts_types/ts_type_table.cpp index 35a19a492c652d2741d9abd190bb659c20634e7a..53b7a396dfd6a3f1898f6ca15fd028a7d5022f4f 100644 --- a/ecmascript/ts_types/ts_type_table.cpp +++ b/ecmascript/ts_types/ts_type_table.cpp @@ -226,9 +226,9 @@ JSHandle TSTypeTable::GetExportTableFromPandFile(JSThread *thread, } }); - array_size_t length = exportTable.size(); + uint32_t length = exportTable.size(); JSHandle exportArray = factory->NewTaggedArray(length); - for (array_size_t i = 0; i < length; i ++) { + for (uint32_t i = 0; i < length; i ++) { JSHandle typeIdString = factory->NewFromUtf8(exportTable[i]); exportArray->Set(thread, i, typeIdString); } diff --git a/ecmascript/weak_vector.h b/ecmascript/weak_vector.h index bab4363db4a3908c9ac491f34dcdc3fce9cc3b4b..9da8b63686db8f99ffd235656f6c129beb1e0a5c 100644 --- a/ecmascript/weak_vector.h +++ b/ecmascript/weak_vector.h @@ -23,7 +23,7 @@ namespace panda::ecmascript { class WeakVector : public TaggedArray { public: - static WeakVector *Cast(ObjectHeader *object) + static WeakVector *Cast(TaggedObject *object) { return static_cast(object); }