Commit 75128636 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[wasm] Remove obsolete %IsNotAsmWasmCode predicate.

By now the predicate in question is an exact negation of %IsAsmWasmCode
as the name intuitively implies. The need for two separate test methods
no longer exists and one of the two can be removed.

R=bradnelson@chromium.org

Review-Url: https://codereview.chromium.org/2562003002
Cr-Commit-Position: refs/heads/master@{#41616}
parent e127ec00
......@@ -677,36 +677,22 @@ RUNTIME_FUNCTION(Runtime_InNewSpace) {
return isolate->heap()->ToBoolean(isolate->heap()->InNewSpace(obj));
}
namespace {
bool IsAsmWasmCode(Isolate* isolate, Handle<JSFunction> function) {
RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
if (!function->shared()->HasAsmWasmData()) {
// Doesn't have wasm data.
return false;
return isolate->heap()->false_value();
}
if (function->shared()->code() !=
isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) {
// Hasn't been compiled yet.
return false;
return isolate->heap()->false_value();
}
return true;
}
} // namespace
RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
return isolate->heap()->ToBoolean(IsAsmWasmCode(isolate, function));
return isolate->heap()->true_value();
}
RUNTIME_FUNCTION(Runtime_IsNotAsmWasmCode) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
return isolate->heap()->ToBoolean(!IsAsmWasmCode(isolate, function));
}
#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
RUNTIME_FUNCTION(Runtime_Has##Name) { \
......
......@@ -905,7 +905,6 @@ namespace internal {
F(SerializeWasmModule, 1, 1) \
F(DeserializeWasmModule, 2, 1) \
F(IsAsmWasmCode, 1, 1) \
F(IsNotAsmWasmCode, 1, 1) \
F(ValidateWasmInstancesChain, 2, 1) \
F(ValidateWasmModuleState, 1, 1) \
F(ValidateWasmOrphanedInstance, 1, 1)
......
......@@ -81,7 +81,7 @@ function assertValidAsm(func) {
assertEquals(Math.fround(-3.0), m.fVar());
var m = DisallowAssignToConstGlobal();
assertTrue(%IsNotAsmWasmCode(DisallowAssignToConstGlobal));
assertFalse(%IsAsmWasmCode(DisallowAssignToConstGlobal));
})();
(function TestModuleArgs() {
......@@ -125,7 +125,7 @@ function assertValidAsm(func) {
return { foo: foo };
}
var m = Module({});
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals(123, m.foo());
})();
......@@ -136,7 +136,7 @@ function assertValidAsm(func) {
return {};
}
var m = Module(1, 2, 3);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals({}, m);
})();
......@@ -147,7 +147,7 @@ function assertValidAsm(func) {
return {};
}
var m = Module(1, 2);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals({}, m);
})();
......@@ -170,7 +170,7 @@ function assertValidAsm(func) {
}
var heap = new ArrayBuffer(1024 * 1024);
var m = Module({}, {}, heap);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals(123, m.foo());
})();
......@@ -204,9 +204,9 @@ function assertValidAsm(func) {
return { foo: foo };
}
var m1 = Module(1, 2, 3);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
var m2 = Module(1, 2, 3);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals(123, m1.foo());
assertEquals(123, m2.foo());
})();
......@@ -225,9 +225,9 @@ function assertValidAsm(func) {
var Module2 = MkModule();
var heap = new ArrayBuffer(1024 * 1024);
var m1 = Module1(1, 2, 3);
assertTrue(%IsNotAsmWasmCode(Module1));
assertFalse(%IsAsmWasmCode(Module1));
var m2 = Module2({}, {}, heap);
assertTrue(%IsNotAsmWasmCode(Module2));
assertFalse(%IsAsmWasmCode(Module2));
assertEquals(123, m1.foo());
assertEquals(123, m2.foo());
})();
......@@ -248,7 +248,7 @@ function assertValidAsm(func) {
var m1 = Module1({NaN: NaN}, {}, heap);
assertValidAsm(Module1);
var m2 = Module2(1, 2, 3);
assertTrue(%IsNotAsmWasmCode(Module2));
assertFalse(%IsAsmWasmCode(Module2));
assertEquals(123, m1.foo());
assertEquals(123, m2.foo());
})();
......@@ -269,9 +269,9 @@ function assertValidAsm(func) {
var m1a = Module1({NaN: NaN}, {}, heap);
assertValidAsm(Module1);
var m2 = Module2(1, 2, 3);
assertTrue(%IsNotAsmWasmCode(Module2));
assertFalse(%IsAsmWasmCode(Module2));
var m1b = Module1({NaN: NaN}, {}, heap);
assertTrue(%IsNotAsmWasmCode(Module1));
assertFalse(%IsAsmWasmCode(Module1));
assertEquals(123, m1a.foo());
assertEquals(123, m1b.foo());
assertEquals(123, m2.foo());
......@@ -298,7 +298,7 @@ function assertValidAsm(func) {
return { foo: foo };
}
var m = Module();
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals(0xffffffff, m.foo());
})();
......@@ -312,7 +312,7 @@ function assertValidAsm(func) {
return { foo: foo };
}
var m = Module();
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals(3, m.foo(3));
})();
......@@ -332,6 +332,6 @@ function assertValidAsm(func) {
return { foo: foo };
}
var m = Module();
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
assertEquals(43, m.foo(3));
})();
......@@ -10,4 +10,4 @@ function Module(stdlib, env) {
return { foo: function(y) { return eval(1); } };
}
Module(this, {bar:0});
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
......@@ -8,4 +8,4 @@ function f() {
"use asm";
}
assertTrue(%IsNotAsmWasmCode(f));
assertFalse(%IsAsmWasmCode(f));
......@@ -13,4 +13,4 @@ function __f_97(stdlib, buffer) {
}
}
var module = __f_97(this);
assertTrue(%IsNotAsmWasmCode(__f_97));
assertFalse(%IsAsmWasmCode(__f_97));
......@@ -15,5 +15,5 @@
return {__f_21:__f_21};
}
__f_41();
assertTrue(%IsNotAsmWasmCode(__f_41));
assertFalse(%IsAsmWasmCode(__f_41));
})();
......@@ -11,4 +11,4 @@ function __f_14() {
return {};
}
__f_14();
assertTrue(%IsNotAsmWasmCode(__f_14));
assertFalse(%IsAsmWasmCode(__f_14));
......@@ -14,4 +14,4 @@ function __f_71(stdlib, buffer) {
}
__f_71(this);
assertTrue(%IsNotAsmWasmCode(__f_71));
assertFalse(%IsAsmWasmCode(__f_71));
......@@ -14,11 +14,11 @@
var Wasm = {
instantiateModuleFromAsm: function(text, stdlib, ffi, heap) {
var module_decl = eval('(' + text + ')');
if (%IsNotAsmWasmCode(module_decl)) {
if (!%IsAsmWasmCode(module_decl)) {
throw "validate failure";
}
var ret = module_decl(stdlib, ffi, heap);
if (%IsNotAsmWasmCode(module_decl)) {
if (!%IsAsmWasmCode(module_decl)) {
throw "bad module args";
}
return ret;
......
......@@ -15,4 +15,4 @@ function __f_100() {
}
return {__f_76: __f_76};
}
assertTrue(%IsNotAsmWasmCode(__f_100));
assertFalse(%IsAsmWasmCode(__f_100));
......@@ -12,4 +12,4 @@ function __f_1() {
}
return { __f_3: __f_3 };
}
assertTrue(%IsNotAsmWasmCode(__f_1));
assertFalse(%IsAsmWasmCode(__f_1));
......@@ -102,7 +102,7 @@ var stdlib_math_members = [
var code = Module.toString().replace('NaN', member);
var decl = eval('(' + code + ')');
decl(stdlib);
assertTrue(%IsNotAsmWasmCode(decl));
assertFalse(%IsAsmWasmCode(decl));
}
for (var i = 0; i < stdlib_math_members.length; ++i) {
var member = stdlib_math_members[i];
......@@ -112,7 +112,7 @@ var stdlib_math_members = [
var code = Module.toString().replace('NaN', 'Math.' + member);
var decl = eval('(' + code + ')');
decl(stdlib);
assertTrue(%IsNotAsmWasmCode(decl));
assertFalse(%IsAsmWasmCode(decl));
}
})();
......@@ -128,7 +128,7 @@ var stdlib_math_members = [
var code = Module.toString().replace('NaN', member);
var decl = eval('(' + code + ')');
decl({});
assertTrue(%IsNotAsmWasmCode(decl));
assertFalse(%IsAsmWasmCode(decl));
}
for (var i = 0; i < stdlib_math_members.length; ++i) {
var member = stdlib_math_members[i];
......@@ -136,7 +136,7 @@ var stdlib_math_members = [
var decl = eval('(' + code + ')');
assertThrows(function() {
decl({});
assertTrue(%IsNotAsmWasmCode(decl));
assertFalse(%IsAsmWasmCode(decl));
});
}
})();
......
......@@ -111,7 +111,7 @@ function BadModule() {
return {caller: caller};
}
assertTrue(%IsNotAsmWasmCode(BadModule));
assertFalse(%IsAsmWasmCode(BadModule));
function TestReturnInBlock() {
......@@ -1390,7 +1390,7 @@ assertWasm(7, TestIntegerMultiplyBothWays);
}
print("TestBadAssignDoubleFromIntish...");
Module(stdlib);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
})();
......@@ -1406,7 +1406,7 @@ assertWasm(7, TestIntegerMultiplyBothWays);
}
print("TestBadAssignIntFromDouble...");
Module(stdlib);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
})();
......@@ -1421,7 +1421,7 @@ assertWasm(7, TestIntegerMultiplyBothWays);
}
print("TestBadMultiplyIntish...");
Module(stdlib);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
})();
......@@ -1436,7 +1436,7 @@ assertWasm(7, TestIntegerMultiplyBothWays);
}
print("TestBadCastFromInt...");
Module(stdlib);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
})();
......@@ -1480,7 +1480,7 @@ assertWasm(-34359738370.75, TestNegativeDouble);
}
Module(stdlib);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
})();
......@@ -1493,7 +1493,7 @@ assertWasm(-34359738370.75, TestNegativeDouble);
}
Module(stdlib);
assertTrue(%IsNotAsmWasmCode(Module));
assertFalse(%IsAsmWasmCode(Module));
})();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment