Title: [210403] branches/safari-603-branch/Source/_javascript_Core

Diff

Modified: branches/safari-603-branch/Source/_javascript_Core/ChangeLog (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/ChangeLog	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/ChangeLog	2017-01-06 01:47:32 UTC (rev 210403)
@@ -1,5 +1,45 @@
 2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r210038. rdar://problem/29759741
+
+    2016-12-20  JF Bastien  <jfbast...@apple.com>
+
+            WebAssembly: construct 32-bit encodedJSValue properly
+            https://bugs.webkit.org/show_bug.cgi?id=166199
+
+            Reviewed by Mark Lam.
+
+            Constructing an encodedJSValue using `{ }` yields the wrong value
+            on 32-bit platforms. WebAssembly doesn't currently target 32-bit
+            platforms, but we may as well get it right.
+
+            * wasm/JSWebAssembly.cpp:
+            (JSC::webAssemblyCompileFunc):
+            (JSC::webAssemblyValidateFunc):
+            * wasm/js/JSWebAssemblyHelpers.h:
+            (JSC::toNonWrappingUint32):
+            * wasm/js/WebAssemblyCompileErrorConstructor.cpp:
+            (JSC::constructJSWebAssemblyCompileError):
+            * wasm/js/WebAssemblyFunction.cpp:
+            (JSC::callWebAssemblyFunction):
+            * wasm/js/WebAssemblyInstanceConstructor.cpp:
+            (JSC::constructJSWebAssemblyInstance):
+            * wasm/js/WebAssemblyMemoryConstructor.cpp:
+            (JSC::constructJSWebAssemblyMemory):
+            * wasm/js/WebAssemblyModuleConstructor.cpp:
+            (JSC::constructJSWebAssemblyModule):
+            * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
+            (JSC::constructJSWebAssemblyRuntimeError):
+            * wasm/js/WebAssemblyTableConstructor.cpp:
+            (JSC::constructJSWebAssemblyTable):
+            * wasm/js/WebAssemblyTablePrototype.cpp:
+            (JSC::webAssemblyTableProtoFuncLength):
+            (JSC::webAssemblyTableProtoFuncGrow):
+            (JSC::webAssemblyTableProtoFuncGet):
+            (JSC::webAssemblyTableProtoFuncSet):
+
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r210026. rdar://problem/29735737
 
     2016-12-20  JF Bastien  <jfbast...@apple.com>

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/JSWebAssembly.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/JSWebAssembly.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/JSWebAssembly.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -49,7 +49,7 @@
     auto catchScope = DECLARE_CATCH_SCOPE(vm);
 
     JSPromiseDeferred* promise = JSPromiseDeferred::create(exec, exec->lexicalGlobalObject());
-    RETURN_IF_EXCEPTION(catchScope, { });
+    RETURN_IF_EXCEPTION(catchScope, encodedJSValue());
 
     // FIXME: Make this truly asynchronous:
     // https://bugs.webkit.org/show_bug.cgi?id=166016
@@ -72,7 +72,7 @@
     size_t byteOffset;
     size_t byteSize;
     uint8_t* base = getWasmBufferFromValue(exec, exec->argument(0), byteOffset, byteSize);
-    RETURN_IF_EXCEPTION(scope, { });
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     Wasm::Plan plan(&vm, base + byteOffset, byteSize);
     // FIXME: We might want to throw an OOM exception here if we detect that something will OOM.
     // https://bugs.webkit.org/show_bug.cgi?id=166015

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyCompileErrorConstructor.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyCompileErrorConstructor.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyCompileErrorConstructor.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -50,7 +50,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSValue message = state->argument(0);
     auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->jsCallee())->globalObject()->WebAssemblyCompileErrorStructure());
-    RETURN_IF_EXCEPTION(scope, { });
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     return JSValue::encode(JSWebAssemblyCompileError::create(state, structure, message, false));
 }
 

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -79,7 +79,7 @@
         case Wasm::Anyfunc:
             RELEASE_ASSERT_NOT_REACHED();
         }
-        RETURN_IF_EXCEPTION(scope, { });
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
         boxedArgs.append(arg);
     }
 

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -77,13 +77,13 @@
 
     Identifier moduleKey = Identifier::fromUid(PrivateName(PrivateName::Description, "WebAssemblyInstance"));
     WebAssemblyModuleRecord* moduleRecord = WebAssemblyModuleRecord::create(exec, vm, globalObject->webAssemblyModuleRecordStructure(), moduleKey, moduleInformation);
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     Structure* instanceStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->WebAssemblyInstanceStructure());
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, instanceStructure, jsModule, moduleRecord->getModuleNamespace(exec));
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     // Let funcs, memories and tables be initially-empty lists of callable _javascript_ objects, WebAssembly.Memory objects and WebAssembly.Table objects, respectively.
     // Let imports be an initially-empty list of external values.
@@ -96,7 +96,7 @@
     for (auto& import : moduleInformation.imports) {
         // 1. Let o be the resultant value of performing Get(importObject, i.module_name).
         JSValue importModuleValue = importObject->get(exec, import.module);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         // 2. If Type(o) is not Object, throw a TypeError.
         if (!importModuleValue.isObject())
             return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("import must be an object"), defaultSourceAppender, runtimeTypeForValue(importModuleValue))));
@@ -104,7 +104,7 @@
         // 3. Let v be the value of performing Get(o, i.item_name)
         JSObject* object = jsCast<JSObject*>(importModuleValue);
         JSValue value = object->get(exec, import.field);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
         switch (import.kind) {
         case Wasm::ExternalKind::Function: {
@@ -271,13 +271,13 @@
     }
 
     moduleRecord->link(exec, instance);
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     if (verbose)
         moduleRecord->dump();
     JSValue startResult = moduleRecord->evaluate(exec);
     UNUSED_PARAM(startResult);
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     return JSValue::encode(instance);
 }

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -67,9 +67,9 @@
     {
         Identifier initial = Identifier::fromString(&vm, "initial");
         JSValue minSizeValue = memoryDescriptor->get(exec, initial);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         uint32_t size = toNonWrappingUint32(exec, minSizeValue);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         if (!Wasm::PageCount::isValid(size))
             return JSValue::encode(throwException(exec, throwScope, createRangeError(exec, ASCIILiteral("WebAssembly.Memory 'initial' page count is too large"))));
         initialPageCount = Wasm::PageCount(size);
@@ -79,12 +79,12 @@
     {
         Identifier maximum = Identifier::fromString(&vm, "maximum");
         bool hasProperty = memoryDescriptor->hasProperty(exec, maximum);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         if (hasProperty) {
             JSValue maxSizeValue = memoryDescriptor->get(exec, maximum);
-            RETURN_IF_EXCEPTION(throwScope, { });
+            RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
             uint32_t size = toNonWrappingUint32(exec, maxSizeValue);
-            RETURN_IF_EXCEPTION(throwScope, { });
+            RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
             if (!Wasm::PageCount::isValid(size))
                 return JSValue::encode(throwException(exec, throwScope, createRangeError(exec, ASCIILiteral("WebAssembly.Memory 'maximum' page count is too large"))));
             maximumPageCount = Wasm::PageCount(size);

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyModuleConstructor.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyModuleConstructor.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyModuleConstructor.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -58,7 +58,7 @@
     VM& vm = exec->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
     auto* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), exec->lexicalGlobalObject()->WebAssemblyModuleStructure());
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     throwScope.release();
     return JSValue::encode(WebAssemblyModuleConstructor::createModule(exec, structure));
 }

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -50,7 +50,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     JSValue message = state->argument(0);
     auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->jsCallee())->globalObject()->WebAssemblyRuntimeErrorStructure());
-    RETURN_IF_EXCEPTION(scope, { });
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     return JSValue::encode(JSWebAssemblyRuntimeError::create(state, structure, message, false));
 }
 

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -61,9 +61,9 @@
     {
         Identifier elementIdent = Identifier::fromString(&vm, "element");
         JSValue elementValue = memoryDescriptor->get(exec, elementIdent);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         String elementString = elementValue.toWTFString(exec);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         if (elementString != "anyfunc")
             return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, ASCIILiteral("WebAssembly.Table expects its 'element' field to be the string 'anyfunc'"))));
     }
@@ -70,19 +70,19 @@
 
     Identifier initialIdent = Identifier::fromString(&vm, "initial");
     JSValue initialSizeValue = memoryDescriptor->get(exec, initialIdent);
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     uint32_t initial = toNonWrappingUint32(exec, initialSizeValue);
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     std::optional<uint32_t> maximum;
     Identifier maximumIdent = Identifier::fromString(&vm, "maximum");
     bool hasProperty = memoryDescriptor->hasProperty(exec, maximumIdent);
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     if (hasProperty) {
         JSValue maxSizeValue = memoryDescriptor->get(exec, maximumIdent);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         maximum = toNonWrappingUint32(exec, maxSizeValue);
-        RETURN_IF_EXCEPTION(throwScope, { });
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
         if (initial > *maximum) {
             return JSValue::encode(throwException(exec, throwScope,

Modified: branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyTablePrototype.cpp (210402 => 210403)


--- branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyTablePrototype.cpp	2017-01-06 01:47:27 UTC (rev 210402)
+++ branches/safari-603-branch/Source/_javascript_Core/wasm/js/WebAssemblyTablePrototype.cpp	2017-01-06 01:47:32 UTC (rev 210403)
@@ -67,7 +67,7 @@
     auto throwScope = DECLARE_THROW_SCOPE(vm);
 
     JSWebAssemblyTable* table = getTable(exec, vm, exec->thisValue());
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     return JSValue::encode(jsNumber(table->size()));
 }
 
@@ -77,10 +77,10 @@
     auto throwScope = DECLARE_THROW_SCOPE(vm);
 
     JSWebAssemblyTable* table = getTable(exec, vm, exec->thisValue());
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     uint32_t index = toNonWrappingUint32(exec, exec->argument(0));
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     if (!table->grow(index)) {
         throwException(exec, throwScope,
             createTypeError(exec, ASCIILiteral("WebAssembly.Table.prototype.grow could not grow the table")));
@@ -96,10 +96,10 @@
     auto throwScope = DECLARE_THROW_SCOPE(vm);
 
     JSWebAssemblyTable* table = getTable(exec, vm, exec->thisValue());
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     uint32_t index = toNonWrappingUint32(exec, exec->argument(0));
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     if (index >= table->size()) {
         throwException(exec, throwScope,
             createRangeError(exec, ASCIILiteral("WebAssembly.Table.prototype.get expects an integer less than the size of the table")));
@@ -117,7 +117,7 @@
     auto throwScope = DECLARE_THROW_SCOPE(vm);
 
     JSWebAssemblyTable* table = getTable(exec, vm, exec->thisValue());
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     JSValue value = exec->argument(1);
     WebAssemblyFunction* function = jsDynamicCast<WebAssemblyFunction*>(value);
@@ -128,7 +128,7 @@
     }
 
     uint32_t index = toNonWrappingUint32(exec, exec->argument(0));
-    RETURN_IF_EXCEPTION(throwScope, { });
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
     if (index >= table->size()) {
         throwException(exec, throwScope,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to