mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-17 02:10:00 +00:00
[Bug]: Bugfix do forin with nativepointer
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB2SZ0 Signed-off-by: hecunmao <hecunmao@huawei.com> Change-Id: I8ebef8c2378eede93d85d96b5abb25032404e704
This commit is contained in:
parent
421fb045ea
commit
2fd7636b6f
@ -1214,6 +1214,7 @@ GateRef NewObjectStubBuilder::EnumerateObjectProperties(GateRef glue, GateRef ob
|
||||
Label empty(env);
|
||||
Label tryGetEnumCache(env);
|
||||
Label cacheHit(env);
|
||||
Label checkNativePointer(env);
|
||||
BRANCH(TaggedIsString(obj), &isString, &isNotString);
|
||||
Bind(&isString);
|
||||
{
|
||||
@ -1226,7 +1227,9 @@ GateRef NewObjectStubBuilder::EnumerateObjectProperties(GateRef glue, GateRef ob
|
||||
Jump(&afterObjectTransform);
|
||||
}
|
||||
Bind(&afterObjectTransform);
|
||||
BRANCH(TaggedIsUndefinedOrNull(*object), &empty, &tryGetEnumCache);
|
||||
BRANCH(TaggedIsUndefinedOrNull(*object), &empty, &checkNativePointer);
|
||||
Bind(&checkNativePointer);
|
||||
BRANCH(IsNativePointer(*object), &empty, &tryGetEnumCache);
|
||||
Bind(&tryGetEnumCache);
|
||||
GateRef enumCache = TryGetEnumCache(glue, *object);
|
||||
BRANCH(TaggedIsUndefined(enumCache), &slowpath, &cacheHit);
|
||||
|
@ -2627,7 +2627,7 @@ JSHandle<JSForInIterator> JSObject::EnumerateObjectProperties(JSThread *thread,
|
||||
|
||||
JSMutableHandle<JSTaggedValue> keys(thread, JSTaggedValue::Undefined());
|
||||
JSMutableHandle<JSTaggedValue> cachedHclass(thread, JSTaggedValue::Undefined());
|
||||
if (object->IsNull() || object->IsUndefined()) {
|
||||
if (object->IsNull() || object->IsUndefined() || object->IsJSNativePointer()) {
|
||||
JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
keys.Update(factory->EmptyArray());
|
||||
|
@ -62,4 +62,14 @@ HWTEST_F_L0(JSForinIteratorTest, Create)
|
||||
JSTaggedValue n4 = JSForInIterator::NextInternal(thread, it);
|
||||
EXPECT_EQ(n4, JSTaggedValue::Undefined());
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSForinIteratorTest, ForinNativePointer)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
int pointArr[10];
|
||||
auto *nativePointer = pointArr;
|
||||
JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(nativePointer);
|
||||
JSHandle<JSForInIterator> it = JSObject::EnumerateObjectProperties(thread, JSHandle<JSTaggedValue>(pointer));
|
||||
EXPECT_EQ(it->GetLength(), 0);
|
||||
}
|
||||
} // namespace panda::test
|
||||
|
Loading…
x
Reference in New Issue
Block a user