mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 12:10:47 +00:00
f02aef4974
With the enhancement of the ability of PGO types, TSManager and TSTypes are no longer needed in the AOT compilation phase. So let's remove them. Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9GG52 Tests: ark_js_host_unittest, AOT pog test262 AOT workload Signed-off-by: huoqingyi <huoqingyi@huawei.com> Change-Id: I381017de86c3f8f74ed84edd848b986bcf85a4b5
96 lines
2.6 KiB
C++
96 lines
2.6 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef ECMASCRIPT_VTABLE_H
|
|
#define ECMASCRIPT_VTABLE_H
|
|
|
|
#include "ecmascript/weak_vector.h"
|
|
|
|
namespace panda::ecmascript {
|
|
class VTable : public TaggedArray {
|
|
public:
|
|
static constexpr uint32_t DEFAULT_SUPERS_CAPACITY = 4;
|
|
|
|
enum TupleItem {
|
|
NAME = 0,
|
|
TYPE,
|
|
OWNER,
|
|
OFFSET,
|
|
|
|
ITEM_NUM,
|
|
ITEM_FIRST = NAME,
|
|
ITEM_LAST = OFFSET,
|
|
};
|
|
|
|
class Tuple {
|
|
public:
|
|
JSHandle<JSTaggedValue> GetItem(TupleItem item) const
|
|
{
|
|
return items_[item];
|
|
}
|
|
private:
|
|
// only allow VTable to create a instance of Tuple
|
|
explicit Tuple(const CVector<JSHandle<JSTaggedValue>> &vec) : items_(std::move(vec)) {}
|
|
CVector<JSHandle<JSTaggedValue>> items_;
|
|
|
|
friend class VTable;
|
|
};
|
|
|
|
enum TypeKind {
|
|
FUNCTION = 0,
|
|
ACCESSOR,
|
|
NORMAL
|
|
};
|
|
|
|
static constexpr uint32_t TUPLE_SIZE = 4;
|
|
|
|
CAST_CHECK(VTable, IsTaggedArray);
|
|
|
|
static Tuple CreateTuple(const JSThread *thread, JSTaggedValue phc,
|
|
const JSHandle<JSTaggedValue> &owner, uint32_t propIndex);
|
|
|
|
static JSHandle<VTable> Copy(const JSThread *thread, const JSHandle<VTable> &vtable);
|
|
|
|
uint32_t GetNumberOfTuples() const
|
|
{
|
|
return GetLength() / TUPLE_SIZE;
|
|
}
|
|
|
|
JSTaggedValue GetTupleItem(uint32_t tupleIdx, TupleItem kind) const
|
|
{
|
|
return Get(tupleIdx * TUPLE_SIZE + kind);
|
|
}
|
|
|
|
bool IsAccessor(uint32_t tupleIdx) const
|
|
{
|
|
TypeKind type = static_cast<TypeKind>(GetTupleItem(tupleIdx, TupleItem::TYPE).GetInt());
|
|
return type == TypeKind::ACCESSOR;
|
|
}
|
|
|
|
Tuple GetTuple(const JSThread *thread, uint32_t tupleIdx) const;
|
|
|
|
void SetByIndex(const JSThread *thread, uint32_t idx, const VTable::Tuple &tuple);
|
|
|
|
void Trim(const JSThread *thread, uint32_t newLength);
|
|
|
|
int GetTupleIndexByName(JSTaggedValue val) const;
|
|
|
|
bool Find(JSTaggedValue val) const;
|
|
|
|
DECL_DUMP()
|
|
};
|
|
} // namespace panda::ecmascript
|
|
|
|
#endif // ECMASCRIPT_VTABLE_H
|