1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_COMPILER_NUMBER_SPECULATIVE_RUNNER_H 17 #define ECMASCRIPT_COMPILER_NUMBER_SPECULATIVE_RUNNER_H 18 19 #include "ecmascript/compiler/number_speculative_lowering.h" 20 #include "ecmascript/compiler/pass_manager.h" 21 #include "ecmascript/compiler/number_speculative_retype.h" 22 #include "ecmascript/compiler/range_guard.h" 23 #include "ecmascript/ts_types/ts_manager.h" 24 25 namespace panda::ecmascript::kungfu { 26 class NumberSpeculativeRunner { 27 public: NumberSpeculativeRunner(Circuit * circuit,bool enableLog,bool enableArrayBoundsCheckElimination,const std::string & name,Chunk * chunk)28 NumberSpeculativeRunner(Circuit *circuit, bool enableLog, bool enableArrayBoundsCheckElimination, 29 const std::string& name, Chunk* chunk) 30 : circuit_(circuit), acc_(circuit), enableLog_(enableLog), 31 enableArrayBoundsCheckElimination_(enableArrayBoundsCheckElimination), methodName_(name), 32 chunk_(chunk), typeInfos_(chunk), rangeInfos_(chunk) {} 33 34 ~NumberSpeculativeRunner() = default; 35 void Run(); 36 private: IsLogEnabled()37 bool IsLogEnabled() const 38 { 39 return enableLog_; 40 } 41 GetMethodName()42 const std::string& GetMethodName() const 43 { 44 return methodName_; 45 } 46 47 Circuit *circuit_ {nullptr}; 48 GateAccessor acc_; 49 bool enableLog_ {false}; 50 bool enableArrayBoundsCheckElimination_ {true}; 51 std::string methodName_; 52 Chunk *chunk_ {nullptr}; 53 ChunkVector<TypeInfo> typeInfos_; 54 ChunkVector<RangeInfo> rangeInfos_; 55 }; 56 } // panda::ecmascript::kungfu 57 #endif // ECMASCRIPT_COMPILER_NUMBER_SPECULATIVE_RUNNER_H 58