arkcompiler_ets_runtime/ecmascript/compiler/argument_accessor.h
huoqingyi 9cf6e63579 Fix bugs in ts aot
Description:
1.Fix the bug that Circuit IR args gates do not match the function args of the abc file.
2.Add class ArgumentAccessor to handle args gates of Circuit IR.
3.Modify to set the AOT function entry when constpool is being parsed.
4.For functions sharing the same instructions, add a map to collect duplicate infomation. The key of the map is the current method and the value is the first method with the same nstructions to be translated.

Issue:
https://gitee.com/openharmony/ark_js_runtime/issues/I5DA6V

Change-Id: I08e48444eb22c4fc2841e1cdae44b90286de84ac
Signed-off-by: huoqingyi <huoqingyi@huawei.com>
2022-07-04 16:19:11 +08:00

60 lines
1.9 KiB
C++

/*
* Copyright (c) 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 ECMASCRIPT_COMPILER_ARGUMENT_ACCESSOR_H
#define ECMASCRIPT_COMPILER_ARGUMENT_ACCESSOR_H
#include "ecmascript/compiler/circuit.h"
#include "ecmascript/compiler/gate.h"
#include "ecmascript/js_method.h"
namespace panda::ecmascript::kungfu {
enum class CommonArgIdx : uint8_t {
GLUE = 0,
LEXENV,
ACTUAL_ARGC,
FUNC,
NEW_TARGET,
THIS,
NUM_OF_ARGS,
};
class ArgumentAccessor {
public:
explicit ArgumentAccessor(Circuit *circuit, const JSMethod *method = nullptr)
: circuit_(circuit), method_(method),
argRoot_(Circuit::GetCircuitRoot(OpCode(OpCode::ARG_LIST))) {}
~ArgumentAccessor() = default;
void NewCommonArg(const CommonArgIdx argIndex, MachineType machineType, GateType gateType);
void NewArg(const size_t argIndex);
// jsmethod must be set
size_t GetActualNumArgs() const;
// jsmethod must be set
GateRef GetArgGate(const size_t currentVreg) const;
GateRef GetCommonArgGate(const CommonArgIdx arg) const;
private:
std::vector<GateRef> GetFunctionArgs() const;
size_t GetFunctionArgIndex(const size_t currentVreg, const bool haveFunc,
const bool haveNewTarget, const bool haveThis) const;
Circuit *circuit_ {nullptr};
const JSMethod *method_ {nullptr};
GateRef argRoot_;
};
}
#endif // ECMASCRIPT_COMPILER_ARGUMENT_ACCESSOR_H