Skip to content

Commit

Permalink
non-RTTI dynamic cast (souffle-lang#2452)
Browse files Browse the repository at this point in the history
Dynamic cast have a significant performance impact on Souffle AST/RAM
pipelines.

* non-RTTI dynamic cast for the ast::Node hierarchy
* non-RTTI dynamic cast for the ast::analysis::Type hierarchy
* non-RTTI dynamic cast for the ram::Node hierarchy
  • Loading branch information
quentin committed Jun 11, 2024
1 parent 19008af commit f1c664a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/ast/Aggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ namespace souffle::ast {
*/
class Aggregator : public Argument {
public:

Aggregator(NodeKind kind, Own<Argument> expr = {}, Own<Argument> second = {}, VecOwn<Literal> body = {},
Aggregator(NodeKind Kind, Own<Argument> expr = {}, Own<Argument> second = {}, VecOwn<Literal> body = {},
VecOwn<OrderByElement> orderby = {}, SrcLocation loc = {});

/** Return target expression */
Expand Down Expand Up @@ -72,6 +71,8 @@ class Aggregator : public Argument {

const VecOwn<OrderByElement>& getOrderByElements() const;

static bool classof(const Node*);

protected:
NodeVec getChildren() const override;

Expand Down
3 changes: 2 additions & 1 deletion src/ast/IntrinsicAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace souffle::ast {
IntrinsicAggregator::IntrinsicAggregator(AggregateOp baseOperator, Own<Argument> expr, Own<Argument> second,
VecOwn<Literal> body, VecOwn<OrderByElement> orderby, SrcLocation loc)
: Aggregator(NK_IntrinsicAggregator, std::move(expr), std::move(second), std::move(body), std::move(orderby), std::move(loc)),
: Aggregator(NK_IntrinsicAggregator, std::move(expr), std::move(second), std::move(body),
std::move(orderby), std::move(loc)),
baseOperator(baseOperator) {}

void IntrinsicAggregator::print(std::ostream& os) const {
Expand Down
2 changes: 1 addition & 1 deletion src/ram/Aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Aggregate : public RelationOperation, public AbstractAggregate {
Aggregate(NodeKind kind, Own<Operation> nested, Own<Aggregator> fun, std::string rel,
Own<Expression> expression, Own<Expression> second, Own<Condition> condition, VecOwn<Expression> orderBy, std::size_t ident)
: RelationOperation(kind, rel, ident, std::move(nested)),
AbstractAggregate(std::move(fun), std::move(expression), std::move(condition), std::move(condition), std::move(orderBy)) {
AbstractAggregate(std::move(fun), std::move(expression), std::move(second), std::move(condition), std::move(orderBy)) {
assert(kind >= NK_Aggregate && kind < NK_LastAggregate);
}

Expand Down
1 change: 1 addition & 0 deletions src/ram/IndexAggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class IndexAggregate : public IndexOperation, public AbstractAggregate {
}
return new IndexAggregate(NK_IndexAggregate, clone(getOperation()), clone(function), relation,
clone(expression), clone(second), clone(condition), clone(orderBy), std::move(pattern), getTupleId());
getTupleId());
}

void apply(const NodeMapper& map) override {
Expand Down

0 comments on commit f1c664a

Please sign in to comment.