14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_COMPILER_BASELINE_BASELINE_STUBS_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_COMPILER_BASELINE_BASELINE_STUBS_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include "ecmascript/compiler/baseline/baseline_compiler_builtins.h" 204514f5e3Sopenharmony_ci#include "ecmascript/compiler/baseline/baseline_stub_csigns.h" 214514f5e3Sopenharmony_ci#include "ecmascript/compiler/stub_builder.h" 224514f5e3Sopenharmony_ci#include "ecmascript/base/config.h" 234514f5e3Sopenharmony_ci#include "ecmascript/compiler/profiler_operation.h" 244514f5e3Sopenharmony_ci 254514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu { 264514f5e3Sopenharmony_ci 274514f5e3Sopenharmony_ciclass BaselineStubBuilder : public StubBuilder { 284514f5e3Sopenharmony_cipublic: 294514f5e3Sopenharmony_ci BaselineStubBuilder(CallSignature *callSignature, Environment *env) 304514f5e3Sopenharmony_ci : StubBuilder(callSignature, env) {} 314514f5e3Sopenharmony_ci ~BaselineStubBuilder() override = default; 324514f5e3Sopenharmony_ci NO_MOVE_SEMANTIC(BaselineStubBuilder); 334514f5e3Sopenharmony_ci NO_COPY_SEMANTIC(BaselineStubBuilder); 344514f5e3Sopenharmony_ci virtual void GenerateCircuit() override = 0; 354514f5e3Sopenharmony_ci 364514f5e3Sopenharmony_ci inline void SetEnvToFrame(GateRef glue, GateRef frame, GateRef value); 374514f5e3Sopenharmony_ci inline void CheckExceptionWithVar(GateRef glue, GateRef sp, GateRef res, GateRef acc); 384514f5e3Sopenharmony_ci inline void CheckException(GateRef glue, GateRef sp, GateRef res); 394514f5e3Sopenharmony_ci inline void CheckExceptionReturn(GateRef glue, GateRef sp, GateRef res); 404514f5e3Sopenharmony_ci inline void CheckExceptionWithJump(GateRef glue, GateRef sp, GateRef res, GateRef acc, Label *jump); 414514f5e3Sopenharmony_ci inline void CheckExceptionWithJumpAndReturn(GateRef glue, GateRef sp, GateRef res, GateRef acc, Label *jump); 424514f5e3Sopenharmony_ci inline void CheckPendingException(GateRef glue, GateRef sp, GateRef res, GateRef acc); 434514f5e3Sopenharmony_ci inline void DispatchLast(GateRef glue, GateRef sp, GateRef acc); 444514f5e3Sopenharmony_ci inline GateRef GetFunctionFromFrame(GateRef frame); 454514f5e3Sopenharmony_ci inline GateRef GetEnvFromFrame(GateRef frame); 464514f5e3Sopenharmony_ci inline GateRef GetAccFromFrame(GateRef frame); 474514f5e3Sopenharmony_ci inline GateRef GetConstpoolFromMethod(GateRef method); 484514f5e3Sopenharmony_ci inline GateRef GetProfileTypeInfoFromFunction(GateRef function); 494514f5e3Sopenharmony_ci inline GateRef GetHotnessCounterFromMethod(GateRef method); 504514f5e3Sopenharmony_ci inline GateRef GetModuleFromFunction(GateRef function); 514514f5e3Sopenharmony_ci inline GateRef GetHomeObjectFromFunction(GateRef function); 524514f5e3Sopenharmony_ci inline GateRef GetModule(GateRef sp); 534514f5e3Sopenharmony_ci inline GateRef GetCurrentFrame(GateRef glue); 544514f5e3Sopenharmony_ci inline GateRef GetFrame(GateRef CurrentSp); 554514f5e3Sopenharmony_ci inline GateRef GetPcFromFrame(GateRef frame); 564514f5e3Sopenharmony_ci inline GateRef GetCallSizeFromFrame(GateRef frame); 574514f5e3Sopenharmony_ci inline GateRef GetThisFromFrame(GateRef frame); 584514f5e3Sopenharmony_ci inline GateRef GetNewTarget(GateRef sp); 594514f5e3Sopenharmony_ci inline GateRef GetStartIdxAndNumArgs(GateRef sp, GateRef restIdx); 604514f5e3Sopenharmony_ci inline void SetVregValue(GateRef glue, GateRef sp, GateRef idx, GateRef val); 614514f5e3Sopenharmony_ci inline GateRef GetVregValue(GateRef sp, GateRef idx); 624514f5e3Sopenharmony_ci inline GateRef GetResumeModeFromGeneratorObject(GateRef obj); 634514f5e3Sopenharmony_ci inline GateRef GetResumeModeFromAsyncGeneratorObject(GateRef obj); 644514f5e3Sopenharmony_ci inline GateRef GetLastLeaveFrame(GateRef glue); 654514f5e3Sopenharmony_ci inline GateRef CallBaselineStub(GateRef glue, int index, const std::initializer_list<GateRef>& args); 664514f5e3Sopenharmony_ci}; 674514f5e3Sopenharmony_ci 684514f5e3Sopenharmony_ci#define DECLARE_STUB_CLASS(name) \ 694514f5e3Sopenharmony_ci class name##StubBuilder : public BaselineStubBuilder { \ 704514f5e3Sopenharmony_ci public: \ 714514f5e3Sopenharmony_ci name##StubBuilder(CallSignature *callSignature, Environment *env) \ 724514f5e3Sopenharmony_ci : BaselineStubBuilder(callSignature, env) \ 734514f5e3Sopenharmony_ci { \ 744514f5e3Sopenharmony_ci env->GetCircuit()->SetFrameType(FrameType::BASELINE_BUILTIN_FRAME); \ 754514f5e3Sopenharmony_ci } \ 764514f5e3Sopenharmony_ci ~name##StubBuilder() = default; \ 774514f5e3Sopenharmony_ci NO_MOVE_SEMANTIC(name##StubBuilder); \ 784514f5e3Sopenharmony_ci NO_COPY_SEMANTIC(name##StubBuilder); \ 794514f5e3Sopenharmony_ci void GenerateCircuit() override; \ 804514f5e3Sopenharmony_ci }; 814514f5e3Sopenharmony_ci BASELINE_COMPILER_BUILTIN_LIST(DECLARE_STUB_CLASS) 824514f5e3Sopenharmony_ci#undef DECLARE_STUB_CLASS 834514f5e3Sopenharmony_ci} // namespace panda::ecmascript::kungfu 844514f5e3Sopenharmony_ci#endif // ECMASCRIPT_COMPILER_BASELINE_BASELINE_STUBS_H 85