mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-24 02:30:03 +00:00
move onheap bit to hclass
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8XS5M Signed-off-by: linxiang8 <linxiang8@huawei.com> Change-Id: I4add7f8ceaf4e09520a5f6ca38ba18450e32cc24
This commit is contained in:
parent
6169f50b05
commit
f13747e131
@ -33,6 +33,39 @@
|
||||
#include "ecmascript/object_factory.h"
|
||||
|
||||
namespace panda::ecmascript::base {
|
||||
|
||||
#define GET_ONHEAP_HCLASS_FROM_TYPE(Type) \
|
||||
JSHandle<JSHClass> TypedArrayHelper::GetOnHeapHclass##Type(JSThread *thread, JSHClass* objHclass) \
|
||||
{ \
|
||||
JSHandle<JSHClass> result; \
|
||||
JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); \
|
||||
if (*JSHandle<JSHClass>(env->Get##Type##RootHclass()) == (objHclass)) { \
|
||||
return JSHandle<JSHClass>(env->Get##Type##RootHclassOnHeap()); \
|
||||
} \
|
||||
result = JSHClass::Clone((thread), JSHandle<JSHClass>((thread), (objHclass))); \
|
||||
result->SetIsOnHeap(true); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
TYPED_ARRAY_TYPES(GET_ONHEAP_HCLASS_FROM_TYPE)
|
||||
#undef GET_ONHEAP_HCLASS_FROM_TYPE
|
||||
|
||||
#define GET_NOT_ONHEAP_HCLASS_FROM_TYPE(Type) \
|
||||
JSHandle<JSHClass> TypedArrayHelper::GetNotOnHeapHclass##Type(JSThread *thread, JSHClass* objHclass) \
|
||||
{ \
|
||||
JSHandle<JSHClass> result; \
|
||||
JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); \
|
||||
if (*JSHandle<JSHClass>(env->Get##Type##RootHclassOnHeap()) == (objHclass)) { \
|
||||
return JSHandle<JSHClass>(env->Get##Type##RootHclass()); \
|
||||
} \
|
||||
result = JSHClass::Clone((thread), JSHandle<JSHClass>((thread), (objHclass))); \
|
||||
result->SetIsOnHeap(false); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
TYPED_ARRAY_TYPES(GET_NOT_ONHEAP_HCLASS_FROM_TYPE)
|
||||
#undef GET_NOT_ONHEAP_HCLASS_FROM_TYPE
|
||||
|
||||
DataViewType TypedArrayHelper::GetType(const JSHandle<JSTypedArray> &obj)
|
||||
{
|
||||
JSType type = obj->GetJSHClass()->GetObjectType();
|
||||
@ -152,6 +185,70 @@ JSHandle<JSFunction> TypedArrayHelper::GetConstructorFromType(JSThread *thread,
|
||||
return JSHandle<JSFunction>(env->GetBigUint64ArrayFunction());
|
||||
}
|
||||
|
||||
JSHandle<JSHClass> TypedArrayHelper::GetOnHeapHclassFromType(
|
||||
JSThread *thread, const JSHandle<JSTypedArray> &obj, const DataViewType arrayType)
|
||||
{
|
||||
JSHClass* objHclass = JSHandle<TaggedObject>(obj)->GetClass();
|
||||
ASSERT_PRINT(!objHclass->IsOnHeapFromBitField(), "must be not on heap");
|
||||
switch (arrayType) {
|
||||
case DataViewType::INT8:
|
||||
return TypedArrayHelper::GetOnHeapHclassInt8Array(thread, objHclass);
|
||||
case DataViewType::UINT8:
|
||||
return TypedArrayHelper::GetOnHeapHclassUint8Array(thread, objHclass);
|
||||
case DataViewType::UINT8_CLAMPED:
|
||||
return TypedArrayHelper::GetOnHeapHclassUint8ClampedArray(thread, objHclass);
|
||||
case DataViewType::INT16:
|
||||
return TypedArrayHelper::GetOnHeapHclassInt16Array(thread, objHclass);
|
||||
case DataViewType::UINT16:
|
||||
return TypedArrayHelper::GetOnHeapHclassUint16Array(thread, objHclass);
|
||||
case DataViewType::INT32:
|
||||
return TypedArrayHelper::GetOnHeapHclassInt32Array(thread, objHclass);
|
||||
case DataViewType::UINT32:
|
||||
return TypedArrayHelper::GetOnHeapHclassUint32Array(thread, objHclass);
|
||||
case DataViewType::FLOAT32:
|
||||
return TypedArrayHelper::GetOnHeapHclassFloat32Array(thread, objHclass);
|
||||
case DataViewType::FLOAT64:
|
||||
return TypedArrayHelper::GetOnHeapHclassFloat64Array(thread, objHclass);
|
||||
case DataViewType::BIGINT64:
|
||||
return TypedArrayHelper::GetOnHeapHclassBigInt64Array(thread, objHclass);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TypedArrayHelper::GetOnHeapHclassBigUint64Array(thread, objHclass);
|
||||
}
|
||||
|
||||
JSHandle<JSHClass> TypedArrayHelper::GetNotOnHeapHclassFromType(
|
||||
JSThread *thread, const JSHandle<JSTypedArray> &obj, const DataViewType arrayType)
|
||||
{
|
||||
JSHClass* objHclass = JSHandle<TaggedObject>(obj)->GetClass();
|
||||
ASSERT_PRINT(objHclass->IsOnHeapFromBitField(), "must be on heap");
|
||||
switch (arrayType) {
|
||||
case DataViewType::INT8:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassInt8Array(thread, objHclass);
|
||||
case DataViewType::UINT8:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassUint8Array(thread, objHclass);
|
||||
case DataViewType::UINT8_CLAMPED:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassUint8ClampedArray(thread, objHclass);
|
||||
case DataViewType::INT16:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassInt16Array(thread, objHclass);
|
||||
case DataViewType::UINT16:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassUint16Array(thread, objHclass);
|
||||
case DataViewType::INT32:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassInt32Array(thread, objHclass);
|
||||
case DataViewType::UINT32:
|
||||
return TypedArrayHelper::GetOnHeapHclassUint32Array(thread, objHclass);
|
||||
case DataViewType::FLOAT32:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassFloat32Array(thread, objHclass);
|
||||
case DataViewType::FLOAT64:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassFloat64Array(thread, objHclass);
|
||||
case DataViewType::BIGINT64:
|
||||
return TypedArrayHelper::GetNotOnHeapHclassBigInt64Array(thread, objHclass);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TypedArrayHelper::GetNotOnHeapHclassBigUint64Array(thread, objHclass);
|
||||
}
|
||||
|
||||
uint32_t TypedArrayHelper::GetSizeFromType(const DataViewType arrayType)
|
||||
{
|
||||
if (arrayType == DataViewType::INT8 ||
|
||||
|
@ -297,7 +297,7 @@ JSTaggedValue TypedArrayHelper::CreateFromTypedArray(EcmaRuntimeCallInfo *argv,
|
||||
jsTypedArray->SetByteLength(byteLength);
|
||||
jsTypedArray->SetByteOffset(0);
|
||||
jsTypedArray->SetArrayLength(elementLength);
|
||||
jsTypedArray->SetIsOnHeap(false);
|
||||
ASSERT_PRINT(!JSHandle<TaggedObject>(obj)->GetClass()->IsOnHeapFromBitField(), "must be not on heap");
|
||||
// 23. Return O.
|
||||
return obj.GetTaggedValue();
|
||||
}
|
||||
@ -405,7 +405,7 @@ JSHandle<JSObject> TypedArrayHelper::AllocateTypedArray(JSThread *thread,
|
||||
jsTypedArray->SetByteLength(0);
|
||||
jsTypedArray->SetByteOffset(0);
|
||||
jsTypedArray->SetArrayLength(0);
|
||||
jsTypedArray->SetIsOnHeap(false);
|
||||
ASSERT_PRINT(!JSHandle<TaggedObject>(obj)->GetClass()->IsOnHeapFromBitField(), "must be not on heap");
|
||||
// 9. Return obj.
|
||||
return obj;
|
||||
}
|
||||
@ -454,14 +454,18 @@ JSHandle<JSObject> TypedArrayHelper::AllocateTypedArrayBuffer(JSThread *thread,
|
||||
uint32_t arrayLength = static_cast<uint32_t>(length);
|
||||
uint64_t byteLength = static_cast<uint64_t>(elementSize) * length;
|
||||
// 7. Let data be ? AllocateArrayBuffer(%ArrayBuffer%, byteLength).
|
||||
JSTaggedValue data;
|
||||
JSHandle<JSTaggedValue> data;
|
||||
if (byteLength > JSTypedArray::MAX_ONHEAP_LENGTH) {
|
||||
JSHandle<JSTaggedValue> constructor = thread->GetEcmaVM()->GetGlobalEnv()->GetArrayBufferFunction();
|
||||
data = BuiltinsArrayBuffer::AllocateArrayBuffer(thread, constructor, byteLength);
|
||||
JSTypedArray::Cast(*obj)->SetIsOnHeap(false);
|
||||
data = JSHandle<JSTaggedValue>(thread,
|
||||
BuiltinsArrayBuffer::AllocateArrayBuffer(thread, constructor, byteLength));
|
||||
ASSERT_PRINT(!JSHandle<TaggedObject>(obj)->GetClass()->IsOnHeapFromBitField(), "must be not on heap");
|
||||
} else {
|
||||
data = thread->GetEcmaVM()->GetFactory()->NewByteArray(arrayLength, elementSize).GetTaggedValue();
|
||||
JSTypedArray::Cast(*obj)->SetIsOnHeap(true);
|
||||
data = JSHandle<JSTaggedValue>(thread,
|
||||
thread->GetEcmaVM()->GetFactory()->NewByteArray(arrayLength, elementSize).GetTaggedValue());
|
||||
JSHandle<JSHClass> onHeapHclass = TypedArrayHelper::GetOnHeapHclassFromType(
|
||||
thread, JSHandle<JSTypedArray>(obj), arrayType);
|
||||
TaggedObject::Cast(*obj)->SynchronizedSetClass(thread, *onHeapHclass); // notOnHeap->onHeap
|
||||
}
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, exception);
|
||||
JSTypedArray *jsTypedArray = JSTypedArray::Cast(*obj);
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "ecmascript/js_dataview.h"
|
||||
#include "ecmascript/js_typed_array.h"
|
||||
|
||||
#include "ecmascript/builtins/builtins_typedarray.h"
|
||||
|
||||
namespace panda::ecmascript::base {
|
||||
enum ElementSize : uint8_t { ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8 };
|
||||
class TypedArrayHelper {
|
||||
@ -51,11 +53,25 @@ public:
|
||||
inline static JSHandle<JSTaggedValue> GetConstructor(JSThread *thread, const JSHandle<JSTaggedValue> &obj);
|
||||
inline static JSHandle<JSFunction> GetConstructorFromType(JSThread *thread,
|
||||
const DataViewType arrayType);
|
||||
inline static JSHandle<JSHClass> GetOnHeapHclassFromType(
|
||||
JSThread *thread, const JSHandle<JSTypedArray> &obj, const DataViewType arrayType);
|
||||
inline static JSHandle<JSHClass> GetNotOnHeapHclassFromType(
|
||||
JSThread *thread, const JSHandle<JSTypedArray> &obj, const DataViewType arrayType);
|
||||
inline static uint32_t GetSizeFromType(const DataViewType arrayType);
|
||||
static int32_t SortCompare(JSThread *thread, const JSHandle<JSTaggedValue> &callbackfnHandle,
|
||||
const JSHandle<JSTaggedValue> &buffer, const JSHandle<JSTaggedValue> &firstValue,
|
||||
const JSHandle<JSTaggedValue> &secondValue);
|
||||
|
||||
#define DEFINE_GET_ONHEAP_HCLASS_FROM_TYPE(Type) \
|
||||
inline static JSHandle<JSHClass> GetOnHeapHclass##Type(JSThread *thread, JSHClass* objHclass);
|
||||
TYPED_ARRAY_TYPES(DEFINE_GET_ONHEAP_HCLASS_FROM_TYPE)
|
||||
#undef DEFINE_GET_ONHEAP_HCLASS_FROM_TYPE
|
||||
|
||||
#define DEFINE_GET_NOT_ONHEAP_HCLASS_FROM_TYPE(Type) \
|
||||
inline static JSHandle<JSHClass> GetNotOnHeapHclass##Type(JSThread *thread, JSHClass* objHclass);
|
||||
TYPED_ARRAY_TYPES(DEFINE_GET_NOT_ONHEAP_HCLASS_FROM_TYPE)
|
||||
#undef DEFINE_GET_NOT_ONHEAP_HCLASS_FROM_TYPE
|
||||
|
||||
private:
|
||||
static JSTaggedValue CreateFromOrdinaryObject(EcmaRuntimeCallInfo *argv, const JSHandle<JSObject> &obj,
|
||||
const DataViewType arrayType);
|
||||
|
@ -2264,6 +2264,9 @@ void Builtins::Initialize##Type(const JSHandle<GlobalEnv> &env, const JSHandle<J
|
||||
/* %TypedArray%.prototype_or_hclass */ \
|
||||
JSHandle<JSHClass> arrFuncInstanceHClass = factory_->NewEcmaHClass( \
|
||||
panda::ecmascript::JSTypedArray::SIZE, JSType::JS_##TYPE, arrFuncPrototypeValue); \
|
||||
JSHandle<JSHClass> arrFuncInstanceHClassOnHeap = factory_->NewEcmaHClass( \
|
||||
panda::ecmascript::JSTypedArray::SIZE, JSType::JS_##TYPE, arrFuncPrototypeValue); \
|
||||
arrFuncInstanceHClassOnHeap->SetIsOnHeap(true); \
|
||||
arrFuncInstanceHClass->SetHasConstructor(false); \
|
||||
/* %TypedArray% = new Function() */ \
|
||||
JSHandle<JSFunction> arrayFunction = factory_->NewSpecificTypedArrayFunction( \
|
||||
@ -2275,6 +2278,8 @@ void Builtins::Initialize##Type(const JSHandle<GlobalEnv> &env, const JSHandle<J
|
||||
SetConstant(JSHandle<JSObject>(arrayFunction), "BYTES_PER_ELEMENT", JSTaggedValue(bytesPerElement)); \
|
||||
env->Set##Type##Function(thread_, arrayFunction); \
|
||||
env->Set##Type##FunctionPrototype(thread_, arrFuncPrototypeValue); \
|
||||
env->Set##Type##RootHclass(thread_, arrFuncInstanceHClass); \
|
||||
env->Set##Type##RootHclassOnHeap(thread_, arrFuncInstanceHClassOnHeap); \
|
||||
/* Initializes HClass record of %TypedArray% */ \
|
||||
thread_->SetInitialBuiltinHClass(BuiltinTypeId::TYPE, \
|
||||
arrayFunction->GetJSHClass(), \
|
||||
|
@ -18,6 +18,19 @@
|
||||
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
|
||||
#define TYPED_ARRAY_TYPES(V) \
|
||||
V(Int8Array) \
|
||||
V(Uint8Array) \
|
||||
V(Uint8ClampedArray) \
|
||||
V(Int16Array) \
|
||||
V(Uint16Array) \
|
||||
V(Int32Array) \
|
||||
V(Uint32Array) \
|
||||
V(Float32Array) \
|
||||
V(Float64Array) \
|
||||
V(BigInt64Array) \
|
||||
V(BigUint64Array)
|
||||
|
||||
// All types of %TypedArray%.
|
||||
// V(Type, TYPE, bytesPerElement) where JSType::JS_##TYPE is the type index.
|
||||
#define BUILTIN_TYPED_ARRAY_TYPES(V) \
|
||||
|
@ -688,6 +688,15 @@ GateRef CircuitBuilder::HasDeleteProperty(GateRef hClass)
|
||||
Int32(0));
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::IsOnHeap(GateRef hClass)
|
||||
{
|
||||
GateRef bitfield = Load(VariableType::INT32(), hClass, IntPtr(JSHClass::BIT_FIELD_OFFSET));
|
||||
return Int32NotEqual(
|
||||
Int32And(Int32LSR(bitfield, Int32(JSHClass::IsOnHeap::START_BIT)),
|
||||
Int32((1LU << JSHClass::IsOnHeap::SIZE) - 1)),
|
||||
Int32(0));
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::IsEcmaObject(GateRef obj)
|
||||
{
|
||||
Label entryPass(env_);
|
||||
|
@ -274,6 +274,7 @@ public:
|
||||
GateRef GetHasChanged(GateRef object);
|
||||
GateRef GetAccessorHasChanged(GateRef object);
|
||||
GateRef HasDeleteProperty(GateRef hClass);
|
||||
GateRef IsOnHeap(GateRef hClass);
|
||||
GateRef IsEcmaObject(GateRef obj);
|
||||
|
||||
// Set
|
||||
|
@ -1404,7 +1404,6 @@ GateRef NewObjectStubBuilder::NewTaggedSubArray(GateRef glue, GateRef srcTypedAr
|
||||
Store(VariableType::INT32(), glue, obj, IntPtr(JSTypedArray::BYTE_OFFSET_OFFSET), beginByteOffset);
|
||||
Store(VariableType::INT32(), glue, obj, IntPtr(JSTypedArray::ARRAY_LENGTH_OFFSET), newLength);
|
||||
Store(VariableType::INT32(), glue, obj, IntPtr(JSTypedArray::CONTENT_TYPE_OFFSET), contentType);
|
||||
Store(VariableType::BOOL(), glue, obj, IntPtr(JSTypedArray::ON_HEAP_OFFSET), Boolean(false));
|
||||
auto ret = *result;
|
||||
env->SubCfgExit();
|
||||
return ret;
|
||||
|
@ -368,7 +368,7 @@ void TypedHCRLowering::LowerTypedArrayCheck(GateRef gate)
|
||||
OnHeapMode onHeapMode = accessor.GetOnHeapMode();
|
||||
if (accessor.IsAccessElement() && !OnHeap::IsNone(onHeapMode)) {
|
||||
GateRef profilingOnHeap = builder_.Boolean(OnHeap::ToBoolean(onHeapMode));
|
||||
GateRef runtimeOnHeap = builder_.LoadConstOffset(VariableType::BOOL(), receiver, JSTypedArray::ON_HEAP_OFFSET);
|
||||
GateRef runtimeOnHeap = builder_.IsOnHeap(builder_.LoadHClass(receiver));
|
||||
GateRef onHeapCheck = builder_.Equal(profilingOnHeap, runtimeOnHeap);
|
||||
builder_.DeoptCheck(onHeapCheck, frameState, DeoptType::INCONSISTENTONHEAP1);
|
||||
}
|
||||
@ -1084,7 +1084,7 @@ GateRef TypedHCRLowering::BuildTypedArrayLoadElement(GateRef receiver, GateRef o
|
||||
DEFVALUE(data, (&builder_), VariableType::JS_ANY(), builder_.Undefined());
|
||||
DEFVALUE(result, (&builder_), type, builder_.Double(0));
|
||||
|
||||
GateRef isOnHeap = builder_.Load(VariableType::BOOL(), receiver, builder_.IntPtr(JSTypedArray::ON_HEAP_OFFSET));
|
||||
GateRef isOnHeap = builder_.IsOnHeap(builder_.LoadHClass(receiver));
|
||||
builder_.Branch(isOnHeap, isByteArray, isArrayBuffer);
|
||||
builder_.Bind(isByteArray);
|
||||
{
|
||||
@ -1251,7 +1251,7 @@ void TypedHCRLowering::BuildTypedArrayStoreElement(GateRef receiver, GateRef off
|
||||
{
|
||||
GateRef byteArrayOrArrayBuffer = builder_.LoadConstOffset(VariableType::JS_POINTER(), receiver,
|
||||
JSTypedArray::VIEWED_ARRAY_BUFFER_OFFSET);
|
||||
GateRef isOnHeap = builder_.Load(VariableType::BOOL(), receiver, builder_.IntPtr(JSTypedArray::ON_HEAP_OFFSET));
|
||||
GateRef isOnHeap = builder_.IsOnHeap(builder_.LoadHClass(receiver));
|
||||
DEFVALUE(data, (&builder_), VariableType::JS_ANY(), builder_.Undefined());
|
||||
builder_.Branch(isOnHeap, isByteArray, isArrayBuffer);
|
||||
builder_.Bind(isByteArray);
|
||||
|
@ -66,6 +66,28 @@
|
||||
V(JSTaggedValue, Float64ArrayFunctionPrototype, FLOAT64_ARRAY_FUNCTION_PROTOTYPE_INDEX) \
|
||||
V(JSTaggedValue, BigInt64ArrayFunctionPrototype, BIGINT64_ARRAY_FUNCTION_PROTOTYPE_INDEX) \
|
||||
V(JSTaggedValue, BigUint64ArrayFunctionPrototype, BIGUINT64_ARRAY_FUNCTION_PROTOTYPE_INDEX) \
|
||||
V(JSTaggedValue, Int8ArrayRootHclass, INT8_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Uint8ArrayRootHclass, UINT8_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Uint8ClampedArrayRootHclass, UINT8_CLAMPED_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Int16ArrayRootHclass, INT16_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Uint16ArrayRootHclass, UINT16_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Int32ArrayRootHclass, INT32_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Uint32ArrayRootHclass, UINT32_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Float32ArrayRootHclass, FLOAT32_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Float64ArrayRootHclass, FLOAT64_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, BigInt64ArrayRootHclass, BIGINT64_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, BigUint64ArrayRootHclass, BIGUINT64_ARRAY_ROOT_HCLASS_INDEX) \
|
||||
V(JSTaggedValue, Int8ArrayRootHclassOnHeap, INT8_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Uint8ArrayRootHclassOnHeap, UINT8_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Uint8ClampedArrayRootHclassOnHeap, UINT8_CLAMPED_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Int16ArrayRootHclassOnHeap, INT16_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Uint16ArrayRootHclassOnHeap, UINT16_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Int32ArrayRootHclassOnHeap, INT32_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Uint32ArrayRootHclassOnHeap, UINT32_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Float32ArrayRootHclassOnHeap, FLOAT32_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, Float64ArrayRootHclassOnHeap, FLOAT64_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, BigInt64ArrayRootHclassOnHeap, BIGINT64_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, BigUint64ArrayRootHclassOnHeap, BIGUINT64_ARRAY_ROOT_HCLASS_ON_HEAP_INDEX) \
|
||||
V(JSTaggedValue, ArrayBufferFunction, ARRAY_BUFFER_FUNCTION_INDEX) \
|
||||
V(JSTaggedValue, SharedArrayBufferFunction, SHAREDARRAY_BUFFER_FUNCTION_INDEX) \
|
||||
V(JSTaggedValue, ArrayProtoValuesFunction, ARRAY_PROTO_VALUES_FUNCTION_INDEX) \
|
||||
|
@ -223,7 +223,7 @@ public:
|
||||
{
|
||||
uint32_t handler = 0;
|
||||
KindBit::Set<uint32_t>(HandlerKind::TYPED_ARRAY, &handler);
|
||||
IsOnHeapBit::Set<uint32_t>(typedArray->GetIsOnHeap(), &handler);
|
||||
IsOnHeapBit::Set<uint32_t>(JSHandle<TaggedObject>(typedArray)->GetClass()->IsOnHeapFromBitField(), &handler);
|
||||
return JSHandle<JSTaggedValue>(thread, JSTaggedValue(handler));
|
||||
}
|
||||
};
|
||||
|
@ -363,7 +363,8 @@ public:
|
||||
using IsTSBit = IsNativeBindingObjectBit::NextFlag; // 24
|
||||
using LevelBit = IsTSBit::NextField<uint32_t, LEVEL_BTTFIELD_NUM>; // 25-29
|
||||
using IsJSFunctionBit = LevelBit::NextFlag; // 30
|
||||
using BitFieldLastBit = IsJSFunctionBit;
|
||||
using IsOnHeap = IsJSFunctionBit::NextFlag; // 31
|
||||
using BitFieldLastBit = IsOnHeap;
|
||||
static_assert(BitFieldLastBit::START_BIT + BitFieldLastBit::SIZE <= sizeof(uint32_t) * BITS_PER_BYTE, "Invalid");
|
||||
|
||||
static constexpr int DEFAULT_CAPACITY_OF_IN_OBJECTS = 4;
|
||||
@ -538,6 +539,11 @@ public:
|
||||
IsJSFunctionBit::Set<uint32_t>(flag, GetBitFieldAddr());
|
||||
}
|
||||
|
||||
inline void SetIsOnHeap(bool flag) const
|
||||
{
|
||||
IsOnHeap::Set<uint32_t>(flag, GetBitFieldAddr());
|
||||
}
|
||||
|
||||
inline bool IsJSObject() const
|
||||
{
|
||||
JSType jsType = GetObjectType();
|
||||
@ -1326,6 +1332,12 @@ public:
|
||||
return IsJSFunctionBit::Decode(bits);
|
||||
}
|
||||
|
||||
inline bool IsOnHeapFromBitField() const
|
||||
{
|
||||
uint32_t bits = GetBitField();
|
||||
return IsOnHeap::Decode(bits);
|
||||
}
|
||||
|
||||
inline bool IsGeneratorFunction() const
|
||||
{
|
||||
return GetObjectType() == JSType::JS_GENERATOR_FUNCTION;
|
||||
|
@ -731,7 +731,11 @@ JSTaggedValue JSTypedArray::GetOffHeapBuffer(JSThread *thread, JSHandle<JSTypedA
|
||||
JSArrayBuffer::CopyDataPointBytes(toBuf, fromBuf, 0, length);
|
||||
}
|
||||
typedArray->SetViewedArrayBufferOrByteArray(thread, arrayBuffer.GetTaggedValue());
|
||||
typedArray->SetIsOnHeap(false);
|
||||
JSHandle<JSTaggedValue> typeName(thread, typedArray->GetTypedArrayName());
|
||||
DataViewType arrayType = JSTypedArray::GetTypeFromName(thread, typeName);
|
||||
JSHandle<JSHClass> notOnHeapHclass = TypedArrayHelper::GetNotOnHeapHclassFromType(
|
||||
thread, typedArray, arrayType);
|
||||
TaggedObject::Cast(*typedArray)->SynchronizedSetClass(thread, *notOnHeapHclass); // onHeap->notOnHeap
|
||||
|
||||
return arrayBuffer.GetTaggedValue();
|
||||
}
|
||||
|
@ -115,8 +115,7 @@ public:
|
||||
ACCESSORS_PRIMITIVE_FIELD(ByteLength, uint32_t, BYTE_LENGTH_OFFSET, BYTE_OFFSET_OFFSET)
|
||||
ACCESSORS_PRIMITIVE_FIELD(ByteOffset, uint32_t, BYTE_OFFSET_OFFSET, ARRAY_LENGTH_OFFSET)
|
||||
ACCESSORS_PRIMITIVE_FIELD(ArrayLength, uint32_t, ARRAY_LENGTH_OFFSET, CONTENT_TYPE_OFFSET)
|
||||
ACCESSORS_PRIMITIVE_FIELD(ContentType, ContentType, CONTENT_TYPE_OFFSET, ON_HEAP_OFFSET)
|
||||
ACCESSORS_PRIMITIVE_FIELD(IsOnHeap, bool, ON_HEAP_OFFSET, LAST_OFFSET)
|
||||
ACCESSORS_PRIMITIVE_FIELD(ContentType, ContentType, CONTENT_TYPE_OFFSET, LAST_OFFSET)
|
||||
|
||||
DEFINE_ALIGN_SIZE(LAST_OFFSET);
|
||||
static const uint32_t MAX_TYPED_ARRAY_INDEX = MAX_ELEMENT_INDEX;
|
||||
|
Loading…
Reference in New Issue
Block a user