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

Side by Side Diff: test/cctest/test-reloc-info.cc

Issue 1477343002: Pass an isolate to RelocInfo (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years 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 unified diff | Download patch
« no previous file with comments | « src/x87/deoptimizer-x87.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // TODO(mythria): Remove this define after this flag is turned on globally 28 // TODO(mythria): Remove this define after this flag is turned on globally
29 #define V8_IMMINENT_DEPRECATION_WARNINGS 29 #define V8_IMMINENT_DEPRECATION_WARNINGS
30 30
31 #include "src/assembler.h" 31 #include "src/assembler.h"
32 #include "src/macro-assembler.h"
32 #include "test/cctest/cctest.h" 33 #include "test/cctest/cctest.h"
33 34
34 namespace v8 { 35 namespace v8 {
35 namespace internal { 36 namespace internal {
36 37
37 static void WriteRinfo(RelocInfoWriter* writer, 38 static void WriteRinfo(RelocInfoWriter* writer,
38 byte* pc, RelocInfo::Mode mode, intptr_t data) { 39 byte* pc, RelocInfo::Mode mode, intptr_t data) {
39 RelocInfo rinfo(pc, mode, data, NULL); 40 RelocInfo rinfo(CcTest::i_isolate(), pc, mode, data, NULL);
40 writer->Write(&rinfo); 41 writer->Write(&rinfo);
41 } 42 }
42 43
43 44
44 // Tests that writing both types of positions and then reading either 45 // Tests that writing both types of positions and then reading either
45 // or both works as expected. 46 // or both works as expected.
46 TEST(Positions) { 47 TEST(Positions) {
48 CcTest::InitializeVM();
47 const int code_size = 10 * KB; 49 const int code_size = 10 * KB;
48 int relocation_info_size = 10 * KB; 50 int relocation_info_size = 10 * KB;
49 const int buffer_size = code_size + relocation_info_size; 51 const int buffer_size = code_size + relocation_info_size;
50 v8::base::SmartArrayPointer<byte> buffer(new byte[buffer_size]); 52 v8::base::SmartArrayPointer<byte> buffer(new byte[buffer_size]);
51 53
52 byte* pc = buffer.get(); 54 byte* pc = buffer.get();
53 byte* buffer_end = buffer.get() + buffer_size; 55 byte* buffer_end = buffer.get() + buffer_size;
54 56
55 RelocInfoWriter writer(buffer_end, pc); 57 RelocInfoWriter writer(buffer_end, pc);
56 byte* relocation_info_end = buffer_end - relocation_info_size; 58 byte* relocation_info_end = buffer_end - relocation_info_size;
57 for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { 59 for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) {
58 RelocInfo::Mode mode = (i % 2 == 0) ? 60 RelocInfo::Mode mode = (i % 2 == 0) ?
59 RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; 61 RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION;
60 if (mode == RelocInfo::STATEMENT_POSITION) { 62 if (mode == RelocInfo::STATEMENT_POSITION) {
61 printf("TEST WRITING STATEMENT %p %d\n", pc, pos); 63 printf("TEST WRITING STATEMENT %p %d\n", pc, pos);
62 } else { 64 } else {
63 printf("TEST WRITING POSITION %p %d\n", pc, pos); 65 printf("TEST WRITING POSITION %p %d\n", pc, pos);
64 } 66 }
65 WriteRinfo(&writer, pc, mode, pos); 67 WriteRinfo(&writer, pc, mode, pos);
66 CHECK(writer.pos() - RelocInfoWriter::kMaxSize >= relocation_info_end); 68 CHECK(writer.pos() - RelocInfoWriter::kMaxSize >= relocation_info_end);
67 } 69 }
68 70
69 writer.Finish(); 71 writer.Finish();
70 relocation_info_size = static_cast<int>(buffer_end - writer.pos()); 72 relocation_info_size = static_cast<int>(buffer_end - writer.pos());
71 CodeDesc desc = {buffer.get(), buffer_size, code_size, relocation_info_size, 73 MacroAssembler assm(CcTest::i_isolate(), nullptr, 0, CodeObjectRequired::kNo);
72 0, NULL}; 74 CodeDesc desc = {buffer.get(), buffer_size, code_size,
75 relocation_info_size, 0, &assm};
73 76
74 // Read only (non-statement) positions. 77 // Read only (non-statement) positions.
75 { 78 {
76 RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::POSITION)); 79 RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::POSITION));
77 pc = buffer.get(); 80 pc = buffer.get();
78 for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { 81 for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) {
79 printf("TESTING 1: %d\n", i); 82 printf("TESTING 1: %d\n", i);
80 RelocInfo::Mode mode = (i % 2 == 0) ? 83 RelocInfo::Mode mode = (i % 2 == 0) ?
81 RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; 84 RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION;
82 if (mode == RelocInfo::POSITION) { 85 if (mode == RelocInfo::POSITION) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 CHECK_EQ(mode, it.rinfo()->rmode()); 120 CHECK_EQ(mode, it.rinfo()->rmode());
118 CHECK_EQ(pos, static_cast<int>(it.rinfo()->data())); 121 CHECK_EQ(pos, static_cast<int>(it.rinfo()->data()));
119 it.next(); 122 it.next();
120 } 123 }
121 CHECK(it.done()); 124 CHECK(it.done());
122 } 125 }
123 } 126 }
124 127
125 } // namespace internal 128 } // namespace internal
126 } // namespace v8 129 } // namespace v8
OLDNEW
« no previous file with comments | « src/x87/deoptimizer-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698