Unreviewed, fix git having a breakdown over trying to reland a rollout.
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 Dec 2016 07:28:25 +0000 (07:28 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 Dec 2016 07:28:25 +0000 (07:28 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209296 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JSTests/ChangeLog
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/wasm/WasmFunctionParser.h

index 35776d8..ac2e9fa 100644 (file)
@@ -1,3 +1,17 @@
+2016-12-02  Keith Miller  <keith_miller@apple.com>
+
+        Unreviewed, fix git having a breakdown over trying to reland a rollout.
+
+2016-12-02  Keith Miller  <keith_miller@apple.com>
+
+        Add Wasm floating point nearest and trunc
+        https://bugs.webkit.org/show_bug.cgi?id=165339
+
+        Reviewed by Saam Barati.
+
+        * wasm/function-tests/nearest.js: Added.
+        * wasm/function-tests/trunc.js: Added.
+
 2016-12-02  Caitlin Potter  <caitp@igalia.com>
 
 [JSC] add additional bit to JSTokenType bitfield
         Add Wasm floating point nearest and trunc
         https://bugs.webkit.org/show_bug.cgi?id=165339
 
-        Reviewed by Saam Barati.
-
-        * wasm/function-tests/nearest.js: Added.
-        * wasm/function-tests/trunc.js: Added.
-
-2016-12-02  Keith Miller  <keith_miller@apple.com>
-
-        Add Wasm floating point nearest and trunc
-        https://bugs.webkit.org/show_bug.cgi?id=165339
-
         Reviewed by Filip Pizlo.
 
         * wasm/function-tests/nearest.js: Added.
index 99ba677..a6e6b06 100644 (file)
@@ -1,3 +1,37 @@
+2016-12-02  Keith Miller  <keith_miller@apple.com>
+
+        Unreviewed, fix git having a breakdown over trying to reland a rollout.
+
+2016-12-02  Keith Miller  <keith_miller@apple.com>
+
+        Add Wasm floating point nearest and trunc
+        https://bugs.webkit.org/show_bug.cgi?id=165339
+
+        Reviewed by Saam Barati.
+
+        This patch also allows any wasm primitive type to be passed as a
+        string.
+
+        * assembler/MacroAssemblerARM64.h:
+        (JSC::MacroAssemblerARM64::nearestIntDouble):
+        (JSC::MacroAssemblerARM64::nearestIntFloat):
+        (JSC::MacroAssemblerARM64::truncDouble):
+        (JSC::MacroAssemblerARM64::truncFloat):
+        * assembler/MacroAssemblerX86Common.h:
+        (JSC::MacroAssemblerX86Common::nearestIntDouble):
+        (JSC::MacroAssemblerX86Common::nearestIntFloat):
+        * jsc.cpp:
+        (box):
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::addOp<F64ConvertUI64>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32ConvertUI64>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F64Nearest>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32Nearest>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F64Trunc>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32Trunc>):
+        * wasm/WasmFunctionParser.h:
+        (JSC::Wasm::FunctionParser<Context>::parseExpression):
+
 2016-12-02  Caitlin Potter  <caitp@igalia.com>
 
 [JSC] add additional bit to JSTokenType bitfield
 
 2016-12-02  Keith Miller  <keith_miller@apple.com>
 
-        Add Wasm floating point nearest and trunc
-        https://bugs.webkit.org/show_bug.cgi?id=165339
-
-        Reviewed by Saam Barati.
-
-        This patch also allows any wasm primitive type to be passed as a
-        string.
-
-        * assembler/MacroAssemblerARM64.h:
-        (JSC::MacroAssemblerARM64::nearestIntDouble):
-        (JSC::MacroAssemblerARM64::nearestIntFloat):
-        (JSC::MacroAssemblerARM64::truncDouble):
-        (JSC::MacroAssemblerARM64::truncFloat):
-        * assembler/MacroAssemblerX86Common.h:
-        (JSC::MacroAssemblerX86Common::nearestIntDouble):
-        (JSC::MacroAssemblerX86Common::nearestIntFloat):
-        * jsc.cpp:
-        (box):
-        * wasm/WasmB3IRGenerator.cpp:
-        (JSC::Wasm::B3IRGenerator::addOp<F64ConvertUI64>):
-        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32ConvertUI64>):
-        (JSC::Wasm::B3IRGenerator::addOp<OpType::F64Nearest>):
-        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32Nearest>):
-        (JSC::Wasm::B3IRGenerator::addOp<OpType::F64Trunc>):
-        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32Trunc>):
-        * wasm/WasmFunctionParser.h:
-        (JSC::Wasm::FunctionParser<Context>::parseExpression):
-
-2016-12-02  Keith Miller  <keith_miller@apple.com>
-
         Unreviewed, forgot to change instruction after renaming.
 
         * assembler/MacroAssemblerARM64.h:
index 6db5c11..88d6358 100644 (file)
@@ -2510,33 +2510,60 @@ static CString valueWithTypeOfWasmValue(ExecState* exec, VM& vm, JSValue value,
 
 static JSValue box(ExecState* exec, VM& vm, JSValue wasmValue)
 {
+
     JSString* type = jsCast<JSString*>(wasmValue.get(exec, makeIdentifier(vm, "type")));
     JSValue value = wasmValue.get(exec, makeIdentifier(vm, "value"));
 
-    const String& typeString = type->value(exec);
-    if (typeString == "i64") {
-        int64_t result;
+    auto unboxString = [&] (const char* hexFormat, const char* decFormat, auto& result) {
+        if (!value.isString())
+            return false;
+
         const char* str = toCString(jsCast<JSString*>(value)->value(exec)).data();
         int scanResult;
-        if (std::strlen(str) > 2 && str[0] == '0' && str[1] == 'x')
-            scanResult = sscanf(str, "%llx", &result);
+        int length = std::strlen(str);
+        if ((length > 2 && (str[0] == '0' && str[1] == 'x'))
+            || (length > 3 && (str[0] == '-' && str[1] == '0' && str[2] == 'x')))
+#if COMPILER(CLANG)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
+            scanResult = sscanf(str, hexFormat, &result);
         else
-            scanResult = sscanf(str, "%lld", &result);
+            scanResult = sscanf(str, decFormat, &result);
+#if COMPILER(CLANG)
+#pragma clang diagnostic pop
+#endif
         RELEASE_ASSERT(scanResult != EOF);
+        return true;
+    };
+
+    const String& typeString = type->value(exec);
+    if (typeString == "i64") {
+        int64_t result;
+        if (!unboxString("%llx", "%lld", result))
+            CRASH();
         return JSValue::decode(result);
     }
-    RELEASE_ASSERT(value.isNumber());
 
     if (typeString == "i32") {
-        RELEASE_ASSERT(value.isInt32());
-        return JSValue::decode(static_cast<uint32_t>(value.asInt32()));
+        int32_t result;
+        if (!unboxString("%x", "%d", result))
+            result = value.asInt32();
+        return JSValue::decode(static_cast<uint32_t>(result));
     }
 
-    if (typeString == "f32")
-        return JSValue::decode(bitwise_cast<uint32_t>(value.toFloat(exec)));
+    if (typeString == "f32") {
+        float result;
+        if (!unboxString("%a", "%f", result))
+            result = value.toFloat(exec);
+        return JSValue::decode(bitwise_cast<uint32_t>(result));
+    }
 
     RELEASE_ASSERT(typeString == "f64");
-    return JSValue::decode(bitwise_cast<uint64_t>(value.asNumber()));
+    double result;
+    if (!unboxString("%la", "%lf", result))
+        result = value.asNumber();
+    return JSValue::decode(bitwise_cast<uint64_t>(result));
 }
 
 static JSValue callWasmFunction(VM* vm, const B3::Compilation& code, Vector<JSValue>& boxedArgs)
index 58c9749..875b2fd 100644 (file)
@@ -213,6 +213,10 @@ bool FunctionParser<Context>::parseExpression(OpType op)
 
     case OpType::F32ConvertUI64: return unaryCase<OpType::F32ConvertUI64>();
     case OpType::F64ConvertUI64: return unaryCase<OpType::F64ConvertUI64>();
+    case OpType::F32Nearest: return unaryCase<OpType::F32Nearest>();
+    case OpType::F64Nearest: return unaryCase<OpType::F64Nearest>();
+    case OpType::F32Trunc: return unaryCase<OpType::F32Trunc>();
+    case OpType::F64Trunc: return unaryCase<OpType::F64Trunc>();
 #define CREATE_CASE(name, id, b3op) case OpType::name: return unaryCase<OpType::name>();
     FOR_EACH_WASM_SIMPLE_UNARY_OP(CREATE_CASE)
 #undef CREATE_CASE