Commit f4c39c1a authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Switch exception values encoding to {FixedArray}.

This changes the encoding of values stored in exception objects from a
typed uint16 array (a JSObject) to a {FixedArray} instead. Note that it
increases the memory footprint of the encoding, but will allow accessing
elements directly from generated code and also encode reference types
properly. The memory footprint can/should be optimized only after the
implementation is feature complete.

R=clemensh@chromium.org
BUG=v8:8341

Change-Id: If67c4e498d815e14f95d014e6a1f7a6725aa0b3a
Reviewed-on: https://chromium-review.googlesource.com/c/1293371
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56854}
parent 49bd7f50
......@@ -866,10 +866,13 @@ RUNTIME_FUNCTION(Runtime_GetWasmExceptionValues) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, exception, 0);
RETURN_RESULT_OR_FAILURE(
isolate, JSReceiver::GetProperty(
isolate, exception,
isolate->factory()->wasm_exception_values_symbol()));
Handle<Object> values_obj;
CHECK(JSReceiver::GetProperty(
isolate, exception,
isolate->factory()->wasm_exception_values_symbol())
.ToHandle(&values_obj));
Handle<FixedArray> values = Handle<FixedArray>::cast(values_obj);
return *isolate->factory()->NewJSArrayWithElements(values);
}
namespace {
......
......@@ -112,8 +112,7 @@ RUNTIME_FUNCTION(Runtime_WasmThrowCreate) {
isolate->factory()->wasm_exception_tag_symbol(),
tag, LanguageMode::kStrict)
.is_null());
Handle<JSTypedArray> values =
isolate->factory()->NewJSTypedArray(ElementsKind::UINT16_ELEMENTS, size);
Handle<FixedArray> values = isolate->factory()->NewFixedArray(size);
CHECK(!JSReceiver::SetProperty(
isolate, exception,
isolate->factory()->wasm_exception_values_symbol(), values,
......@@ -159,15 +158,11 @@ RUNTIME_FUNCTION(Runtime_WasmExceptionGetElement) {
isolate, exception,
isolate->factory()->wasm_exception_values_symbol())
.ToHandle(&values_obj)) {
if (values_obj->IsJSTypedArray()) {
Handle<JSTypedArray> values = Handle<JSTypedArray>::cast(values_obj);
CHECK_EQ(values->type(), kExternalUint16Array);
if (values_obj->IsFixedArray()) {
Handle<FixedArray> values = Handle<FixedArray>::cast(values_obj);
CONVERT_SMI_ARG_CHECKED(index, 1);
CHECK(!values->WasNeutered());
CHECK_LT(index, Smi::ToInt(values->length()));
auto* vals =
reinterpret_cast<uint16_t*>(values->GetBuffer()->backing_store());
return Smi::FromInt(vals[index]);
CHECK_LT(index, values->length());
return values->get(index);
}
}
}
......@@ -190,16 +185,12 @@ RUNTIME_FUNCTION(Runtime_WasmExceptionSetElement) {
isolate, exception,
isolate->factory()->wasm_exception_values_symbol())
.ToHandle(&values_obj)) {
if (values_obj->IsJSTypedArray()) {
Handle<JSTypedArray> values = Handle<JSTypedArray>::cast(values_obj);
CHECK_EQ(values->type(), kExternalUint16Array);
if (values_obj->IsFixedArray()) {
Handle<FixedArray> values = Handle<FixedArray>::cast(values_obj);
CONVERT_SMI_ARG_CHECKED(index, 1);
CHECK(!values->WasNeutered());
CHECK_LT(index, Smi::ToInt(values->length()));
CONVERT_SMI_ARG_CHECKED(value, 2);
auto* vals =
reinterpret_cast<uint16_t*>(values->GetBuffer()->backing_store());
vals[index] = static_cast<uint16_t>(value);
CHECK_LT(index, values->length());
CONVERT_ARG_CHECKED(Object, value, 2);
values->set(index, value);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment