Detect also marked as needed methods if the method was previous add as replacement

This commit is contained in:
Volker Berlin 2022-05-22 18:36:36 +02:00
parent 52dd9a1665
commit 5a22c94b29
No known key found for this signature in database
GPG Key ID: 988423EF815BE4CB
2 changed files with 8 additions and 5 deletions

View File

@ -45,6 +45,8 @@ class FunctionManager {
private final Set<String> usedClasses = new LinkedHashSet<>(); private final Set<String> usedClasses = new LinkedHashSet<>();
private int neededCount;
private boolean isFinish; private boolean isFinish;
/** /**
@ -71,12 +73,12 @@ class FunctionManager {
} }
/** /**
* Get the count of known functions * Get the count of needed functions
* *
* @return the count * @return the count
*/ */
int size() { int getNeededCount() {
return states.size(); return neededCount;
} }
/** /**
@ -171,6 +173,7 @@ class FunctionManager {
if( isFinish ) { if( isFinish ) {
throw new WasmException( "Prepare was already finish: " + name.signatureName, -1 ); throw new WasmException( "Prepare was already finish: " + name.signatureName, -1 );
} }
neededCount++;
state.state = State.Needed; state.state = State.Needed;
state.needThisParameter = needThisParameter; state.needThisParameter = needThisParameter;
JWebAssembly.LOGGER.fine( "\t\tcall: " + name.signatureName ); JWebAssembly.LOGGER.fine( "\t\tcall: " + name.signatureName );

View File

@ -327,10 +327,10 @@ public class ModuleGenerator {
int functCount; int functCount;
do { do {
scanFunctions(); 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(); scanForClinit();
types.scanTypeHierarchy(); // scan the type hierarchy can find new functions 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 // write only the needed imports to the output
for( Iterator<FunctionName> iterator = functions.getNeededImports(); iterator.hasNext(); ) { for( Iterator<FunctionName> iterator = functions.getNeededImports(); iterator.hasNext(); ) {