Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(954)

Unified Diff: test/cctest/compiler/test-run-wasm-machops.cc

Issue 1921203002: Add new relocation type WASM_MEMORY_SIZE_REFERENCE, use relocatable pointers to update wasm memory … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ben's review Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | test/cctest/test-run-wasm-relocation-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 29709e981b02325e003cfd7e9a6d37b078cee54f..0b23669cf7d04280e551ff36d2b1bb03150fcc84 100644
--- a/test/cctest/compiler/test-run-wasm-machops.cc
+++ b/test/cctest/compiler/test-run-wasm-machops.cc
@@ -18,14 +18,16 @@ using namespace v8::internal;
using namespace v8::internal::compiler;
static void UpdateMemoryReferences(Handle<Code> code, Address old_base,
- Address new_base, size_t old_size,
- size_t new_size) {
+ Address new_base, uint32_t old_size,
+ uint32_t new_size) {
Isolate* isolate = CcTest::i_isolate();
bool modified = false;
- int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE);
+ int mode_mask = RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_REFERENCE) |
+ RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
RelocInfo::Mode mode = it.rinfo()->rmode();
- if (RelocInfo::IsWasmMemoryReference(mode)) {
+ if (RelocInfo::IsWasmMemoryReference(mode) ||
+ RelocInfo::IsWasmMemorySizeReference(mode)) {
// Patch addresses with change in memory start address
it.rinfo()->update_wasm_memory_reference(old_base, new_base, old_size,
new_size);
@@ -143,3 +145,26 @@ TEST(RunLoadStoreRelocationOffset) {
RunLoadStoreRelocationOffset<float>(MachineType::Float32());
RunLoadStoreRelocationOffset<double>(MachineType::Float64());
}
+
+TEST(Uint32LessThanRelocation) {
+ RawMachineAssemblerTester<uint32_t> m;
+ RawMachineLabel within_bounds, out_of_bounds;
+ Node* index = m.Int32Constant(0x200);
+ Node* limit =
+ m.RelocatableInt32Constant(0x200, RelocInfo::WASM_MEMORY_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();
+ UpdateMemoryReferences(code, reinterpret_cast<Address>(1234),
+ reinterpret_cast<Address>(1234), 0x200, 0x400);
+ // Check that after limit is increased, index is within bounds.
+ CHECK_EQ(0xaced, m.Call());
+}
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | test/cctest/test-run-wasm-relocation-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698