summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/asm/immutable.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/asm/immutable.js')
-rw-r--r--deps/v8/test/mjsunit/asm/immutable.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/asm/immutable.js b/deps/v8/test/mjsunit/asm/immutable.js
new file mode 100644
index 0000000000..29c15cc7d9
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/immutable.js
@@ -0,0 +1,48 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax
+
+(function FailImmutableFunction() {
+ function Module(stdlib, imports, heap) {
+ "use asm";
+ function f(a) {
+ a = a | 0;
+ if (a) {
+ a = f((a - 1) | 0) | 0;
+ f = 0;
+ return (a + 1) | 0;
+ }
+ return 23;
+ }
+ return { f:f };
+ }
+ var m = Module(this);
+ assertFalse(%IsAsmWasmCode(Module));
+ assertEquals(23, m.f(0));
+ assertEquals(24, m.f(1));
+ assertThrows(() => m.f(2));
+})();
+
+(function FailImmutableFunctionTable() {
+ function Module(stdlib, imports, heap) {
+ "use asm";
+ function f(a) {
+ a = a | 0;
+ if (a) {
+ a = funTable[a & 0]((a - 1) | 0) | 0;
+ funTable = 0;
+ return (a + 1) | 0;
+ }
+ return 23;
+ }
+ var funTable = [ f ];
+ return { f:f };
+ }
+ var m = Module(this);
+ assertFalse(%IsAsmWasmCode(Module));
+ assertEquals(23, m.f(0));
+ assertEquals(24, m.f(1));
+ assertThrows(() => m.f(2));
+})();