Modified: trunk/JSTests/ChangeLog (209295 => 209296)
--- trunk/JSTests/ChangeLog 2016-12-03 06:40:37 UTC (rev 209295)
+++ trunk/JSTests/ChangeLog 2016-12-03 07:28:25 UTC (rev 209296)
@@ -1,3 +1,17 @@
+2016-12-02 Keith Miller <[email protected]>
+
+ Unreviewed, fix git having a breakdown over trying to reland a rollout.
+
+2016-12-02 Keith Miller <[email protected]>
+
+ 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 <[email protected]>
[JSC] add additional bit to JSTokenType bitfield
@@ -29,16 +43,6 @@
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 <[email protected]>
-
- 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.
Modified: trunk/Source/_javascript_Core/ChangeLog (209295 => 209296)
--- trunk/Source/_javascript_Core/ChangeLog 2016-12-03 06:40:37 UTC (rev 209295)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-12-03 07:28:25 UTC (rev 209296)
@@ -1,3 +1,37 @@
+2016-12-02 Keith Miller <[email protected]>
+
+ Unreviewed, fix git having a breakdown over trying to reland a rollout.
+
+2016-12-02 Keith Miller <[email protected]>
+
+ 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 <[email protected]>
[JSC] add additional bit to JSTokenType bitfield
@@ -50,36 +84,6 @@
2016-12-02 Keith Miller <[email protected]>
- 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 <[email protected]>
-
Unreviewed, forgot to change instruction after renaming.
* assembler/MacroAssemblerARM64.h:
Modified: trunk/Source/_javascript_Core/jsc.cpp (209295 => 209296)
--- trunk/Source/_javascript_Core/jsc.cpp 2016-12-03 06:40:37 UTC (rev 209295)
+++ trunk/Source/_javascript_Core/jsc.cpp 2016-12-03 07:28:25 UTC (rev 209296)
@@ -2510,33 +2510,60 @@
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)
Modified: trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h (209295 => 209296)
--- trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h 2016-12-03 06:40:37 UTC (rev 209295)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h 2016-12-03 07:28:25 UTC (rev 209296)
@@ -213,6 +213,10 @@
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