• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_DEPEND_CHAIN_HELPER_H
17 #define ECMASCRIPT_COMPILER_DEPEND_CHAIN_HELPER_H
18 
19 #include "ecmascript/compiler/circuit_builder.h"
20 #include "ecmascript/compiler/gate_accessor.h"
21 #include "ecmascript/compiler/graph_visitor.h"
22 #include "ecmascript/compiler/later_elimination.h"
23 #include "ecmascript/compiler/range_guard.h"
24 #include "ecmascript/mem/chunk_containers.h"
25 
26 namespace panda::ecmascript::kungfu {
27 class LaterElimination;
28 class RangeGuard;
29 class DependChains : public ChunkObject {
30 public:
DependChains(Chunk * chunk)31     DependChains(Chunk* chunk) : chunk_(chunk) {}
32     ~DependChains() = default;
33 
34     DependChains* UpdateNode(GateRef gate);
35     bool Equals(DependChains* that);
36     void Merge(DependChains* that);
CopyFrom(DependChains * other)37     void CopyFrom(DependChains *other)
38     {
39         head_ = other->head_;
40         size_ = other->size_;
41     }
42     uint32_t FoundIndexCheckedForLength(RangeGuard* rangeGuard, GateRef input);
43     uint32_t FoundIndexCheckedForIndex(RangeGuard* rangeGuard, GateRef input);
44     GateRef LookupNode(LaterElimination* elimination, GateRef gate);
45 private:
46     struct Node {
NodeNode47         Node(GateRef gate, Node* next) : gate(gate), next(next) {}
48         GateRef gate;
49         Node *next;
50     };
51 
52     Node *head_{nullptr};
53     size_t size_ {0};
54     Chunk* chunk_;
55 };
56 }  // panda::ecmascript::kungfu
57 #endif  // ECMASCRIPT_COMPILER_DEPEND_CHAIN_HELPER_H