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

[wasm] Rename "except_ref" to "exnref" throughout the code.

Also see: https://github.com/WebAssembly/exception-handling/pull/84

R=ahaas@chromium.org
BUG=v8:8091

Change-Id: Ibcf9a2bba019cbd634884cb217e1507231a5bcf8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1700077Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62717}
parent 9f8d52df
......@@ -2197,7 +2197,7 @@ Node* WasmGraphBuilder::Throw(uint32_t exception_index,
break;
case wasm::kWasmAnyRef:
case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef:
case wasm::kWasmExnRef:
STORE_FIXED_ARRAY_SLOT_ANY(values_array, index, value);
++index;
break;
......@@ -2336,7 +2336,7 @@ Node** WasmGraphBuilder::GetExceptionValues(
break;
case wasm::kWasmAnyRef:
case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef:
case wasm::kWasmExnRef:
value = LOAD_FIXED_ARRAY_SLOT_ANY(values_array, index);
++index;
break;
......@@ -5200,7 +5200,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
return BuildChangeFloat64ToTagged(node);
case wasm::kWasmAnyRef:
case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef:
case wasm::kWasmExnRef:
return node;
default:
UNREACHABLE();
......@@ -5254,8 +5254,8 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
Node* FromJS(Node* node, Node* js_context, wasm::ValueType type) {
DCHECK_NE(wasm::kWasmStmt, type);
// The parameter is of type anyref or except_ref, we take it as is.
if (type == wasm::kWasmAnyRef || type == wasm::kWasmExceptRef) {
// The parameter is of type anyref or exnref, we take it as is.
if (type == wasm::kWasmAnyRef || type == wasm::kWasmExnRef) {
return node;
}
......
......@@ -226,7 +226,7 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
#undef CASE_ARG_TYPE
case wasm::kWasmAnyRef:
case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: {
case wasm::kWasmExnRef: {
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetParam(i)),
kSystemPointerSize);
Handle<Object> ref(base::ReadUnalignedValue<Object>(arg_buf_ptr),
......@@ -277,7 +277,7 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
#undef CASE_RET_TYPE
case wasm::kWasmAnyRef:
case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: {
case wasm::kWasmExnRef: {
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetReturn(i)),
kSystemPointerSize);
base::WriteUnalignedValue<Object>(arg_buf_ptr,
......
......@@ -221,7 +221,7 @@ class LiftoffCompiler {
case kWasmFuncRef:
case kWasmNullRef:
return kAnyRef;
case kWasmExceptRef:
case kWasmExnRef:
return kExceptionHandling;
case kWasmBottom:
return kMultiValue;
......
......@@ -1257,7 +1257,7 @@ void PushArgs(i::wasm::FunctionSig* sig, const Val args[],
case i::wasm::kWasmFuncRef:
packer->Push(impl(args[i].ref())->v8_object()->ptr());
break;
case i::wasm::kWasmExceptRef:
case i::wasm::kWasmExnRef:
// TODO(jkummerow): Implement these.
UNIMPLEMENTED();
break;
......@@ -1297,7 +1297,7 @@ void PopArgs(i::wasm::FunctionSig* sig, Val results[],
}
break;
}
case i::wasm::kWasmExceptRef:
case i::wasm::kWasmExnRef:
// TODO(jkummerow): Implement these.
UNIMPLEMENTED();
break;
......
......@@ -236,8 +236,8 @@ inline bool decode_local_type(uint8_t val, ValueType* result) {
case kLocalAnyRef:
*result = kWasmAnyRef;
return true;
case kLocalExceptRef:
*result = kWasmExceptRef;
case kLocalExnRef:
*result = kWasmExnRef;
return true;
default:
*result = kWasmBottom;
......@@ -859,9 +859,9 @@ class WasmDecoder : public Decoder {
"local type 'funcref' is not enabled with "
"--experimental-wasm-anyref");
return false;
case kLocalExceptRef:
case kLocalExnRef:
if (enabled.eh) {
type = kWasmExceptRef;
type = kWasmExnRef;
break;
}
decoder->error(decoder->pc() - 1, "invalid local type");
......@@ -1769,7 +1769,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
}
case kExprRethrow: {
CHECK_PROTOTYPE_OPCODE(eh);
auto exception = Pop(0, kWasmExceptRef);
auto exception = Pop(0, kWasmExnRef);
CALL_INTERFACE_IF_REACHABLE(Rethrow, exception);
EndControl();
break;
......@@ -1815,7 +1815,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
FallThruTo(c);
stack_.erase(stack_.begin() + c->stack_depth, stack_.end());
c->reachability = control_at(1)->innerReachability();
auto* exception = Push(kWasmExceptRef);
auto* exception = Push(kWasmExnRef);
CALL_INTERFACE_IF_PARENT_REACHABLE(Catch, c, exception);
break;
}
......@@ -1825,7 +1825,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (!this->Validate(this->pc_, imm.depth, control_.size())) break;
if (!this->Validate(this->pc_ + imm.depth.length, imm.index)) break;
Control* c = control_at(imm.depth.depth);
auto exception = Pop(0, kWasmExceptRef);
auto exception = Pop(0, kWasmExnRef);
const WasmExceptionSig* sig = imm.index.exception->sig;
size_t value_count = sig->parameter_count();
// TODO(mstarzinger): This operand stack mutation is an ugly hack to
......@@ -1844,7 +1844,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
}
len = 1 + imm.length;
for (size_t i = 0; i < value_count; ++i) Pop();
auto* pexception = Push(kWasmExceptRef);
auto* pexception = Push(kWasmExnRef);
*pexception = exception;
break;
}
......
......@@ -692,7 +692,7 @@ class WasmGraphBuildingInterface {
return builder_->S128Zero();
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef:
case kWasmExnRef:
return builder_->RefNull();
default:
UNREACHABLE();
......
......@@ -1601,8 +1601,8 @@ class ModuleDecoderImpl : public Decoder {
case kLocalAnyRef:
if (enabled_features_.anyref) return kWasmAnyRef;
break;
case kLocalExceptRef:
if (enabled_features_.eh) return kWasmExceptRef;
case kLocalExnRef:
if (enabled_features_.eh) return kWasmExnRef;
break;
default:
break;
......
......@@ -751,7 +751,7 @@ void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global,
}
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef: {
case kWasmExnRef: {
tagged_globals_->set(global.offset, *value->GetRef());
break;
}
......
......@@ -21,7 +21,7 @@ namespace wasm {
//
// AnyRef
// / \
// FuncRef ExceptRef
// FuncRef ExnRef
// \ /
// I32 I64 F32 F64 NullRef
// \ \ \ \ /
......@@ -36,7 +36,7 @@ enum ValueType : uint8_t {
kWasmAnyRef,
kWasmFuncRef,
kWasmNullRef,
kWasmExceptRef,
kWasmExnRef,
kWasmBottom,
};
......@@ -192,17 +192,16 @@ class V8_EXPORT_PRIVATE ValueTypes {
return (expected == actual) ||
(expected == kWasmAnyRef && actual == kWasmNullRef) ||
(expected == kWasmAnyRef && actual == kWasmFuncRef) ||
(expected == kWasmAnyRef && actual == kWasmExceptRef) ||
(expected == kWasmAnyRef && actual == kWasmExnRef) ||
(expected == kWasmFuncRef && actual == kWasmNullRef) ||
// TODO(mstarzinger): For now we treat "null_ref" as a sub-type of
// "except_ref", which is correct but might change. See here:
// TODO(mstarzinger): For now we treat "nullref" as a sub-type of
// "exnref", which is correct but might change. See here:
// https://github.com/WebAssembly/exception-handling/issues/55
(expected == kWasmExceptRef && actual == kWasmNullRef);
(expected == kWasmExnRef && actual == kWasmNullRef);
}
static inline bool IsReferenceType(ValueType type) {
return type == kWasmAnyRef || type == kWasmFuncRef ||
type == kWasmExceptRef;
return type == kWasmAnyRef || type == kWasmFuncRef || type == kWasmExnRef;
}
static inline ValueType CommonSubType(ValueType a, ValueType b) {
......@@ -232,7 +231,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
return 16;
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef:
case kWasmExnRef:
return kSystemPointerSize;
default:
UNREACHABLE();
......@@ -251,7 +250,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
return 4;
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef:
case kWasmExnRef:
return kSystemPointerSizeLog2;
default:
UNREACHABLE();
......@@ -276,8 +275,8 @@ class V8_EXPORT_PRIVATE ValueTypes {
return kLocalAnyRef;
case kWasmFuncRef:
return kLocalFuncRef;
case kWasmExceptRef:
return kLocalExceptRef;
case kWasmExnRef:
return kLocalExnRef;
case kWasmStmt:
return kLocalVoid;
default:
......@@ -297,7 +296,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
return MachineType::Float64();
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef:
case kWasmExnRef:
return MachineType::TaggedPointer();
case kWasmS128:
return MachineType::Simd128();
......@@ -321,7 +320,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmNullRef:
case kWasmExceptRef:
case kWasmExnRef:
return MachineRepresentation::kTaggedPointer;
case kWasmS128:
return MachineRepresentation::kSimd128;
......@@ -394,7 +393,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
return "funcref";
case kWasmNullRef:
return "nullref";
case kWasmExceptRef:
case kWasmExnRef:
return "exn";
case kWasmS128:
return "s128";
......
......@@ -28,7 +28,7 @@ enum ValueTypeCode : uint8_t {
kLocalS128 = 0x7b,
kLocalFuncRef = 0x70,
kLocalAnyRef = 0x6f,
kLocalExceptRef = 0x68,
kLocalExnRef = 0x68,
};
// Binary encoding of other types.
constexpr uint8_t kWasmFunctionTypeCode = 0x60;
......
......@@ -1284,7 +1284,7 @@ class ThreadImpl {
#undef CASE_TYPE
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef: {
case kWasmExnRef: {
HandleScope handle_scope(isolate_); // Avoid leaking handles.
Handle<FixedArray> global_buffer; // The buffer of the global.
uint32_t global_index = 0; // The index into the buffer.
......@@ -1465,7 +1465,7 @@ class ThreadImpl {
#undef CASE_TYPE
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef: {
case kWasmExnRef: {
val = WasmValue(isolate_->factory()->null_value());
break;
}
......@@ -2670,7 +2670,7 @@ class ThreadImpl {
}
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef: {
case kWasmExnRef: {
Handle<Object> anyref = value.to_anyref();
encoded_values->set(encoded_index++, *anyref);
break;
......@@ -2770,7 +2770,7 @@ class ThreadImpl {
}
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef: {
case kWasmExnRef: {
Handle<Object> anyref(encoded_values->get(encoded_index++), isolate_);
value = WasmValue(anyref);
break;
......@@ -3224,7 +3224,7 @@ class ThreadImpl {
#undef CASE_TYPE
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef: {
case kWasmExnRef: {
HandleScope handle_scope(isolate_); // Avoid leaking handles.
Handle<FixedArray> global_buffer; // The buffer of the global.
uint32_t global_index = 0; // The index into the buffer.
......@@ -3685,7 +3685,7 @@ class ThreadImpl {
break;
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef:
case kWasmExnRef:
packer.Push(arg.to_anyref()->ptr());
break;
default:
......@@ -3724,7 +3724,7 @@ class ThreadImpl {
break;
case kWasmAnyRef:
case kWasmFuncRef:
case kWasmExceptRef: {
case kWasmExnRef: {
Handle<Object> ref(Object(packer.Pop<Address>()), isolate);
Push(WasmValue(ref));
break;
......
......@@ -1864,7 +1864,7 @@ void WebAssemblyGlobalGetValueCommon(
break;
case i::wasm::kWasmAnyRef:
case i::wasm::kWasmFuncRef:
case i::wasm::kWasmExceptRef:
case i::wasm::kWasmExnRef:
return_value.Set(Utils::ToLocal(receiver->GetRef()));
break;
default:
......@@ -1933,7 +1933,7 @@ void WebAssemblyGlobalSetValue(
break;
}
case i::wasm::kWasmAnyRef:
case i::wasm::kWasmExceptRef: {
case i::wasm::kWasmExnRef: {
receiver->SetAnyRef(Utils::OpenHandle(*args[0]));
break;
}
......
......@@ -165,7 +165,7 @@ double WasmGlobalObject::GetF64() {
}
Handle<Object> WasmGlobalObject::GetRef() {
// We use this getter for anyref, funcref, and except_ref.
// We use this getter for anyref, funcref, and exnref.
DCHECK(wasm::ValueTypes::IsReferenceType(type()));
return handle(tagged_buffer().get(offset()), GetIsolate());
}
......@@ -187,8 +187,8 @@ void WasmGlobalObject::SetF64(double value) {
}
void WasmGlobalObject::SetAnyRef(Handle<Object> value) {
// We use this getter anyref and except_ref.
DCHECK(type() == wasm::kWasmAnyRef || type() == wasm::kWasmExceptRef);
// We use this getter anyref and exnref.
DCHECK(type() == wasm::kWasmAnyRef || type() == wasm::kWasmExnRef);
tagged_buffer().set(offset(), *value);
}
......
......@@ -2149,7 +2149,7 @@ uint32_t WasmExceptionPackage::GetEncodedSize(
break;
case wasm::kWasmAnyRef:
case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef:
case wasm::kWasmExnRef:
encoded_size += 1;
break;
default:
......
......@@ -121,13 +121,13 @@ load("test/mjsunit/wasm/exceptions-utils.js");
})();
// Test throwing/catching an encapsulated exception type value.
(function TestThrowCatchExceptRef() {
(function TestThrowCatchExnRef() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let except = builder.addException(kSig_v_e);
builder.addFunction("throw_catch_param", kSig_e_e)
.addBody([
kExprTry, kWasmExceptRef,
kExprTry, kWasmExnRef,
kExprGetLocal, 0,
kExprThrow, except,
kExprCatch,
......
......@@ -9,41 +9,41 @@
load("test/mjsunit/wasm/wasm-module-builder.js");
// First we just test that "except_ref" global variables are allowed.
(function TestGlobalExceptRefSupported() {
// First we just test that "exnref" global variables are allowed.
(function TestGlobalExnRefSupported() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g = builder.addGlobal(kWasmExceptRef);
builder.addFunction("push_and_drop_except_ref", kSig_v_v)
let g = builder.addGlobal(kWasmExnRef);
builder.addFunction("push_and_drop_exnref", kSig_v_v)
.addBody([
kExprGetGlobal, g.index,
kExprDrop,
]).exportFunc();
let instance = builder.instantiate();
assertDoesNotThrow(instance.exports.push_and_drop_except_ref);
assertDoesNotThrow(instance.exports.push_and_drop_exnref);
})();
// Test default value that global "except_ref" variables are initialized with.
(function TestGlobalExceptRefDefaultValue() {
// Test default value that global "exnref" variables are initialized with.
(function TestGlobalExnRefDefaultValue() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g = builder.addGlobal(kWasmExceptRef);
builder.addFunction('push_and_return_except_ref', kSig_e_v)
let g = builder.addGlobal(kWasmExnRef);
builder.addFunction('push_and_return_exnref', kSig_e_v)
.addBody([kExprGetGlobal, g.index])
.exportFunc();
let instance = builder.instantiate();
assertEquals(null, instance.exports.push_and_return_except_ref());
assertEquals(null, instance.exports.push_and_return_exnref());
})();
// Test storing a caught exception into an exported mutable "except_ref" global.
(function TestGlobalExceptRefSetCaught() {
// Test storing a caught exception into an exported mutable "exnref" global.
(function TestGlobalExnRefSetCaught() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let except = builder.addException(kSig_v_i);
let g = builder.addGlobal(kWasmExceptRef, true).exportAs("exn");
builder.addFunction('catch_and_set_except_ref', kSig_v_i)
let g = builder.addGlobal(kWasmExnRef, true).exportAs("exn");
builder.addFunction('catch_and_set_exnref', kSig_v_i)
.addBody([
kExprTry, kWasmStmt,
kExprGetLocal, 0,
......@@ -54,18 +54,18 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
]).exportFunc();
let instance = builder.instantiate();
assertDoesNotThrow(() => instance.exports.catch_and_set_except_ref(23));
assertDoesNotThrow(() => instance.exports.catch_and_set_exnref(23));
let exception = instance.exports.exn.value; // Exported mutable global.
assertInstanceof(exception, WebAssembly.RuntimeError);
assertEquals(except, %GetWasmExceptionId(exception, instance));
})();
// Test storing a parameter into an exported mutable "except_ref" global.
(function TestGlobalExceptRefSetParameter() {
// Test storing a parameter into an exported mutable "exnref" global.
(function TestGlobalExnRefSetParameter() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g = builder.addGlobal(kWasmExceptRef, true).exportAs("exn");
builder.addFunction('set_param_except_ref', kSig_v_e)
let g = builder.addGlobal(kWasmExnRef, true).exportAs("exn");
builder.addFunction('set_param_exnref', kSig_v_e)
.addBody([
kExprTry, kWasmStmt,
kExprGetLocal, 0,
......@@ -77,16 +77,16 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
let exception = "my fancy exception";
let instance = builder.instantiate();
assertDoesNotThrow(() => instance.exports.set_param_except_ref(exception));
assertDoesNotThrow(() => instance.exports.set_param_exnref(exception));
assertEquals(exception, instance.exports.exn.value);
})();
// Test loading an imported "except_ref" global and re-throwing the exception.
(function TestGlobalExceptRefGetImportedAndRethrow() {
// Test loading an imported "exnref" global and re-throwing the exception.
(function TestGlobalExnRefGetImportedAndRethrow() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g_index = builder.addImportedGlobal("m", "exn", kWasmExceptRef);
builder.addFunction('rethrow_except_ref', kSig_v_v)
let g_index = builder.addImportedGlobal("m", "exn", kWasmExnRef);
builder.addFunction('rethrow_exnref', kSig_v_v)
.addBody([
kExprGetGlobal, g_index,
kExprRethrow,
......@@ -94,15 +94,15 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
let exception = "my fancy exception";
let instance = builder.instantiate({ "m": { "exn": exception }});
assertThrowsEquals(() => instance.exports.rethrow_except_ref(), exception);
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception);
})();
// Test loading an exported mutable "except_ref" being changed from the outside.
(function TestGlobalExceptRefGetExportedMutableAndRethrow() {
// Test loading an exported mutable "exnref" being changed from the outside.
(function TestGlobalExnRefGetExportedMutableAndRethrow() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g = builder.addGlobal(kWasmExceptRef, true).exportAs("exn");
builder.addFunction('rethrow_except_ref', kSig_v_v)
let g = builder.addGlobal(kWasmExnRef, true).exportAs("exn");
builder.addFunction('rethrow_exnref', kSig_v_v)
.addBody([
kExprGetGlobal, g.index,
kExprRethrow,
......@@ -110,45 +110,45 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
let instance = builder.instantiate();
let exception1 = instance.exports.exn.value = "my fancy exception";
assertThrowsEquals(() => instance.exports.rethrow_except_ref(), exception1);
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception1);
let exception2 = instance.exports.exn.value = "an even fancier exception";
assertThrowsEquals(() => instance.exports.rethrow_except_ref(), exception2);
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception2);
})();
// TODO(mstarzinger): Add the following test once proposal makes it clear how
// far interaction with the mutable globals proposal is intended to go.
// Test loading an imported mutable "except_ref" being changed from the outside.
/*(function TestGlobalExceptRefGetImportedMutableAndRethrow() {
// Test loading an imported mutable "exnref" being changed from the outside.
/*(function TestGlobalExnRefGetImportedMutableAndRethrow() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g_index = builder.addImportedGlobal("m", "exn", kWasmExceptRef, true);
builder.addFunction('rethrow_except_ref', kSig_v_v)
let g_index = builder.addImportedGlobal("m", "exn", kWasmExnRef, true);
builder.addFunction('rethrow_exnref', kSig_v_v)
.addBody([
kExprGetGlobal, g_index,
kExprRethrow,
]).exportFunc();
let exception1 = "my fancy exception";
let desc = { value: 'except_ref', mutable: true };
let desc = { value: 'exnref', mutable: true };
let mutable_global = new WebAssembly.Global(desc, exception1);
let instance = builder.instantiate({ "m": { "exn": mutable_global }});
assertThrowsEquals(() => instance.exports.rethrow_except_ref(), exception1);
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception1);
let exception2 = mutable_global.value = "an even fancier exception";
assertThrowsEquals(() => instance.exports.rethrow_except_ref(), exception2);
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception2);
})();*/
// Test custom initialization index for a global "except_ref" variable.
(function TestGlobalExceptRefInitIndex() {
// Test custom initialization index for a global "exnref" variable.
(function TestGlobalExnRefInitIndex() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g1_index = builder.addImportedGlobal("m", "exn", kWasmExceptRef);
let g2 = builder.addGlobal(kWasmExceptRef);
let g1_index = builder.addImportedGlobal("m", "exn", kWasmExnRef);
let g2 = builder.addGlobal(kWasmExnRef);
g2.init_index = g1_index; // Initialize {g2} to equal {g1}.
builder.addFunction('push_and_return_except_ref', kSig_e_v)
builder.addFunction('push_and_return_exnref', kSig_e_v)
.addBody([kExprGetGlobal, g2.index])
.exportFunc();
let exception = { x: "my fancy exception" };
let instance = builder.instantiate({ "m": { "exn": exception }});
assertSame(exception, instance.exports.push_and_return_except_ref());
assertSame(exception, instance.exports.push_and_return_exnref());
})();
......@@ -7,11 +7,11 @@
load("test/mjsunit/wasm/wasm-module-builder.js");
load("test/mjsunit/wasm/exceptions-utils.js");
// First we just test that "except_ref" local variables are allowed.
(function TestLocalExceptRef() {
// First we just test that "exnref" local variables are allowed.
(function TestLocalExnRef() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
builder.addFunction("push_and_drop_except_ref", kSig_v_v)
builder.addFunction("push_and_drop_exnref", kSig_v_v)
.addLocals({except_count: 1})
.addBody([
kExprGetLocal, 0,
......@@ -19,7 +19,7 @@ load("test/mjsunit/wasm/exceptions-utils.js");
]).exportFunc();
let instance = builder.instantiate();
assertDoesNotThrow(instance.exports.push_and_drop_except_ref);
assertDoesNotThrow(instance.exports.push_and_drop_exnref);
})();
// The following method doesn't attempt to catch an raised exception.
......
......@@ -100,7 +100,7 @@ let kWasmF64 = 0x7c;
let kWasmS128 = 0x7b;
let kWasmAnyRef = 0x6f;
let kWasmAnyFunc = 0x70;
let kWasmExceptRef = 0x68;
let kWasmExnRef = 0x68;
let kExternalFunction = 0;
let kExternalTable = 1;
......@@ -150,17 +150,17 @@ let kSig_f_d = makeSig([kWasmF64], [kWasmF32]);
let kSig_d_d = makeSig([kWasmF64], [kWasmF64]);
let kSig_r_r = makeSig([kWasmAnyRef], [kWasmAnyRef]);
let kSig_a_a = makeSig([kWasmAnyFunc], [kWasmAnyFunc]);
let kSig_e_e = makeSig([kWasmExceptRef], [kWasmExceptRef]);
let kSig_e_e = makeSig([kWasmExnRef], [kWasmExnRef]);
let kSig_i_r = makeSig([kWasmAnyRef], [kWasmI32]);
let kSig_v_r = makeSig([kWasmAnyRef], []);
let kSig_v_a = makeSig([kWasmAnyFunc], []);
let kSig_v_e = makeSig([kWasmExceptRef], []);
let kSig_v_e = makeSig([kWasmExnRef], []);
let kSig_v_rr = makeSig([kWasmAnyRef, kWasmAnyRef], []);
let kSig_v_aa = makeSig([kWasmAnyFunc, kWasmAnyFunc], []);
let kSig_r_v = makeSig([], [kWasmAnyRef]);
let kSig_a_v = makeSig([], [kWasmAnyFunc]);
let kSig_a_i = makeSig([kWasmI32], [kWasmAnyFunc]);
let kSig_e_v = makeSig([], [kWasmExceptRef]);
let kSig_e_v = makeSig([], [kWasmExnRef]);
function makeSig(params, results) {
return {params: params, results: results};
......@@ -1087,7 +1087,7 @@ class WasmModuleBuilder {
section.emit_u8(kExprRefNull);
}
break;
case kWasmExceptRef:
case kWasmExnRef:
section.emit_u8(kExprRefNull);
break;
}
......@@ -1263,7 +1263,7 @@ class WasmModuleBuilder {
local_decls.push({count: l.anyfunc_count, type: kWasmAnyFunc});
}
if (l.except_count > 0) {
local_decls.push({count: l.except_count, type: kWasmExceptRef});
local_decls.push({count: l.except_count, type: kWasmExnRef});
}
}
......
......@@ -3718,9 +3718,9 @@ TEST_F(LocalDeclDecoderTest, UseEncoder) {
pos = ExpectRun(map, pos, kWasmI64, 212);
}
TEST_F(LocalDeclDecoderTest, ExceptRef) {
TEST_F(LocalDeclDecoderTest, ExnRef) {
WASM_FEATURE_SCOPE(eh);
ValueType type = kWasmExceptRef;
ValueType type = kWasmExnRef;
const byte data[] = {1, 1,
static_cast<byte>(ValueTypes::ValueTypeCodeFor(type))};
BodyLocalDecls decls(zone());
......
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