mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
description: Add constant gates caching mechanism for Circuit IR Signed-off-by: Mingliang Zeng <zengmingliang1@huawei.com>
This commit is contained in:
parent
877b24e726
commit
245286cf1c
@ -448,4 +448,16 @@ void Circuit::SetFrameType(panda::ecmascript::FrameType type)
|
||||
{
|
||||
frameType_ = type;
|
||||
}
|
||||
|
||||
GateRef Circuit::GetConstantGate(MachineType bitValue, BitField bitfield,
|
||||
GateType type)
|
||||
{
|
||||
if (constantCache_.count({bitValue, bitfield, type})) {
|
||||
return constantCache_.at({bitValue, bitfield, type});
|
||||
}
|
||||
auto gate = NewGate(OpCode(OpCode::CONSTANT), bitValue, bitfield,
|
||||
{GetCircuitRoot(OpCode(OpCode::CONSTANT_LIST))}, type);
|
||||
constantCache_[{bitValue, bitfield, type}] = gate;
|
||||
return gate;
|
||||
}
|
||||
} // namespace panda::ecmascript::kungfu
|
||||
|
@ -95,6 +95,8 @@ public:
|
||||
void SetSpaceDataSize(size_t sz);
|
||||
panda::ecmascript::FrameType GetFrameType() const;
|
||||
void SetFrameType(panda::ecmascript::FrameType type);
|
||||
GateRef GetConstantGate(MachineType bitValue, BitField bitfield,
|
||||
GateType type);
|
||||
|
||||
private:
|
||||
uint8_t *AllocateSpace(size_t gateSize);
|
||||
@ -106,6 +108,7 @@ private:
|
||||
size_t gateCount_;
|
||||
TimeStamp time_;
|
||||
std::vector<uint8_t> dataSection_ {};
|
||||
std::map<std::tuple<MachineType, BitField, GateType>, GateRef> constantCache_ {};
|
||||
panda::ecmascript::FrameType frameType_ {panda::ecmascript::FrameType::OPTIMIZED_FRAME};
|
||||
};
|
||||
} // namespace panda::ecmascript::kungfu
|
||||
|
Loading…
Reference in New Issue
Block a user