mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Descriptor: delete some internal unused code
details: delete unused code issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5COHE Signed-off-by: wengchangcheng <wengchangcheng@huawei.com> Change-Id: I5fe62c58353839d4aac1144fc99e2cf87f4374eb
This commit is contained in:
parent
65bbc261b3
commit
cc184ba66c
1
BUILD.gn
1
BUILD.gn
@ -137,7 +137,6 @@ config("ark_jsruntime_public_config") {
|
||||
"$js_root",
|
||||
|
||||
# Dependent on runtime_core include
|
||||
"$ark_root/runtime",
|
||||
"$ark_root",
|
||||
]
|
||||
}
|
||||
|
@ -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. 编译方舟前端,编译命令:
|
||||
|
@ -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.
|
||||
|
@ -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. 首次编译后增量编译方舟前端:
|
||||
|
@ -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:
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
using InternalGetFunc = JSTaggedValue (*)(JSThread *, const JSHandle<JSObject> &);
|
||||
using InternalSetFunc = bool (*)(JSThread *, const JSHandle<JSObject> &, const JSHandle<JSTaggedValue> &, bool);
|
||||
|
||||
static AccessorData *Cast(ObjectHeader *object)
|
||||
static AccessorData *Cast(TaggedObject *object)
|
||||
{
|
||||
ASSERT(JSTaggedValue(object).IsAccessorData() || JSTaggedValue(object).IsInternalAccessor());
|
||||
return static_cast<AccessorData *>(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<CompletionRecord *>(object);
|
||||
|
@ -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 {
|
||||
|
@ -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));
|
||||
|
@ -2682,7 +2682,7 @@ JSTaggedValue BuiltinsArray::Flat(EcmaRuntimeCallInfo *argv)
|
||||
JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
|
||||
|
||||
// 2. Let sourceLen be ? LengthOfArrayLike(O).
|
||||
@ -2769,7 +2769,7 @@ JSTaggedValue BuiltinsArray::Includes(EcmaRuntimeCallInfo *argv)
|
||||
JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
|
||||
array_size_t argc = argv->GetArgsNumber();
|
||||
uint32_t argc = argv->GetArgsNumber();
|
||||
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
|
||||
JSHandle<JSTaggedValue> searchElement = GetCallArg(argv, 0);
|
||||
|
||||
|
@ -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<JSTaggedValue> 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<JSTaggedValue> 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<JSTaggedValue> 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<JSTaggedValue> zeroString = globalConst->GetHandledZeroString();
|
||||
JSHandle<JSTaggedValue> matchStr(
|
||||
thread, FastRuntimeStub::FastGetProperty(thread, result.GetTaggedValue(), zeroString.GetTaggedValue()));
|
||||
JSTaggedValue matchVal = FastRuntimeStub::FastGetPropertyByValue(
|
||||
thread, result.GetTaggedValue(), zeroString.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> matchStr(thread, matchVal);
|
||||
JSHandle<EcmaString> 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<JSTaggedValue> lastIndexHandle(
|
||||
thread,
|
||||
FastRuntimeStub::FastGetProperty(thread, thisObj.GetTaggedValue(), lastIndexString.GetTaggedValue()));
|
||||
JSTaggedValue lastIndex = FastRuntimeStub::FastGetPropertyByValue(thread, thisObj.GetTaggedValue(),
|
||||
lastIndexString.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> 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<JSTag
|
||||
lastIndex = 0;
|
||||
} else {
|
||||
JSTaggedValue thisIndex =
|
||||
FastRuntimeStub::FastGetProperty(thread, regexp.GetTaggedValue(), lastIndexHandle.GetTaggedValue());
|
||||
FastRuntimeStub::FastGetPropertyByValue(thread, regexp.GetTaggedValue(), lastIndexHandle.GetTaggedValue());
|
||||
if (thisIndex.IsInt()) {
|
||||
lastIndex = static_cast<uint32_t>(thisIndex.GetInt());
|
||||
} else {
|
||||
@ -651,8 +652,8 @@ JSTaggedValue BuiltinsRegExp::RegExpReplaceFast(JSThread *thread, JSHandle<JSTag
|
||||
if (!matchResult.isSuccess_) {
|
||||
if (flags & (RegExpParser::FLAG_STICKY | RegExpParser::FLAG_GLOBAL)) {
|
||||
lastIndex = 0;
|
||||
FastRuntimeStub::FastSetProperty(thread, regexp.GetTaggedValue(), lastIndexHandle.GetTaggedValue(),
|
||||
JSTaggedValue(0), true);
|
||||
FastRuntimeStub::FastSetPropertyByValue(thread, regexp.GetTaggedValue(),
|
||||
lastIndexHandle.GetTaggedValue(), JSTaggedValue(0));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
}
|
||||
break;
|
||||
@ -666,8 +667,8 @@ JSTaggedValue BuiltinsRegExp::RegExpReplaceFast(JSThread *thread, JSHandle<JSTag
|
||||
nextPosition = endIndex;
|
||||
if (!(flags & RegExpParser::FLAG_GLOBAL)) {
|
||||
// a. Let setStatus be Set(R, "lastIndex", e, true).
|
||||
FastRuntimeStub::FastSetProperty(thread, regexp.GetTaggedValue(), lastIndexHandle.GetTaggedValue(),
|
||||
JSTaggedValue(lastIndex), true);
|
||||
FastRuntimeStub::FastSetPropertyByValue(thread, regexp.GetTaggedValue(), lastIndexHandle.GetTaggedValue(),
|
||||
JSTaggedValue(lastIndex));
|
||||
// b. ReturnIfAbrupt(setStatus).
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
break;
|
||||
@ -726,7 +727,7 @@ JSTaggedValue BuiltinsRegExp::Replace(EcmaRuntimeCallInfo *argv)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedValue> 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<JSTaggedValue> getMatch(
|
||||
thread, FastRuntimeStub::FastGetProperty(thread, execResult.GetTaggedValue(), matchedStr.GetTaggedValue()));
|
||||
JSTaggedValue getMatchVal = FastRuntimeStub::FastGetPropertyByValue(
|
||||
thread, execResult.GetTaggedValue(), matchedStr.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> getMatch(thread, getMatchVal);
|
||||
JSHandle<EcmaString> 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<JSTaggedValue> thisIndexHandle(
|
||||
thread, FastRuntimeStub::FastGetProperty(thread, thisObj.GetTaggedValue(), lastIndex.GetTaggedValue()));
|
||||
JSTaggedValue thisIndexVal = FastRuntimeStub::FastGetPropertyByValue(
|
||||
thread, thisObj.GetTaggedValue(), lastIndex.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> thisIndexHandle(thread, thisIndexVal);
|
||||
uint32_t thisIndex = 0;
|
||||
if (thisIndexHandle->IsInt()) {
|
||||
thisIndex = static_cast<uint32_t>(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<JSTaggedValue> 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<JSTaggedValue> resultIndex = globalConst->GetHandledIndexString();
|
||||
JSTaggedValue positionTag =
|
||||
FastRuntimeStub::FastGetPropertyByName(thread, resultValues.GetTaggedValue(), resultIndex.GetTaggedValue());
|
||||
JSTaggedValue positionTag = FastRuntimeStub::FastGetPropertyByValue(
|
||||
thread, resultValues.GetTaggedValue(), resultIndex.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedValue> 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<JSTaggedValue> 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<JSTaggedValue> 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 JSHandle<JSTagg
|
||||
|
||||
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
||||
JSHandle<JSTaggedValue> execHandle = globalConst->GetHandledExecString();
|
||||
JSHandle<JSTaggedValue> exec(
|
||||
thread, FastRuntimeStub::FastGetProperty(thread, regexp.GetTaggedValue(), execHandle.GetTaggedValue()));
|
||||
JSTaggedValue execVal = FastRuntimeStub::FastGetPropertyByValue(thread, regexp.GetTaggedValue(),
|
||||
execHandle.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedValue> 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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -16,6 +16,8 @@
|
||||
#ifndef ECMASCRIPT_COMPILER_CIRCUIT_BUILDER_H
|
||||
#define ECMASCRIPT_COMPILER_CIRCUIT_BUILDER_H
|
||||
|
||||
#include <stack>
|
||||
|
||||
#include "ecmascript/compiler/circuit.h"
|
||||
#include "ecmascript/compiler/gate.h"
|
||||
#include "ecmascript/compiler/gate_accessor.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"
|
||||
|
@ -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;
|
||||
|
@ -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<JSObject> 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<true>(thread, obj.GetTaggedValue(), 1, JSTaggedValue(x));
|
||||
FastRuntimeStub::SetPropertyByIndex<true>(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<JSTaggedType *>(thread->GetCurrentSPFrame());
|
||||
FastRuntimeStub::SetOwnElement(thread, obj.GetTaggedValue(), 1, JSTaggedValue(x));
|
||||
FastRuntimeStub::SetOwnElement(thread, obj.GetTaggedValue(), 10250, JSTaggedValue(y));
|
||||
FastRuntimeStub::SetPropertyByIndex<true>(thread, obj.GetTaggedValue(), 1, JSTaggedValue(x));
|
||||
FastRuntimeStub::SetPropertyByIndex<true>(thread, obj.GetTaggedValue(), 10250, JSTaggedValue(y));
|
||||
|
||||
JSHandle<JSTaggedValue> strA(factory->NewFromASCII("a"));
|
||||
JSHandle<JSTaggedValue> strBig(factory->NewFromASCII("biggest"));
|
||||
@ -1209,8 +1208,8 @@ HWTEST_F_L0(StubTest, FastEqualTest)
|
||||
// test for obj == obj
|
||||
JSHandle<JSObject> obj1 = factory->NewEmptyJSObject();
|
||||
JSHandle<JSObject> obj2 = factory->NewEmptyJSObject();
|
||||
FastRuntimeStub::SetOwnElement(thread, obj1.GetTaggedValue(), 1, JSTaggedValue(1));
|
||||
FastRuntimeStub::SetOwnElement(thread, obj2.GetTaggedValue(), 1, JSTaggedValue(1));
|
||||
FastRuntimeStub::SetPropertyByIndex<true>(thread, obj1.GetTaggedValue(), 1, JSTaggedValue(1));
|
||||
FastRuntimeStub::SetPropertyByIndex<true>(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);
|
||||
|
@ -663,7 +663,7 @@ void HeapSnapshot::FillEdges()
|
||||
toValue.RemoveWeakTag();
|
||||
}
|
||||
if (toValue.IsHeapObject()) {
|
||||
auto *to = reinterpret_cast<TaggedObject *>(toValue.GetHeapObject());
|
||||
auto *to = reinterpret_cast<TaggedObject *>(toValue.GetTaggedObject());
|
||||
entryTo = entryMap_.FindEntry(Node::NewAddress(to));
|
||||
}
|
||||
if (entryTo == nullptr) {
|
||||
|
@ -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);
|
||||
|
@ -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<TYPE *>(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<CAST_TYPE *>(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<CAST_TYPE *>(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<const CAST_TYPE *>(object); \
|
||||
}
|
||||
|
||||
#define CAST_NO_CHECK(CAST_TYPE) \
|
||||
static inline CAST_TYPE *Cast(ObjectHeader *object) \
|
||||
static inline CAST_TYPE *Cast(TaggedObject *object) \
|
||||
{ \
|
||||
return static_cast<CAST_TYPE *>(object); \
|
||||
} \
|
||||
static const inline CAST_TYPE *ConstCast(const ObjectHeader *object) \
|
||||
static const inline CAST_TYPE *ConstCast(const TaggedObject *object) \
|
||||
{ \
|
||||
return static_cast<const CAST_TYPE *>(object); \
|
||||
}
|
||||
|
@ -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<EcmaString *>(object);
|
||||
|
@ -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);
|
||||
|
@ -491,7 +491,7 @@ void EcmaVM::EnableUserUncaughtErrorHandler()
|
||||
isUncaughtExceptionRegistered_ = true;
|
||||
}
|
||||
|
||||
void EcmaVM::HandleUncaughtException(ObjectHeader *exception)
|
||||
void EcmaVM::HandleUncaughtException(TaggedObject *exception)
|
||||
{
|
||||
if (isUncaughtExceptionRegistered_) {
|
||||
return;
|
||||
|
@ -350,7 +350,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void HandleUncaughtException(ObjectHeader *exception);
|
||||
void HandleUncaughtException(TaggedObject *exception);
|
||||
|
||||
void PrintJSErrorInfo(const JSHandle<JSTaggedValue> &exceptionInfo);
|
||||
|
||||
|
@ -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<GlobalEnv *>(object);
|
||||
|
@ -193,7 +193,7 @@ public:
|
||||
JSHandle<TransitionHandler> handler = factory->NewTransitionHandler();
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedValue>::Cast(handler);
|
||||
}
|
||||
|
@ -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<uint32_t>(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<int>(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<uint32_t>(index) * JSTaggedValue::TaggedTypeSize(), value);
|
||||
return;
|
||||
}
|
||||
TaggedArray *array = TaggedArray::Cast(receiver->GetProperties().GetHeapObject());
|
||||
TaggedArray *array = TaggedArray::Cast(receiver->GetProperties().GetTaggedObject());
|
||||
ASSERT(index < static_cast<int>(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<size_t>(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<uint32_t>(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<uint32_t>(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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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<PropertyBox *>(object);
|
||||
|
@ -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<ProtoChangeMarker *>(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<ProtoChangeDetails *>(object);
|
||||
@ -62,7 +62,7 @@ public:
|
||||
|
||||
class ChangeListener : public WeakVector {
|
||||
public:
|
||||
static ChangeListener *Cast(ObjectHeader *object)
|
||||
static ChangeListener *Cast(TaggedObject *object)
|
||||
{
|
||||
return static_cast<ChangeListener *>(object);
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ HWTEST_F_L0(ICRuntimeStubTest, StoreICWithHandler)
|
||||
OffsetBit::Set<uint32_t>(bitOffset, &handler);
|
||||
AccessorBit::Set<uint32_t>(true, &handler);
|
||||
|
||||
array_size_t arrayLength = bitOffset + 1U;
|
||||
uint32_t arrayLength = bitOffset + 1U;
|
||||
JSHandle<JSObject> handleHolder = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun);
|
||||
JSHandle<TaggedArray> handleTaggedArr = factory->NewTaggedArray(arrayLength);
|
||||
handleTaggedArr->Set(thread, bitOffset, handleAccessor.GetTaggedValue());
|
||||
@ -389,7 +389,7 @@ HWTEST_F_L0(ICRuntimeStubTest, LoadICWithHandler)
|
||||
OffsetBit::Set<uint32_t>(bitOffset, &handler);
|
||||
AccessorBit::Set<uint32_t>(true, &handler);
|
||||
|
||||
array_size_t arrayLength = bitOffset + 1U;
|
||||
uint32_t arrayLength = bitOffset + 1U;
|
||||
JSHandle<JSObject> handleHolder = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun);
|
||||
JSHandle<TaggedArray> handleTaggedArr = factory->NewTaggedArray(arrayLength);
|
||||
handleTaggedArr->Set(thread, bitOffset, handleAccessor.GetTaggedValue());
|
||||
@ -428,7 +428,7 @@ HWTEST_F_L0(ICRuntimeStubTest, Prototype_StoreAndLoad)
|
||||
OffsetBit::Set<uint32_t>(bitOffset, &handler);
|
||||
KindBit::Set<uint32_t>(HandlerKind::FIELD, &handler); // test filed
|
||||
|
||||
array_size_t arrayLength = bitOffset + 1U;
|
||||
uint32_t arrayLength = bitOffset + 1U;
|
||||
JSHandle<JSObject> handleObj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun);
|
||||
JSHandle<TaggedArray> handleTaggedArr = factory->NewTaggedArray(arrayLength);
|
||||
handleObj->SetProperties(thread, handleTaggedArr.GetTaggedValue());
|
||||
@ -462,7 +462,7 @@ HWTEST_F_L0(ICRuntimeStubTest, StoreWithTransition_In_Filed)
|
||||
OffsetBit::Set<uint32_t>(bitOffset, &handler);
|
||||
KindBit::Set<uint32_t>(HandlerKind::FIELD, &handler);
|
||||
|
||||
array_size_t arrayLength = bitOffset + 1U;
|
||||
uint32_t arrayLength = bitOffset + 1U;
|
||||
JSHandle<TaggedArray> 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<uint32_t>(bitOffset, &handler);
|
||||
|
||||
array_size_t arrayLength = bitOffset + 1U;
|
||||
uint32_t arrayLength = bitOffset + 1U;
|
||||
JSHandle<TaggedArray> handleTaggedArr = factory->NewTaggedArray(arrayLength);
|
||||
handleTaggedArr->Set(thread, bitOffset, JSTaggedValue::Undefined());
|
||||
|
||||
@ -533,7 +533,7 @@ HWTEST_F_L0(ICRuntimeStubTest, Element_StoreAndLoad)
|
||||
KindBit::Set<uint32_t>(HandlerKind::ELEMENT, &handlerInfo);
|
||||
IsJSArrayBit::Set<uint32_t>(true, &handlerInfo);
|
||||
|
||||
array_size_t arrayLength = 3U;
|
||||
uint32_t arrayLength = 3U;
|
||||
JSArray *handleArr = JSArray::ArrayCreate(thread, JSTaggedNumber(arrayLength)).GetObject<JSArray>();
|
||||
JSHandle<JSObject> handleArrObj(thread, handleArr);
|
||||
JSHandle<TaggedArray> handleTaggedArr = factory->NewTaggedArray(arrayLength);
|
||||
|
@ -62,7 +62,7 @@ HWTEST_F_L0(PropertiesCacheTest, SetAndGet)
|
||||
JSHandle<JSTaggedValue> handleFunction(factory->NewJSFunction(env));
|
||||
JSHandle<JSSymbol> handleSymbol(factory->NewJSSymbol());
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedValue> handleKey(factory->NewFromASCII("10"));
|
||||
JSHandle<JSTaggedValue> 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);
|
||||
|
@ -96,7 +96,7 @@ HWTEST_F_L0(ProtoChangeDetailsTest, SetChangeListener)
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSTaggedValue> handleValue(thread, JSTaggedValue(1));
|
||||
|
||||
array_size_t weakVectorCapacity = 100;
|
||||
uint32_t weakVectorCapacity = 100;
|
||||
JSHandle<WeakVector> weakVector = WeakVector::Create(thread, weakVectorCapacity);
|
||||
JSHandle<ChangeListener> handleChangeListener = JSHandle<ChangeListener>::Cast(weakVector);
|
||||
JSHandle<ProtoChangeDetails> handleChangeDetails = factory->NewProtoChangeDetails();
|
||||
@ -138,8 +138,8 @@ HWTEST_F_L0(ProtoChangeDetailsTest, Add_001)
|
||||
JSHandle<JSTaggedValue> objFun = env->GetObjectFunction();
|
||||
JSHandle<JSObject> handleObj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun);
|
||||
JSHandle<JSTaggedValue> 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 = 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<JSTaggedValue> objFun = env->GetObjectFunction();
|
||||
JSHandle<JSObject> handleObj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun);
|
||||
JSHandle<JSTaggedValue> 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 = 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<JSTaggedValue> objFun = env->GetObjectFunction();
|
||||
JSHandle<JSObject> handleObj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun);
|
||||
JSHandle<JSTaggedValue> 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 = 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 = 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<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
|
||||
JSHandle<JSTaggedValue> objFun = env->GetObjectFunction();
|
||||
|
@ -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<JSObject>(thread, receiver), index,
|
||||
JSHandle<JSTaggedValue>(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<JSTaggedValue> objHandle(thread, receiver);
|
||||
JSHandle<JSTaggedValue> 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<JSObject>(thread, receiver), index,
|
||||
JSHandle<JSTaggedValue>(thread, value), PropertyAttributes::Default());
|
||||
}
|
||||
if (holder.IsJSProxy()) {
|
||||
return JSProxy::SetProperty(
|
||||
thread, JSHandle<JSProxy>(thread, holder), JSHandle<JSTaggedValue>(thread, JSTaggedValue(index)),
|
||||
JSHandle<JSTaggedValue>(thread, value), JSHandle<JSTaggedValue>(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<JSTaggedValue>(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<JSObject>(thread, receiver),
|
||||
JSHandle<JSTaggedValue>(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<GlobalDictionary> 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<JSObject>(thread, receiver),
|
||||
JSHandle<JSTaggedValue>(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<JSTaggedValue> objHandle(thread, receiver);
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedValue>(thread, holder),
|
||||
JSTypedArray::ToPropKey(thread, JSHandle<JSTaggedValue>(thread, key)),
|
||||
JSHandle<JSTaggedValue>(thread, value),
|
||||
JSHandle<JSTaggedValue>(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<JSTaggedValue>(thread, value),
|
||||
PropertyAttributes::Default());
|
||||
|
||||
return true;
|
||||
}
|
||||
if (holder.IsJSProxy()) {
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
return JSProxy::SetProperty(thread, JSHandle<JSProxy>(thread, holder), JSHandle<JSTaggedValue>(thread, key),
|
||||
JSHandle<JSTaggedValue>(thread, value),
|
||||
JSHandle<JSTaggedValue>(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<JSTaggedValue> keyHandle(thread, key);
|
||||
JSHandle<JSTaggedValue> valHandle(thread, value);
|
||||
JSHandle<JSObject> objHandle(thread, obj);
|
||||
JSHandle<GlobalDictionary> dictHandle(GlobalDictionary::Create(thread));
|
||||
|
||||
// Add PropertyBox to global dictionary
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<PropertyBox> boxHandle = factory->NewPropertyBox(valHandle);
|
||||
boxHandle->SetValue(thread, valHandle.GetTaggedValue());
|
||||
PropertyBoxType boxType = valHandle->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT;
|
||||
attr.SetBoxType(boxType);
|
||||
|
||||
JSHandle<GlobalDictionary> properties =
|
||||
GlobalDictionary::PutIfAbsent(thread, dictHandle, keyHandle, JSHandle<JSTaggedValue>(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<GlobalDictionary> 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<JSTaggedValue> objHandle(thread, receiver);
|
||||
JSHandle<JSTaggedValue> setFunc(thread, setter);
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedValue> keyHandle(thread, key);
|
||||
JSHandle<JSTaggedValue> valHandle(thread, value);
|
||||
JSHandle<JSObject> objHandle(thread, obj);
|
||||
JSHandle<GlobalDictionary> dictHandle(thread, dict);
|
||||
|
||||
// Add PropertyBox to global dictionary
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<PropertyBox> boxHandle = factory->NewPropertyBox(keyHandle);
|
||||
boxHandle->SetValue(thread, valHandle.GetTaggedValue());
|
||||
PropertyBoxType boxType = valHandle->IsUndefined() ? PropertyBoxType::UNDEFINED : PropertyBoxType::CONSTANT;
|
||||
attr.SetBoxType(boxType);
|
||||
|
||||
JSHandle<GlobalDictionary> properties =
|
||||
GlobalDictionary::PutIfAbsent(thread, dictHandle, keyHandle, JSHandle<JSTaggedValue>(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<JSTaggedValue>(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<JSObject>(thread, receiver), index,
|
||||
JSHandle<JSTaggedValue>(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<JSTaggedValue>(thread, receiver),
|
||||
JSHandle<JSTaggedValue>(thread, key),
|
||||
JSHandle<JSTaggedValue>(thread, value), mayThrow);
|
||||
}
|
||||
if (key.IsString()) {
|
||||
key = JSTaggedValue(thread->GetEcmaVM()->GetFactory()->InternString(JSHandle<JSTaggedValue>(thread, key)));
|
||||
}
|
||||
return FastRuntimeStub::SetPropertyByName(thread, receiver, key, value, mayThrow);
|
||||
}
|
||||
return JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>(thread, receiver),
|
||||
JSHandle<JSTaggedValue>(thread, key), JSHandle<JSTaggedValue>(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<JSTaggedValue>(thread, key)));
|
||||
}
|
||||
result = FastRuntimeStub::GetPropertyByName(thread, receiver, key);
|
||||
}
|
||||
}
|
||||
if (!result.IsHole()) {
|
||||
if (UNLIKELY(result.IsAccessor())) {
|
||||
return JSObject::CallGetter(thread, AccessorData::Cast(result.GetHeapObject()),
|
||||
JSHandle<JSTaggedValue>(thread, receiver));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>(thread, receiver),
|
||||
JSHandle<JSTaggedValue>(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<int>(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<int>(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<int>(attr.GetOffset()) == entry);
|
||||
return attr.IsInlinedProps() ? obj->GetPropertyInlinedProps(entry)
|
||||
: array->Get(static_cast<uint32_t>(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<int>(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<JSFunction> ctorHandle(thread, ctor);
|
||||
JSHandle<JSTaggedValue> newTargetHandle(thread, newTarget);
|
||||
JSHandle<JSObject> 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()) {
|
||||
|
@ -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<bool UseOwn = false>
|
||||
static inline JSTaggedValue GetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key);
|
||||
template<bool UseOwn = false>
|
||||
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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<MicroJobQueue *>(object);
|
||||
|
@ -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<PendingJob *>(object);
|
||||
|
@ -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<JSTaggedValue> handleValue(thread, JSTaggedValue(123));
|
||||
|
||||
JSHandle<TaggedQueue> handlePromiseQueue = factory->NewTaggedQueue(capacity);
|
||||
|
@ -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<JSAPIArrayList *>(object);
|
||||
|
@ -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<JSAPIArrayListIterator *>(obj);
|
||||
|
@ -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<JSAPIDeque *>(object);
|
||||
|
@ -44,7 +44,7 @@ JSTaggedValue JSAPIDequeIterator::Next(EcmaRuntimeCallInfo *argv)
|
||||
uint32_t index = iter->GetNextIndex();
|
||||
|
||||
JSHandle<TaggedArray> 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) {
|
||||
|
@ -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<JSAPIDequeIterator *>(obj);
|
||||
|
@ -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<JSAPILinkedList *>(object);
|
||||
|
@ -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<JSAPILinkedListIterator *>(obj);
|
||||
|
@ -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<JSAPIList *>(object);
|
||||
|
@ -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<JSAPIListIterator *>(obj);
|
||||
|
@ -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<JSAPIPlainArray *>(object);
|
||||
|
@ -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<JSAPIPlainArrayIterator *>(obj);
|
||||
|
@ -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<JSAPIQueue *>(object);
|
||||
|
@ -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<JSAPIQueueIterator *>(obj);
|
||||
|
@ -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<JSAPIStack *>(object);
|
||||
|
@ -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<JSAPIStackIterator *>(obj);
|
||||
|
@ -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<JSAPITreeMap *>(object);
|
||||
}
|
||||
|
@ -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<JSAPITreeMapIterator *>(obj);
|
||||
|
@ -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<JSAPITreeSet *>(object);
|
||||
}
|
||||
|
@ -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<JSAPITreeSetIterator *>(obj);
|
||||
|
@ -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<JSAPIVector *>(object);
|
||||
|
@ -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<JSAPIVectorIterator *>(obj);
|
||||
|
@ -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<JSAsyncFunction *>(object);
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
class CellRecordVector : public WeakVector {
|
||||
public:
|
||||
static CellRecordVector *Cast(ObjectHeader *object)
|
||||
static CellRecordVector *Cast(TaggedObject *object)
|
||||
{
|
||||
return static_cast<CellRecordVector *>(object);
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ void JSFunction::SetFunctionNameNoPrefix(JSThread *thread, JSFunction *func, JST
|
||||
GetHandledRightSquareBracketString());
|
||||
concatName = factory->ConcatFromString(
|
||||
leftBrackets,
|
||||
JSHandle<EcmaString>(thread, JSSymbol::Cast(nameBegin->GetHeapObject())->GetDescription()));
|
||||
JSHandle<EcmaString>(thread, JSSymbol::Cast(nameBegin->GetTaggedObject())->GetDescription()));
|
||||
concatName = factory->ConcatFromString(concatName, rightBrackets);
|
||||
nameHandle.Update(concatName.GetTaggedValue());
|
||||
}
|
||||
|
@ -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<GlobalEnv> &env, const JSHandle<JSFunction> &func,
|
||||
@ -191,7 +190,6 @@ public:
|
||||
GetClass()->SetClassConstructor(flag);
|
||||
}
|
||||
|
||||
/* -------------- Common API End, Don't change those interface!!! ----------------- */
|
||||
static void InitializeJSFunction(JSThread *thread, const JSHandle<JSFunction> &func,
|
||||
FunctionKind kind = FunctionKind::NORMAL_FUNCTION, bool strict = true);
|
||||
static JSHClass *GetOrCreateInitialJSHClass(JSThread *thread, const JSHandle<JSFunction> &fun);
|
||||
|
@ -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<JSGlobalObject *>(object);
|
||||
|
@ -85,11 +85,6 @@ public:
|
||||
address_ = EcmaHandleScope::NewHandle(const_cast<JSThread *>(thread), value.GetRawData());
|
||||
}
|
||||
|
||||
explicit JSHandle(const JSThread *thread, const ObjectHeader *value)
|
||||
{
|
||||
address_ = EcmaHandleScope::NewHandle(const_cast<JSThread *>(thread), JSTaggedValue(value).GetRawData());
|
||||
}
|
||||
|
||||
explicit JSHandle(const JSThread *thread, const TaggedObject *value)
|
||||
{
|
||||
address_ = EcmaHandleScope::NewHandle(const_cast<JSThread *>(thread), JSTaggedValue(value).GetRawData());
|
||||
|
@ -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<JSIntl *>(object);
|
||||
|
@ -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<JSLocale *>(object);
|
||||
|
@ -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<JSMapIterator *>(obj);
|
||||
|
@ -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<JSNativePointer *>(object);
|
||||
|
@ -1156,16 +1156,16 @@ bool JSObject::CreateMethodProperty(JSThread *thread, const JSHandle<JSObject> &
|
||||
JSHandle<JSTaggedValue> JSObject::GetMethod(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
|
||||
const JSHandle<JSTaggedValue> &key)
|
||||
{
|
||||
JSTaggedValue func = FastRuntimeStub::FastGetProperty(thread, obj.GetTaggedValue(), key.GetTaggedValue());
|
||||
if (func.IsUndefined() || func.IsNull()) {
|
||||
JSHandle<JSTaggedValue> func = GetProperty(thread, obj, key).GetValue();
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
if (func->IsUndefined() || func->IsNull()) {
|
||||
return JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined());
|
||||
}
|
||||
|
||||
JSHandle<JSTaggedValue> 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<JSTaggedType>(this, HASH_OFFSET, JSTaggedValue(hash).GetRawData());
|
||||
@ -1878,7 +1878,7 @@ int32_t ECMAObject::GetHash() const
|
||||
JSTaggedType hashField = Barriers::GetDynValue<JSTaggedType>(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<JSTaggedType>(this, HASH_OFFSET);
|
||||
JSTaggedValue value(hashField);
|
||||
if (value.IsHeapObject()) {
|
||||
TaggedArray *array = TaggedArray::Cast(value.GetHeapObject());
|
||||
TaggedArray *array = TaggedArray::Cast(value.GetTaggedObject());
|
||||
len = static_cast<int32_t>(array->GetLength() - 1);
|
||||
}
|
||||
return len;
|
||||
|
@ -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<JSRealm *>(object);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -1639,7 +1639,7 @@ bool Serializer::FinalizeTransfer(JSThread *thread, const JSHandle<JSTaggedValue
|
||||
{
|
||||
for (int idx : arrayBufferIdxs_) {
|
||||
JSHandle<JSTaggedValue> element = JSArray::FastGetPropertyByValue(thread, transfer, idx);
|
||||
JSArrayBuffer::Cast(element->GetHeapObject())->Detach(thread);
|
||||
JSArrayBuffer::Cast(element->GetTaggedObject())->Detach(thread);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -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<JSTaggedType>(ToUintPtr(v))) {}
|
||||
|
||||
explicit JSTaggedValue(const TaggedObject *v) : value_(static_cast<JSTaggedType>(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<ObjectHeader *>(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<ObjectHeader *>(value_);
|
||||
return reinterpret_cast<TaggedObject *>(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<ObjectHeader *>(value_ & (~TAG_WEAK_MASK));
|
||||
return reinterpret_cast<TaggedObject *>(value_ & (~TAG_WEAK_MASK));
|
||||
}
|
||||
|
||||
static inline JSTaggedType Cast(void *ptr)
|
||||
@ -364,7 +355,9 @@ public:
|
||||
|
||||
inline TaggedObject *GetTaggedObject() const
|
||||
{
|
||||
return reinterpret_cast<TaggedObject *>(GetHeapObject());
|
||||
ASSERT_PRINT(IsHeapObject() && ((value_ & TAG_WEAK_FILTER) == 0U),
|
||||
"can not convert JSTaggedValue to HeapObject :" << std::hex << value_);
|
||||
return reinterpret_cast<TaggedObject *>(value_);
|
||||
}
|
||||
|
||||
inline TaggedObject *GetRawTaggedObject() const
|
||||
|
@ -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;
|
||||
|
@ -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())) {
|
||||
|
@ -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"
|
||||
|
@ -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<JSWeakMap *>(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<JSWeakSet *>(object);
|
||||
|
@ -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<JSWeakRef *>(object);
|
||||
|
@ -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 {
|
||||
|
@ -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<ConstantPool *>(object);
|
||||
|
@ -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<LayoutInfo *>(obj);
|
||||
|
@ -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<LexicalEnv *>(object);
|
||||
|
@ -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<EcmaString *>(key.GetHeapObject());
|
||||
auto keyString = reinterpret_cast<EcmaString *>(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<int32_t>(
|
||||
GetHash32(reinterpret_cast<uint8_t *>(&keyValue), sizeof(keyValue) / sizeof(uint8_t)));
|
||||
ECMAObject::Cast(key.GetHeapObject())->SetHash(hash);
|
||||
ECMAObject::Cast(key.GetTaggedObject())->SetHash(hash);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public:
|
||||
|
||||
class LinkedHashMap : public LinkedHashTable<LinkedHashMap, LinkedHashMapObject> {
|
||||
public:
|
||||
static LinkedHashMap *Cast(ObjectHeader *obj)
|
||||
static LinkedHashMap *Cast(TaggedObject *obj)
|
||||
{
|
||||
return static_cast<LinkedHashMap *>(obj);
|
||||
}
|
||||
@ -342,7 +342,7 @@ public:
|
||||
|
||||
class LinkedHashSet : public LinkedHashTable<LinkedHashSet, LinkedHashSetObject> {
|
||||
public:
|
||||
static LinkedHashSet *Cast(ObjectHeader *obj)
|
||||
static LinkedHashSet *Cast(TaggedObject *obj)
|
||||
{
|
||||
return static_cast<LinkedHashSet *>(obj);
|
||||
}
|
||||
|
@ -597,10 +597,10 @@ void Heap::UpdateDerivedObjectInStack()
|
||||
" derived:" << derivedAddr << " old Value: " << *derivedAddr << std::endl;
|
||||
#endif
|
||||
// derived is always bigger than base
|
||||
*derivedAddr = reinterpret_cast<uintptr_t>(base.GetHeapObject()) + (*derivedAddr - baseOldObject);
|
||||
*derivedAddr = reinterpret_cast<uintptr_t>(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
|
||||
}
|
||||
|
@ -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<MachineCode *>(object);
|
||||
|
@ -18,6 +18,10 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifndef PANDA_TARGET_WINDOWS
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include "ecmascript/ecma_param_configuration.h"
|
||||
#include "ecmascript/mem/tagged_object.h"
|
||||
#include "libpandabase/mem/mem.h"
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ecmascript/mem/mem_map_allocator.h"
|
||||
#include "mem/runslots.h"
|
||||
#if defined(PANDA_TARGET_WINDOWS)
|
||||
#include <io.h>
|
||||
#include <sysinfoapi.h>
|
||||
#elif defined(PANDA_TARGET_MACOS)
|
||||
#include "sys/sysctl.h"
|
||||
|
@ -48,6 +48,9 @@
|
||||
#undef STRICT
|
||||
#endif
|
||||
|
||||
#ifdef VOID
|
||||
#undef VOID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace panda::ecmascript {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
*reinterpret_cast<JSTaggedType *>(slotAddress_) = value;
|
||||
}
|
||||
|
||||
TaggedObject *GetTaggedObjectHeader() const
|
||||
TaggedObject *GetTaggedObject() const
|
||||
{
|
||||
return reinterpret_cast<TaggedObject *>(GetTaggedType());
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
namespace panda::ecmascript {
|
||||
inline void TaggedObject::SetClassWithoutBarrier(JSHClass *hclass)
|
||||
{
|
||||
*reinterpret_cast<MarkWordType *>(ToUintPtr(this)) = reinterpret_cast<MarkWordType>(hclass);
|
||||
class_ = reinterpret_cast<MarkWordType>(hclass);
|
||||
}
|
||||
|
||||
inline void TaggedObject::SetClass(JSHClass *hclass)
|
||||
@ -42,7 +42,7 @@ inline void TaggedObject::SetClass(JSHandle<JSHClass> hclass)
|
||||
|
||||
inline JSHClass *TaggedObject::GetClass() const
|
||||
{
|
||||
return reinterpret_cast<JSHClass *>(*reinterpret_cast<MarkWordType *>(ToUintPtr(this)));
|
||||
return reinterpret_cast<JSHClass *>(class_);
|
||||
}
|
||||
|
||||
inline void TaggedObject::SynchronizedSetClass(JSHClass *hclass)
|
||||
|
@ -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<typename T>
|
||||
class JSHandle;
|
||||
class JSThread;
|
||||
|
||||
class TaggedObject : public ObjectHeader {
|
||||
class TaggedObject {
|
||||
public:
|
||||
static TaggedObject *Cast(ObjectHeader *header)
|
||||
static TaggedObject *Cast(TaggedObject *header)
|
||||
{
|
||||
return static_cast<TaggedObject *>(header);
|
||||
}
|
||||
@ -47,6 +46,9 @@ public:
|
||||
}
|
||||
|
||||
JSThread* GetJSThread() const;
|
||||
|
||||
private:
|
||||
MarkWordType class_;
|
||||
};
|
||||
static_assert(TaggedObject::TaggedObjectSize() == sizeof(MarkWordType));
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -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<JSTaggedValue> 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()) {
|
||||
|
@ -92,7 +92,7 @@ OperationResult ModuleNamespace::GetProperty(JSThread *thread, const JSHandle<JS
|
||||
JSTaggedValue targetModule = resolvedBind->GetModule();
|
||||
// 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 JSHandle<Tag
|
||||
ASSERT(binding->IsResolvedBinding());
|
||||
JSTaggedValue targetModule = JSHandle<ResolvedBinding>::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);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ int32_t ModuleRecord::Evaluate(JSThread *thread, const JSHandle<JSTaggedValue> &
|
||||
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();
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ CVector<std::string> 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<std::string> 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> SourceTextModule::HostResolveImportedModule(JSThread
|
||||
const JSHandle<SourceTextModule> &module,
|
||||
const JSHandle<JSTaggedValue> &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<int>(moduleFilename.find_last_of('.'));
|
||||
if (suffixEnd == -1) {
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(SourceTextModule, thread);
|
||||
@ -664,7 +664,7 @@ void SourceTextModule::ModuleExecution(JSThread *thread, const JSHandle<SourceTe
|
||||
{
|
||||
JSTaggedValue moduleFileName = module->GetEcmaModuleFilename();
|
||||
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) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user