Skip to content

Commit

Permalink
Upgrade wasm-v8
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Mar 20, 2023
1 parent cbf8997 commit f83333e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ V8_MODE = release

WASM_FLAGS = -DWASM_API_DEBUG # -DWASM_API_DEBUG_LOG
C_FLAGS = ${WASM_FLAGS} -Wall -Werror -ggdb -O -fsanitize=address
CC_FLAGS = -std=c++11 ${C_FLAGS}
CC_FLAGS = -std=c++17 ${C_FLAGS}
LD_FLAGS = -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor

C_COMP = clang
Expand Down
13 changes: 8 additions & 5 deletions src/wasm-v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <iostream>
#include <type_traits>
#include <cstring>

#ifdef WASM_API_DEBUG
#include <atomic>
Expand Down Expand Up @@ -272,7 +273,7 @@ struct EngineImpl : Engine {

~EngineImpl() {
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
stats.free(Stats::ENGINE, this);
}
};
Expand Down Expand Up @@ -1315,8 +1316,9 @@ auto Module::validate(Store* store_abs, const vec<byte_t>& binary) -> bool {
v8::Isolate* isolate = store->isolate();
v8::HandleScope handle_scope(isolate);

auto array_buffer = v8::ArrayBuffer::New(
isolate, const_cast<byte_t*>(binary.get()), binary.size());
auto array_buffer = v8::ArrayBuffer::New(isolate, binary.size());
memcpy(array_buffer->GetBackingStore()->Data(),
binary.get(), binary.size());

v8::Local<v8::Value> args[] = {array_buffer};
auto result = store->v8_function(V8_F_VALIDATE)->Call(
Expand All @@ -1332,8 +1334,9 @@ auto Module::make(Store* store_abs, const vec<byte_t>& binary) -> own<Module> {
auto context = store->context();
v8::HandleScope handle_scope(isolate);

auto array_buffer = v8::ArrayBuffer::New(
isolate, const_cast<byte_t*>(binary.get()), binary.size());
auto array_buffer = v8::ArrayBuffer::New(isolate, binary.size());
memcpy(array_buffer->GetBackingStore()->Data(),
binary.get(), binary.size());

v8::Local<v8::Value> args[] = {array_buffer};
auto maybe_obj =
Expand Down

0 comments on commit f83333e

Please sign in to comment.