mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
use needThisParameter for popCount of method calls
This commit is contained in:
parent
f87e1c6519
commit
4377db747d
@ -59,7 +59,7 @@ class WasmCallIndirectInstruction extends WasmCallInstruction {
|
|||||||
* compiler properties
|
* compiler properties
|
||||||
*/
|
*/
|
||||||
WasmCallIndirectInstruction( FunctionName name, int javaCodePos, int lineNumber, TypeManager types, WasmOptions options ) {
|
WasmCallIndirectInstruction( FunctionName name, int javaCodePos, int lineNumber, TypeManager types, WasmOptions options ) {
|
||||||
super( name, javaCodePos, lineNumber, types );
|
super( name, javaCodePos, lineNumber, types, true );
|
||||||
this.type = types.valueOf( name.className );
|
this.type = types.valueOf( name.className );
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
@ -128,12 +128,4 @@ class WasmCallIndirectInstruction extends WasmCallInstruction {
|
|||||||
writer.writeVirtualFunctionCall( getFunctionName(), type );
|
writer.writeVirtualFunctionCall( getFunctionName(), type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
int getPopCount() {
|
|
||||||
return super.getPopCount() + 1; // this -> +1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,15 @@ import de.inetsoftware.jwebassembly.wasm.AnyType;
|
|||||||
*/
|
*/
|
||||||
class WasmCallInstruction extends WasmInstruction {
|
class WasmCallInstruction extends WasmInstruction {
|
||||||
|
|
||||||
private AnyType valueType;
|
private AnyType valueType;
|
||||||
|
|
||||||
private FunctionName name;
|
private FunctionName name;
|
||||||
|
|
||||||
private int paramCount = -1;
|
private int paramCount = -1;
|
||||||
|
|
||||||
private TypeManager types;
|
private final TypeManager types;
|
||||||
|
|
||||||
|
private final boolean needThisParameter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of a function call instruction
|
* Create an instance of a function call instruction
|
||||||
@ -50,11 +52,14 @@ class WasmCallInstruction extends WasmInstruction {
|
|||||||
* the line number in the Java source code
|
* the line number in the Java source code
|
||||||
* @param types
|
* @param types
|
||||||
* the type manager
|
* the type manager
|
||||||
|
* @param needThisParameter
|
||||||
|
* true, if this function need additional to the parameter of the signature an extra "this" parameter
|
||||||
*/
|
*/
|
||||||
WasmCallInstruction( FunctionName name, int javaCodePos, int lineNumber, TypeManager types ) {
|
WasmCallInstruction( FunctionName name, int javaCodePos, int lineNumber, TypeManager types, boolean needThisParameter ) {
|
||||||
super( javaCodePos, lineNumber );
|
super( javaCodePos, lineNumber );
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.types = types;
|
this.types = types;
|
||||||
|
this.needThisParameter = needThisParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +122,7 @@ class WasmCallInstruction extends WasmInstruction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<AnyType> parser = name.getSignature( types );
|
Iterator<AnyType> parser = name.getSignature( types );
|
||||||
paramCount = name.methodName.equals( "<init>" ) ? 1 : 0;
|
paramCount = needThisParameter ? 1 : 0;
|
||||||
while( parser.next() != null ) {
|
while( parser.next() != null ) {
|
||||||
paramCount++;
|
paramCount++;
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,8 @@ public abstract class WasmCodeBuilder {
|
|||||||
* the line number in the Java source code
|
* the line number in the Java source code
|
||||||
*/
|
*/
|
||||||
protected void addCallInstruction( FunctionName name, int javaCodePos, int lineNumber ) {
|
protected void addCallInstruction( FunctionName name, int javaCodePos, int lineNumber ) {
|
||||||
WasmCallInstruction instruction = new WasmCallInstruction( name, javaCodePos, lineNumber, types );
|
boolean needThisParameter = functions.needThisParameter( name );
|
||||||
|
WasmCallInstruction instruction = new WasmCallInstruction( name, javaCodePos, lineNumber, types, needThisParameter );
|
||||||
|
|
||||||
if( "<init>".equals( name.methodName ) ) {
|
if( "<init>".equals( name.methodName ) ) {
|
||||||
// check if there a factory for the constructor in JavaScript then we need to do some more complex patching
|
// check if there a factory for the constructor in JavaScript then we need to do some more complex patching
|
||||||
@ -459,7 +460,7 @@ public abstract class WasmCodeBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// the new instruction
|
// the new instruction
|
||||||
instruction = new WasmCallInstruction( factoryName, javaCodePos, lineNumber, types );
|
instruction = new WasmCallInstruction( factoryName, javaCodePos, lineNumber, types, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user