@@ -53,9 +53,9 @@ private static void PatchConstructor(BaseMethodCompiler methodCompiler)
5353 Operand v2 = methodCompiler . CreateVirtualRegister ( methodPointerOperand . Type ) ;
5454 Operand v3 = methodCompiler . CreateVirtualRegister ( instanceOperand . Type ) ;
5555
56- context . AppendInstruction ( IRInstruction . LoadInteger , v1 , methodCompiler . StackFrame , thisOperand ) ;
57- context . AppendInstruction ( IRInstruction . LoadInteger , v2 , methodCompiler . StackFrame , methodPointerOperand ) ;
58- context . AppendInstruction ( IRInstruction . LoadInteger , v3 , methodCompiler . StackFrame , instanceOperand ) ;
56+ context . AppendInstruction ( IRInstruction . LoadParameterInteger , v1 , thisOperand ) ;
57+ context . AppendInstruction ( IRInstruction . LoadParameterInteger , v2 , methodPointerOperand ) ;
58+ context . AppendInstruction ( IRInstruction . LoadParameterInteger , v3 , instanceOperand ) ;
5959
6060 context . AppendInstruction ( IRInstruction . StoreInteger , size , null , v1 , methodPointerOffsetOperand , v2 ) ;
6161 context . MosaType = methodPointerOperand . Type ;
@@ -88,13 +88,23 @@ private static void PatchInvoke(BaseMethodCompiler methodCompiler)
8888
8989 for ( int i = 0 ; i < methodCompiler . Parameters . Length ; i ++ )
9090 {
91- vrs [ i ] = methodCompiler . VirtualRegisters . Allocate ( methodCompiler . Parameters [ i ] . Type ) ;
92-
93- //fixme: handle structs
94- var loadInstruction = BaseMethodCompilerStage . GetLoadInstruction ( vrs [ i ] . Type ) ;
95- var moveSize = BaseMethodCompilerStage . GetInstructionSize ( vrs [ i ] . Type ) ;
96-
97- b0 . AppendInstruction ( loadInstruction , moveSize , vrs [ i ] , methodCompiler . StackFrame , methodCompiler . Parameters [ i ] ) ;
91+ var type = methodCompiler . Parameters [ i ] . Type ;
92+
93+ if ( methodCompiler . StoreOnStack ( type ) )
94+ {
95+ b0 . AppendInstruction ( IRInstruction . LoadParameterCompound , vrs [ i ] , methodCompiler . Parameters [ i ] ) ;
96+ b0 . MosaType = type ;
97+ }
98+ else
99+ {
100+ vrs [ i ] = methodCompiler . VirtualRegisters . Allocate ( methodCompiler . Parameters [ i ] . Type ) ;
101+
102+ var loadInstruction = BaseMethodCompilerStage . GetLoadParameterInstruction ( vrs [ i ] . Type ) ;
103+ var loadsize = BaseMethodCompilerStage . GetInstructionSize ( vrs [ i ] . Type ) ;
104+
105+ b0 . AppendInstruction ( loadInstruction , loadsize , vrs [ i ] , methodCompiler . Parameters [ i ] ) ;
106+ b0 . MosaType = type ;
107+ }
98108 }
99109
100110 Operand thisOperand = vrs [ 0 ] ;
0 commit comments