144 |
} |
} |
145 |
else |
else |
146 |
{ |
{ |
147 |
offset += GetTypeSize(type); |
offset += GetTypeSize(coder->process, type); |
148 |
} |
} |
149 |
} |
} |
150 |
|
|
194 |
{ |
{ |
195 |
type = ILTypeGetLocal(signature, current); |
type = ILTypeGetLocal(signature, current); |
196 |
coder->localOffsets[current] = offset; |
coder->localOffsets[current] = offset; |
197 |
offset += GetTypeSize(type); |
offset += GetTypeSize(coder->process, type); |
198 |
} |
} |
199 |
|
|
200 |
/* Record the number of words used for local variables */ |
/* Record the number of words used for local variables */ |
208 |
* Make space for an extra local. If "type" is NULL, then allocate |
* Make space for an extra local. If "type" is NULL, then allocate |
209 |
* a single word for a pointer argument. |
* a single word for a pointer argument. |
210 |
*/ |
*/ |
211 |
static void CVMEntryNeedExtraLocal(CVMEntryContext *ctx, ILType *type) |
static void CVMEntryNeedExtraLocal(ILExecProcess *process, CVMEntryContext *ctx, |
212 |
|
ILType *type) |
213 |
{ |
{ |
214 |
ctx->extraLocals += (type ? GetTypeSize(type) : 1); |
ctx->extraLocals += (type ? GetTypeSize(process, type) : 1); |
215 |
} |
} |
216 |
|
|
217 |
/* |
/* |
219 |
* If "type" is NULL, then allocate a single word for a |
* If "type" is NULL, then allocate a single word for a |
220 |
* pointer argument. |
* pointer argument. |
221 |
*/ |
*/ |
222 |
static ILUInt32 CVMEntryAllocExtraLocal(CVMEntryContext *ctx, ILType *type) |
static ILUInt32 CVMEntryAllocExtraLocal(ILExecProcess *process, CVMEntryContext *ctx, ILType *type) |
223 |
{ |
{ |
224 |
ILUInt32 size = (type ? GetTypeSize(type) : 1); |
ILUInt32 size = (type ? GetTypeSize(process, type) : 1); |
225 |
ILUInt32 offset = ctx->extraOffset; |
ILUInt32 offset = ctx->extraOffset; |
226 |
ctx->firstExtraIsTop = (offset == 0 && ctx->extraLocals == size); |
ctx->firstExtraIsTop = (offset == 0 && ctx->extraLocals == size); |
227 |
ctx->extraOffset += size; |
ctx->extraOffset += size; |
443 |
if(coder) |
if(coder) |
444 |
{ |
{ |
445 |
/* Allocate space for the return value */ |
/* Allocate space for the return value */ |
446 |
offset = CVMEntryAllocExtraLocal(ctx, returnType); |
offset = CVMEntryAllocExtraLocal(coder->process, ctx, returnType); |
447 |
ctx->returnOffset = offset; |
ctx->returnOffset = offset; |
448 |
|
|
449 |
/* Pass the pointer to the native method */ |
/* Pass the pointer to the native method */ |
457 |
{ |
{ |
458 |
CVM_OUT_WIDE(COP_WADDR, offset); |
CVM_OUT_WIDE(COP_WADDR, offset); |
459 |
CVM_ADJUST(1); |
CVM_ADJUST(1); |
460 |
offset = CVMEntryAllocExtraLocal(ctx, 0); |
offset = CVMEntryAllocExtraLocal(coder->process, ctx, 0); |
461 |
if(offset < 4) |
if(offset < 4) |
462 |
{ |
{ |
463 |
CVM_OUT_NONE(COP_PSTORE_0 + offset); |
CVM_OUT_NONE(COP_PSTORE_0 + offset); |
474 |
else |
else |
475 |
{ |
{ |
476 |
/* Inform the context that we need space for the return value */ |
/* Inform the context that we need space for the return value */ |
477 |
CVMEntryNeedExtraLocal(ctx, returnType); |
CVMEntryNeedExtraLocal((ILExecProcess *)0, ctx, returnType); |
478 |
if(!useRawCalls) |
if(!useRawCalls) |
479 |
{ |
{ |
480 |
/* We also need space for the pointer to the value */ |
/* We also need space for the pointer to the value */ |
481 |
CVMEntryNeedExtraLocal(ctx, 0); |
CVMEntryNeedExtraLocal((ILExecProcess *)0, ctx, 0); |
482 |
} |
} |
483 |
} |
} |
484 |
} |
} |
487 |
/* Allocate space for the return value */ |
/* Allocate space for the return value */ |
488 |
if(coder) |
if(coder) |
489 |
{ |
{ |
490 |
ctx->returnOffset = CVMEntryAllocExtraLocal(ctx, returnType); |
ctx->returnOffset = CVMEntryAllocExtraLocal(coder->process, ctx, returnType); |
491 |
} |
} |
492 |
else |
else |
493 |
{ |
{ |
494 |
CVMEntryNeedExtraLocal(ctx, returnType); |
CVMEntryNeedExtraLocal((ILExecProcess *)0, ctx, returnType); |
495 |
} |
} |
496 |
} |
} |
497 |
else if(isConstructor) |
else if(isConstructor) |
499 |
/* We need space to return the object pointer */ |
/* We need space to return the object pointer */ |
500 |
if(coder) |
if(coder) |
501 |
{ |
{ |
502 |
ctx->returnOffset = CVMEntryAllocExtraLocal(ctx, 0); |
ctx->returnOffset = CVMEntryAllocExtraLocal(coder->process, ctx, 0); |
503 |
} |
} |
504 |
else |
else |
505 |
{ |
{ |
506 |
CVMEntryNeedExtraLocal(ctx, 0); |
CVMEntryNeedExtraLocal((ILExecProcess *)0, ctx, 0); |
507 |
} |
} |
508 |
} |
} |
509 |
|
|
668 |
we use the non-raw version of function invocation */ |
we use the non-raw version of function invocation */ |
669 |
if(!useRawCalls && isInternal && ILType_IsValueType(paramType)) |
if(!useRawCalls && isInternal && ILType_IsValueType(paramType)) |
670 |
{ |
{ |
671 |
CVMEntryNeedExtraLocal(ctx, 0); |
CVMEntryNeedExtraLocal((ILExecProcess *)0, ctx, 0); |
672 |
} |
} |
673 |
continue; |
continue; |
674 |
} |
} |
867 |
|
|
868 |
default: |
default: |
869 |
{ |
{ |
870 |
size = GetTypeSize(paramType); |
size = GetTypeSize(coder->process, paramType); |
871 |
CVM_OUT_DWIDE(COP_MLOAD, offset, size); |
CVM_OUT_DWIDE(COP_MLOAD, offset, size); |
872 |
CVM_ADJUST(size); |
CVM_ADJUST(size); |
873 |
ctx->nativeArgWords += size; |
ctx->nativeArgWords += size; |
906 |
/* Push a pointer to the value type onto the native stack */ |
/* Push a pointer to the value type onto the native stack */ |
907 |
CVM_OUT_WIDE(COP_WADDR, coder->argOffsets[param - thisAdjust]); |
CVM_OUT_WIDE(COP_WADDR, coder->argOffsets[param - thisAdjust]); |
908 |
CVM_ADJUST(1); |
CVM_ADJUST(1); |
909 |
offset = CVMEntryAllocExtraLocal(ctx, 0); |
offset = CVMEntryAllocExtraLocal(coder->process, ctx, 0); |
910 |
if(offset < 4) |
if(offset < 4) |
911 |
{ |
{ |
912 |
CVM_OUT_NONE(COP_PSTORE_0 + offset); |
CVM_OUT_NONE(COP_PSTORE_0 + offset); |
1174 |
|
|
1175 |
default: |
default: |
1176 |
{ |
{ |
1177 |
size = GetTypeSize(returnType); |
size = GetTypeSize(coder->process, returnType); |
1178 |
if(ctx->returnOffset != 0 || !(ctx->firstExtraIsTop)) |
if(ctx->returnOffset != 0 || !(ctx->firstExtraIsTop)) |
1179 |
{ |
{ |
1180 |
CVM_OUT_DWIDE(COP_MLOAD, ctx->returnOffset, size); |
CVM_OUT_DWIDE(COP_MLOAD, ctx->returnOffset, size); |
1188 |
else if(ILType_IsValueType(returnType)) |
else if(ILType_IsValueType(returnType)) |
1189 |
{ |
{ |
1190 |
/* Load the value type onto the stack and return */ |
/* Load the value type onto the stack and return */ |
1191 |
size = GetTypeSize(returnType); |
size = GetTypeSize(coder->process, returnType); |
1192 |
if(ctx->returnOffset != 0 || !(ctx->firstExtraIsTop)) |
if(ctx->returnOffset != 0 || !(ctx->firstExtraIsTop)) |
1193 |
{ |
{ |
1194 |
CVM_OUT_DWIDE(COP_MLOAD, ctx->returnOffset, size); |
CVM_OUT_DWIDE(COP_MLOAD, ctx->returnOffset, size); |