summaryrefslogtreecommitdiff
path: root/chromium/v8/src/wasm/wasm-objects.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/v8/src/wasm/wasm-objects.cc')
-rw-r--r--chromium/v8/src/wasm/wasm-objects.cc70
1 files changed, 33 insertions, 37 deletions
diff --git a/chromium/v8/src/wasm/wasm-objects.cc b/chromium/v8/src/wasm/wasm-objects.cc
index 28834678893..ae9d64b956d 100644
--- a/chromium/v8/src/wasm/wasm-objects.cc
+++ b/chromium/v8/src/wasm/wasm-objects.cc
@@ -283,7 +283,9 @@ Handle<WasmTableObject> WasmTableObject::New(Isolate* isolate,
table_obj->set_entries(*backing_store);
table_obj->set_current_length(initial);
table_obj->set_maximum_length(*max);
- table_obj->set_raw_type(static_cast<int>(type.kind()));
+ // TODO(7748): Make this work with other table types.
+ CHECK(type.is_nullable());
+ table_obj->set_raw_type(static_cast<int>(type.heap_type()));
table_obj->set_dispatch_tables(ReadOnlyRoots(isolate).empty_fixed_array());
if (entries != nullptr) {
@@ -384,14 +386,10 @@ bool WasmTableObject::IsValidElement(Isolate* isolate,
Handle<WasmTableObject> table,
Handle<Object> entry) {
// Anyref and exnref tables take everything.
- if (table->type() == wasm::kWasmAnyRef ||
- table->type() == wasm::kWasmExnRef) {
+ if (table->type().heap_type() == wasm::kHeapExtern ||
+ table->type().heap_type() == wasm::kHeapExn) {
return true;
}
- // Nullref only takes {null}.
- if (table->type() == wasm::kWasmNullRef) {
- return entry->IsNull(isolate);
- }
// FuncRef tables can store {null}, {WasmExportedFunction}, {WasmJSFunction},
// or {WasmCapiFunction} objects.
if (entry->IsNull(isolate)) return true;
@@ -409,8 +407,8 @@ void WasmTableObject::Set(Isolate* isolate, Handle<WasmTableObject> table,
Handle<FixedArray> entries(table->entries(), isolate);
// The FixedArray is addressed with int's.
int entry_index = static_cast<int>(index);
- if (table->type() == wasm::kWasmAnyRef ||
- table->type() == wasm::kWasmExnRef) {
+ if (table->type().heap_type() == wasm::kHeapExtern ||
+ table->type().heap_type() == wasm::kHeapExn) {
entries->set(entry_index, *entry);
return;
}
@@ -454,9 +452,9 @@ Handle<Object> WasmTableObject::Get(Isolate* isolate,
Handle<Object> entry(entries->get(entry_index), isolate);
- // First we handle the easy anyref and exnref table case.
- if (table->type() == wasm::kWasmAnyRef ||
- table->type() == wasm::kWasmExnRef) {
+ // First we handle the easy externref and exnref table case.
+ if (table->type().heap_type() == wasm::kHeapExtern ||
+ table->type().heap_type() == wasm::kHeapExn) {
return entry;
}
@@ -634,7 +632,7 @@ void WasmTableObject::GetFunctionTableEntry(
Isolate* isolate, Handle<WasmTableObject> table, int entry_index,
bool* is_valid, bool* is_null, MaybeHandle<WasmInstanceObject>* instance,
int* function_index, MaybeHandle<WasmJSFunction>* maybe_js_function) {
- DCHECK_EQ(table->type(), wasm::kWasmFuncRef);
+ DCHECK_EQ(table->type().heap_type(), wasm::kHeapFunc);
DCHECK_LT(entry_index, table->current_length());
// We initialize {is_valid} with {true}. We may change it later.
*is_valid = true;
@@ -856,7 +854,7 @@ void WasmMemoryObject::update_instances(Isolate* isolate,
int32_t WasmMemoryObject::Grow(Isolate* isolate,
Handle<WasmMemoryObject> memory_object,
uint32_t pages) {
- TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "GrowMemory");
+ TRACE_EVENT0("v8.wasm", "wasm.GrowMemory");
Handle<JSArrayBuffer> old_buffer(memory_object->array_buffer(), isolate);
// Any buffer used as an asmjs memory cannot be detached, and
// therefore this memory cannot be grown.
@@ -951,13 +949,13 @@ MaybeHandle<WasmGlobalObject> WasmGlobalObject::New(
// Disallow GC until all fields have acceptable types.
DisallowHeapAllocation no_gc;
- global_obj->set_flags(0);
+ global_obj->set_raw_type(0);
global_obj->set_type(type);
global_obj->set_offset(offset);
global_obj->set_is_mutable(is_mutable);
}
- if (type.IsReferenceType()) {
+ if (type.is_reference_type()) {
DCHECK(maybe_untagged_buffer.is_null());
Handle<FixedArray> tagged_buffer;
if (!maybe_tagged_buffer.ToHandle(&tagged_buffer)) {
@@ -1175,16 +1173,6 @@ const WasmModule* WasmInstanceObject::module() {
return module_object().module();
}
-Handle<WasmDebugInfo> WasmInstanceObject::GetOrCreateDebugInfo(
- Handle<WasmInstanceObject> instance) {
- if (instance->has_debug_info()) {
- return handle(instance->debug_info(), instance->GetIsolate());
- }
- Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(instance);
- DCHECK(instance->has_debug_info());
- return new_info;
-}
-
Handle<WasmInstanceObject> WasmInstanceObject::New(
Isolate* isolate, Handle<WasmModuleObject> module_object) {
Handle<JSFunction> instance_cons(
@@ -1483,7 +1471,7 @@ void WasmInstanceObject::ImportWasmJSFunctionIntoTable(
// static
uint8_t* WasmInstanceObject::GetGlobalStorage(
Handle<WasmInstanceObject> instance, const wasm::WasmGlobal& global) {
- DCHECK(!global.type.IsReferenceType());
+ DCHECK(!global.type.is_reference_type());
if (global.mutability && global.imported) {
return reinterpret_cast<byte*>(
instance->imported_mutable_globals()[global.index]);
@@ -1496,7 +1484,7 @@ uint8_t* WasmInstanceObject::GetGlobalStorage(
std::pair<Handle<FixedArray>, uint32_t>
WasmInstanceObject::GetGlobalBufferAndIndex(Handle<WasmInstanceObject> instance,
const wasm::WasmGlobal& global) {
- DCHECK(global.type.IsReferenceType());
+ DCHECK(global.type.is_reference_type());
Isolate* isolate = instance->GetIsolate();
if (global.mutability && global.imported) {
Handle<FixedArray> buffer(
@@ -1522,10 +1510,19 @@ MaybeHandle<String> WasmInstanceObject::GetGlobalNameOrNull(
// static
MaybeHandle<String> WasmInstanceObject::GetMemoryNameOrNull(
Isolate* isolate, Handle<WasmInstanceObject> instance,
- uint32_t global_index) {
+ uint32_t memory_index) {
return WasmInstanceObject::GetNameFromImportsAndExportsOrNull(
isolate, instance, wasm::ImportExportKindCode::kExternalMemory,
- global_index);
+ memory_index);
+}
+
+// static
+MaybeHandle<String> WasmInstanceObject::GetTableNameOrNull(
+ Isolate* isolate, Handle<WasmInstanceObject> instance,
+ uint32_t table_index) {
+ return WasmInstanceObject::GetNameFromImportsAndExportsOrNull(
+ isolate, instance, wasm::ImportExportKindCode::kExternalTable,
+ table_index);
}
// static
@@ -1533,7 +1530,8 @@ MaybeHandle<String> WasmInstanceObject::GetNameFromImportsAndExportsOrNull(
Isolate* isolate, Handle<WasmInstanceObject> instance,
wasm::ImportExportKindCode kind, uint32_t index) {
DCHECK(kind == wasm::ImportExportKindCode::kExternalGlobal ||
- kind == wasm::ImportExportKindCode::kExternalMemory);
+ kind == wasm::ImportExportKindCode::kExternalMemory ||
+ kind == wasm::ImportExportKindCode::kExternalTable);
wasm::ModuleWireBytes wire_bytes(
instance->module_object().native_module()->wire_bytes());
@@ -1562,7 +1560,7 @@ MaybeHandle<String> WasmInstanceObject::GetNameFromImportsAndExportsOrNull(
wasm::WasmValue WasmInstanceObject::GetGlobalValue(
Handle<WasmInstanceObject> instance, const wasm::WasmGlobal& global) {
Isolate* isolate = instance->GetIsolate();
- if (global.type.IsReferenceType()) {
+ if (global.type.is_reference_type()) {
Handle<FixedArray> global_buffer; // The buffer of the global.
uint32_t global_index = 0; // The index into the buffer.
std::tie(global_buffer, global_index) =
@@ -1727,17 +1725,15 @@ uint32_t WasmExceptionPackage::GetEncodedSize(
DCHECK_EQ(8, ComputeEncodedElementSize(sig->GetParam(i)));
encoded_size += 8;
break;
- case wasm::ValueType::kAnyRef:
- case wasm::ValueType::kFuncRef:
- case wasm::ValueType::kNullRef:
- case wasm::ValueType::kExnRef:
case wasm::ValueType::kRef:
case wasm::ValueType::kOptRef:
- case wasm::ValueType::kEqRef:
encoded_size += 1;
break;
+ case wasm::ValueType::kRtt:
case wasm::ValueType::kStmt:
case wasm::ValueType::kBottom:
+ case wasm::ValueType::kI8:
+ case wasm::ValueType::kI16:
UNREACHABLE();
}
}