Changeset 272071 in webkit
- Timestamp:
- Jan 29, 2021 11:26:36 AM (18 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/wasm/references/globals.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/wasm/WasmTable.cpp (modified) (1 diff)
-
Source/JavaScriptCore/wasm/WasmTable.h (modified) (1 diff)
-
Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h (modified) (1 diff)
-
Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp (modified) (1 diff)
-
Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r272031 r272071 1 2021-01-29 Dmitry Bezhetskov <dbezhetskov@igalia.com> 2 3 [JSC] WebAssembly.Global should support Funcref and Externref 4 https://bugs.webkit.org/show_bug.cgi?id=220914 5 6 Reviewed by Yusuke Suzuki. 7 8 Add tests for WebAssembly.Global ctors with 9 new reference types: 10 https://webassembly.github.io/reference-types/js-api/index.html#dom-global-global. 11 12 * wasm/references/globals.js: Added. 13 (Pelmen): 14 (testGlobalConstructorForExternref): 15 (async testGlobalConstructorForFuncref): 16 1 17 2021-01-28 Yusuke Suzuki <ysuzuki@apple.com> 2 18 -
trunk/Source/JavaScriptCore/ChangeLog
r272064 r272071 1 2021-01-29 Dmitry Bezhetskov <dbezhetskov@igalia.com> 2 3 [JSC] WebAssembly.Global should support Funcref and Externref 4 https://bugs.webkit.org/show_bug.cgi?id=220914 5 6 Reviewed by Yusuke Suzuki. 7 8 Allow using reference types in ctor of WebAssembly.Global 9 according to the spec 10 https://webassembly.github.io/reference-types/js-api/index.html#dom-global-global. 11 12 * wasm/js/WebAssemblyGlobalConstructor.cpp: 13 (JSC::JSC_DEFINE_HOST_FUNCTION): 14 1 15 2021-01-29 David Kilzer <ddkilzer@apple.com> 2 16 -
trunk/Source/JavaScriptCore/wasm/WasmTable.cpp
r271303 r272071 175 175 } 176 176 177 Type Table::wasmType() const 178 { 179 if (isExternrefTable()) 180 return Type::Externref; 181 ASSERT(isFuncrefTable()); 182 return Type::Funcref; 183 } 184 177 185 FuncRefTable* Table::asFuncrefTable() 178 186 { -
trunk/Source/JavaScriptCore/wasm/WasmTable.h
r271303 r272071 69 69 bool isExternrefTable() const { return m_type == TableElementType::Externref; } 70 70 bool isFuncrefTable() const { return m_type == TableElementType::Funcref; } 71 Type wasmType() const; 71 72 FuncRefTable* asFuncrefTable(); 72 73 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h
r271903 r272071 136 136 } 137 137 138 ALWAYS_INLINE JSValue defaultValueFor Table(const Wasm::TableElementType tableType)138 ALWAYS_INLINE JSValue defaultValueForReferenceType(const Wasm::Type type) 139 139 { 140 if (tableType == Wasm::TableElementType::Externref) 140 ASSERT(Wasm::isRefType(type)); 141 if (type == Wasm::Type::Externref) 141 142 return jsUndefined(); 142 ASSERT(t ableType == Wasm::TableElementType::Funcref);143 ASSERT(type == Wasm::Type::Funcref); 143 144 return jsNull(); 144 145 } -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp
r271168 r272071 31 31 #include "JSCInlines.h" 32 32 #include "JSWebAssemblyGlobal.h" 33 #include "WasmFormat.h" 33 34 #include "WebAssemblyGlobalPrototype.h" 34 35 … … 94 95 else if (valueString == "f64") 95 96 type = Wasm::Type::F64; 97 else if (Options::useWebAssemblyReferences() && valueString == "anyfunc") 98 type = Wasm::Type::Funcref; 99 else if (Options::useWebAssemblyReferences() && valueString == "externref") 100 type = Wasm::Type::Externref; 96 101 else 97 102 return JSValue::encode(throwException(globalObject, throwScope, createTypeError(globalObject, "WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'"_s))); … … 126 131 break; 127 132 } 133 case Wasm::Type::Funcref: 134 case Wasm::Type::Externref: { 135 // We check default value for these types later in set method. 136 ASSERT(Options::useWebAssemblyReferences()); 137 break; 138 } 128 139 default: 129 140 RELEASE_ASSERT_NOT_REACHED(); … … 132 143 133 144 Ref<Wasm::Global> wasmGlobal = Wasm::Global::create(type, mutability, initialValue); 134 RELEASE_AND_RETURN(throwScope, JSValue::encode(JSWebAssemblyGlobal::tryCreate(globalObject, vm, webAssemblyGlobalStructure, WTFMove(wasmGlobal)))); 145 JSWebAssemblyGlobal* jsWebAssemblyGlobal = JSWebAssemblyGlobal::tryCreate(globalObject, vm, webAssemblyGlobalStructure, WTFMove(wasmGlobal)); 146 RETURN_IF_EXCEPTION(throwScope, { }); 147 148 if (Wasm::isRefType(type)) { 149 ASSERT(Options::useWebAssemblyReferences()); 150 if (argument.isUndefined()) 151 argument = defaultValueForReferenceType(type); 152 jsWebAssemblyGlobal->global()->set(globalObject, argument); 153 RETURN_IF_EXCEPTION(throwScope, { }); 154 } 155 return JSValue::encode(jsWebAssemblyGlobal); 135 156 } 136 157 -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp
r271903 r272071 123 123 if (Options::useWebAssemblyReferences()) { 124 124 JSValue defaultValue = callFrame->argumentCount() < 2 125 ? defaultValueFor Table(jsWebAssemblyTable->table()->type())125 ? defaultValueForReferenceType(jsWebAssemblyTable->table()->wasmType()) 126 126 : callFrame->uncheckedArgument(1); 127 127 WebAssemblyFunction* wasmFunction = nullptr; -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp
r271903 r272071 95 95 if (Options::useWebAssemblyReferences()) { 96 96 if (callFrame->argumentCount() < 2) 97 defaultValue = defaultValueFor Table(table->table()->type());97 defaultValue = defaultValueForReferenceType(table->table()->wasmType()); 98 98 else 99 99 defaultValue = callFrame->uncheckedArgument(1); … … 141 141 JSValue value = callFrame->argument(1); 142 142 if (Options::useWebAssemblyReferences() && callFrame->argumentCount() < 2) 143 value = defaultValueFor Table(table->table()->type());143 value = defaultValueForReferenceType(table->table()->wasmType()); 144 144 145 145 if (table->table()->asFuncrefTable()) {
Note: See TracChangeset
for help on using the changeset viewer.