| 257 | }; |
| 258 | |
| 259 | static bool isEqualAstRecursive(const AstNode& lhs, const AstNode& rhs) { |
| 260 | |
| 261 | // number of operands and size of the operands must match |
| 262 | const int children_size = lhs.children_size(); |
| 263 | if (children_size != rhs.children_size()) return false; |
| 264 | if (lhs.bits() != rhs.bits()) return false; |
| 265 | |
| 266 | if (lhs.kind() != rhs.kind()) { |
| 267 | // to maximize the reuse of JIT'ed functions, jigsaw does not |
| 268 | // care about which relational operator is used, as long as |
| 269 | // they are both relational operators |
| 270 | if (isRelationalKind(lhs.kind()) && isRelationalKind(rhs.kind())) { |
| 271 | // do nothing, fall through to compare operands |
| 272 | } else { |
| 273 | return false; |
| 274 | } |
| 275 | } else if (lhs.hash() != rhs.hash()) { |
| 276 | // if the kind is the same, then hash has to match |
| 277 | return false; |
| 278 | } |
| 279 | // compare each operand |
| 280 | for (int i = 0; i < children_size; i++) { |
| 281 | if (!isEqualAstRecursive(lhs.children(i), rhs.children(i))) |
| 282 | return false; |
| 283 | } |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | static inline bool isEqualAst(const AstNode& lhs, const AstNode& rhs) { |
| 288 | return isEqualAstRecursive(lhs, rhs); |
no test coverage detected