mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
getproperty put in slow path
Signed-off-by: chenhantao <chenhantao3@huawei.com> Change-Id: I6b040060100dc81d4d3f67c4bf0f6a375e574800
This commit is contained in:
parent
80d4e62825
commit
4bffa48bd9
@ -24,6 +24,7 @@
|
|||||||
#include "ecmascript/ecma_macros.h"
|
#include "ecmascript/ecma_macros.h"
|
||||||
#include "ecmascript/ecma_vm.h"
|
#include "ecmascript/ecma_vm.h"
|
||||||
#include "ecmascript/global_env.h"
|
#include "ecmascript/global_env.h"
|
||||||
|
#include "ecmascript/ic/proto_change_details.h"
|
||||||
#include "ecmascript/js_array_iterator.h"
|
#include "ecmascript/js_array_iterator.h"
|
||||||
#include "ecmascript/js_arraybuffer.h"
|
#include "ecmascript/js_arraybuffer.h"
|
||||||
#include "ecmascript/js_hclass.h"
|
#include "ecmascript/js_hclass.h"
|
||||||
@ -300,5 +301,16 @@ uint32_t TypedArrayHelper::GetSizeFromType(const DataViewType arrayType)
|
|||||||
|
|
||||||
return ElementSize::EIGHT;
|
return ElementSize::EIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TypedArrayHelper::IsAccessorHasChanged(const JSHandle<JSTaggedValue> &obj)
|
||||||
|
{
|
||||||
|
if (obj->IsHeapObject()) {
|
||||||
|
JSTaggedValue markerValue = obj->GetTaggedObject()->GetClass()->GetProtoChangeMarker();
|
||||||
|
if (markerValue.IsProtoChangeMarker()) {
|
||||||
|
return ProtoChangeMarker::Cast(markerValue.GetTaggedObject())->GetAccessorHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} // namespace panda::ecmascript::base
|
} // namespace panda::ecmascript::base
|
||||||
#endif // ECMASCRIPT_BASE_TYPED_ARRAY_HELPER_INL_H
|
#endif // ECMASCRIPT_BASE_TYPED_ARRAY_HELPER_INL_H
|
||||||
|
@ -502,18 +502,13 @@ JSHandle<JSObject> TypedArrayHelper::TypedArraySpeciesCreate(JSThread *thread, c
|
|||||||
JSHandle<JSTaggedValue> defaultConstructor =
|
JSHandle<JSTaggedValue> defaultConstructor =
|
||||||
TypedArrayHelper::GetConstructor(thread, JSHandle<JSTaggedValue>(obj));
|
TypedArrayHelper::GetConstructor(thread, JSHandle<JSTaggedValue>(obj));
|
||||||
JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
|
JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
|
||||||
JSHandle<JSTaggedValue> key = thread->GlobalConstants()->GetHandledConstructorString();
|
|
||||||
JSHandle<JSTaggedValue> objConstructor =
|
|
||||||
JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(obj), key, JSHandle<JSTaggedValue>(obj)).GetValue();
|
|
||||||
JSHandle<JSObject> result;
|
JSHandle<JSObject> result;
|
||||||
JSHandle<JSTaggedValue> proto(thread, obj->GetJSHClass()->GetPrototype());
|
JSHandle<JSTaggedValue> proto(thread, obj->GetJSHClass()->GetPrototype());
|
||||||
bool ctrVali = objConstructor->IsUndefined();
|
|
||||||
bool isJSTypedArr = proto->IsJSTypedArray();
|
|
||||||
bool isCtrUnchanged = PropertyDetector::IsTypedArraySpeciesProtectDetectorValid(env) &&
|
bool isCtrUnchanged = PropertyDetector::IsTypedArraySpeciesProtectDetectorValid(env) &&
|
||||||
!objConstructor->IsClassConstructor();
|
!TypedArrayHelper::IsAccessorHasChanged(proto) &&
|
||||||
|
!obj->GetJSHClass()->HasConstructor();
|
||||||
bool isCtrBylen = buffHandle->IsInt();
|
bool isCtrBylen = buffHandle->IsInt();
|
||||||
bool isCtrObj = objConstructor->IsECMAObject();
|
if (isCtrUnchanged && isCtrBylen) {
|
||||||
if (ctrVali || (isJSTypedArr && isCtrUnchanged && isCtrBylen && isCtrObj)) {
|
|
||||||
JSType type = obj->GetJSHClass()->GetObjectType();
|
JSType type = obj->GetJSHClass()->GetObjectType();
|
||||||
DataViewType arrayType = GetType(type);
|
DataViewType arrayType = GetType(type);
|
||||||
uint32_t length = buffHandle->GetInt();
|
uint32_t length = buffHandle->GetInt();
|
||||||
@ -523,6 +518,9 @@ JSHandle<JSObject> TypedArrayHelper::TypedArraySpeciesCreate(JSThread *thread, c
|
|||||||
defaultConstructor, length, arrayType);
|
defaultConstructor, length, arrayType);
|
||||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSHandle<JSObject>(thread, JSTaggedValue::Exception()));
|
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSHandle<JSObject>(thread, JSTaggedValue::Exception()));
|
||||||
} else {
|
} else {
|
||||||
|
JSHandle<JSTaggedValue> key = thread->GlobalConstants()->GetHandledConstructorString();
|
||||||
|
JSHandle<JSTaggedValue> objConstructor =
|
||||||
|
JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(obj), key, JSHandle<JSTaggedValue>(obj)).GetValue();
|
||||||
// 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
|
// 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
|
||||||
JSHandle<JSTaggedValue> thisConstructor =
|
JSHandle<JSTaggedValue> thisConstructor =
|
||||||
JSObject::SlowSpeciesConstructor(thread, objConstructor, defaultConstructor);
|
JSObject::SlowSpeciesConstructor(thread, objConstructor, defaultConstructor);
|
||||||
|
@ -60,6 +60,7 @@ public:
|
|||||||
inline static JSHandle<JSHClass> GetNotOnHeapHclassFromType(
|
inline static JSHandle<JSHClass> GetNotOnHeapHclassFromType(
|
||||||
JSThread *thread, const JSHandle<JSTypedArray> &obj, const DataViewType arrayType);
|
JSThread *thread, const JSHandle<JSTypedArray> &obj, const DataViewType arrayType);
|
||||||
inline static uint32_t GetSizeFromType(const DataViewType arrayType);
|
inline static uint32_t GetSizeFromType(const DataViewType arrayType);
|
||||||
|
inline static bool IsAccessorHasChanged(const JSHandle<JSTaggedValue> &obj);
|
||||||
static int32_t SortCompare(JSThread *thread, const JSHandle<JSTaggedValue> &callbackfnHandle,
|
static int32_t SortCompare(JSThread *thread, const JSHandle<JSTaggedValue> &callbackfnHandle,
|
||||||
const JSHandle<JSTaggedValue> &buffer, const JSHandle<JSTaggedValue> &firstValue,
|
const JSHandle<JSTaggedValue> &buffer, const JSHandle<JSTaggedValue> &firstValue,
|
||||||
const JSHandle<JSTaggedValue> &secondValue);
|
const JSHandle<JSTaggedValue> &secondValue);
|
||||||
|
@ -1420,7 +1420,12 @@ JSTaggedValue BuiltinsTypedArray::Slice(EcmaRuntimeCallInfo *argv)
|
|||||||
// iv. Increase targetByteIndex by 1.
|
// iv. Increase targetByteIndex by 1.
|
||||||
uint8_t *srcBuf = (uint8_t *)BuiltinsArrayBuffer::GetDataPointFromBuffer(srcBuffer, srcByteIndex);
|
uint8_t *srcBuf = (uint8_t *)BuiltinsArrayBuffer::GetDataPointFromBuffer(srcBuffer, srcByteIndex);
|
||||||
uint8_t *targetBuf = (uint8_t *)BuiltinsArrayBuffer::GetDataPointFromBuffer(targetBuffer, targetByteIndex);
|
uint8_t *targetBuf = (uint8_t *)BuiltinsArrayBuffer::GetDataPointFromBuffer(targetBuffer, targetByteIndex);
|
||||||
while (count--) {
|
if (srcBuffer != targetBuffer && memmove_s(
|
||||||
|
targetBuf, elementSize * count, srcBuf, elementSize * count) != EOK) {
|
||||||
|
LOG_FULL(FATAL) << "memcpy_s failed";
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
while (srcBuffer == targetBuffer && count--) {
|
||||||
if (memcpy_s(targetBuf, elementSize, srcBuf, elementSize) != EOK) {
|
if (memcpy_s(targetBuf, elementSize, srcBuf, elementSize) != EOK) {
|
||||||
LOG_FULL(FATAL) << "memcpy_s failed";
|
LOG_FULL(FATAL) << "memcpy_s failed";
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -824,6 +824,10 @@ bool ObjectOperator::WriteDataProperty(const JSHandle<JSObject> &receiver, const
|
|||||||
bool success = UpdateValueAndDetails(receiver, value, attr, attrChanged);
|
bool success = UpdateValueAndDetails(receiver, value, attr, attrChanged);
|
||||||
if (success) {
|
if (success) {
|
||||||
JSHandle<JSObject> obj(receiver);
|
JSHandle<JSObject> obj(receiver);
|
||||||
|
if (obj->GetJSHClass()->IsPrototype()) {
|
||||||
|
JSHandle<ProtoChangeMarker> markerHandle = thread_->GetEcmaVM()->GetFactory()->NewProtoChangeMarker();
|
||||||
|
obj->GetJSHClass()->SetProtoChangeMarker(thread_, markerHandle.GetTaggedValue());
|
||||||
|
}
|
||||||
JSHClass::NotifyAccessorChanged(thread_, JSHandle<JSHClass>(thread_, obj->GetJSHClass()));
|
JSHClass::NotifyAccessorChanged(thread_, JSHandle<JSHClass>(thread_, obj->GetJSHClass()));
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
@ -21,3 +21,4 @@
|
|||||||
7
|
7
|
||||||
8
|
8
|
||||||
0
|
0
|
||||||
|
1
|
||||||
|
@ -42,4 +42,14 @@ class Array1 extends Int8Array {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const a = new Array1(1, 2, 3);
|
const a = new Array1(1, 2, 3);
|
||||||
print(a.slice(0, 1));
|
print(a.slice(0, 1));
|
||||||
|
|
||||||
|
var sample = new BigInt64Array([40n, 41n, 42n, 43n]);
|
||||||
|
var calls = 0;
|
||||||
|
Object.defineProperty(BigInt64Array.prototype, "constructor", {
|
||||||
|
get: function() {
|
||||||
|
calls++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sample.slice();
|
||||||
|
print(calls);
|
Loading…
Reference in New Issue
Block a user