Lines Matching defs:global
343 void WriteGlobalValue(const WasmGlobal& global, const WasmValue& value);
376 // Process a single imported global.
387 const WasmGlobal& global,
400 T* GetRawUntaggedGlobalPtr(const WasmGlobal& global);
584 // TODO(binji): This allocates one slot for each mutable global, which is
1038 void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global,
1041 global.type.is_reference()
1044 global.offset, value.to_string().c_str(), global.type.name().c_str());
1045 DCHECK(IsSubtypeOf(value.type(), global.type, module_));
1046 if (global.type.is_numeric()) {
1047 value.CopyTo(GetRawUntaggedGlobalPtr<byte>(global));
1049 tagged_globals_->set(global.offset, *value.to_ref());
1388 const WasmGlobal& global, Handle<WasmGlobalObject> global_object) {
1389 if (static_cast<bool>(global_object->is_mutable()) != global.mutability) {
1390 ReportLinkError("imported global does not match the expected mutability",
1401 global.mutability
1402 ? EquivalentTypes(global_object->type(), global.type,
1404 : IsSubtypeOf(global_object->type(), global.type, global_type_module,
1408 ReportLinkError("imported global does not match the expected type",
1412 if (global.mutability) {
1413 DCHECK_LT(global.index, module_->num_imported_mutable_globals);
1416 if (global.type.is_reference()) {
1432 instance->imported_mutable_globals_buffers().set(global.index, *buffer);
1433 instance->imported_mutable_globals()[global.index] = address_or_offset;
1464 WriteGlobalValue(global, value);
1473 // Immutable global imports are converted to numbers and written into
1476 // Mutable global imports instead have their backing array buffers
1478 // global in the {imported_mutable_globals_} array.
1479 const WasmGlobal& global = module_->globals[global_index];
1481 // SIMD proposal allows modules to define an imported v128 global, and only
1482 // supports importing a WebAssembly.Global object for this global, but also
1485 // be allowed to declare such a global (no validation error).
1486 if (global.type == kWasmS128 && !value->IsWasmGlobalObject()) {
1487 ReportLinkError("global import of type v128 must be a WebAssembly.Global",
1501 MaybeHandle<Object> converted = global.type == kWasmI32
1506 ReportLinkError("global import must be a number", import_index,
1516 import_name, global, global_object);
1519 if (global.mutability) {
1521 "imported mutable global must be a WebAssembly.Global object",
1526 if (global.type.is_reference()) {
1528 if (!wasm::TypecheckJSObject(isolate_, module_, value, global.type,
1533 if (IsSubtypeOf(global.type, kWasmFuncRef, module_) && !value->IsNull()) {
1537 WriteGlobalValue(global, WasmValue(value, global.type));
1541 if (value->IsNumber() && global.type != kWasmI64) {
1546 WasmValue wasm_value = global.type == kWasmI32
1548 : global.type == kWasmF32
1551 WriteGlobalValue(global, wasm_value);
1555 if (global.type == kWasmI64 && value->IsBigInt()) {
1556 WriteGlobalValue(global, WasmValue(BigInt::cast(*value).AsInt64()));
1561 "global import must be a number, valid Wasm reference, or "
1711 T* InstanceBuilder::GetRawUntaggedGlobalPtr(const WasmGlobal& global) {
1712 return reinterpret_cast<T*>(raw_buffer_ptr(untagged_globals_, global.offset));
1717 for (const WasmGlobal& global : module_->globals) {
1718 if (global.mutability && global.imported) continue;
1720 if (!global.init.is_set()) continue;
1723 EvaluateInitExpression(&init_expr_zone_, global.init, global.type,
1727 if (global.type.is_reference()) {
1728 tagged_globals_->set(global.offset, *value.to_ref());
1730 value.CopyTo(GetRawUntaggedGlobalPtr<byte>(global));
1760 // If an imported WebAssembly function or global gets exported, the export
1840 const WasmGlobal& global = module_->globals[exp.index];
1841 if (global.imported) {
1852 if (global.mutability && global.imported) {
1855 if (global.type.is_reference()) {
1857 FixedArray::cast(buffers_array->get(global.index)), isolate_);
1860 Address addr = instance->imported_mutable_globals()[global.index];
1866 handle(JSArrayBuffer::cast(buffers_array->get(global.index)),
1869 instance->imported_mutable_globals()[global.index];
1879 if (global.type.is_reference()) {
1885 offset = global.offset;
1888 // Since the global's array untagged_buffer is always provided,
1892 tagged_buffer, global.type, offset,
1893 global.mutability)