node/deps/v8/test/mjsunit/asm/immutable.js
Myles Borins 0a66b223e1
deps: update V8 to 6.0.286.52
PR-URL: https://github.com/nodejs/node/pull/14004
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-08-01 15:23:15 -05:00

49 lines
1.1 KiB
JavaScript

// 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));
})();