Skip to content

Commit

Permalink
Detect also marked as needed methods if the method was previous add a…
Browse files Browse the repository at this point in the history
…s replacement
  • Loading branch information
Horcrux7 committed May 22, 2022
1 parent 52dd9a1 commit 5a22c94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/de/inetsoftware/jwebassembly/module/FunctionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class FunctionManager {

private final Set<String> usedClasses = new LinkedHashSet<>();

private int neededCount;

private boolean isFinish;

/**
Expand All @@ -71,12 +73,12 @@ private FunctionState getOrCreate( @Nonnull FunctionName name ) {
}

/**
* Get the count of known functions
* Get the count of needed functions
*
* @return the count
*/
int size() {
return states.size();
int getNeededCount() {
return neededCount;
}

/**
Expand Down Expand Up @@ -171,6 +173,7 @@ FunctionName markAsNeeded( @Nonnull FunctionName name, boolean needThisParameter
if( isFinish ) {
throw new WasmException( "Prepare was already finish: " + name.signatureName, -1 );
}
neededCount++;
state.state = State.Needed;
state.needThisParameter = needThisParameter;
JWebAssembly.LOGGER.fine( "\t\tcall: " + name.signatureName );
Expand Down
4 changes: 2 additions & 2 deletions src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ public void prepareFinish() throws IOException {
int functCount;
do {
scanFunctions();
functCount = functions.size(); // scan the functions can find new needed types or only new needed fields in the known types
functCount = functions.getNeededCount(); // scan the functions can find new needed types or only new needed fields in the known types
scanForClinit();
types.scanTypeHierarchy(); // scan the type hierarchy can find new functions
} while( functCount < functions.size() );
} while( functCount < functions.getNeededCount() );

// write only the needed imports to the output
for( Iterator<FunctionName> iterator = functions.getNeededImports(); iterator.hasNext(); ) {
Expand Down

0 comments on commit 5a22c94

Please sign in to comment.