summaryrefslogtreecommitdiff
path: root/chromium/v8/src/wasm/c-api.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/wasm/c-api.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/wasm/c-api.cc')
-rw-r--r--chromium/v8/src/wasm/c-api.cc146
1 files changed, 76 insertions, 70 deletions
diff --git a/chromium/v8/src/wasm/c-api.cc b/chromium/v8/src/wasm/c-api.cc
index cd5d04bd2d8..aedf5726194 100644
--- a/chromium/v8/src/wasm/c-api.cc
+++ b/chromium/v8/src/wasm/c-api.cc
@@ -71,10 +71,19 @@ ValKind V8ValueTypeToWasm(i::wasm::ValueType v8_valtype) {
return F32;
case i::wasm::ValueType::kF64:
return F64;
- case i::wasm::ValueType::kFuncRef:
- return FUNCREF;
- case i::wasm::ValueType::kAnyRef:
- return ANYREF;
+ case i::wasm::ValueType::kRef:
+ case i::wasm::ValueType::kOptRef:
+ switch (v8_valtype.heap_type()) {
+ case i::wasm::kHeapFunc:
+ return FUNCREF;
+ case i::wasm::kHeapExtern:
+ // TODO(7748): Rename this to EXTERNREF if/when third-party API
+ // changes.
+ return ANYREF;
+ default:
+ // TODO(wasm+): support new value types
+ UNREACHABLE();
+ }
default:
// TODO(wasm+): support new value types
UNREACHABLE();
@@ -94,7 +103,7 @@ i::wasm::ValueType WasmValKindToV8(ValKind kind) {
case FUNCREF:
return i::wasm::kWasmFuncRef;
case ANYREF:
- return i::wasm::kWasmAnyRef;
+ return i::wasm::kWasmExternRef;
default:
// TODO(wasm+): support new value types
UNREACHABLE();
@@ -201,8 +210,6 @@ auto seal(const typename implement<C>::type* x) -> const C* {
// Configuration
struct ConfigImpl {
- ConfigImpl() {}
- ~ConfigImpl() {}
};
template <>
@@ -249,7 +256,7 @@ void Engine::operator delete(void* p) { ::operator delete(p); }
auto Engine::make(own<Config>&& config) -> own<Engine> {
i::FLAG_expose_gc = true;
- i::FLAG_experimental_wasm_anyref = true;
+ i::FLAG_experimental_wasm_reftypes = true;
i::FLAG_experimental_wasm_bigint = true;
i::FLAG_experimental_wasm_mv = true;
auto engine = new (std::nothrow) EngineImpl;
@@ -372,10 +379,10 @@ ValTypeImpl* valtype_i32 = new ValTypeImpl(I32);
ValTypeImpl* valtype_i64 = new ValTypeImpl(I64);
ValTypeImpl* valtype_f32 = new ValTypeImpl(F32);
ValTypeImpl* valtype_f64 = new ValTypeImpl(F64);
-ValTypeImpl* valtype_anyref = new ValTypeImpl(ANYREF);
+ValTypeImpl* valtype_externref = new ValTypeImpl(ANYREF);
ValTypeImpl* valtype_funcref = new ValTypeImpl(FUNCREF);
-ValType::~ValType() {}
+ValType::~ValType() = default;
void ValType::operator delete(void*) {}
@@ -395,7 +402,7 @@ own<ValType> ValType::make(ValKind k) {
valtype = valtype_f64;
break;
case ANYREF:
- valtype = valtype_anyref;
+ valtype = valtype_externref;
break;
case FUNCREF:
valtype = valtype_funcref;
@@ -417,7 +424,7 @@ struct ExternTypeImpl {
ExternKind kind;
explicit ExternTypeImpl(ExternKind kind) : kind(kind) {}
- virtual ~ExternTypeImpl() {}
+ virtual ~ExternTypeImpl() = default;
};
template <>
@@ -455,8 +462,6 @@ struct FuncTypeImpl : ExternTypeImpl {
: ExternTypeImpl(EXTERN_FUNC),
params(std::move(params)),
results(std::move(results)) {}
-
- ~FuncTypeImpl() {}
};
template <>
@@ -464,7 +469,7 @@ struct implement<FuncType> {
using type = FuncTypeImpl;
};
-FuncType::~FuncType() {}
+FuncType::~FuncType() = default;
auto FuncType::make(ownvec<ValType>&& params, ownvec<ValType>&& results)
-> own<FuncType> {
@@ -510,7 +515,7 @@ struct GlobalTypeImpl : ExternTypeImpl {
content(std::move(content)),
mutability(mutability) {}
- ~GlobalTypeImpl() {}
+ ~GlobalTypeImpl() override = default;
};
template <>
@@ -518,7 +523,7 @@ struct implement<GlobalType> {
using type = GlobalTypeImpl;
};
-GlobalType::~GlobalType() {}
+GlobalType::~GlobalType() = default;
auto GlobalType::make(own<ValType>&& content, Mutability mutability)
-> own<GlobalType> {
@@ -563,7 +568,7 @@ struct TableTypeImpl : ExternTypeImpl {
element(std::move(element)),
limits(limits) {}
- ~TableTypeImpl() {}
+ ~TableTypeImpl() override = default;
};
template <>
@@ -571,7 +576,7 @@ struct implement<TableType> {
using type = TableTypeImpl;
};
-TableType::~TableType() {}
+TableType::~TableType() = default;
auto TableType::make(own<ValType>&& element, Limits limits) -> own<TableType> {
return element ? own<TableType>(seal<TableType>(
@@ -609,7 +614,7 @@ struct MemoryTypeImpl : ExternTypeImpl {
explicit MemoryTypeImpl(Limits limits)
: ExternTypeImpl(EXTERN_MEMORY), limits(limits) {}
- ~MemoryTypeImpl() {}
+ ~MemoryTypeImpl() override = default;
};
template <>
@@ -617,7 +622,7 @@ struct implement<MemoryType> {
using type = MemoryTypeImpl;
};
-MemoryType::~MemoryType() {}
+MemoryType::~MemoryType() = default;
auto MemoryType::make(Limits limits) -> own<MemoryType> {
return own<MemoryType>(
@@ -655,8 +660,6 @@ struct ImportTypeImpl {
: module(std::move(module)),
name(std::move(name)),
type(std::move(type)) {}
-
- ~ImportTypeImpl() {}
};
template <>
@@ -697,8 +700,6 @@ struct ExportTypeImpl {
ExportTypeImpl(Name& name, // NOLINT(runtime/references)
own<ExternType>& type) // NOLINT(runtime/references)
: name(std::move(name)), type(std::move(type)) {}
-
- ~ExportTypeImpl() {}
};
template <>
@@ -767,7 +768,7 @@ class RefImpl {
}
private:
- RefImpl() {}
+ RefImpl() = default;
i::Address* location() const {
return reinterpret_cast<i::Address*>(val_.address());
@@ -813,8 +814,6 @@ struct FrameImpl {
func_offset(func_offset),
module_offset(module_offset) {}
- ~FrameImpl() {}
-
own<Instance> instance;
uint32_t func_index;
size_t func_offset;
@@ -854,7 +853,7 @@ struct implement<Trap> {
using type = RefImpl<Trap, i::JSReceiver>;
};
-Trap::~Trap() {}
+Trap::~Trap() = default;
auto Trap::copy() const -> own<Trap> { return impl(this)->copy(); }
@@ -941,7 +940,7 @@ struct implement<Foreign> {
using type = RefImpl<Foreign, i::JSReceiver>;
};
-Foreign::~Foreign() {}
+Foreign::~Foreign() = default;
auto Foreign::copy() const -> own<Foreign> { return impl(this)->copy(); }
@@ -962,7 +961,7 @@ struct implement<Module> {
using type = RefImpl<Module, i::WasmModuleObject>;
};
-Module::~Module() {}
+Module::~Module() = default;
auto Module::copy() const -> own<Module> { return impl(this)->copy(); }
@@ -1106,7 +1105,7 @@ struct implement<Extern> {
using type = RefImpl<Extern, i::JSReceiver>;
};
-Extern::~Extern() {}
+Extern::~Extern() = default;
auto Extern::copy() const -> own<Extern> { return impl(this)->copy(); }
@@ -1177,7 +1176,7 @@ struct implement<Func> {
using type = RefImpl<Func, i::JSFunction>;
};
-Func::~Func() {}
+Func::~Func() = default;
auto Func::copy() const -> own<Func> { return impl(this)->copy(); }
@@ -1384,7 +1383,7 @@ void PrepareFunctionData(i::Isolate* isolate,
if (!function_data->c_wrapper_code().IsSmi()) return;
// Compile wrapper code.
i::Handle<i::Code> wrapper_code =
- i::compiler::CompileCWasmEntry(isolate, sig).ToHandleChecked();
+ i::compiler::CompileCWasmEntry(isolate, sig);
function_data->set_c_wrapper_code(*wrapper_code);
// Compute packed args size.
function_data->set_packed_args_size(
@@ -1414,16 +1413,13 @@ void PushArgs(const i::wasm::FunctionSig* sig, const Val args[],
case i::wasm::ValueType::kF64:
packer->Push(args[i].f64());
break;
- case i::wasm::ValueType::kAnyRef:
- case i::wasm::ValueType::kFuncRef:
- case i::wasm::ValueType::kNullRef:
+ case i::wasm::ValueType::kRef:
+ case i::wasm::ValueType::kOptRef:
+ // TODO(7748): Make sure this works for all types.
packer->Push(WasmRefToV8(store->i_isolate(), args[i].ref())->ptr());
break;
- case i::wasm::ValueType::kExnRef:
- // TODO(jkummerow): Implement these.
- UNIMPLEMENTED();
- break;
default:
+ // TODO(7748): Implement these.
UNIMPLEMENTED();
}
}
@@ -1447,20 +1443,23 @@ void PopArgs(const i::wasm::FunctionSig* sig, Val results[],
case i::wasm::ValueType::kF64:
results[i] = Val(packer->Pop<double>());
break;
- case i::wasm::ValueType::kAnyRef:
- case i::wasm::ValueType::kFuncRef:
- case i::wasm::ValueType::kNullRef: {
- i::Address raw = packer->Pop<i::Address>();
- i::Handle<i::Object> obj(i::Object(raw), store->i_isolate());
- DCHECK_IMPLIES(type == i::wasm::kWasmNullRef, obj->IsNull());
- results[i] = Val(V8RefValueToWasm(store, obj));
- break;
- }
- case i::wasm::ValueType::kExnRef:
- // TODO(jkummerow): Implement these.
- UNIMPLEMENTED();
+ case i::wasm::ValueType::kRef:
+ case i::wasm::ValueType::kOptRef:
+ switch (type.heap_type()) {
+ case i::wasm::kHeapExtern:
+ case i::wasm::kHeapFunc: {
+ i::Address raw = packer->Pop<i::Address>();
+ i::Handle<i::Object> obj(i::Object(raw), store->i_isolate());
+ results[i] = Val(V8RefValueToWasm(store, obj));
+ break;
+ }
+ default:
+ // TODO(jkummerow): Implement these.
+ UNIMPLEMENTED();
+ }
break;
default:
+ // TODO(7748): Implement these.
UNIMPLEMENTED();
}
}
@@ -1662,7 +1661,7 @@ struct implement<Global> {
using type = RefImpl<Global, i::WasmGlobalObject>;
};
-Global::~Global() {}
+Global::~Global() = default;
auto Global::copy() const -> own<Global> { return impl(this)->copy(); }
@@ -1707,14 +1706,21 @@ auto Global::get() const -> Val {
return Val(v8_global->GetF32());
case i::wasm::ValueType::kF64:
return Val(v8_global->GetF64());
- case i::wasm::ValueType::kAnyRef:
- case i::wasm::ValueType::kFuncRef: {
- StoreImpl* store = impl(this)->store();
- i::HandleScope scope(store->i_isolate());
- return Val(V8RefValueToWasm(store, v8_global->GetRef()));
- }
+ case i::wasm::ValueType::kRef:
+ case i::wasm::ValueType::kOptRef:
+ switch (v8_global->type().heap_type()) {
+ case i::wasm::kHeapExtern:
+ case i::wasm::kHeapFunc: {
+ StoreImpl* store = impl(this)->store();
+ i::HandleScope scope(store->i_isolate());
+ return Val(V8RefValueToWasm(store, v8_global->GetRef()));
+ }
+ default:
+ // TODO(wasm+): Support new value types.
+ UNREACHABLE();
+ }
default:
- // TODO(wasm+): support new value types
+ // TODO(7748): Implement these.
UNREACHABLE();
}
}
@@ -1731,7 +1737,7 @@ void Global::set(const Val& val) {
case F64:
return v8_global->SetF64(val.f64());
case ANYREF:
- return v8_global->SetAnyRef(
+ return v8_global->SetExternRef(
WasmRefToV8(impl(this)->store()->i_isolate(), val.ref()));
case FUNCREF: {
i::Isolate* isolate = impl(this)->store()->i_isolate();
@@ -1754,7 +1760,7 @@ struct implement<Table> {
using type = RefImpl<Table, i::WasmTableObject>;
};
-Table::~Table() {}
+Table::~Table() = default;
auto Table::copy() const -> own<Table> { return impl(this)->copy(); }
@@ -1772,8 +1778,8 @@ auto Table::make(Store* store_abs, const TableType* type, const Ref* ref)
break;
case ANYREF:
// See Engine::make().
- DCHECK(i::wasm::WasmFeatures::FromFlags().has_anyref());
- i_type = i::wasm::kWasmAnyRef;
+ DCHECK(i::wasm::WasmFeatures::FromFlags().has_reftypes());
+ i_type = i::wasm::kWasmExternRef;
break;
default:
UNREACHABLE();
@@ -1815,11 +1821,11 @@ auto Table::type() const -> own<TableType> {
uint32_t max;
if (!table->maximum_length().ToUint32(&max)) max = 0xFFFFFFFFu;
ValKind kind;
- switch (table->type().kind()) {
- case i::wasm::ValueType::kFuncRef:
+ switch (table->type().heap_type()) {
+ case i::wasm::kHeapFunc:
kind = FUNCREF;
break;
- case i::wasm::ValueType::kAnyRef:
+ case i::wasm::kHeapExtern:
kind = ANYREF;
break;
default:
@@ -1873,7 +1879,7 @@ struct implement<Memory> {
using type = RefImpl<Memory, i::WasmMemoryObject>;
};
-Memory::~Memory() {}
+Memory::~Memory() = default;
auto Memory::copy() const -> own<Memory> { return impl(this)->copy(); }
@@ -1941,7 +1947,7 @@ struct implement<Instance> {
using type = RefImpl<Instance, i::WasmInstanceObject>;
};
-Instance::~Instance() {}
+Instance::~Instance() = default;
auto Instance::copy() const -> own<Instance> { return impl(this)->copy(); }