Index: test/cctest/compiler/test-run-wasm-machops.cc |
diff --git a/test/cctest/compiler/test-run-wasm-machops.cc b/test/cctest/compiler/test-run-wasm-machops.cc |
index c3f42388d4cc23fe0978cf376b5e9a36e8fad4c2..9359b2577949b21d37b1627be4ee8e4f181e65aa 100644 |
--- a/test/cctest/compiler/test-run-wasm-machops.cc |
+++ b/test/cctest/compiler/test-run-wasm-machops.cc |
@@ -40,6 +40,26 @@ static void UpdateMemoryReferences(Handle<Code> code, Address old_base, |
} |
} |
+static void UpdateFunctionTableSizeReferences(Handle<Code> code, |
+ uint32_t old_size, |
+ uint32_t new_size) { |
+ Isolate* isolate = CcTest::i_isolate(); |
+ bool modified = false; |
+ int mode_mask = |
+ RelocInfo::ModeMask(RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE); |
+ for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
+ RelocInfo::Mode mode = it.rinfo()->rmode(); |
+ if (RelocInfo::IsWasmFunctionTableSizeReference(mode)) { |
+ it.rinfo()->update_wasm_function_table_size_reference(old_size, new_size); |
+ modified = true; |
+ } |
+ } |
+ if (modified) { |
+ Assembler::FlushICache(isolate, code->instruction_start(), |
+ code->instruction_size()); |
+ } |
+} |
+ |
template <typename CType> |
static void RunLoadStoreRelocation(MachineType rep) { |
const int kNumElems = 2; |
@@ -146,7 +166,7 @@ TEST(RunLoadStoreRelocationOffset) { |
RunLoadStoreRelocationOffset<double>(MachineType::Float64()); |
} |
-TEST(Uint32LessThanRelocation) { |
+TEST(Uint32LessThanMemoryRelocation) { |
RawMachineAssemblerTester<uint32_t> m; |
RawMachineLabel within_bounds, out_of_bounds; |
Node* index = m.Int32Constant(0x200); |
@@ -168,3 +188,25 @@ TEST(Uint32LessThanRelocation) { |
// Check that after limit is increased, index is within bounds. |
CHECK_EQ(0xacedu, m.Call()); |
} |
+ |
+TEST(Uint32LessThanFunctionTableRelocation) { |
+ RawMachineAssemblerTester<uint32_t> m; |
+ RawMachineLabel within_bounds, out_of_bounds; |
+ Node* index = m.Int32Constant(0x200); |
+ Node* limit = m.RelocatableInt32Constant( |
+ 0x200, RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE); |
+ Node* cond = m.AddNode(m.machine()->Uint32LessThan(), index, limit); |
+ m.Branch(cond, &within_bounds, &out_of_bounds); |
+ m.Bind(&within_bounds); |
+ m.Return(m.Int32Constant(0xaced)); |
+ m.Bind(&out_of_bounds); |
+ m.Return(m.Int32Constant(0xdeadbeef)); |
+ // Check that index is out of bounds with current size |
+ CHECK_EQ(0xdeadbeef, m.Call()); |
+ m.GenerateCode(); |
+ |
+ Handle<Code> code = m.GetCode(); |
+ UpdateFunctionTableSizeReferences(code, 0x200, 0x400); |
+ // Check that after limit is increased, index is within bounds. |
+ CHECK_EQ(0xaced, m.Call()); |
+} |