update to the sdk 0.6.0 version

This commit is contained in:
vms 2021-04-12 15:25:24 +03:00
parent 0f66c1dd62
commit 2c2f486044
4 changed files with 16 additions and 15 deletions

View File

@ -7,7 +7,7 @@ default: all
wasm: wasm:
cd src && $(MAKE) -f Makefile_wasm && mv redis.wasm ../ cd src && $(MAKE) -f Makefile_wasm && mv redis.wasm ../
~/.cargo/bin/fce embed -i redis.wasm -o redis.wasm -w redis.wit #~/.cargo/bin/fce embed -i redis.wasm -o redis.wasm -w redis.wit
install: install:
cd src && $(MAKE) $@ cd src && $(MAKE) $@

View File

@ -1,4 +1,5 @@
;; Fluence Redis fork Wasm Interface Types ;; Fluence Redis fork Wasm Interface Types
(@interface it_version "0.19.0")
;; allocate ;; allocate
(@interface type (func (param $size: i32) (result i32))) ;; 0 (@interface type (func (param $size: i32) (result i32))) ;; 0
@ -16,7 +17,7 @@
(@interface type (func (param $result: i32))) ;; 4 (@interface type (func (param $result: i32))) ;; 4
(@interface export "allocate" (func 0)) ;; 0 (@interface export "allocate" (func 0)) ;; 0
(@interface export "deallocate" (func 1)) ;; 1 (@interface export "release_objects" (func 1)) ;; 1
(@interface export "invoke" (func 2)) ;; 2 (@interface export "invoke" (func 2)) ;; 2
(@interface export "get_result_size" (func 3)) ;; 3 (@interface export "get_result_size" (func 3)) ;; 3
(@interface export "get_result_ptr" (func 3)) ;; 4 (@interface export "get_result_ptr" (func 3)) ;; 4
@ -34,9 +35,7 @@
call-core 4 ;; call get_result_size call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr call-core 3 ;; call get_result_ptr
string.lift_memory string.lift_memory
call-core 4 ;; call get_result_size call-core 1 ;; call release_objects
call-core 3 ;; call get_result_ptr
call-core 1 ;; call deallocate
) )
;; Implementations ;; Implementations

View File

@ -10,7 +10,7 @@ SDK = sdk/syscalls_stubs.c
EXPORT_FUNCS = \ EXPORT_FUNCS = \
--export=allocate,$\ --export=allocate,$\
--export=deallocate,$\ --export=release_objects,$\
--export=set_result_size,$\ --export=set_result_size,$\
--export=set_result_ptr,$\ --export=set_result_ptr,$\
--export=get_result_size,$\ --export=get_result_size,$\

View File

@ -5,7 +5,7 @@
#include <string.h> #include <string.h>
client *g_client; client *g_client;
char *RESULT_PTR; void *RESULT_PTR;
int RESULT_SIZE; int RESULT_SIZE;
// TODO: add handling of the initialization process errors // TODO: add handling of the initialization process errors
@ -27,8 +27,14 @@ void deallocate(void *ptr, int size) {
zfree(ptr); zfree(ptr);
} }
void set_result_ptr(char *ptr) { void release_objects() {
*RESULT_PTR = ptr; deallocate(RESULT_PTR, RESULT_SIZE);
RESULT_PTR = 0;
RESULT_SIZE = 0;
}
void set_result_ptr(void *ptr) {
RESULT_PTR = ptr;
} }
void set_result_size(int size) { void set_result_size(int size) {
@ -39,14 +45,10 @@ int get_result_size(void) {
return RESULT_SIZE; return RESULT_SIZE;
} }
char *get_result_ptr() { void *get_result_ptr() {
return RESULT_PTR; return RESULT_PTR;
} }
unsigned char load(const unsigned char *ptr) {
return *ptr;
}
// Cleans client output buffers to - client is blocked and // Cleans client output buffers to - client is blocked and
// doesn't receive requests until output buffer isn't empty. // doesn't receive requests until output buffer isn't empty.
void clean_client_buffer(client *c) { void clean_client_buffer(client *c) {
@ -117,7 +119,7 @@ void invoke(char *request, int request_size) {
} else { } else {
readQueryFromClient(g_client, 0, request, request_size); readQueryFromClient(g_client, 0, request, request_size);
} }
deallocate(request, 0); deallocate(request, request_size);
serverLog(LL_DEBUG, "readQueryFromClient\n"); serverLog(LL_DEBUG, "readQueryFromClient\n");
const size_t reply_bytes_before = g_client->reply_bytes; const size_t reply_bytes_before = g_client->reply_bytes;