Changeset 272119 in webkit
- Timestamp:
- Jan 30, 2021 11:51:08 AM (18 months ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
wasm/js/WebAssemblyGlobalConstructor.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r272099 r272119 1 2021-01-30 Yusuke Suzuki <ysuzuki@apple.com> 2 3 Unreviewed, fix after r272071 4 https://bugs.webkit.org/show_bug.cgi?id=220914 5 6 Since WebAssembly.Global can be "immutable", we cannot use Wasm::Global::set when setting an initial value. 7 8 * wasm/js/WebAssemblyGlobalConstructor.cpp: 9 (JSC::JSC_DEFINE_HOST_FUNCTION): 10 1 11 2021-01-29 Yusuke Suzuki <ysuzuki@apple.com> 2 12 -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp
r272081 r272119 105 105 uint64_t initialValue = 0; 106 106 JSValue argument = callFrame->argument(1); 107 if (!argument.isUndefined()) {108 switch (type){109 case Wasm::Type::I32:{107 switch (type) { 108 case Wasm::Type::I32: { 109 if (!argument.isUndefined()) { 110 110 int32_t value = argument.toInt32(globalObject); 111 111 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 112 112 initialValue = static_cast<uint64_t>(bitwise_cast<uint32_t>(value)); 113 break; 114 } 115 case Wasm::Type::I64: { 113 } 114 break; 115 } 116 case Wasm::Type::I64: { 117 if (!argument.isUndefined()) { 116 118 int64_t value = argument.toBigInt64(globalObject); 117 119 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 118 120 initialValue = static_cast<uint64_t>(value); 119 break; 120 } 121 case Wasm::Type::F32: { 121 } 122 break; 123 } 124 case Wasm::Type::F32: { 125 if (!argument.isUndefined()) { 122 126 float value = argument.toFloat(globalObject); 123 127 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 124 128 initialValue = static_cast<uint64_t>(bitwise_cast<uint32_t>(value)); 125 break; 126 } 127 case Wasm::Type::F64: { 129 } 130 break; 131 } 132 case Wasm::Type::F64: { 133 if (!argument.isUndefined()) { 128 134 double value = argument.toNumber(globalObject); 129 135 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 130 136 initialValue = bitwise_cast<uint64_t>(value); 131 break; 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 } 139 default: 140 RELEASE_ASSERT_NOT_REACHED(); 141 } 137 } 138 break; 139 } 140 case Wasm::Type::Funcref: { 141 ASSERT(Options::useWebAssemblyReferences()); 142 if (argument.isUndefined()) 143 argument = defaultValueForReferenceType(type); 144 if (!isWebAssemblyHostFunction(vm, argument) && !argument.isNull()) { 145 throwException(globalObject, throwScope, createJSWebAssemblyRuntimeError(globalObject, vm, "Funcref must be an exported wasm function")); 146 return { }; 147 } 148 initialValue = JSValue::encode(argument); 149 break; 150 } 151 case Wasm::Type::Externref: { 152 ASSERT(Options::useWebAssemblyReferences()); 153 if (argument.isUndefined()) 154 argument = defaultValueForReferenceType(type); 155 initialValue = JSValue::encode(argument); 156 break; 157 } 158 default: 159 RELEASE_ASSERT_NOT_REACHED(); 142 160 } 143 161 … … 145 163 JSWebAssemblyGlobal* jsWebAssemblyGlobal = JSWebAssemblyGlobal::tryCreate(globalObject, vm, webAssemblyGlobalStructure, WTFMove(wasmGlobal)); 146 164 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 } 165 ensureStillAliveHere(bitwise_cast<void*>(initialValue)); // Ensure this is kept alive while creating JSWebAssemblyGlobal. 155 166 return JSValue::encode(jsWebAssemblyGlobal); 156 167 }
Note: See TracChangeset
for help on using the changeset viewer.