2021-09-04 08:06:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021 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.
|
|
|
|
*/
|
|
|
|
|
2021-12-17 09:18:10 +00:00
|
|
|
#ifndef ECMASCRIPT_COMPILER_STUB_H
|
|
|
|
#define ECMASCRIPT_COMPILER_STUB_H
|
2021-09-04 08:06:49 +00:00
|
|
|
|
|
|
|
#include "ecmascript/compiler/circuit.h"
|
|
|
|
#include "ecmascript/compiler/circuit_builder.h"
|
2022-03-03 09:22:12 +00:00
|
|
|
#include "ecmascript/compiler/circuit_builder-inl.h"
|
2021-09-04 08:06:49 +00:00
|
|
|
#include "ecmascript/compiler/gate.h"
|
2022-03-01 08:31:08 +00:00
|
|
|
#include "ecmascript/compiler/variable_type.h"
|
2022-03-16 10:12:15 +00:00
|
|
|
#include "ecmascript/compiler/call_signature.h"
|
|
|
|
#include "ecmascript/global_env_constants.h"
|
2021-09-04 08:06:49 +00:00
|
|
|
|
2021-12-23 06:55:22 +00:00
|
|
|
namespace panda::ecmascript::kungfu {
|
2021-10-08 06:45:08 +00:00
|
|
|
using namespace panda::ecmascript;
|
2021-09-04 08:06:49 +00:00
|
|
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
2021-09-24 03:47:27 +00:00
|
|
|
#define DEFVARIABLE(varname, type, val) Stub::Variable varname(GetEnvironment(), type, NextVariableId(), val)
|
2022-03-16 10:12:15 +00:00
|
|
|
#define NOGC_RTSTUB_CSIGNS_BEGIN (CommonStubCSigns::NUM_OF_STUBS + BytecodeStubCSigns::NUM_OF_VALID_STUBS)
|
2021-12-23 06:55:22 +00:00
|
|
|
class CompilationConfig {
|
|
|
|
public:
|
|
|
|
enum class Triple {
|
|
|
|
TRIPLE_AMD64,
|
|
|
|
TRIPLE_AARCH64,
|
|
|
|
TRIPLE_ARM32,
|
|
|
|
};
|
2022-03-09 09:53:59 +00:00
|
|
|
// fake parameters for register r1 ~ r3
|
|
|
|
static constexpr int FAKE_REGISTER_PARAMTERS_ARM32 = 3;
|
2021-12-23 06:55:22 +00:00
|
|
|
|
|
|
|
explicit CompilationConfig(const std::string &triple)
|
2022-03-09 09:53:59 +00:00
|
|
|
: triple_(GetTripleFromString(triple))
|
2021-12-23 06:55:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
~CompilationConfig() = default;
|
|
|
|
|
2022-02-07 09:23:03 +00:00
|
|
|
inline bool Is32Bit() const
|
2021-12-23 06:55:22 +00:00
|
|
|
{
|
|
|
|
return triple_ == Triple::TRIPLE_ARM32;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsAArch64() const
|
|
|
|
{
|
|
|
|
return triple_ == Triple::TRIPLE_AARCH64;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsAmd64() const
|
|
|
|
{
|
|
|
|
return triple_ == Triple::TRIPLE_AMD64;
|
|
|
|
}
|
|
|
|
|
2022-02-09 08:51:58 +00:00
|
|
|
inline bool Is64Bit() const
|
|
|
|
{
|
|
|
|
return IsAArch64() || IsAmd64();
|
|
|
|
}
|
|
|
|
|
2021-12-23 06:55:22 +00:00
|
|
|
Triple GetTriple() const
|
|
|
|
{
|
|
|
|
return triple_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
inline Triple GetTripleFromString(const std::string &triple)
|
|
|
|
{
|
|
|
|
if (triple.compare("x86_64-unknown-linux-gnu") == 0) {
|
|
|
|
return Triple::TRIPLE_AMD64;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (triple.compare("aarch64-unknown-linux-gnu") == 0) {
|
|
|
|
return Triple::TRIPLE_AARCH64;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (triple.compare("arm-unknown-linux-gnu") == 0) {
|
|
|
|
return Triple::TRIPLE_ARM32;
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
Triple triple_;
|
|
|
|
};
|
|
|
|
|
2021-09-09 09:40:54 +00:00
|
|
|
class Stub {
|
2021-09-04 08:06:49 +00:00
|
|
|
public:
|
2021-09-09 09:40:54 +00:00
|
|
|
class Environment;
|
2021-09-24 03:47:27 +00:00
|
|
|
class Label;
|
|
|
|
class Variable;
|
2021-09-09 09:40:54 +00:00
|
|
|
|
2021-09-24 03:47:27 +00:00
|
|
|
class Label {
|
2021-09-04 08:06:49 +00:00
|
|
|
public:
|
2021-09-24 03:47:27 +00:00
|
|
|
class LabelImpl {
|
2021-09-09 09:40:54 +00:00
|
|
|
public:
|
2021-12-17 09:18:10 +00:00
|
|
|
LabelImpl(Environment *env, GateRef control)
|
2021-09-09 09:40:54 +00:00
|
|
|
: env_(env), control_(control), predeControl_(-1), isSealed_(false)
|
|
|
|
{
|
|
|
|
}
|
2021-09-24 03:47:27 +00:00
|
|
|
~LabelImpl() = default;
|
|
|
|
NO_MOVE_SEMANTIC(LabelImpl);
|
|
|
|
NO_COPY_SEMANTIC(LabelImpl);
|
2021-09-09 09:40:54 +00:00
|
|
|
void Seal();
|
2021-12-17 09:18:10 +00:00
|
|
|
void WriteVariable(Variable *var, GateRef value);
|
|
|
|
GateRef ReadVariable(Variable *var);
|
2021-09-09 09:40:54 +00:00
|
|
|
void Bind();
|
|
|
|
void MergeAllControl();
|
2021-09-26 06:47:20 +00:00
|
|
|
void MergeAllDepend();
|
2021-09-24 03:47:27 +00:00
|
|
|
void AppendPredecessor(LabelImpl *predecessor);
|
|
|
|
std::vector<LabelImpl *> GetPredecessors() const
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
2021-09-26 06:47:20 +00:00
|
|
|
return predecessors_;
|
2021-09-09 09:40:54 +00:00
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
void SetControl(GateRef control)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
control_ = control;
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
void SetPreControl(GateRef control)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
predeControl_ = control;
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
void MergeControl(GateRef control)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
if (predeControl_ == -1) {
|
|
|
|
predeControl_ = control;
|
|
|
|
control_ = predeControl_;
|
|
|
|
} else {
|
|
|
|
otherPredeControls_.push_back(control);
|
|
|
|
}
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef GetControl() const
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
return control_;
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
void SetDepend(GateRef depend)
|
2021-09-26 06:47:20 +00:00
|
|
|
{
|
|
|
|
depend_ = depend;
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef GetDepend() const
|
2021-09-26 06:47:20 +00:00
|
|
|
{
|
|
|
|
return depend_;
|
|
|
|
}
|
2022-03-22 02:33:19 +00:00
|
|
|
|
2021-09-09 09:40:54 +00:00
|
|
|
private:
|
|
|
|
bool IsNeedSeal() const;
|
|
|
|
bool IsSealed() const
|
|
|
|
{
|
|
|
|
return isSealed_;
|
|
|
|
}
|
|
|
|
bool IsLoopHead() const;
|
2021-09-26 06:47:20 +00:00
|
|
|
bool IsControlCase() const;
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef ReadVariableRecursive(Variable *var);
|
2021-09-09 09:40:54 +00:00
|
|
|
Environment *env_;
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef control_;
|
|
|
|
GateRef predeControl_ {-1};
|
|
|
|
GateRef dependRelay_ {-1};
|
|
|
|
GateRef depend_ {-1};
|
|
|
|
GateRef loopDepend_ {-1};
|
|
|
|
std::vector<GateRef> otherPredeControls_;
|
2021-09-26 06:47:20 +00:00
|
|
|
bool isSealed_ {false};
|
2021-12-17 09:18:10 +00:00
|
|
|
std::map<Variable *, GateRef> valueMap_;
|
|
|
|
std::vector<GateRef> phi;
|
2021-09-26 06:47:20 +00:00
|
|
|
std::vector<LabelImpl *> predecessors_;
|
2021-12-17 09:18:10 +00:00
|
|
|
std::map<Variable *, GateRef> incompletePhis_;
|
2021-09-09 09:40:54 +00:00
|
|
|
};
|
2021-09-24 03:47:27 +00:00
|
|
|
explicit Label() = default;
|
|
|
|
explicit Label(Environment *env);
|
|
|
|
explicit Label(LabelImpl *impl) : impl_(impl) {}
|
|
|
|
~Label() = default;
|
|
|
|
Label(Label const &label) = default;
|
|
|
|
Label &operator=(Label const &label) = default;
|
|
|
|
Label(Label &&label) = default;
|
|
|
|
Label &operator=(Label &&label) = default;
|
2022-03-16 10:12:15 +00:00
|
|
|
void Seal();
|
|
|
|
void WriteVariable(Variable *var, GateRef value);
|
|
|
|
GateRef ReadVariable(Variable *var);
|
|
|
|
void Bind();
|
|
|
|
void MergeAllControl();
|
|
|
|
void MergeAllDepend();
|
|
|
|
void AppendPredecessor(const Label *predecessor);
|
|
|
|
std::vector<Label> GetPredecessors() const;
|
|
|
|
void SetControl(GateRef control);
|
|
|
|
void SetPreControl(GateRef control);
|
|
|
|
void MergeControl(GateRef control);
|
|
|
|
GateRef GetControl() const;
|
|
|
|
GateRef GetDepend() const;
|
|
|
|
void SetDepend(GateRef depend);
|
2022-03-22 02:33:19 +00:00
|
|
|
|
2021-09-04 08:06:49 +00:00
|
|
|
private:
|
2021-09-09 09:40:54 +00:00
|
|
|
friend class Environment;
|
2021-09-24 03:47:27 +00:00
|
|
|
LabelImpl *GetRawLabel() const
|
2021-09-04 08:06:49 +00:00
|
|
|
{
|
2021-09-09 09:40:54 +00:00
|
|
|
return impl_;
|
2021-09-04 08:06:49 +00:00
|
|
|
}
|
2021-09-24 03:47:27 +00:00
|
|
|
LabelImpl *impl_ {nullptr};
|
2021-09-04 08:06:49 +00:00
|
|
|
};
|
|
|
|
|
2021-09-09 09:40:54 +00:00
|
|
|
class Environment {
|
|
|
|
public:
|
2021-09-24 03:47:27 +00:00
|
|
|
using LabelImpl = Label::LabelImpl;
|
2021-09-09 09:40:54 +00:00
|
|
|
explicit Environment(size_t arguments, Circuit *circuit);
|
|
|
|
~Environment();
|
|
|
|
NO_COPY_SEMANTIC(Environment);
|
|
|
|
NO_MOVE_SEMANTIC(Environment);
|
2021-09-24 03:47:27 +00:00
|
|
|
Label *GetCurrentLabel() const
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
return currentLabel_;
|
|
|
|
}
|
2021-09-24 03:47:27 +00:00
|
|
|
void SetCurrentLabel(Label *label)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
currentLabel_ = label;
|
|
|
|
}
|
|
|
|
CircuitBuilder &GetCircuitBuilder()
|
|
|
|
{
|
|
|
|
return builder_;
|
|
|
|
}
|
|
|
|
Circuit *GetCircuit()
|
|
|
|
{
|
|
|
|
return circuit_;
|
2021-09-04 08:06:49 +00:00
|
|
|
}
|
2021-12-23 06:55:22 +00:00
|
|
|
void SetCompilationConfig(const CompilationConfig *cfg)
|
|
|
|
{
|
|
|
|
compCfg_ = cfg;
|
|
|
|
}
|
2022-02-19 02:09:52 +00:00
|
|
|
|
|
|
|
const CompilationConfig *GetCompilationConfig() const
|
|
|
|
{
|
|
|
|
return compCfg_;
|
|
|
|
}
|
|
|
|
|
2022-02-07 09:23:03 +00:00
|
|
|
inline bool Is32Bit() const
|
2021-12-23 06:55:22 +00:00
|
|
|
{
|
2022-02-07 09:23:03 +00:00
|
|
|
return compCfg_->Is32Bit();
|
2021-12-23 06:55:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsAArch64() const
|
|
|
|
{
|
|
|
|
return compCfg_->IsAArch64();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsAmd64() const
|
|
|
|
{
|
|
|
|
return compCfg_->IsAmd64();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsArch64Bit() const
|
|
|
|
{
|
|
|
|
return compCfg_->IsAmd64() || compCfg_->IsAArch64();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsArch32Bit() const
|
|
|
|
{
|
2022-02-07 09:23:03 +00:00
|
|
|
return compCfg_->Is32Bit();
|
2021-12-23 06:55:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-16 10:12:15 +00:00
|
|
|
GateType GetGateType(GateRef gate) const;
|
|
|
|
Label GetLabelFromSelector(GateRef sel);
|
|
|
|
void AddSelectorToLabel(GateRef sel, Label label);
|
|
|
|
LabelImpl *NewLabel(Environment *env, GateRef control = -1);
|
|
|
|
void PushCurrentLabel(Label *entry);
|
|
|
|
void PopCurrentLabel();
|
|
|
|
void SetFrameType(FrameType type);
|
|
|
|
GateRef GetArgument(size_t index) const;
|
2022-03-22 02:33:19 +00:00
|
|
|
|
2021-09-09 09:40:54 +00:00
|
|
|
private:
|
2021-12-23 06:55:22 +00:00
|
|
|
const CompilationConfig *compCfg_;
|
2021-09-24 03:47:27 +00:00
|
|
|
Label *currentLabel_ {nullptr};
|
2021-09-09 09:40:54 +00:00
|
|
|
Circuit *circuit_;
|
|
|
|
CircuitBuilder builder_;
|
2021-12-23 06:55:22 +00:00
|
|
|
std::unordered_map<GateRef, LabelImpl *> phiToLabels_;
|
2021-12-17 09:18:10 +00:00
|
|
|
std::vector<GateRef> arguments_;
|
2021-09-24 03:47:27 +00:00
|
|
|
Label entry_;
|
2021-12-23 06:55:22 +00:00
|
|
|
std::vector<LabelImpl *> rawLabels_;
|
2021-09-24 03:47:27 +00:00
|
|
|
std::stack<Label *> stack_;
|
2021-09-09 09:40:54 +00:00
|
|
|
};
|
2021-09-04 08:06:49 +00:00
|
|
|
|
2021-09-24 03:47:27 +00:00
|
|
|
class Variable {
|
2021-09-09 09:40:54 +00:00
|
|
|
public:
|
2022-03-01 08:31:08 +00:00
|
|
|
Variable(Environment *env, VariableType type, uint32_t id, GateRef value) : id_(id), type_(type), env_(env)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
Bind(value);
|
|
|
|
env_->GetCurrentLabel()->WriteVariable(this, value);
|
|
|
|
}
|
2021-09-24 03:47:27 +00:00
|
|
|
~Variable() = default;
|
|
|
|
NO_MOVE_SEMANTIC(Variable);
|
|
|
|
NO_COPY_SEMANTIC(Variable);
|
2021-12-17 09:18:10 +00:00
|
|
|
void Bind(GateRef value)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
currentValue_ = value;
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef Value() const
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
return currentValue_;
|
|
|
|
}
|
2022-03-01 08:31:08 +00:00
|
|
|
VariableType Type() const
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
return type_;
|
|
|
|
}
|
|
|
|
bool IsBound() const
|
|
|
|
{
|
|
|
|
return currentValue_ != 0;
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
Variable &operator=(const GateRef value)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
env_->GetCurrentLabel()->WriteVariable(this, value);
|
|
|
|
Bind(value);
|
|
|
|
return *this;
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef operator*()
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
return env_->GetCurrentLabel()->ReadVariable(this);
|
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef AddPhiOperand(GateRef val);
|
|
|
|
GateRef AddOperandToSelector(GateRef val, size_t idx, GateRef in);
|
|
|
|
GateRef TryRemoveTrivialPhi(GateRef phi);
|
2021-09-09 09:40:54 +00:00
|
|
|
void RerouteOuts(const std::vector<Out *> &outs, Gate *newGate);
|
2021-12-17 09:18:10 +00:00
|
|
|
bool IsSelector(GateRef gate) const
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
return env_->GetCircuit()->IsSelector(gate);
|
|
|
|
}
|
|
|
|
bool IsSelector(const Gate *gate) const
|
|
|
|
{
|
2022-01-11 13:09:24 +00:00
|
|
|
return gate->GetOpCode() == OpCode::VALUE_SELECTOR;
|
2021-09-09 09:40:54 +00:00
|
|
|
}
|
|
|
|
uint32_t GetId() const
|
|
|
|
{
|
|
|
|
return id_;
|
|
|
|
}
|
2022-03-22 02:33:19 +00:00
|
|
|
|
2021-09-09 09:40:54 +00:00
|
|
|
private:
|
|
|
|
uint32_t id_;
|
2022-03-01 08:31:08 +00:00
|
|
|
VariableType type_;
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef currentValue_ {0};
|
2021-09-09 09:40:54 +00:00
|
|
|
Environment *env_;
|
|
|
|
};
|
2021-09-04 08:06:49 +00:00
|
|
|
|
2021-09-09 09:40:54 +00:00
|
|
|
class SubCircuitScope {
|
|
|
|
public:
|
2021-09-24 03:47:27 +00:00
|
|
|
explicit SubCircuitScope(Environment *env, Label *entry) : env_(env)
|
2021-09-09 09:40:54 +00:00
|
|
|
{
|
|
|
|
env_->PushCurrentLabel(entry);
|
|
|
|
}
|
|
|
|
~SubCircuitScope()
|
|
|
|
{
|
|
|
|
env_->PopCurrentLabel();
|
|
|
|
}
|
2022-03-22 02:33:19 +00:00
|
|
|
|
2021-09-09 09:40:54 +00:00
|
|
|
private:
|
|
|
|
Environment *env_;
|
|
|
|
};
|
2021-09-04 08:06:49 +00:00
|
|
|
|
2021-12-23 06:55:22 +00:00
|
|
|
explicit Stub(const char *name, int argCount, Circuit *circuit)
|
|
|
|
: env_(argCount, circuit), methodName_(name)
|
2021-09-04 08:06:49 +00:00
|
|
|
{
|
|
|
|
}
|
2021-09-09 09:40:54 +00:00
|
|
|
virtual ~Stub() = default;
|
|
|
|
NO_MOVE_SEMANTIC(Stub);
|
|
|
|
NO_COPY_SEMANTIC(Stub);
|
2021-12-23 06:55:22 +00:00
|
|
|
virtual void GenerateCircuit(const CompilationConfig *cfg)
|
|
|
|
{
|
|
|
|
env_.SetCompilationConfig(cfg);
|
|
|
|
}
|
2021-09-09 09:40:54 +00:00
|
|
|
Environment *GetEnvironment()
|
2021-09-04 08:06:49 +00:00
|
|
|
{
|
2021-09-09 09:40:54 +00:00
|
|
|
return &env_;
|
2021-09-04 08:06:49 +00:00
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
int NextVariableId()
|
2021-09-04 08:06:49 +00:00
|
|
|
{
|
2021-12-17 09:18:10 +00:00
|
|
|
return nextVariableId_++;
|
2021-09-04 08:06:49 +00:00
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
std::string GetMethodName() const
|
2021-09-26 06:47:20 +00:00
|
|
|
{
|
2021-12-17 09:18:10 +00:00
|
|
|
return methodName_;
|
2021-09-26 06:47:20 +00:00
|
|
|
}
|
2021-12-17 09:18:10 +00:00
|
|
|
// constant
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef GetInt8Constant(int8_t value);
|
|
|
|
GateRef GetInt16Constant(int16_t value);
|
|
|
|
GateRef GetInt32Constant(int32_t value);
|
|
|
|
GateRef GetInt64Constant(int64_t value);
|
|
|
|
GateRef GetIntPtrConstant(int64_t value);
|
|
|
|
GateRef GetIntPtrSize();
|
|
|
|
GateRef GetRelocatableData(uint64_t value);
|
|
|
|
GateRef TrueConstant();
|
|
|
|
GateRef FalseConstant();
|
|
|
|
GateRef GetBooleanConstant(bool value);
|
|
|
|
GateRef GetDoubleConstant(double value);
|
|
|
|
GateRef GetUndefinedConstant(VariableType type = VariableType::JS_ANY());
|
|
|
|
GateRef GetHoleConstant(VariableType type = VariableType::JS_ANY());
|
|
|
|
GateRef GetNullConstant(VariableType type = VariableType::JS_ANY());
|
|
|
|
GateRef GetExceptionConstant(VariableType type = VariableType::JS_ANY());
|
|
|
|
GateRef IntPtrMul(GateRef x, GateRef y);
|
2021-09-04 08:06:49 +00:00
|
|
|
// parameter
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef Argument(size_t index);
|
|
|
|
GateRef Int1Argument(size_t index);
|
|
|
|
GateRef Int32Argument(size_t index);
|
|
|
|
GateRef Int64Argument(size_t index);
|
|
|
|
GateRef TaggedArgument(size_t index);
|
|
|
|
GateRef TaggedPointerArgument(size_t index, GateType type = GateType::TAGGED_POINTER);
|
|
|
|
GateRef PtrArgument(size_t index, GateType type = GateType::C_VALUE);
|
|
|
|
GateRef Float32Argument(size_t index);
|
|
|
|
GateRef Float64Argument(size_t index);
|
|
|
|
GateRef Alloca(int size);
|
2021-09-04 08:06:49 +00:00
|
|
|
// control flow
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef Return(GateRef value);
|
|
|
|
GateRef Return();
|
|
|
|
void Bind(Label *label);
|
2021-09-04 08:06:49 +00:00
|
|
|
void Jump(Label *label);
|
2021-12-17 09:18:10 +00:00
|
|
|
void Branch(GateRef condition, Label *trueLabel, Label *falseLabel);
|
2022-01-04 11:30:40 +00:00
|
|
|
void Switch(GateRef index, Label *defaultLabel, int64_t *keysValue, Label *keysLabel, int numberOfKeys);
|
2021-09-04 08:06:49 +00:00
|
|
|
void LoopBegin(Label *loopHead);
|
|
|
|
void LoopEnd(Label *loopHead);
|
|
|
|
// call operation
|
2022-03-30 07:12:36 +00:00
|
|
|
GateRef CallRuntime(GateRef glue, size_t index,
|
2022-03-16 10:12:15 +00:00
|
|
|
std::initializer_list<GateRef> args);
|
2022-03-30 07:12:36 +00:00
|
|
|
GateRef CallRuntime(GateRef glue, size_t index, GateRef depend,
|
2022-03-16 10:12:15 +00:00
|
|
|
std::initializer_list<GateRef> args);
|
|
|
|
GateRef CallRuntimeTrampoline(GateRef glue, GateRef target, std::initializer_list<GateRef> args);
|
|
|
|
GateRef CallRuntimeTrampoline(GateRef glue, GateRef target, GateRef depend, std::initializer_list<GateRef> args);
|
2022-03-30 07:12:36 +00:00
|
|
|
GateRef CallNGCRuntime(GateRef glue, size_t index,
|
|
|
|
std::initializer_list<GateRef> args);
|
|
|
|
GateRef CallStub(GateRef glue, size_t index,
|
2022-02-23 08:50:04 +00:00
|
|
|
std::initializer_list<GateRef> args);
|
2022-03-16 10:12:15 +00:00
|
|
|
void DebugPrint(GateRef thread, std::initializer_list<GateRef> args);
|
2022-03-21 07:18:47 +00:00
|
|
|
void FatalPrint(GateRef thread, std::initializer_list<GateRef> args);
|
2021-09-04 08:06:49 +00:00
|
|
|
// memory
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef Load(VariableType type, GateRef base, GateRef offset);
|
|
|
|
GateRef Load(VariableType type, GateRef base);
|
2022-03-22 09:00:19 +00:00
|
|
|
void Store(VariableType type, GateRef glue, GateRef base, GateRef offset, GateRef value);
|
2021-09-04 08:06:49 +00:00
|
|
|
// arithmetic
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef TaggedCastToIntPtr(GateRef x);
|
|
|
|
GateRef Int16Add(GateRef x, GateRef y);
|
|
|
|
GateRef Int32Add(GateRef x, GateRef y);
|
|
|
|
GateRef Int64Add(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleAdd(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrAdd(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrSub(GateRef x, GateRef y);
|
|
|
|
GateRef PointerSub(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef Int16Sub(GateRef x, GateRef y);
|
|
|
|
GateRef Int32Sub(GateRef x, GateRef y);
|
|
|
|
GateRef Int64Sub(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleSub(GateRef x, GateRef y);
|
|
|
|
GateRef Int32Mul(GateRef x, GateRef y);
|
|
|
|
GateRef Int64Mul(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleMul(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleDiv(GateRef x, GateRef y);
|
|
|
|
GateRef Int32Div(GateRef x, GateRef y);
|
|
|
|
GateRef UInt32Div(GateRef x, GateRef y);
|
|
|
|
GateRef UInt64Div(GateRef x, GateRef y);
|
|
|
|
GateRef Int32Mod(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleMod(GateRef x, GateRef y);
|
|
|
|
GateRef Int64Div(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrDiv(GateRef x, GateRef y);
|
2021-09-04 08:06:49 +00:00
|
|
|
// bit operation
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef Int32Or(GateRef x, GateRef y);
|
|
|
|
GateRef Int8And(GateRef x, GateRef y);
|
|
|
|
GateRef Int32And(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrAnd(GateRef x, GateRef y);
|
|
|
|
GateRef BoolAnd(GateRef x, GateRef y);
|
|
|
|
GateRef BoolOr(GateRef x, GateRef y);
|
|
|
|
GateRef Int32Not(GateRef x);
|
|
|
|
GateRef BoolNot(GateRef x);
|
|
|
|
GateRef Int32Xor(GateRef x, GateRef y);
|
|
|
|
GateRef FixLoadType(GateRef x);
|
|
|
|
GateRef Int64Or(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrOr(GateRef x, GateRef y);
|
|
|
|
GateRef Int64And(GateRef x, GateRef y);
|
|
|
|
GateRef Int64Xor(GateRef x, GateRef y);
|
|
|
|
GateRef Int64Not(GateRef x);
|
|
|
|
GateRef Int16LSL(GateRef x, GateRef y);
|
|
|
|
GateRef Int32LSL(GateRef x, GateRef y);
|
|
|
|
GateRef Int64LSL(GateRef x, GateRef y);
|
|
|
|
GateRef UInt64LSL(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrLSL(GateRef x, GateRef y);
|
|
|
|
GateRef Int8LSR(GateRef x, GateRef y);
|
|
|
|
GateRef UInt32LSR(GateRef x, GateRef y);
|
|
|
|
GateRef UInt64LSR(GateRef x, GateRef y);
|
|
|
|
GateRef IntPtrLSR(GateRef x, GateRef y);
|
2022-03-21 12:06:33 +00:00
|
|
|
GateRef Int32ASR(GateRef x, GateRef y);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef TaggedIsInt(GateRef x);
|
|
|
|
GateRef TaggedIsDouble(GateRef x);
|
|
|
|
GateRef TaggedIsObject(GateRef x);
|
|
|
|
GateRef TaggedIsNumber(GateRef x);
|
|
|
|
GateRef TaggedIsHole(GateRef x);
|
|
|
|
GateRef TaggedIsNotHole(GateRef x);
|
|
|
|
GateRef TaggedIsUndefined(GateRef x);
|
|
|
|
GateRef TaggedIsException(GateRef x);
|
|
|
|
GateRef TaggedIsSpecial(GateRef x);
|
|
|
|
GateRef TaggedIsHeapObject(GateRef x);
|
|
|
|
GateRef ObjectAddressToRange(GateRef x);
|
2022-03-25 01:31:39 +00:00
|
|
|
GateRef InYoungGeneration(GateRef x);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef TaggedIsGeneratorObject(GateRef x);
|
|
|
|
GateRef TaggedIsPropertyBox(GateRef x);
|
|
|
|
GateRef TaggedIsWeak(GateRef x);
|
|
|
|
GateRef TaggedIsPrototypeHandler(GateRef x);
|
|
|
|
GateRef TaggedIsTransitionHandler(GateRef x);
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef TaggedIsString(GateRef obj);
|
|
|
|
GateRef TaggedIsStringOrSymbol(GateRef obj);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef GetNextPositionForHash(GateRef last, GateRef count, GateRef size);
|
|
|
|
GateRef DoubleIsNAN(GateRef x);
|
|
|
|
GateRef DoubleIsINF(GateRef x);
|
|
|
|
GateRef TaggedIsNull(GateRef x);
|
|
|
|
GateRef TaggedIsUndefinedOrNull(GateRef x);
|
|
|
|
GateRef TaggedIsTrue(GateRef x);
|
|
|
|
GateRef TaggedIsFalse(GateRef x);
|
|
|
|
GateRef TaggedIsBoolean(GateRef x);
|
|
|
|
GateRef TaggedGetInt(GateRef x);
|
|
|
|
GateRef Int8BuildTaggedTypeWithNoGC(GateRef x);
|
|
|
|
GateRef Int16BuildTaggedWithNoGC(GateRef x);
|
|
|
|
GateRef Int16BuildTaggedTypeWithNoGC(GateRef x);
|
|
|
|
GateRef IntBuildTaggedWithNoGC(GateRef x);
|
|
|
|
GateRef IntBuildTaggedTypeWithNoGC(GateRef x);
|
|
|
|
GateRef DoubleBuildTaggedWithNoGC(GateRef x);
|
|
|
|
GateRef DoubleBuildTaggedTypeWithNoGC(GateRef x);
|
|
|
|
GateRef CastDoubleToInt64(GateRef x);
|
|
|
|
GateRef TaggedTrue();
|
|
|
|
GateRef TaggedFalse();
|
2021-09-04 08:06:49 +00:00
|
|
|
// compare operation
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef Int8Equal(GateRef x, GateRef y);
|
|
|
|
GateRef Int32Equal(GateRef x, GateRef y);
|
|
|
|
GateRef Int32NotEqual(GateRef x, GateRef y);
|
|
|
|
GateRef Int64Equal(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleEqual(GateRef x, GateRef y);
|
|
|
|
GateRef Int64NotEqual(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleLessThan(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleLessThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleGreaterThan(GateRef x, GateRef y);
|
|
|
|
GateRef DoubleGreaterThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef Int32GreaterThan(GateRef x, GateRef y);
|
|
|
|
GateRef Int32LessThan(GateRef x, GateRef y);
|
|
|
|
GateRef Int32GreaterThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef Int32LessThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef UInt32GreaterThan(GateRef x, GateRef y);
|
|
|
|
GateRef UInt32LessThan(GateRef x, GateRef y);
|
|
|
|
GateRef UInt32LessThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef UInt32GreaterThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef Int64GreaterThan(GateRef x, GateRef y);
|
|
|
|
GateRef Int64LessThan(GateRef x, GateRef y);
|
|
|
|
GateRef Int64LessThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef Int64GreaterThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef UInt6464GreaterThan(GateRef x, GateRef y);
|
|
|
|
GateRef UInt64LessThan(GateRef x, GateRef y);
|
|
|
|
GateRef UInt64LessThanOrEqual(GateRef x, GateRef y);
|
|
|
|
GateRef UInt6464GreaterThanOrEqual(GateRef x, GateRef y);
|
2021-09-04 08:06:49 +00:00
|
|
|
// cast operation
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef ChangeInt64ToInt32(GateRef val);
|
|
|
|
GateRef ChangeInt64ToIntPtr(GateRef val);
|
|
|
|
GateRef ChangeInt32ToIntPtr(GateRef val);
|
2021-09-04 08:06:49 +00:00
|
|
|
// math operation
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef Sqrt(GateRef x);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef GetSetterFromAccessor(GateRef accessor);
|
|
|
|
GateRef GetElementsArray(GateRef object);
|
|
|
|
void SetElementsArray(GateRef glue, GateRef object, GateRef elementsArray);
|
|
|
|
GateRef GetPropertiesArray(GateRef object);
|
2021-12-17 09:18:10 +00:00
|
|
|
// SetProperties in js_object.h
|
2022-03-16 10:12:15 +00:00
|
|
|
void SetPropertiesArray(GateRef glue, GateRef object, GateRef propsArray);
|
|
|
|
GateRef GetLengthOfTaggedArray(GateRef array);
|
2021-09-04 08:06:49 +00:00
|
|
|
// object operation
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef IsJSHClass(GateRef obj);
|
|
|
|
GateRef LoadHClass(GateRef object);
|
|
|
|
void StoreHClass(GateRef glue, GateRef object, GateRef hclass);
|
2021-12-17 09:18:10 +00:00
|
|
|
void CopyAllHClass(GateRef glue, GateRef dstHClass, GateRef scrHClass);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef GetObjectType(GateRef hClass);
|
|
|
|
GateRef IsDictionaryMode(GateRef object);
|
|
|
|
GateRef IsDictionaryModeByHClass(GateRef hClass);
|
|
|
|
GateRef IsDictionaryElement(GateRef hClass);
|
|
|
|
GateRef NotBuiltinsConstructor(GateRef object);
|
|
|
|
GateRef IsClassConstructor(GateRef object);
|
|
|
|
GateRef IsClassPrototype(GateRef object);
|
|
|
|
GateRef IsExtensible(GateRef object);
|
|
|
|
GateRef IsEcmaObject(GateRef obj);
|
|
|
|
GateRef IsSymbol(GateRef obj);
|
|
|
|
GateRef IsString(GateRef obj);
|
|
|
|
GateRef IsJsProxy(GateRef obj);
|
|
|
|
GateRef IsJSFunctionBase(GateRef obj);
|
|
|
|
GateRef IsJsArray(GateRef obj);
|
|
|
|
GateRef IsJSObject(GateRef obj);
|
|
|
|
GateRef IsWritable(GateRef attr);
|
|
|
|
GateRef IsAccessor(GateRef attr);
|
|
|
|
GateRef IsInlinedProperty(GateRef attr);
|
|
|
|
GateRef IsField(GateRef attr);
|
|
|
|
GateRef IsNonExist(GateRef attr);
|
|
|
|
GateRef HandlerBaseIsAccessor(GateRef attr);
|
|
|
|
GateRef HandlerBaseIsJSArray(GateRef attr);
|
|
|
|
GateRef HandlerBaseIsInlinedProperty(GateRef attr);
|
|
|
|
GateRef HandlerBaseGetOffset(GateRef attr);
|
|
|
|
GateRef IsInvalidPropertyBox(GateRef obj);
|
|
|
|
GateRef GetValueFromPropertyBox(GateRef obj);
|
|
|
|
void SetValueToPropertyBox(GateRef glue, GateRef obj, GateRef value);
|
|
|
|
GateRef GetTransitionFromHClass(GateRef obj);
|
|
|
|
GateRef GetTransitionHandlerInfo(GateRef obj);
|
|
|
|
GateRef IsInternalAccessor(GateRef attr);
|
|
|
|
GateRef GetProtoCell(GateRef object);
|
|
|
|
GateRef GetPrototypeHandlerHolder(GateRef object);
|
|
|
|
GateRef GetPrototypeHandlerHandlerInfo(GateRef object);
|
|
|
|
GateRef GetHasChanged(GateRef object);
|
|
|
|
GateRef HclassIsPrototypeHandler(GateRef hclass);
|
|
|
|
GateRef HclassIsTransitionHandler(GateRef hclass);
|
|
|
|
GateRef HclassIsPropertyBox(GateRef hclass);
|
|
|
|
GateRef PropAttrGetOffset(GateRef attr);
|
2021-10-28 07:06:25 +00:00
|
|
|
// SetDictionaryOrder func in property_attribute.h
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef SetDictionaryOrderFieldInPropAttr(GateRef attr, GateRef value);
|
|
|
|
GateRef GetPrototypeFromHClass(GateRef hClass);
|
|
|
|
GateRef GetLayoutFromHClass(GateRef hClass);
|
|
|
|
GateRef GetBitFieldFromHClass(GateRef hClass);
|
2022-03-21 03:38:21 +00:00
|
|
|
void SetBitFieldToHClass(GateRef glue, GateRef hClass, GateRef bitfield);
|
|
|
|
void SetPrototypeToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef proto);
|
|
|
|
void SetProtoChangeDetailsToHClass(VariableType type, GateRef glue, GateRef hClass,
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef protoChange);
|
2022-03-21 03:38:21 +00:00
|
|
|
void SetLayoutToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef attr);
|
|
|
|
void SetEnumCacheToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef key);
|
|
|
|
void SetTransitionsToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef transition);
|
2022-03-16 10:12:15 +00:00
|
|
|
void SetIsProtoTypeToHClass(GateRef glue, GateRef hClass, GateRef value);
|
|
|
|
GateRef IsProtoTypeHClass(GateRef hClass);
|
|
|
|
void SetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass,
|
|
|
|
GateRef value, GateRef attrOffset, VariableType type = VariableType::JS_ANY());
|
2021-12-17 09:18:10 +00:00
|
|
|
|
2022-03-16 10:12:15 +00:00
|
|
|
void IncNumberOfProps(GateRef glue, GateRef hClass);
|
|
|
|
GateRef GetNumberOfPropsFromHClass(GateRef hClass);
|
|
|
|
void SetNumberOfPropsToHClass(GateRef glue, GateRef hClass, GateRef value);
|
|
|
|
GateRef GetObjectSizeFromHClass(GateRef hClass);
|
|
|
|
GateRef GetInlinedPropsStartFromHClass(GateRef hClass);
|
|
|
|
GateRef GetInlinedPropertiesFromHClass(GateRef hClass);
|
2021-12-17 09:18:10 +00:00
|
|
|
void ThrowTypeAndReturn(GateRef glue, int messageId, GateRef val);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef GetValueFromTaggedArray(VariableType returnType, GateRef elements, GateRef index);
|
|
|
|
void SetValueToTaggedArray(VariableType valType, GateRef glue, GateRef array, GateRef index, GateRef val);
|
|
|
|
void UpdateValueAndAttributes(GateRef glue, GateRef elements, GateRef index, GateRef value, GateRef attr);
|
|
|
|
GateRef IsSpecialIndexedObj(GateRef jsType);
|
|
|
|
GateRef IsSpecialContainer(GateRef jsType);
|
|
|
|
GateRef IsAccessorInternal(GateRef value);
|
|
|
|
template<typename DictionaryT>
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef GetAttributesFromDictionary(GateRef elements, GateRef entry);
|
2022-03-16 10:12:15 +00:00
|
|
|
template<typename DictionaryT>
|
2022-03-01 08:31:08 +00:00
|
|
|
GateRef GetValueFromDictionary(VariableType returnType, GateRef elements, GateRef entry);
|
2022-03-16 10:12:15 +00:00
|
|
|
template<typename DictionaryT>
|
2022-03-01 08:31:08 +00:00
|
|
|
GateRef GetKeyFromDictionary(VariableType returnType, GateRef elements, GateRef entry);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef GetPropAttrFromLayoutInfo(GateRef layout, GateRef entry);
|
|
|
|
GateRef GetPropertiesAddrFromLayoutInfo(GateRef layout);
|
|
|
|
GateRef GetPropertyMetaDataFromAttr(GateRef attr);
|
|
|
|
GateRef GetKeyFromLayoutInfo(GateRef layout, GateRef entry);
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef FindElementWithCache(GateRef glue, GateRef layoutInfo, GateRef hClass,
|
|
|
|
GateRef key, GateRef propsNum);
|
2022-02-19 02:09:52 +00:00
|
|
|
GateRef FindElementFromNumberDictionary(GateRef glue, GateRef elements, GateRef index);
|
2021-12-17 09:18:10 +00:00
|
|
|
GateRef FindEntryFromNameDictionary(GateRef glue, GateRef elements, GateRef key);
|
|
|
|
GateRef IsMatchInTransitionDictionary(GateRef element, GateRef key, GateRef metaData, GateRef attr);
|
|
|
|
GateRef FindEntryFromTransitionDictionary(GateRef glue, GateRef elements, GateRef key, GateRef metaData);
|
2022-03-01 08:31:08 +00:00
|
|
|
GateRef JSObjectGetProperty(VariableType returnType, GateRef obj, GateRef hClass, GateRef propAttr);
|
2021-12-17 09:18:10 +00:00
|
|
|
void JSObjectSetProperty(GateRef glue, GateRef obj, GateRef hClass, GateRef attr, GateRef value);
|
|
|
|
GateRef ShouldCallSetter(GateRef receiver, GateRef holder, GateRef accessor, GateRef attr);
|
|
|
|
GateRef CallSetterUtil(GateRef glue, GateRef holder, GateRef accessor, GateRef value);
|
|
|
|
GateRef SetHasConstructorCondition(GateRef glue, GateRef receiver, GateRef key);
|
|
|
|
GateRef AddPropertyByName(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef propertyAttributes);
|
|
|
|
GateRef IsUtf16String(GateRef string);
|
|
|
|
GateRef IsUtf8String(GateRef string);
|
|
|
|
GateRef IsInternalString(GateRef string);
|
|
|
|
GateRef IsDigit(GateRef ch);
|
|
|
|
GateRef StringToElementIndex(GateRef string);
|
|
|
|
GateRef TryToElementsIndex(GateRef key);
|
|
|
|
GateRef ComputePropertyCapacityInJSObj(GateRef oldLength);
|
|
|
|
GateRef FindTransitions(GateRef glue, GateRef receiver, GateRef hclass, GateRef key, GateRef attr);
|
|
|
|
GateRef TaggedToRepresentation(GateRef value);
|
|
|
|
GateRef LoadFromField(GateRef receiver, GateRef handlerInfo);
|
|
|
|
GateRef LoadGlobal(GateRef cell);
|
|
|
|
GateRef LoadElement(GateRef receiver, GateRef key);
|
|
|
|
GateRef TryToElementsIndex(GateRef glue, GateRef key);
|
|
|
|
GateRef CheckPolyHClass(GateRef cachedValue, GateRef hclass);
|
|
|
|
GateRef LoadICWithHandler(GateRef glue, GateRef receiver, GateRef holder, GateRef handler);
|
|
|
|
GateRef StoreICWithHandler(GateRef glue, GateRef receiver, GateRef holder,
|
|
|
|
GateRef value, GateRef handler);
|
|
|
|
GateRef ICStoreElement(GateRef glue, GateRef receiver, GateRef key,
|
|
|
|
GateRef value, GateRef handlerInfo);
|
|
|
|
GateRef GetArrayLength(GateRef object);
|
2022-03-07 06:42:40 +00:00
|
|
|
GateRef DoubleToInt(GateRef glue, GateRef x);
|
2021-12-17 09:18:10 +00:00
|
|
|
void StoreField(GateRef glue, GateRef receiver, GateRef value, GateRef handler);
|
|
|
|
void StoreWithTransition(GateRef glue, GateRef receiver, GateRef value, GateRef handler);
|
|
|
|
GateRef StoreGlobal(GateRef glue, GateRef value, GateRef cell);
|
|
|
|
void JSHClassAddProperty(GateRef glue, GateRef receiver, GateRef key, GateRef attr);
|
|
|
|
void NotifyHClassChanged(GateRef glue, GateRef oldHClass, GateRef newHClass);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef TaggedCastToInt64(GateRef x);
|
|
|
|
GateRef TaggedCastToInt32(GateRef x);
|
|
|
|
GateRef TaggedCastToDouble(GateRef x);
|
|
|
|
GateRef TaggedCastToWeakReferentUnChecked(GateRef x);
|
|
|
|
GateRef ChangeInt32ToFloat64(GateRef x);
|
2022-03-21 02:09:13 +00:00
|
|
|
GateRef ChangeUInt32ToFloat64(GateRef x);
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef ChangeFloat64ToInt32(GateRef x);
|
|
|
|
GateRef ChangeTaggedPointerToInt64(GateRef x);
|
|
|
|
GateRef ChangeInt64ToTagged(GateRef x);
|
|
|
|
GateRef CastInt64ToFloat64(GateRef x);
|
|
|
|
GateRef SExtInt32ToInt64(GateRef x);
|
|
|
|
GateRef SExtInt1ToInt64(GateRef x);
|
|
|
|
GateRef SExtInt1ToInt32(GateRef x);
|
|
|
|
GateRef ZExtInt8ToInt16(GateRef x);
|
|
|
|
GateRef ZExtInt32ToInt64(GateRef x);
|
|
|
|
GateRef ZExtInt1ToInt64(GateRef x);
|
|
|
|
GateRef ZExtInt1ToInt32(GateRef x);
|
|
|
|
GateRef ZExtInt8ToInt32(GateRef x);
|
|
|
|
GateRef ZExtInt8ToInt64(GateRef x);
|
|
|
|
GateRef ZExtInt8ToPtr(GateRef x);
|
|
|
|
GateRef ZExtInt16ToPtr(GateRef x);
|
|
|
|
GateRef SExtInt32ToPtr(GateRef x);
|
|
|
|
GateRef ZExtInt16ToInt32(GateRef x);
|
|
|
|
GateRef ZExtInt16ToInt64(GateRef x);
|
|
|
|
GateRef TruncInt64ToInt32(GateRef x);
|
|
|
|
GateRef TruncPtrToInt32(GateRef x);
|
|
|
|
GateRef TruncInt64ToInt1(GateRef x);
|
|
|
|
GateRef TruncInt32ToInt1(GateRef x);
|
|
|
|
GateRef GetGlobalConstantAddr(GateRef index);
|
|
|
|
GateRef GetGlobalConstantString(ConstantIndex index);
|
|
|
|
GateRef IsCallable(GateRef obj);
|
|
|
|
GateRef GetOffsetFieldInPropAttr(GateRef attr);
|
|
|
|
GateRef SetOffsetFieldInPropAttr(GateRef attr, GateRef value);
|
|
|
|
GateRef SetIsInlinePropsFieldInPropAttr(GateRef attr, GateRef value);
|
|
|
|
void SetHasConstructorToHClass(GateRef glue, GateRef hClass, GateRef value);
|
|
|
|
void UpdateValueInDict(GateRef glue, GateRef elements, GateRef index, GateRef value);
|
|
|
|
GateRef GetBitMask(GateRef bitoffset);
|
|
|
|
GateRef IntptrEuqal(GateRef x, GateRef y);
|
2021-12-17 09:18:10 +00:00
|
|
|
void SetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value);
|
|
|
|
GateRef GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index);
|
|
|
|
GateRef GetPropertyByName(GateRef glue, GateRef receiver, GateRef key);
|
|
|
|
GateRef SetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value);
|
|
|
|
GateRef SetPropertyByName(GateRef glue, GateRef receiver, GateRef key,
|
|
|
|
GateRef value); // Crawl prototype chain
|
|
|
|
|
|
|
|
GateRef SetPropertyByNameWithOwn(GateRef glue, GateRef receiver, GateRef key,
|
|
|
|
GateRef value); // Do not crawl the prototype chain
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef GetParentEnv(GateRef object);
|
|
|
|
GateRef GetPropertiesFromLexicalEnv(GateRef object, GateRef index);
|
|
|
|
void SetPropertiesToLexicalEnv(GateRef glue, GateRef object, GateRef index, GateRef value);
|
|
|
|
GateRef GetFunctionBitFieldFromJSFunction(GateRef object);
|
|
|
|
GateRef GetHomeObjectFromJSFunction(GateRef object);
|
|
|
|
void SetLexicalEnvToFunction(GateRef glue, GateRef object, GateRef lexicalEnv);
|
|
|
|
GateRef GetGlobalObject(GateRef glue);
|
|
|
|
GateRef GetEntryIndexOfGlobalDictionary(GateRef entry);
|
|
|
|
GateRef GetBoxFromGlobalDictionary(GateRef object, GateRef entry);
|
|
|
|
GateRef GetValueFromGlobalDictionary(GateRef object, GateRef entry);
|
|
|
|
GateRef GetPropertiesFromJSObject(GateRef object);
|
2022-03-14 03:50:02 +00:00
|
|
|
template<OpCode::Op Op, MachineType Type>
|
2022-03-16 10:12:15 +00:00
|
|
|
GateRef BinaryOp(GateRef x, GateRef y);
|
2022-02-19 02:09:52 +00:00
|
|
|
GateRef GetGlobalOwnProperty(GateRef glue, GateRef receiver, GateRef key);
|
|
|
|
// fast path
|
|
|
|
GateRef FastEqual(GateRef left, GateRef right);
|
2022-03-14 03:50:02 +00:00
|
|
|
GateRef FastMod(GateRef gule, GateRef left, GateRef right);
|
|
|
|
GateRef FastTypeOf(GateRef left, GateRef right);
|
2022-02-19 02:09:52 +00:00
|
|
|
GateRef FastMul(GateRef left, GateRef right);
|
|
|
|
GateRef FastDiv(GateRef left, GateRef right);
|
2022-03-14 03:50:02 +00:00
|
|
|
GateRef FastAdd(GateRef left, GateRef right);
|
|
|
|
GateRef FastSub(GateRef left, GateRef right);
|
2021-10-15 02:20:54 +00:00
|
|
|
|
2022-01-04 11:30:40 +00:00
|
|
|
// Add SpecialContainer
|
|
|
|
GateRef GetContainerProperty(GateRef glue, GateRef receiver, GateRef index, GateRef jsType);
|
|
|
|
GateRef JSArrayListGet(GateRef glue, GateRef receiver, GateRef index);
|
2021-09-04 08:06:49 +00:00
|
|
|
private:
|
2022-03-21 12:06:33 +00:00
|
|
|
using BinaryOperation = std::function<GateRef(Environment*, GateRef, GateRef)>;
|
|
|
|
template<OpCode::Op Op>
|
|
|
|
GateRef FastAddSubAndMul(GateRef left, GateRef right);
|
|
|
|
GateRef FastBinaryOp(GateRef left, GateRef right,
|
|
|
|
const BinaryOperation& intOp, const BinaryOperation& floatOp);
|
2021-09-09 09:40:54 +00:00
|
|
|
Environment env_;
|
|
|
|
std::string methodName_;
|
|
|
|
int nextVariableId_ {0};
|
2021-09-04 08:06:49 +00:00
|
|
|
};
|
2021-12-23 06:55:22 +00:00
|
|
|
} // namespace panda::ecmascript::kungfu
|
2021-12-17 09:18:10 +00:00
|
|
|
#endif // ECMASCRIPT_COMPILER_STUB_H
|