• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
24 namespace panda::ecmascript::kungfu {
25 class NumberSpeculativeRunner {
26 public:
NumberSpeculativeRunner(Circuit * circuit,bool enableLog,bool enableArrayBoundsCheckElimination,const std::string & name,Chunk * chunk)27     NumberSpeculativeRunner(Circuit *circuit, bool enableLog, bool enableArrayBoundsCheckElimination,
28                             const std::string& name, Chunk* chunk)
29         : circuit_(circuit), acc_(circuit), enableLog_(enableLog),
30           enableArrayBoundsCheckElimination_(enableArrayBoundsCheckElimination), methodName_(name),
31           chunk_(chunk), typeInfos_(chunk), rangeInfos_(chunk) {}
32 
33     ~NumberSpeculativeRunner() = default;
34     void Run();
35 private:
IsLogEnabled()36     bool IsLogEnabled() const
37     {
38         return enableLog_;
39     }
40 
GetMethodName()41     const std::string& GetMethodName() const
42     {
43         return methodName_;
44     }
45 
46     Circuit *circuit_ {nullptr};
47     GateAccessor acc_;
48     bool enableLog_ {false};
49     bool enableArrayBoundsCheckElimination_ {true};
50     std::string methodName_;
51     Chunk *chunk_ {nullptr};
52     ChunkVector<TypeInfo> typeInfos_;
53     ChunkVector<RangeInfo> rangeInfos_;
54 };
55 }  // panda::ecmascript::kungfu
56 #endif  // ECMASCRIPT_COMPILER_NUMBER_SPECULATIVE_RUNNER_H
57