Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGrulich committed Mar 23, 2024
1 parent 96fa858 commit f353545
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
42 changes: 26 additions & 16 deletions nautilus-api/include/Interface/DataTypes/Val.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,21 @@ namespace nautilus {
inline val<ValueType>(ValueType value, const std::source_location loc = std::source_location::current())
: value(value), loc(loc), state(tracing::traceConstant(value)) {
//std::cout << loc.file_name() << std::endl;
// ((auto tag = tracing::getTag();
tracing::getVarRefMap()[state]++;
// std::cout << "value constructor " << state << " - " << tag << std::endl;
// ((auto tag = tracing::getTag();
if (tracing::inTracer()) {
tracing::getVarRefMap()[state]++;
}
// std::cout << "value constructor " << state << " - " << tag << std::endl;
};


inline val<ValueType>(const val<ValueType> &other,
const std::source_location loc = std::source_location::current())
: value(other.value), loc(loc), state(other.state) {

tracing::getVarRefMap()[state]++;
if (tracing::inTracer()) {
tracing::getVarRefMap()[state]++;
}
//std::cout << "copy constructor " << this->state << " - " << other.state << " - " << tag << std::endl;
//std::cout << "copy constructor " << this->state << " - " << other.state << " - " << std::endl;
// tracing::traceAssignment(other.state, other.state);
Expand All @@ -174,25 +178,31 @@ namespace nautilus {

#ifdef ENABLE_TRACING

inline val<ValueType>(ValueType, tracing::value_ref &tc) : state(tc) {
// auto tag = tracing::getTag();
tracing::getVarRefMap()[state]++;
// std::cout << "trace constructor " << state << " - " << tag << std::endl;
inline val<ValueType>(ValueType, tracing::value_ref &tc) : state(tc) {
// auto tag = tracing::getTag();
if (tracing::inTracer()) {
tracing::getVarRefMap()[state]++;
}
// std::cout << "trace constructor " << state << " - " << tag << std::endl;
};
#endif


~val() {
// auto tag = tracing::getTag();
tracing::getVarRefMap()[state]--;
if (tracing::getVarRefMap()[state] == 0) {
tracing::traceValueDestruction(state);
//std::cout << "destructor " << state << " - " << tag << std::endl;
// auto tag = tracing::getTag();
if (tracing::inTracer()) {

tracing::getVarRefMap()[state]--;
if (tracing::getVarRefMap()[state] == 0) {
tracing::traceValueDestruction(state);
//std::cout << "destructor " << state << " - " << tag << std::endl;
}

}
}

val<ValueType> &operator=(const val<ValueType> &other) {
// auto tag = tracing::getTag();
// auto tag = tracing::getTag();
//std::cout << "copy assignment " << this->state << "<- " << other.state << " - " << tag << std::endl;
#ifdef ENABLE_TRACING
if (tracing::inTracer()) {
Expand Down Expand Up @@ -470,15 +480,15 @@ namespace nautilus {
val<bool> inline lAnd(val<bool> &left, val<bool> &right) {
if (tracing::inTracer()) {
auto tc = tracing::traceBinaryOp<tracing::AND, bool>(left.state, right.state);
return val<bool>{true,tc};
return val<bool>{true, tc};
}
return left.value && right.value;
}

val<bool> inline lNot(val<bool> &val) {
if (tracing::inTracer()) {
auto tc = tracing::traceUnaryOp<tracing::NOT, bool>(val.state);
return ::nautilus::val<bool>{true,tc};
return ::nautilus::val<bool>{true, tc};
}
return !val.value;
}
Expand Down
2 changes: 0 additions & 2 deletions nautilus-api/test/ExecutionTests/ExpressionFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace nautilus::engine {
val<int8_t> int8AddExpression(val<int8_t> x) {
val<int8_t> y = (int8_t) 2;
auto res = x + y;
y = res;
return y + x;
}

Expand Down
2 changes: 2 additions & 0 deletions nautilus-jit/src/Tracing/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace nautilus::tracing {

template<typename T>
[[maybe_unused]] value_ref traceConstant(T value) {
if (!inTracer())
return 0;
auto anyValue = std::any(value);
return TraceContext::get()->traceConstValue(to_type<T>(), anyValue);
}
Expand Down

0 comments on commit f353545

Please sign in to comment.