Skip to content

Commit

Permalink
Special handling for table entries
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Mar 21, 2023
1 parent a18ad80 commit baba1c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -8,7 +8,7 @@ V8_ARCH = x64
V8_MODE = release

WASM_FLAGS = -DWASM_API_DEBUG # -DWASM_API_DEBUG_LOG
V8_FLAGS = -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_SANDBOX
V8_FLAGS = -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX
C_FLAGS = ${WASM_FLAGS} ${V8_FLAGS} -Wall -Werror -ggdb -O -fsanitize=address
CC_FLAGS = -std=c++17 ${C_FLAGS}
LD_FLAGS = -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor
Expand Down
9 changes: 9 additions & 0 deletions src/wasm-v8-lowlevel.cc
Expand Up @@ -381,6 +381,15 @@ auto table_get(v8::Local<v8::Object> table, size_t index) -> v8::MaybeLocal<v8::
v8::internal::Handle<v8::internal::Object> v8_value =
v8::internal::WasmTableObject::Get(
v8_table->GetIsolate(), v8_table, static_cast<uint32_t>(index));

if (v8_value->IsWasmInternalFunction()) {
v8_value =
handle(v8::internal::Handle<v8::internal::WasmInternalFunction>::cast(
v8_value)->external(), v8_table->GetIsolate());
} else if (v8_value->IsWasmNull()) {
v8_value = v8_table->GetIsolate()->factory()->null_value();
}

return v8::Utils::ToLocal(v8::internal::Handle<v8::internal::Object>::cast(v8_value));
}

Expand Down
4 changes: 0 additions & 4 deletions src/wasm-v8.cc
Expand Up @@ -1130,10 +1130,6 @@ auto v8_to_ref(StoreImpl* store, v8::Local<v8::Value> value) -> own<Ref> {
} else if (value->IsObject()) {
return RefImpl<Ref>::make(store, v8::Local<v8::Object>::Cast(value));
} else {
const int len = 200;
char buffer[len];
value->TypeOf(store->isolate())->WriteUtf8(store->isolate(), buffer, len);
std::cerr << "[v8_to_ref type " << buffer << "]\n";
UNIMPLEMENTED("JS primitive ref value");
}
}
Expand Down

0 comments on commit baba1c5

Please sign in to comment.