Index: test/cctest/test-assembler-mips.cc |
diff --git a/test/cctest/test-assembler-mips.cc b/test/cctest/test-assembler-mips.cc |
index bd080a3b63658a1f942cab650869aacd005c4984..4b4e658afb4763a8d317160fefab042881068129 100644 |
--- a/test/cctest/test-assembler-mips.cc |
+++ b/test/cctest/test-assembler-mips.cc |
@@ -5102,4 +5102,35 @@ TEST(bal) { |
} |
+TEST(Trampoline) { |
+ // Private member of Assembler class. |
+ static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; |
+ |
+ CcTest::InitializeVM(); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ HandleScope scope(isolate); |
+ |
+ MacroAssembler assm(isolate, nullptr, 0); |
+ Label done; |
+ size_t nr_calls = kMaxBranchOffset / (2 * Instruction::kInstrSize) + 2; |
+ |
+ for (size_t i = 0; i < nr_calls; ++i) { |
+ __ BranchShort(&done, eq, a0, Operand(a1)); |
+ } |
+ __ bind(&done); |
+ __ Ret(USE_DELAY_SLOT); |
+ __ mov(v0, zero_reg); |
+ |
+ CodeDesc desc; |
+ assm.GetCode(&desc); |
+ Handle<Code> code = isolate->factory()->NewCode( |
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
+ F2 f = FUNCTION_CAST<F2>(code->entry()); |
+ |
+ int32_t res = |
+ reinterpret_cast<int32_t>(CALL_GENERATED_CODE(f, 42, 42, 0, 0, 0)); |
+ CHECK_EQ(res, 0); |
+} |
+ |
+ |
#undef __ |