Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / js / src / jsapi-tests / testWasmReturnCalls.cpp
blobd06ffe45f6cf12b6fbd8f8c424730928252818e7
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/. */
8 #include "jit/MacroAssembler.h"
10 #include "jsapi-tests/tests.h"
11 #include "jsapi-tests/testsJit.h"
13 #include "jit/MacroAssembler-inl.h"
15 using namespace js;
16 using namespace js::jit;
18 #if defined(ENABLE_WASM_TAIL_CALLS) && !defined(JS_CODEGEN_NONE)
20 // Check if wasmMarkSlowCall produces the byte sequence that can
21 // wasmCheckSlowCallsite detect.
22 BEGIN_TEST(testWasmCheckSlowCallMarkerHit) {
23 js::LifoAlloc lifo(4096);
24 TempAllocator alloc(&lifo);
25 JitContext jc(cx);
26 StackMacroAssembler masm(cx, alloc);
27 AutoCreatedBy acb(masm, __func__);
29 PrepareJit(masm);
31 Label check, fail, end;
32 masm.call(&check);
33 masm.wasmMarkSlowCall();
34 masm.jump(&end);
36 masm.bind(&check);
37 # ifdef JS_USE_LINK_REGISTER
38 # if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64)
39 static constexpr Register ra = lr;
40 # endif
41 # else
42 static constexpr Register ra = ABINonArgReg2;
43 masm.loadPtr(Address(StackPointer, 0), ra);
44 # endif
46 masm.wasmCheckSlowCallsite(ra, &fail, ABINonArgReg1, ABINonArgReg2);
47 masm.abiret();
49 masm.bind(&fail);
50 masm.printf("Failed\n");
51 masm.breakpoint();
53 masm.bind(&end);
54 return ExecuteJit(cx, masm);
56 END_TEST(testWasmCheckSlowCallMarkerHit)
58 // Check if wasmCheckSlowCallsite does not detect non-marked slow calls.
59 BEGIN_TEST(testWasmCheckSlowCallMarkerMiss) {
60 js::LifoAlloc lifo(4096);
61 TempAllocator alloc(&lifo);
62 JitContext jc(cx);
63 StackMacroAssembler masm(cx, alloc);
64 AutoCreatedBy acb(masm, __func__);
66 PrepareJit(masm);
68 Label check, fast, end;
69 masm.call(&check);
70 masm.nop();
71 masm.jump(&end);
73 masm.bind(&check);
74 # ifdef JS_USE_LINK_REGISTER
75 # if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64)
76 static constexpr Register ra = lr;
77 # endif
78 # else
79 static constexpr Register ra = ABINonArgReg2;
80 masm.loadPtr(Address(StackPointer, 0), ra);
81 # endif
83 masm.wasmCheckSlowCallsite(ra, &fast, ABINonArgReg1, ABINonArgReg2);
84 masm.printf("Failed\n");
85 masm.breakpoint();
87 masm.bind(&fast);
88 masm.abiret();
90 masm.bind(&end);
91 return ExecuteJit(cx, masm);
93 END_TEST(testWasmCheckSlowCallMarkerMiss)
95 #endif // ENABLE_WASM_TAIL_CALLS