extensions
Volodymyr Shymanskyy 4 years ago
parent 457e5715bd
commit 5d4414ebe5

@ -233,12 +233,10 @@ bool Is64BitType (u8 i_m3Type)
u32 SizeOfType (u8 i_m3Type)
{
u32 size = sizeof (i64);
if (i_m3Type == c_m3Type_i32 or i_m3Type == c_m3Type_f32)
size = sizeof (i32);
return sizeof (i32);
return size;
return sizeof (i64);
}

@ -276,7 +276,7 @@ void Environment_ReleaseCodePages (IM3Environment i_environment, IM3CodePage i
}
IM3Runtime m3_NewRuntime (IM3Environment i_environment, u32 i_stackSizeInBytes, M3StackInfo * i_nativeStackInfo)
IM3Runtime m3_NewRuntime (IM3Environment i_environment, u32 i_stackSizeInBytes, void * unused)
{
IM3Runtime runtime = NULL;
m3Alloc (& runtime, M3Runtime, 1);
@ -413,7 +413,7 @@ M3Result EvaluateExpression (IM3Module i_module, void * o_expressed, u8 i_type
{
* (u32 *) o_expressed = * ((u32 *) stack);
}
else if (SizeOfType (i_type) == sizeof (u64))
else
{
* (u64 *) o_expressed = * ((u64 *) stack);
}
@ -968,27 +968,6 @@ void m3_ResetErrorInfo (IM3Runtime i_runtime)
i_runtime->error.message = "";
}
void GetStackInfo (M3StackInfo * io_info)
{
io_info->startAddr = (void *) io_info;
bool stackGrowsDown = false;
stackGrowsDown = io_info->startAddr > (void *) & stackGrowsDown;
if (stackGrowsDown)
io_info->stackSize *= -1;
}
M3StackInfo m3_GetNativeStackInfo (i32 i_stackSize)
{
M3StackInfo info = { NULL, i_stackSize };
GetStackInfo (& info);
return info;
}
uint8_t * m3_GetMemory (IM3Runtime i_runtime, uint32_t * o_memorySizeInBytes, uint32_t i_memoryIndex)
{
uint8_t * memory = NULL;

@ -52,7 +52,9 @@ typedef struct M3Function
u32 numCodePageRefs;
# endif
# if defined(DEBUG)
u32 hits;
# endif
u16 maxStackSlots;

@ -200,7 +200,7 @@ d_m3OpDef (Compile)
if (not result)
{
// patch up compiled pc and call rewriten op_Call
* ((size_t *) --_pc) = (size_t) (function->compiled);
* ((void**) --_pc) = (void*) (function->compiled);
--_pc;
result = nextOpDirect ();
}
@ -223,8 +223,11 @@ d_m3OpDef (Entry)
if ((void *) ((m3slot_t *) _sp + function->maxStackSlots) < _mem->maxStack)
#endif
{
function->hits++; m3log (exec, " enter %p > %s %s", _pc - 2, function->name ? function->name : ".unnamed", SPrintFunctionArgList (function, _sp));
m3log (exec, " enter %p > %s %s", _pc - 2, function->name ? function->name : ".unnamed", SPrintFunctionArgList (function, _sp));
#if defined(DEBUG)
function->hits++;
#endif
u8 * stack = (u8 *) ((m3slot_t *) _sp + function->numArgSlots);
memset (stack, 0x0, function->numLocalBytes);

@ -45,14 +45,6 @@ typedef struct M3ErrorInfo
M3ErrorInfo;
typedef struct M3StackInfo
{
void * startAddr;
int32_t stackSize;
}
M3StackInfo;
enum // EWaTypes
{
c_m3Type_none = 0,
@ -156,16 +148,6 @@ d_m3ErrorConst (trapStackOverflow, "[trap] stack overflow")
// configuration, can be found in m3_config.h, m3_config_platforms.h, m3_core.h)
//-------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------
// initialization
//-------------------------------------------------------------------------------------------------------------------------------
// not yet implemented
// M3StackInfo m3_GetNativeStackInfo (int32_t i_stackSize);
// GetNativeStackInfo should be called at the start of main() or, if runtimes are used in a thread,
// at the start of the thread start function.
//-------------------------------------------------------------------------------------------------------------------------------
// global environment than can host multiple runtimes
//-------------------------------------------------------------------------------------------------------------------------------
@ -179,7 +161,7 @@ d_m3ErrorConst (trapStackOverflow, "[trap] stack overflow")
IM3Runtime m3_NewRuntime (IM3Environment io_environment,
uint32_t i_stackSizeInBytes,
M3StackInfo * i_nativeStackInfo); // i_nativeStackInfo can be NULL
void * unused);
void m3_FreeRuntime (IM3Runtime i_runtime);

Loading…
Cancel
Save