Skip to content
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

[3.2] reenable warnings for softfloat and wasm-jit, and fix a warning in wasm-jit #263

Merged
merged 7 commits into from
Oct 4, 2022
5 changes: 0 additions & 5 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ set(EOSVM_INSTALL_COMPONENT "dev")

add_subdirectory( libfc )
add_subdirectory( builtins )

# Suppress warnings on 3rdParty Library
add_definitions( -w )
add_subdirectory( softfloat )
add_subdirectory( wasm-jit )
remove_definitions( -w )

add_subdirectory( chainbase )
set(APPBASE_ENABLE_AUTO_VERSION OFF CACHE BOOL "enable automatic discovery of version via 'git describe'")
add_subdirectory( appbase )
Expand Down
6 changes: 1 addition & 5 deletions libraries/wasm-jit/Source/Logging/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ namespace Log
static bool categoryEnabled[(Uptr)Category::num] =
{
true, // error
#ifdef _DEBUG // debug
true,
#else
false,
#endif
false,// debug
WAVM_METRICS_OUTPUT != 0 // metrics
};
void setCategoryEnabled(Category category,bool enable)
Expand Down
20 changes: 1 addition & 19 deletions libraries/wasm-jit/Source/WAST/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,8 @@ namespace WAST
addLiteralToNFA(literalString,nfaBuilder,0,finalState);
}

#ifndef _DEBUG
if(false)
#endif
{
std::ofstream debugGraphStream("nfaGraph.dot");
debugGraphStream << NFA::dumpNFAGraphViz(nfaBuilder).c_str();
debugGraphStream.close();
}

nfaMachine = NFA::Machine(nfaBuilder);

#ifndef _DEBUG
if(false)
#endif
{
std::ofstream debugGraphStream("dfaGraph.dot");
debugGraphStream << nfaMachine.dumpDFAGraphViz().c_str();
debugGraphStream.close();
}

Timing::logTimer("built lexer tables",timer);
}

Expand Down Expand Up @@ -366,4 +348,4 @@ namespace WAST

return result;
}
}
}
137 changes: 1 addition & 136 deletions libraries/wasm-jit/Source/WAST/NFA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,139 +463,4 @@ namespace NFA
if(numSetChars > 1) { edgeLabel += "]"; }
return edgeLabel;
}

std::string dumpNFAGraphViz(const Builder* builder)
{
std::string result;
result += "digraph {\n";
std::set<StateIndex> terminalStates;
for(Uptr stateIndex = 0;stateIndex < builder->nfaStates.size();++stateIndex)
{
const NFAState& nfaState = builder->nfaStates[stateIndex];

result += "state" + std::to_string(stateIndex) + "[shape=square label=\"" + std::to_string(stateIndex) + "\"];\n";

for(const auto& statePredicatePair : nfaState.nextStateToPredicateMap)
{
std::string edgeLabel = getGraphEdgeLabel(statePredicatePair.second);
std::string nextStateName = statePredicatePair.first < 0
? "terminal" + std::to_string(-statePredicatePair.first)
: "state" + std::to_string(statePredicatePair.first);
result += "state" + std::to_string(stateIndex)
+ " -> "
+ nextStateName + "[label=\"" + escapeString(edgeLabel) + "\"];\n";
if(statePredicatePair.first < 0)
{
terminalStates.emplace(statePredicatePair.first);
}
}

for(auto epsilonNextState : nfaState.epsilonNextStates)
{
std::string nextStateName = epsilonNextState < 0
? "terminal" + std::to_string(-epsilonNextState)
: "state" + std::to_string(epsilonNextState);
result += "state" + std::to_string(stateIndex) + " -> " + nextStateName + "[label=\"&epsilon;\"];\n";
}
}
for(auto terminalState : terminalStates)
{
result += "terminal" + std::to_string(-terminalState)
+ "[shape=octagon label=\"" + std::to_string(maximumTerminalStateIndex - terminalState) + "\"];\n";
}
result += "}\n";
return result;
}

std::string Machine::dumpDFAGraphViz() const
{
std::string result;
result += "digraph {\n";
std::set<StateIndex> terminalStates;

CharSet* classCharSets = (CharSet*)alloca(sizeof(CharSet) * numClasses);
memset(classCharSets,0,sizeof(CharSet) * numClasses);
for(Uptr charIndex = 0;charIndex < 256;++charIndex)
{
const Uptr classIndex = charToOffsetMap[charIndex] / numStates;
classCharSets[classIndex].add((U8)charIndex);
}

{
std::map<StateIndex,CharSet> transitions;
for(Uptr classIndex = 0;classIndex < numClasses;++classIndex)
{
const InternalStateIndex nextState = stateAndOffsetToNextStateMap[0 + classIndex * numStates];
CharSet& transitionPredicate = transitions[nextState];
transitionPredicate = classCharSets[classIndex] | transitionPredicate;
}

Uptr startIndex = 0;
for(auto transitionPair : transitions)
{
if((transitionPair.first & ~edgeDoesntConsumeInputFlag) != unmatchedCharacterTerminal)
{
result += "start" + std::to_string(startIndex) + "[shape=triangle label=\"\"];\n";

std::string edgeLabel = getGraphEdgeLabel(transitionPair.second);
std::string nextStateName = transitionPair.first < 0
? "terminal" + std::to_string(-(transitionPair.first & ~edgeDoesntConsumeInputFlag))
: "state" + std::to_string(transitionPair.first);
result += "start" + std::to_string(startIndex)
+ " -> "
+ nextStateName + "[label=\""
+ (transitionPair.first < 0 && (transitionPair.first & edgeDoesntConsumeInputFlag) != 0 ? "&epsilon; " : "")
+ escapeString(edgeLabel) + "\"];\n";

if(transitionPair.first < 0)
{
terminalStates.emplace(StateIndex(transitionPair.first & ~edgeDoesntConsumeInputFlag));
}

++startIndex;
}
}
}

for(Uptr stateIndex = 1;stateIndex < numStates;++stateIndex)
{
result += "state" + std::to_string(stateIndex) + "[shape=square label=\"" + std::to_string(stateIndex) + "\"];\n";

std::map<StateIndex,CharSet> transitions;
for(Uptr classIndex = 0;classIndex < numClasses;++classIndex)
{
const InternalStateIndex nextState = stateAndOffsetToNextStateMap[stateIndex + classIndex * numStates];
CharSet& transitionPredicate = transitions[nextState];
transitionPredicate = classCharSets[classIndex] | transitionPredicate;
}

for(auto transitionPair : transitions)
{
if((transitionPair.first & ~edgeDoesntConsumeInputFlag) != unmatchedCharacterTerminal)
{
std::string edgeLabel = getGraphEdgeLabel(transitionPair.second);
std::string nextStateName = transitionPair.first < 0
? "terminal" + std::to_string(-(transitionPair.first & ~edgeDoesntConsumeInputFlag))
: "state" + std::to_string(transitionPair.first);
result += "state" + std::to_string(stateIndex)
+ " -> "
+ nextStateName + "[label=\""
+ (transitionPair.first < 0 && (transitionPair.first & edgeDoesntConsumeInputFlag) != 0 ? "&epsilon; " : "")
+ escapeString(edgeLabel) + "\"];\n";

if(transitionPair.first < 0)
{
terminalStates.emplace(transitionPair.first);
}
}
}
}
for(auto terminalState : terminalStates)
{
result += "terminal" + std::to_string(-(terminalState & ~edgeDoesntConsumeInputFlag))
+ "[shape=octagon label=\"" + std::to_string(maximumTerminalStateIndex - (terminalState & ~edgeDoesntConsumeInputFlag)) + "\"];\n";
}
result += "}\n";
return result;
}
}
}
8 changes: 1 addition & 7 deletions libraries/wasm-jit/Source/WAST/NFA.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ namespace NFA
void addEpsilonEdge(Builder* builder,StateIndex initialState,StateIndex nextState);
StateIndex getNonTerminalEdge(Builder* builder,StateIndex initialState,char c);

// Dumps the NFA's states and edges to the GraphViz .dot format.
std::string dumpNFAGraphViz(const Builder* builder);

// Encapsulates a NFA that has been translated into a DFA that can be efficiently executed.
struct Machine
{
Expand Down Expand Up @@ -71,9 +68,6 @@ namespace NFA
return (StateIndex)state;
}

// Dumps the DFA's states and edges to the GraphViz .dot format.
std::string dumpDFAGraphViz() const;

private:

typedef I16 InternalStateIndex;
Expand All @@ -86,4 +80,4 @@ namespace NFA

void moveFrom(Machine&& inMachine);
};
}
}