!5019 Fix camera crash

Merge pull request !5019 from herongpeng/master
This commit is contained in:
openharmony_ci 2023-10-24 14:16:03 +00:00 committed by Gitee
commit c77b9493bf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 87 additions and 8 deletions

View File

@ -90,6 +90,11 @@ void GlobalEnvConstants::InitRootsClass(JSThread *thread, JSHClass *hClass)
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
SetConstant(ConstantIndex::HCLASS_CLASS_INDEX, JSTaggedValue(hClass));
// To reverse the order, the hclass of string needs to load default supers
SetConstant(ConstantIndex::ARRAY_CLASS_INDEX,
factory->NewEcmaReadOnlyHClass(hClass, 0, JSType::TAGGED_ARRAY));
SetConstant(ConstantIndex::DEFAULT_SUPERS_INDEX,
WeakVector::Create(thread, SubtypingOperator::DEFAULT_SUPERS_CAPACITY, MemSpaceType::NON_MOVABLE));
SetConstant(ConstantIndex::FREE_OBJECT_WITH_NONE_FIELD_CLASS_INDEX,
factory->NewEcmaReadOnlyHClass(hClass, FreeObject::NEXT_OFFSET, JSType::FREE_OBJECT_WITH_NONE_FIELD));
SetConstant(ConstantIndex::FREE_OBJECT_WITH_ONE_FIELD_CLASS_INDEX,
@ -102,8 +107,6 @@ void GlobalEnvConstants::InitRootsClass(JSThread *thread, JSHClass *hClass)
SetConstant(ConstantIndex::CONSTANT_STRING_CLASS_INDEX,
factory->NewEcmaReadOnlyHClass(hClass, 0, JSType::CONSTANT_STRING));
SetConstant(ConstantIndex::TREE_STRING_CLASS_INDEX, factory->NewEcmaReadOnlyHClass(hClass, 0, JSType::TREE_STRING));
SetConstant(ConstantIndex::ARRAY_CLASS_INDEX,
factory->NewEcmaReadOnlyHClass(hClass, 0, JSType::TAGGED_ARRAY));
SetConstant(ConstantIndex::BYTE_ARRAY_CLASS_INDEX,
factory->NewEcmaReadOnlyHClass(hClass, 0, JSType::BYTE_ARRAY));
SetConstant(ConstantIndex::CONSTANT_POOL_CLASS_INDEX,
@ -302,8 +305,6 @@ void GlobalEnvConstants::InitGlobalConstantSpecial(JSThread *thread)
auto vm = thread->GetEcmaVM();
SetConstant(ConstantIndex::EMPTY_STRING_OBJECT_INDEX, JSTaggedValue(EcmaStringAccessor::CreateEmptyString(vm)));
SetConstant(ConstantIndex::EMPTY_ARRAY_OBJECT_INDEX, factory->NewEmptyArray());
SetConstant(ConstantIndex::DEFAULT_SUPERS_INDEX,
WeakVector::Create(thread, SubtypingOperator::DEFAULT_SUPERS_CAPACITY));
SetConstant(ConstantIndex::EMPTY_LAYOUT_INFO_OBJECT_INDEX, factory->CreateLayoutInfo(0));
SetConstant(ConstantIndex::EMPTY_TAGGED_QUEUE_OBJECT_INDEX, factory->NewTaggedQueue(0));
}

View File

@ -164,7 +164,8 @@ void JSHClass::Initialize(const JSThread *thread, uint32_t size, JSType type, ui
void JSHClass::InitTSInheritInfo(const JSThread *thread)
{
// Supers and Level are used to record the relationship between TSHClass.
if (IsECMAObject()) {
if (ShouldSetDefaultSupers()) {
ASSERT(thread->GlobalConstants()->GetDefaultSupers().IsTaggedArray());
SetSupers(thread, thread->GlobalConstants()->GetDefaultSupers());
} else {
SetSupers(thread, JSTaggedValue::Undefined());

View File

@ -540,6 +540,11 @@ public:
return (JSType::ECMA_OBJECT_FIRST <= jsType && jsType <= JSType::ECMA_OBJECT_LAST);
}
inline bool ShouldSetDefaultSupers() const
{
return IsECMAObject() || IsStringOrSymbol();
}
inline bool IsRealm() const
{
return GetObjectType() == JSType::JS_REALM;

View File

@ -18,12 +18,17 @@
#include "ecmascript/object_factory.h"
namespace panda::ecmascript {
JSHandle<WeakVector> WeakVector::Create(const JSThread *thread, uint32_t capacity)
JSHandle<WeakVector> WeakVector::Create(const JSThread *thread, uint32_t capacity, MemSpaceType type)
{
ASSERT(capacity < MAX_VECTOR_INDEX);
uint32_t length = VectorToArrayIndex(capacity);
JSHandle<WeakVector> vector = JSHandle<WeakVector>(thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length));
JSHandle<WeakVector> vector;
if (type == MemSpaceType::NON_MOVABLE) {
vector = JSHandle<WeakVector>(thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length, JSTaggedValue::Hole(), true));
} else {
vector = JSHandle<WeakVector>(thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length));
}
vector->SetEnd(thread, 0);
return vector;

View File

@ -35,7 +35,7 @@ public:
static constexpr uint32_t DEFAULT_CAPACITY = 4;
static constexpr uint32_t DEFAULT_GROW_SIZE = 4;
static JSHandle<WeakVector> Create(const JSThread *thread, uint32_t capacity = DEFAULT_CAPACITY);
static JSHandle<WeakVector> Create(const JSThread *thread, uint32_t capacity = DEFAULT_CAPACITY, MemSpaceType type = MemSpaceType::SEMI_SPACE);
static JSHandle<WeakVector> Grow(const JSThread *thread, const JSHandle<WeakVector> &old, uint32_t newCapacity);
static JSHandle<WeakVector> Append(const JSThread *thread, const JSHandle<WeakVector> &vec,
const JSHandle<JSTaggedValue> &value, ElementType type = ElementType::NORMAL);

View File

@ -74,6 +74,7 @@ group("ark_aot_ts_test") {
"createobjectwithexcludedkeys",
"createregexpwithliteral",
"dec",
"default_supers",
"defineasyncfunc",
"defineclasswithbuffer",
"defineclass",

View File

@ -0,0 +1,17 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("default_supers") {
deps = []
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class A {
a:number = 1;
}
class B {
foo(a : A) {
print(a.a);
}
}
let b = new B();
let a = new A();
print(1);
a = "aaaaa";
b.foo(a);
print(2);
a = Symbol();
b.foo(a);
print(3);

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
1
undefined
2
undefined
3