8000 Make Sorbet faster to start in debug build by jez · Pull Request #8050 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make Sorbet faster to start in debug build #8050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ast/verifier/Verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VerifierWalker {
};

ExpressionPtr Verifier::run(core::Context ctx, ExpressionPtr node) {
if (!debug_mode) {
if constexpr (!debug_mode) {
return node;
}
VerifierWalker vw;
Expand Down
2 changes: 1 addition & 1 deletion cfg/CFG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ CFG::ReadsAndWrites CFG::findAllReadsAndWrites(core::Context ctx) {
}

void CFG::sanityCheck(core::Context ctx) {
if (!debug_mode) {
if constexpr (!debug_mode) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion cfg/builder/builder_finalize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void CFGBuilder::simplify(core::Context ctx, CFG &cfg) {
}

void CFGBuilder::sanityCheck(core::Context ctx, CFG &cfg) {
if (!debug_mode) {
if constexpr (!debug_mode) {
return;
}
for (auto &bb : cfg.basicBlocks) {
Expand Down
2 changes: 1 addition & 1 deletion common/backtrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void sorbet::Exception::printBacktrace() noexcept {
void sorbet::Exception::printBacktrace() noexcept {}
#endif // ifndef EMSCRIPTEN
void sorbet::Exception::failInFuzzer() noexcept {
if (fuzz_mode) {
if constexpr (fuzz_mode) {
__builtin_trap();
}
}
6 changes: 3 additions & 3 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ constexpr bool skip_slow_enforce = false;
} \
} while (false);

#define DEBUG_ONLY(X) \
if (debug_mode) { \
X; \
#define DEBUG_ONLY(X) \
if constexpr (debug_mode) { \
X; \
}

#define SLOW_DEBUG_ONLY(X) \
Expand Down
10 changes: 5 additions & 5 deletions common/counters/Counters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CounterImpl::histogramAdd(const char *histogram, int key, unsigned long val
}

void CounterImpl::prodHistogramAdd(const char *histogram, int key, unsigned long value) {
if (fuzz_mode) {
if constexpr (fuzz_mode) {
return;
}
this->histograms[histogram][key] += value;
Expand All @@ -65,7 +65,7 @@ void CounterImpl::categoryCounterAdd(const char *category, const char *counter,
}

void CounterImpl::prodCategoryCounterAdd(const char *category, const char *counter, unsigned long value) {
if (fuzz_mode) {
if constexpr (fuzz_mode) {
return;
}
this->countersByCategory[category][counter] += value;
Expand All @@ -79,21 +79,21 @@ void CounterImpl::counterAdd(const char *counter, unsigned long value) {
}

void CounterImpl::prodCounterAdd(const char *counter, unsigned long value) {
if (fuzz_mode) {
if constexpr (fuzz_mode) {
return;
}
this->counters[counter] += value;
}

void CounterImpl::prodCounterSet(const char *counter, unsigned long value) {
if (fuzz_mode) {
if constexpr (fuzz_mode) {
return;
}
this->counters[counter] = value;
}

void CounterImpl::timingAdd(CounterImpl::Timing timing) {
if (fuzz_mode) {
if constexpr (fuzz_mode) {
return;
}
this->timings.emplace_back(move(timing));
Expand Down
8 changes: 4 additions & 4 deletions core/FileHash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ FoundDefinitionRef FoundStaticFieldHash::owner() const {
}

void FoundStaticFieldHash::sanityCheck() const {
ENFORCE(nameHash.isDefined());
ENFORCE_NO_TIMER(nameHash.isDefined());
}

string FoundStaticFieldHash::toString() const {
Expand All @@ -122,7 +122,7 @@ FoundDefinitionRef FoundTypeMemberHash::owner() const {
}

void FoundTypeMemberHash::sanityCheck() const {
ENFORCE(nameHash.isDefined());
ENFORCE_NO_TIMER(nameHash.isDefined());
}

string FoundTypeMemberHash::toString() const {
Expand All @@ -140,7 +140,7 @@ FoundDefinitionRef FoundMethodHash::owner() const {
}

void FoundMethodHash::sanityCheck() const {
ENFORCE(nameHash.isDefined());
ENFORCE_NO_TIMER(nameHash.isDefined());
}

string FoundMethodHash::toString() const {
Expand All @@ -158,7 +158,7 @@ FoundDefinitionRef FoundFieldHash::owner() const {
}

void FoundFieldHash::sanityCheck() const {
ENFORCE(nameHash.isDefined());
ENFORCE_NO_TIMER(nameHash.isDefined());
}

string FoundFieldHash::toString() const {
Expand Down
32 changes: 16 additions & 16 deletions core/FileHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class WithoutUniqueNameHash {
WithoutUniqueNameHash(const WithoutUniqueNameHash &nm) noexcept = default;
WithoutUniqueNameHash() noexcept : _hashValue(0){};
inline bool operator==(const WithoutUniqueNameHash &rhs) const noexcept {
ENFORCE(isDefined());
ENFORCE(rhs.isDefined());
ENFORCE_NO_TIMER(isDefined());
ENFORCE_NO_TIMER(rhs.isDefined());
return _hashValue == rhs._hashValue;
}

Expand Down Expand Up @@ -52,8 +52,8 @@ class FullNameHash {
FullNameHash(const FullNameHash &nm) noexcept = default;
FullNameHash() noexcept : _hashValue(0){};
inline bool operator==(const FullNameHash &rhs) const noexcept {
ENFORCE(isDefined());
ENFORCE(rhs.isDefined());
ENFORCE_NO_TIMER(isDefined());
ENFORCE_NO_TIMER(rhs.isDefined());
return _hashValue == rhs._hashValue;
}

Expand Down Expand Up @@ -299,19 +299,19 @@ struct LocalSymbolTableHashes {
bool isInvalidParse() const {
DEBUG_ONLY(
if (hierarchyHash == HASH_STATE_INVALID_PARSE) {
ENFORCE(classModuleHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(typeMemberHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(fieldHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(staticFieldHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(classAliasHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(methodHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(classModuleHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(typeMemberHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(fieldHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(staticFieldHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(classAliasHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(methodHash == core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
} else {
ENFORCE(classModuleHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(typeMemberHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(fieldHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(staticFieldHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(classAliasHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE(methodHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(classModuleHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(typeMemberHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(fieldHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(staticFieldHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(classAliasHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
ENFORCE_NO_TIMER(methodHash != core::LocalSymbolTableHashes::HASH_STATE_INVALID_PARSE);
});
return hie 10000 rarchyHash == HASH_STATE_INVALID_PARSE;
}
Expand Down
42 changes: 21 additions & 21 deletions core/FoundDefinitions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,62 @@ using namespace std;
namespace sorbet::core {

FoundClass &FoundDefinitionRef::klass(FoundDefinitions &foundDefs) {
ENFORCE(kind() == FoundDefinitionRef::Kind::Class);
ENFORCE(foundDefs._klasses.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::Class);
ENFORCE_NO_TIMER(foundDefs._klasses.size() > idx());
return foundDefs._klasses[idx()];
}
const FoundClass &FoundDefinitionRef::klass(const FoundDefinitions &foundDefs) const {
ENFORCE(kind() == FoundDefinitionRef::Kind::Class);
ENFORCE(foundDefs._klasses.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::Class);
ENFORCE_NO_TIMER(foundDefs._klasses.size() > idx());
return foundDefs._klasses[idx()];
}

FoundMethod &FoundDefinitionRef::method(FoundDefinitions &foundDefs) {
ENFORCE(kind() == FoundDefinitionRef::Kind::Method);
ENFORCE(foundDefs._methods.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::Method);
ENFORCE_NO_TIMER(foundDefs._methods.size() > idx());
return foundDefs._methods[idx()];
}
const FoundMethod &FoundDefinitionRef::method(const FoundDefinitions &foundDefs) const {
ENFORCE(kind() == FoundDefinitionRef::Kind::Method);
ENFORCE(foundDefs._methods.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::Method);
ENFORCE_NO_TIMER(foundDefs._methods.size() > idx());
return foundDefs._methods[idx()];
}

FoundStaticField &FoundDefinitionRef::staticField(FoundDefinitions &foundDefs) {
ENFORCE(kind() == FoundDefinitionRef::Kind::StaticField);
ENFORCE(foundDefs._staticFields.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::StaticField);
ENFORCE_NO_TIMER(foundDefs._staticFields.size() > idx());
return foundDefs._staticFields[idx()];
}
const FoundStaticField &FoundDefinitionRef::staticField(const FoundDefinitions &foundDefs) const {
ENFORCE(kind() == FoundDefinitionRef::Kind::StaticField);
ENFORCE(foundDefs._staticFields.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::StaticField);
ENFORCE_NO_TIMER(foundDefs._staticFields.size() > idx());
return foundDefs._staticFields[idx()];
}

FoundTypeMember &FoundDefinitionRef::typeMember(FoundDefinitions &foundDefs) {
ENFORCE(kind() == FoundDefinitionRef::Kind::TypeMember);
ENFORCE(foundDefs._typeMembers.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::TypeMember);
ENFORCE_NO_TIMER(foundDefs._typeMembers.size() > idx());
return foundDefs._typeMembers[idx()];
}
const FoundTypeMember &FoundDefinitionRef::typeMember(const FoundDefinitions &foundDefs) const {
ENFORCE(kind() == FoundDefinitionRef::Kind::TypeMember);
ENFORCE(foundDefs._typeMembers.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::TypeMember);
ENFORCE_NO_TIMER(foundDefs._typeMembers.size() > idx());
return foundDefs._typeMembers[idx()];
}

FoundField &FoundDefinitionRef::field(FoundDefinitions &foundDefs) {
ENFORCE(kind() == FoundDefinitionRef::Kind::Field);
ENFORCE(foundDefs._fields.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::Field);
ENFORCE_NO_TIMER(foundDefs._fields.size() > idx());
return foundDefs._fields[idx()];
}
const FoundField &FoundDefinitionRef::field(const FoundDefinitions &foundDefs) const {
ENFORCE(kind() == FoundDefinitionRef::Kind::Field);
ENFORCE(foundDefs._fields.size() > idx());
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::Field);
ENFORCE_NO_TIMER(foundDefs._fields.size() > idx());
return foundDefs._fields[idx()];
}

core::ClassOrModuleRef FoundDefinitionRef::symbol() const {
ENFORCE(kind() == FoundDefinitionRef::Kind::Symbol);
ENFORCE_NO_TIMER(kind() == FoundDefinitionRef::Kind::Symbol);
return core::ClassOrModuleRef::fromRaw(_storage.id);
}

Expand Down
Loading
0