/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
deps/v8/test/mjsunit/asm/call-stdlib.js
85 строк
2 KB
Myles Borins
deps: update V8 to 6.0.286.52
01 авг 2017, 23:23
Не верифицирован
01 авг 2017, 23:23
0a66b22
Код
Авторство
О чём код?
// 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 --validate-asm // This file contains test cases that are particularly interesting because they // omit the usual call-site coercion of function calls that target well-known // stdlib functions. (function SuccessStdlibWithoutAnnotation() { function Module(stdlib, imports, heap) { "use asm"; var imul = stdlib.Math.imul; function f(a, b) { a = a | 0; b = b | 0; var r = 0; r = imul(a, b); return r | 0; } return { f:f }; } var m = Module(this); assertTrue(%IsAsmWasmCode(Module)); assertEquals(966, m.f(23, 42)); assertEquals(-0x0fffffff, m.f(0x7ffffff, 0x7ffffff)); })(); (function SuccessStdlibWithoutAnnotationThenRound() { function Module(stdlib, imports, heap) { "use asm"; var fround = stdlib.Math.fround; var imul = stdlib.Math.imul; function f(a, b) { a = a | 0; b = b | 0; var r = fround(0); r = fround(imul(a, b)); return fround(r); } return { f:f }; } var m = Module(this); assertTrue(%IsAsmWasmCode(Module)); assertEquals(966, m.f(23, 42)); assertEquals(-0x0fffffff - 1, m.f(0x7ffffff, 0x7ffffff)); })(); (function FailureStdlibWithoutAnnotationMismatch() { function Module(stdlib, imports, heap) { "use asm"; var fround = stdlib.Math.fround; var imul = stdlib.Math.imul; function f(a, b) { a = a | 0; b = b | 0; var r = fround(0); r = imul(a, b); return r | 0; } return { f:f }; } var m = Module(this); assertFalse(%IsAsmWasmCode(Module)); assertEquals(966, m.f(23, 42)); assertEquals(-0x0fffffff, m.f(0x7ffffff, 0x7ffffff)); })(); (function SuccessStdlibWithoutAnnotationUsedInReturn() { function Module(stdlib, imports, heap) { "use asm"; var imul = stdlib.Math.imul; function f(a, b) { a = a | 0; b = b | 0; return imul(a, b); } return { f:f }; } var m = Module(this); assertTrue(%IsAsmWasmCode(Module)); assertEquals(966, m.f(23, 42)); assertEquals(-0x0fffffff, m.f(0x7ffffff, 0x7ffffff)); })();