extensions
Volodymyr Shymanskyy 5 years ago
parent 999eafd0c8
commit 7214c86fd4

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -11,7 +11,6 @@
#include "m3_api_defs.h"
#include "m3_env.h"
#include "m3_module.h"
#include "m3_exception.h"
#include <time.h>

@ -11,7 +11,6 @@
#include "m3_api_defs.h"
#include "m3_env.h"
#include "m3_module.h"
#include "m3_exception.h"
#if defined(d_m3HasWASI)

@ -9,7 +9,7 @@
#include <stdarg.h>
#include "m3.h"
#include "m3_module.h"
#include "m3_env.h"
#include "m3_compile.h"
#include "m3_exec.h"
#include "m3_exception.h"

@ -124,25 +124,25 @@ u64 rotr64(u64 n, unsigned c) {
*/
#define OP_DIV_U(RES, A, B) \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
RES = A / B;
#define OP_REM_U(RES, A, B) \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
RES = A % B;
// 2's complement detection
#if (INT_MIN != -INT_MAX)
#define OP_DIV_S(RES, A, B, TYPE_MIN) \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
if (UNLIKELY(B == -1 and A == TYPE_MIN)) { \
return m3Err_trapIntegerOverflow; \
return m3Err_trapIntegerOverflow; \
} \
RES = A / B;
#define OP_REM_S(RES, A, B, TYPE_MIN) \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
if (UNLIKELY(B == 0)) return m3Err_trapDivisionByZero; \
if (UNLIKELY(B == -1 and A == TYPE_MIN)) RES = 0; \
else RES = A % B;
@ -159,10 +159,10 @@ u64 rotr64(u64 n, unsigned c) {
#define OP_TRUNC(RES, A, TYPE, RMIN, RMAX) \
if (UNLIKELY(isnan(A))) { \
return m3Err_trapIntegerConversion; \
return m3Err_trapIntegerConversion; \
} \
if (UNLIKELY(A <= RMIN or A >= RMAX)) { \
return m3Err_trapIntegerOverflow; \
return m3Err_trapIntegerOverflow; \
} \
RES = (TYPE)A;

@ -7,7 +7,7 @@
//
#include "m3_module.h"
#include "m3_env.h"
void m3_FreeModule (IM3Module i_module)
{
@ -95,64 +95,3 @@ IM3Function Module_GetFunction (IM3Module i_module, u32 i_functionIndex)
return func;
}
#if 0
M3Result Module_EnsureMemorySize (IM3Module i_module, M3Memory * io_memory, size_t i_memorySize)
{
M3Result result = m3Err_none;
// TODO: Handle case when memory is not there at all
//if (i_memorySize <= io_memory->virtualSize)
//{
const size_t i_memorySizeFull = i_memorySize + sizeof (M3MemoryHeader);
size_t actualSize = 0;
if (io_memory->mallocated)
actualSize = (u8 *) io_memory->mallocated->end - (u8 *) io_memory->mallocated;
if (i_memorySizeFull > actualSize)
{
io_memory->mallocated = (M3MemoryHeader *)m3Realloc (io_memory->mallocated, i_memorySizeFull, actualSize);
m3log (runtime, "resized WASM linear memory to %lu bytes (%p)", i_memorySize, io_memory->mallocated);
if (io_memory->mallocated)
{
// store pointer to module and end of memory. gives the runtime access to this info.
io_memory->mallocated->runtime = i_module->runtime;
io_memory->mallocated->end = (u8 *)(io_memory->mallocated) + i_memorySizeFull;
io_memory->wasmPages = (u8 *) (io_memory->mallocated + 1);
// printf ("start= %p end= %p \n", ptr, end);
io_memory->heapOffset = i_memorySize;
}
else result = m3Err_mallocFailed;
}
//}
//else result = m3Err_wasmMemoryOverflow;
return result;
}
#endif
i32 AllocatePrivateHeap (M3Memory * io_memory, i32 i_size)
{
/*
i_size = (i_size + 7) & ~7;
size_t ptrOffset = io_memory->heapOffset + (io_memory->heapAllocated += i_size);
size_t size = (u8 *) io_memory->mallocated->end - io_memory->wasmPages;
if (ptrOffset >= size) {
m3Abort("ptrOffset >= size");
}
return (i32) ptrOffset;*/
return 0;
}

@ -1,18 +0,0 @@
//
// m3_module.h
// m3
//
// Created by Steven Massey on 7/7/19.
// Copyright © 2019 Steven Massey. All rights reserved.
//
#ifndef m3_module_h
#define m3_module_h
#include "m3_env.h"
i32 AllocatePrivateHeap (M3Memory * io_memory, i32 i_size);
#endif /* m3_module_h */
Loading…
Cancel
Save