当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
57 Star 30 Fork 160

OpenHarmony-SIG/arkcompiler_runtime_core
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
code_data_accessor.h 3.91 KB
一键复制 编辑 原始数据 按行查看 历史
/**
* Copyright (c) 2021-2022 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 LIBPANDAFILE_CODE_DATA_ACCESSOR_H_
#define LIBPANDAFILE_CODE_DATA_ACCESSOR_H_
#include "file-inl.h"
namespace panda::panda_file {
class CodeDataAccessor {
public:
class TryBlock {
public:
explicit TryBlock(Span<const uint8_t> data);
~TryBlock() = default;
NO_COPY_SEMANTIC(TryBlock);
NO_MOVE_SEMANTIC(TryBlock);
uint32_t GetStartPc() const
{
return start_pc_;
}
uint32_t GetLength() const
{
return length_;
}
uint32_t GetNumCatches() const
{
return num_catches_;
}
template <class Callback>
void EnumerateCatchBlocks(const Callback &cb);
size_t GetSize()
{
if (size_ == 0) {
SkipCatchBlocks();
}
return size_;
}
private:
void SkipCatchBlocks();
Span<const uint8_t> data_;
uint32_t start_pc_;
uint32_t length_;
uint32_t num_catches_;
Span<const uint8_t> catch_blocks_sp_ {nullptr, nullptr};
size_t size_ {0};
};
class CatchBlock {
public:
explicit CatchBlock(Span<const uint8_t> data);
~CatchBlock() = default;
NO_COPY_SEMANTIC(CatchBlock);
NO_MOVE_SEMANTIC(CatchBlock);
uint32_t GetTypeIdx() const
{
return type_idx_;
}
uint32_t GetHandlerPc() const
{
return handler_pc_;
}
uint32_t GetCodeSize() const
{
return code_size_;
}
size_t GetSize() const
{
return size_;
}
private:
uint32_t type_idx_;
uint32_t handler_pc_;
uint32_t code_size_;
size_t size_;
};
CodeDataAccessor(const File &panda_file, File::EntityId code_id);
~CodeDataAccessor() = default;
NO_COPY_SEMANTIC(CodeDataAccessor);
NO_MOVE_SEMANTIC(CodeDataAccessor);
static uint32_t GetNumVregs(const File &pf, File::EntityId code_id);
static const uint8_t *GetInstructions(const File &pf, File::EntityId code_id, uint32_t *vregs);
static const uint8_t *GetInstructions(const File &pf, File::EntityId code_id);
uint32_t GetNumVregs() const
{
return num_vregs_;
}
uint32_t GetNumArgs() const
{
return num_args_;
}
uint32_t GetCodeSize() const
{
return code_size_;
}
uint32_t GetTriesSize() const
{
return tries_size_;
}
const uint8_t *GetInstructions() const
{
return instructions_ptr_;
}
template <class Callback>
void EnumerateTryBlocks(const Callback &cb);
size_t GetSize()
{
if (size_ == 0) {
SkipTryBlocks();
}
return size_;
}
const File &GetPandaFile() const
{
return panda_file_;
}
File::EntityId GetCodeId()
{
return code_id_;
}
private:
void SkipTryBlocks();
const File &panda_file_;
File::EntityId code_id_;
uint32_t num_vregs_;
uint32_t num_args_;
uint32_t code_size_;
uint32_t tries_size_;
const uint8_t *instructions_ptr_;
Span<const uint8_t> try_blocks_sp_ {nullptr, nullptr};
size_t size_ {0};
};
} // namespace panda::panda_file
#endif // LIBPANDAFILE_CODE_DATA_ACCESSOR_H_
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
git@gitee.com:openharmony-sig/arkcompiler_runtime_core.git
openharmony-sig
arkcompiler_runtime_core
arkcompiler_runtime_core
master

搜索帮助