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