|
|
|
@ -9,8 +9,10 @@ instruction_memory_size()
|
|
|
|
|
|
|
|
|
|
// All of these are pretty generic
|
|
|
|
|
INLINE float
|
|
|
|
|
get_f32(int32_t offset)
|
|
|
|
|
get_f32(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(float) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -18,8 +20,10 @@ get_f32(int32_t offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE double
|
|
|
|
|
get_f64(int32_t offset)
|
|
|
|
|
get_f64(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(double) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -27,8 +31,10 @@ get_f64(int32_t offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE int8_t
|
|
|
|
|
get_i8(int32_t offset)
|
|
|
|
|
get_i8(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int8_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -36,8 +42,10 @@ get_i8(int32_t offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE int16_t
|
|
|
|
|
get_i16(int32_t offset)
|
|
|
|
|
get_i16(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int16_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -45,8 +53,10 @@ get_i16(int32_t offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE int32_t
|
|
|
|
|
get_i32(int32_t offset)
|
|
|
|
|
get_i32(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int32_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -54,8 +64,10 @@ get_i32(int32_t offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE int64_t
|
|
|
|
|
get_i64(int32_t offset)
|
|
|
|
|
get_i64(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int64_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -63,8 +75,10 @@ get_i64(int32_t offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE int32_t
|
|
|
|
|
get_global_i32(int32_t offset)
|
|
|
|
|
get_global_i32(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int32_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -72,8 +86,10 @@ get_global_i32(int32_t offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE int64_t
|
|
|
|
|
get_global_i64(int32_t offset)
|
|
|
|
|
get_global_i64(uint32_t offset)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int64_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -82,8 +98,10 @@ get_global_i64(int32_t offset)
|
|
|
|
|
|
|
|
|
|
// Now setting routines
|
|
|
|
|
INLINE void
|
|
|
|
|
set_f32(int32_t offset, float v)
|
|
|
|
|
set_f32(uint32_t offset, float v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(float) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -91,8 +109,10 @@ set_f32(int32_t offset, float v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE void
|
|
|
|
|
set_f64(int32_t offset, double v)
|
|
|
|
|
set_f64(uint32_t offset, double v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(double) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -100,8 +120,10 @@ set_f64(int32_t offset, double v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE void
|
|
|
|
|
set_i8(int32_t offset, int8_t v)
|
|
|
|
|
set_i8(uint32_t offset, int8_t v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int8_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -109,8 +131,10 @@ set_i8(int32_t offset, int8_t v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE void
|
|
|
|
|
set_i16(int32_t offset, int16_t v)
|
|
|
|
|
set_i16(uint32_t offset, int16_t v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int16_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -118,8 +142,10 @@ set_i16(int32_t offset, int16_t v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE void
|
|
|
|
|
set_i32(int32_t offset, int32_t v)
|
|
|
|
|
set_i32(uint32_t offset, int32_t v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int32_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -127,8 +153,10 @@ set_i32(int32_t offset, int32_t v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE void
|
|
|
|
|
set_i64(int32_t offset, int64_t v)
|
|
|
|
|
set_i64(uint32_t offset, int64_t v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int64_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -136,8 +164,10 @@ set_i64(int32_t offset, int64_t v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE void
|
|
|
|
|
set_global_i32(int32_t offset, int32_t v)
|
|
|
|
|
set_global_i32(uint32_t offset, int32_t v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int32_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -145,8 +175,10 @@ set_global_i32(int32_t offset, int32_t v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INLINE void
|
|
|
|
|
set_global_i64(int32_t offset, int64_t v)
|
|
|
|
|
set_global_i64(uint32_t offset, int64_t v)
|
|
|
|
|
{
|
|
|
|
|
assert(offset + sizeof(int64_t) < local_sandbox_context_cache.memory.size);
|
|
|
|
|
|
|
|
|
|
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
|
|
|
|
void *address = &mem_as_chars[offset];
|
|
|
|
|
|
|
|
|
@ -157,11 +189,12 @@ set_global_i64(int32_t offset, int64_t v)
|
|
|
|
|
INLINE char *
|
|
|
|
|
get_function_from_table(uint32_t idx, uint32_t type_id)
|
|
|
|
|
{
|
|
|
|
|
printf("get_function_from_table idx: %u, type: %u\n", idx, type_id);
|
|
|
|
|
assert(idx < INDIRECT_TABLE_SIZE);
|
|
|
|
|
|
|
|
|
|
struct indirect_table_entry f = local_sandbox_context_cache.module_indirect_table[idx];
|
|
|
|
|
assert(f.type_id == type_id);
|
|
|
|
|
|
|
|
|
|
// assert(f.type_id == type_id);
|
|
|
|
|
assert(f.func_pointer);
|
|
|
|
|
|
|
|
|
|
return f.func_pointer;
|
|
|
|
|