Debian Codegraph @

js/src/jsapi-tests/testWasmReturnCalls.cpp

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 #include "jit/MacroAssembler.h"
9
10 #include "jsapi-tests/tests.h"
11 #include "jsapi-tests/testsJit.h"
12
13 #include "jit/MacroAssembler-inl.h"
14
15 using namespace js;
16 using namespace js::jit;
17
18 #ifndef JS_CODEGEN_NONE
19
20 // Check if wasmMarkCallAsSlow produces the byte sequence that can
21 // wasmCheckSlowCallsite detect.
22 BEGIN_TEST(testWasmCheckSlowCallMarkerHit) {
23 js::LifoAlloc lifo(4096, js::MallocArena);
24 TempAllocator alloc(&lifo);
25 JitContext jc(cx);
26 StackMacroAssembler masm(cx, alloc);
27 AutoCreatedBy acb(masm, __func__);
28
29 PrepareJit(masm);
30
31 Label check, fail, end;
32 masm.call(&check);
33 masm.wasmMarkCallAsSlow();
34 masm.jump(&end);
35
36 masm.bind(&check);
37 # ifdef JS_USE_LINK_REGISTER
38 # if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64) && \
39 !defined(JS_CODEGEN_RISCV64)
40 static constexpr Register ra = lr;
41 # endif
42 # else
43 static constexpr Register ra = ABINonArgReg2;
44 masm.loadPtr(Address(StackPointer, 0), ra);
45 # endif
46
47 masm.wasmCheckSlowCallsite(ra, &fail, ABINonArgReg1, ABINonArgReg2);
48 masm.abiret();
49
50 masm.bind(&fail);
51 masm.printf("Failed\n");
52 masm.breakpoint();
53
54 masm.bind(&end);
55 return ExecuteJit(cx, masm);
56 }
57 END_TEST(testWasmCheckSlowCallMarkerHit)
58
59 // Check if wasmCheckSlowCallsite does not detect non-marked slow calls.
60 BEGIN_TEST(testWasmCheckSlowCallMarkerMiss) {
61 js::LifoAlloc lifo(4096, js::MallocArena);
62 TempAllocator alloc(&lifo);
63 JitContext jc(cx);
64 StackMacroAssembler masm(cx, alloc);
65 AutoCreatedBy acb(masm, __func__);
66
67 PrepareJit(masm);
68
69 Label check, fast, end;
70 masm.call(&check);
71 masm.nop();
72 masm.jump(&end);
73
74 masm.bind(&check);
75 # ifdef JS_USE_LINK_REGISTER
76 # if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64) && \
77 !defined(JS_CODEGEN_RISCV64)
78 static constexpr Register ra = lr;
79 # endif
80 # else
81 static constexpr Register ra = ABINonArgReg2;
82 masm.loadPtr(Address(StackPointer, 0), ra);
83 # endif
84
85 masm.wasmCheckSlowCallsite(ra, &fast, ABINonArgReg1, ABINonArgReg2);
86 masm.printf("Failed\n");
87 masm.breakpoint();
88
89 masm.bind(&fast);
90 masm.abiret();
91
92 masm.bind(&end);
93 return ExecuteJit(cx, masm);
94 }
95 END_TEST(testWasmCheckSlowCallMarkerMiss)
96
97 #endif