mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!10240 SharedBitvector part2
Merge pull request !10240 from chengyuli/SharedBitVector
This commit is contained in:
commit
264dc89213
@ -51,7 +51,7 @@ JSTaggedValue ContainersBitVector::BitVectorConstructor(EcmaRuntimeCallInfo* arg
|
||||
|
||||
auto* newBitSetVector = new std::vector<std::bitset<JSAPIBitVector::BIT_SET_LENGTH>>();
|
||||
if (!length->IsZero()) {
|
||||
int32_t capacity = (length->GetInt() / JSAPIBitVector::BIT_SET_LENGTH) + 1;
|
||||
int32_t capacity = std::max(0, (length->GetInt() / JSAPIBitVector::BIT_SET_LENGTH) + 1);
|
||||
|
||||
std::bitset<JSAPIBitVector::BIT_SET_LENGTH> initBitSet;
|
||||
newBitSetVector->resize(capacity, initBitSet);
|
||||
@ -60,7 +60,7 @@ JSTaggedValue ContainersBitVector::BitVectorConstructor(EcmaRuntimeCallInfo* arg
|
||||
ContainersBitVector::FreeBitsetVectorPointer,
|
||||
newBitSetVector);
|
||||
obj->SetNativePointer(thread, pointer);
|
||||
obj->SetLength(length->GetInt());
|
||||
obj->SetLength(std::max(0, length->GetInt()));
|
||||
return obj.GetTaggedValue();
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ JSTaggedValue JSAPIBitVector::FlipBitByIndex(JSThread* thread, const JSHandle<JS
|
||||
{
|
||||
[[maybe_unused]] ConcurrentApiScope<JSAPIBitVector, ModType::WRITE> scope(thread,
|
||||
JSHandle<JSTaggedValue>::Cast(bitVector));
|
||||
if (index >= bitVector->GetLength()) {
|
||||
if (index >= bitVector->GetLength() || index < 0) {
|
||||
std::ostringstream oss;
|
||||
oss << "The value of \"index\" is out of range. It must be >= 0 && <= " << (bitVector->GetLength() - 1)
|
||||
<< ". Received value is: " << index;
|
||||
|
@ -80,7 +80,9 @@ public:
|
||||
ACCESSORS_PRIMITIVE_FIELD(Length, int32_t, LENGTH_OFFSET, MOD_RECORD_OFFSET);
|
||||
ACCESSORS_SYNCHRONIZED_PRIMITIVE_FIELD(ModRecord, uint32_t, MOD_RECORD_OFFSET, LAST_OFFSET);
|
||||
DEFINE_ALIGN_SIZE(LAST_OFFSET);
|
||||
|
||||
|
||||
static constexpr uint32_t MAX_INLINE = PropertyAttributes::MAX_FAST_PROPS_CAPACITY -
|
||||
SIZE / JSTaggedValue::TaggedTypeSize() + 1;
|
||||
DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, NATIVE_POINTER_OFFSET, LENGTH_OFFSET);
|
||||
DECL_DUMP()
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "ecmascript/jspandafile/class_info_extractor.h"
|
||||
|
||||
#include "ecmascript/js_api/js_api_bitvector.h"
|
||||
#include "ecmascript/js_object-inl.h"
|
||||
#include "ecmascript/jspandafile/program_object.h"
|
||||
#include "ecmascript/shared_objects/js_sendable_arraybuffer.h"
|
||||
@ -1179,6 +1180,8 @@ std::pair<uint32_t, uint32_t> SendableClassDefiner::GetSizeAndMaxInlineByType(JS
|
||||
return { JSSharedSet::SIZE, JSSharedSet::MAX_INLINE };
|
||||
case JSType::JS_SENDABLE_ARRAY_BUFFER:
|
||||
return { JSSendableArrayBuffer::SIZE, JSSendableArrayBuffer::MAX_INLINE };
|
||||
case JSType::JS_API_BITVECTOR:
|
||||
return { JSAPIBitVector::SIZE, JSAPIBitVector::MAX_INLINE };
|
||||
default:
|
||||
if (JSType::JS_SHARED_TYPED_ARRAY_FIRST < type && type <= JSType::JS_SHARED_TYPED_ARRAY_LAST) {
|
||||
return { JSSharedTypedArray::SIZE, JSSharedTypedArray::MAX_INLINE };
|
||||
|
@ -602,6 +602,7 @@ public:
|
||||
bool IsTreeMap(const EcmaVM *vm);
|
||||
bool IsTreeSet(const EcmaVM *vm);
|
||||
bool IsVector(const EcmaVM *vm);
|
||||
bool IsBitVector(const EcmaVM *vm);
|
||||
bool IsSendableObject(const EcmaVM *vm);
|
||||
bool IsJSShared(const EcmaVM *vm);
|
||||
bool IsSharedArray(const EcmaVM *vm);
|
||||
|
@ -1004,6 +1004,12 @@ bool JSValueRef::IsVector(const EcmaVM *vm)
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIVector();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsBitVector(const EcmaVM *vm)
|
||||
{
|
||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||
return JSNApiHelper::ToJSTaggedValue(this).IsJSAPIBitVector();
|
||||
}
|
||||
|
||||
bool JSValueRef::IsSendableObject(const EcmaVM *vm)
|
||||
{
|
||||
ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
|
||||
|
Loading…
Reference in New Issue
Block a user