OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2016 the V8 project authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include <cmath> | 5 #include <cmath> |
6 #include <functional> | 6 #include <functional> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 static void RunLoadStoreRelocation(MachineType rep) { | 44 static void RunLoadStoreRelocation(MachineType rep) { |
45 const int kNumElems = 2; | 45 const int kNumElems = 2; |
46 CType buffer[kNumElems]; | 46 CType buffer[kNumElems]; |
47 CType new_buffer[kNumElems]; | 47 CType new_buffer[kNumElems]; |
48 byte* raw = reinterpret_cast<byte*>(buffer); | 48 byte* raw = reinterpret_cast<byte*>(buffer); |
49 byte* new_raw = reinterpret_cast<byte*>(new_buffer); | 49 byte* new_raw = reinterpret_cast<byte*>(new_buffer); |
50 for (size_t i = 0; i < sizeof(buffer); i++) { | 50 for (size_t i = 0; i < sizeof(buffer); i++) { |
51 raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); | 51 raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); |
52 new_raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); | 52 new_raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); |
53 } | 53 } |
54 int32_t OK = 0x29000; | 54 uint32_t OK = 0x29000; |
55 RawMachineAssemblerTester<uint32_t> m; | 55 RawMachineAssemblerTester<uint32_t> m; |
56 Node* base = m.RelocatableIntPtrConstant(reinterpret_cast<intptr_t>(raw), | 56 Node* base = m.RelocatableIntPtrConstant(reinterpret_cast<intptr_t>(raw), |
57 RelocInfo::WASM_MEMORY_REFERENCE); | 57 RelocInfo::WASM_MEMORY_REFERENCE); |
58 Node* base1 = m.RelocatableIntPtrConstant( | 58 Node* base1 = m.RelocatableIntPtrConstant( |
59 reinterpret_cast<intptr_t>(raw + sizeof(CType)), | 59 reinterpret_cast<intptr_t>(raw + sizeof(CType)), |
60 RelocInfo::WASM_MEMORY_REFERENCE); | 60 RelocInfo::WASM_MEMORY_REFERENCE); |
61 Node* index = m.Int32Constant(0); | 61 Node* index = m.Int32Constant(0); |
62 Node* load = m.Load(rep, base, index); | 62 Node* load = m.Load(rep, base, index); |
63 m.Store(rep.representation(), base1, index, load, kNoWriteBarrier); | 63 m.Store(rep.representation(), base1, index, load, kNoWriteBarrier); |
64 m.Return(m.Int32Constant(OK)); | 64 m.Return(m.Int32Constant(OK)); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 m.Bind(&out_of_bounds); | 159 m.Bind(&out_of_bounds); |
160 m.Return(m.Int32Constant(0xdeadbeef)); | 160 m.Return(m.Int32Constant(0xdeadbeef)); |
161 // Check that index is out of bounds with current size | 161 // Check that index is out of bounds with current size |
162 CHECK_EQ(0xdeadbeef, m.Call()); | 162 CHECK_EQ(0xdeadbeef, m.Call()); |
163 m.GenerateCode(); | 163 m.GenerateCode(); |
164 | 164 |
165 Handle<Code> code = m.GetCode(); | 165 Handle<Code> code = m.GetCode(); |
166 UpdateMemoryReferences(code, reinterpret_cast<Address>(1234), | 166 UpdateMemoryReferences(code, reinterpret_cast<Address>(1234), |
167 reinterpret_cast<Address>(1234), 0x200, 0x400); | 167 reinterpret_cast<Address>(1234), 0x200, 0x400); |
168 // Check that after limit is increased, index is within bounds. | 168 // Check that after limit is increased, index is within bounds. |
169 CHECK_EQ(0xaced, m.Call()); | 169 CHECK_EQ(0xacedu, m.Call()); |
170 } | 170 } |
OLD | NEW |