|
|
@ -1,5 +1,5 @@
|
|
|
|
/* https://github.com/gwsystems/silverfish/blob/master/runtime/memory/64bit_nix.c */
|
|
|
|
/* https://github.com/gwsystems/silverfish/blob/master/runtime/memory/64bit_nix.c */
|
|
|
|
#include <types.h>
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_MEM_VM
|
|
|
|
#ifdef USE_MEM_VM
|
|
|
|
|
|
|
|
|
|
|
@ -7,7 +7,7 @@
|
|
|
|
INLINE float
|
|
|
|
INLINE float
|
|
|
|
get_f32(i32 offset)
|
|
|
|
get_f32(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(float *)address;
|
|
|
|
return *(float *)address;
|
|
|
@ -16,7 +16,7 @@ get_f32(i32 offset)
|
|
|
|
INLINE double
|
|
|
|
INLINE double
|
|
|
|
get_f64(i32 offset)
|
|
|
|
get_f64(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(double *)address;
|
|
|
|
return *(double *)address;
|
|
|
@ -25,7 +25,7 @@ get_f64(i32 offset)
|
|
|
|
INLINE i8
|
|
|
|
INLINE i8
|
|
|
|
get_i8(i32 offset)
|
|
|
|
get_i8(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(i8 *)address;
|
|
|
|
return *(i8 *)address;
|
|
|
@ -34,7 +34,7 @@ get_i8(i32 offset)
|
|
|
|
INLINE i16
|
|
|
|
INLINE i16
|
|
|
|
get_i16(i32 offset)
|
|
|
|
get_i16(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(i16 *)address;
|
|
|
|
return *(i16 *)address;
|
|
|
@ -43,7 +43,7 @@ get_i16(i32 offset)
|
|
|
|
INLINE i32
|
|
|
|
INLINE i32
|
|
|
|
get_i32(i32 offset)
|
|
|
|
get_i32(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(i32 *)address;
|
|
|
|
return *(i32 *)address;
|
|
|
@ -52,7 +52,7 @@ get_i32(i32 offset)
|
|
|
|
INLINE i64
|
|
|
|
INLINE i64
|
|
|
|
get_i64(i32 offset)
|
|
|
|
get_i64(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(i64 *)address;
|
|
|
|
return *(i64 *)address;
|
|
|
@ -61,7 +61,7 @@ get_i64(i32 offset)
|
|
|
|
INLINE i32
|
|
|
|
INLINE i32
|
|
|
|
get_global_i32(i32 offset)
|
|
|
|
get_global_i32(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(i32 *)address;
|
|
|
|
return *(i32 *)address;
|
|
|
@ -70,7 +70,7 @@ get_global_i32(i32 offset)
|
|
|
|
INLINE i64
|
|
|
|
INLINE i64
|
|
|
|
get_global_i64(i32 offset)
|
|
|
|
get_global_i64(i32 offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
return *(i64 *)address;
|
|
|
|
return *(i64 *)address;
|
|
|
@ -80,7 +80,7 @@ get_global_i64(i32 offset)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_f32(i32 offset, float v)
|
|
|
|
set_f32(i32 offset, float v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(float *)address = v;
|
|
|
|
*(float *)address = v;
|
|
|
@ -89,7 +89,7 @@ set_f32(i32 offset, float v)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_f64(i32 offset, double v)
|
|
|
|
set_f64(i32 offset, double v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(double *)address = v;
|
|
|
|
*(double *)address = v;
|
|
|
@ -98,7 +98,7 @@ set_f64(i32 offset, double v)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_i8(i32 offset, i8 v)
|
|
|
|
set_i8(i32 offset, i8 v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(i8 *)address = v;
|
|
|
|
*(i8 *)address = v;
|
|
|
@ -107,7 +107,7 @@ set_i8(i32 offset, i8 v)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_i16(i32 offset, i16 v)
|
|
|
|
set_i16(i32 offset, i16 v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(i16 *)address = v;
|
|
|
|
*(i16 *)address = v;
|
|
|
@ -116,7 +116,7 @@ set_i16(i32 offset, i16 v)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_i32(i32 offset, i32 v)
|
|
|
|
set_i32(i32 offset, i32 v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(i32 *)address = v;
|
|
|
|
*(i32 *)address = v;
|
|
|
@ -125,7 +125,7 @@ set_i32(i32 offset, i32 v)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_i64(i32 offset, i64 v)
|
|
|
|
set_i64(i32 offset, i64 v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(i64 *)address = v;
|
|
|
|
*(i64 *)address = v;
|
|
|
@ -134,7 +134,7 @@ set_i64(i32 offset, i64 v)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_global_i32(i32 offset, i32 v)
|
|
|
|
set_global_i32(i32 offset, i32 v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(i32 *)address = v;
|
|
|
|
*(i32 *)address = v;
|
|
|
@ -143,7 +143,7 @@ set_global_i32(i32 offset, i32 v)
|
|
|
|
INLINE void
|
|
|
|
INLINE void
|
|
|
|
set_global_i64(i32 offset, i64 v)
|
|
|
|
set_global_i64(i32 offset, i64 v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *mem_as_chars = (char *)sandbox_lmbase;
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_member_cache.linear_memory_start;
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
|
|
|
*(i64 *)address = v;
|
|
|
|
*(i64 *)address = v;
|
|
|
@ -155,7 +155,7 @@ get_function_from_table(u32 idx, u32 type_id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(idx < INDIRECT_TABLE_SIZE);
|
|
|
|
assert(idx < INDIRECT_TABLE_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
struct indirect_table_entry f = module_indirect_table[idx];
|
|
|
|
struct indirect_table_entry f = local_sandbox_member_cache.module_indirect_table[idx];
|
|
|
|
|
|
|
|
|
|
|
|
// assert(f.type_id == type_id);
|
|
|
|
// assert(f.type_id == type_id);
|
|
|
|
assert(f.func_pointer);
|
|
|
|
assert(f.func_pointer);
|
|
|
|