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:
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"
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
);
26 StackMacroAssembler
masm(cx
, alloc
);
27 AutoCreatedBy
acb(masm
, __func__
);
31 Label check
, fail
, end
;
33 masm
.wasmMarkSlowCall();
37 # ifdef JS_USE_LINK_REGISTER
38 # if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64)
39 static constexpr Register ra
= lr
;
42 static constexpr Register ra
= ABINonArgReg2
;
43 masm
.loadPtr(Address(StackPointer
, 0), ra
);
46 masm
.wasmCheckSlowCallsite(ra
, &fail
, ABINonArgReg1
, ABINonArgReg2
);
50 masm
.printf("Failed\n");
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
);
63 StackMacroAssembler
masm(cx
, alloc
);
64 AutoCreatedBy
acb(masm
, __func__
);
68 Label check
, fast
, end
;
74 # ifdef JS_USE_LINK_REGISTER
75 # if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64)
76 static constexpr Register ra
= lr
;
79 static constexpr Register ra
= ABINonArgReg2
;
80 masm
.loadPtr(Address(StackPointer
, 0), ra
);
83 masm
.wasmCheckSlowCallsite(ra
, &fast
, ABINonArgReg1
, ABINonArgReg2
);
84 masm
.printf("Failed\n");
91 return ExecuteJit(cx
, masm
);
93 END_TEST(testWasmCheckSlowCallMarkerMiss
)
95 #endif // ENABLE_WASM_TAIL_CALLS