Skip to content

Commit

Permalink
Cleanup: Switch jsg::Data invariant assertion to be fully inline
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaimano committed Apr 13, 2023
1 parent 4e2f3db commit a94ac02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
7 changes: 0 additions & 7 deletions src/workerd/jsg/jsg.c++
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ void Data::destroy() {
}
}

#ifdef KJ_DEBUG
void Data::assertInvariantImpl() {
// Assert that only empty values are associated with null isolates.
KJ_DASSERT(isolate != nullptr || handle.IsEmpty());
}
#endif

Lock::Lock(v8::Isolate* v8Isolate)
: v8Isolate(v8Isolate), locker(v8Isolate), scope(v8Isolate),
previousData(v8Isolate->GetData(2)),
Expand Down
13 changes: 7 additions & 6 deletions src/workerd/jsg/jsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <kj/function.h>
#include <kj/exception.h>
#include <kj/one-of.h>
#include <kj/debug.h>
#include <type_traits>
#include <v8.h>
#include "macro-meta.h"
Expand Down Expand Up @@ -784,13 +785,13 @@ class Data {

// Debugging helpers.
void assertInvariant() {
#ifdef KJ_DEBUG
assertInvariantImpl();
#endif
// Assert that only empty values are associated with null isolates.
//
// Note that we use IASSERT (which is only enabled in debug) here because this function is
// intended to be invoked from the move ctor and assignment operator. We expect them to be
// invoked a lot and want them to be as optimizable as possible.
KJ_IASSERT(isolate != nullptr || handle.IsEmpty());
}
#ifdef KJ_DEBUG
void assertInvariantImpl();
#endif
};

template <typename T>
Expand Down

0 comments on commit a94ac02

Please # to comment.