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

Side by Side Diff: test/cctest/test-macro-assembler-mips64.cc

Issue 2434753003: [cleanup] Delete MacroAssembler::CopyBytes, it is dead code (Closed)
Patch Set: update .golden files Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-macro-assembler-mips.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 27 matching lines...) Expand all
38 38
39 39
40 using namespace v8::internal; 40 using namespace v8::internal;
41 41
42 typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4); 42 typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4);
43 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); 43 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4);
44 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); 44 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4);
45 45
46 #define __ masm-> 46 #define __ masm->
47 47
48
49 static byte to_non_zero(int n) {
50 return static_cast<unsigned>(n) % 255 + 1;
51 }
52
53
54 static bool all_zeroes(const byte* beg, const byte* end) {
55 CHECK(beg);
56 CHECK(beg <= end);
57 while (beg < end) {
58 if (*beg++ != 0)
59 return false;
60 }
61 return true;
62 }
63
64 TEST(BYTESWAP) { 48 TEST(BYTESWAP) {
65 DCHECK(kArchVariant == kMips64r6 || kArchVariant == kMips64r2); 49 DCHECK(kArchVariant == kMips64r6 || kArchVariant == kMips64r2);
66 CcTest::InitializeVM(); 50 CcTest::InitializeVM();
67 Isolate* isolate = CcTest::i_isolate(); 51 Isolate* isolate = CcTest::i_isolate();
68 HandleScope scope(isolate); 52 HandleScope scope(isolate);
69 53
70 struct T { 54 struct T {
71 int64_t r1; 55 int64_t r1;
72 int64_t r2; 56 int64_t r2;
73 int64_t r3; 57 int64_t r3;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 122
139 CHECK_EQ(static_cast<int64_t>(0xCC7A329DCDFF1256), t.r1); 123 CHECK_EQ(static_cast<int64_t>(0xCC7A329DCDFF1256), t.r1);
140 CHECK_EQ(static_cast<int64_t>(0xC3151A7800000000), t.r2); 124 CHECK_EQ(static_cast<int64_t>(0xC3151A7800000000), t.r2);
141 CHECK_EQ(static_cast<int64_t>(0xDEFCFFFFFFFFFFFF), t.r3); 125 CHECK_EQ(static_cast<int64_t>(0xDEFCFFFFFFFFFFFF), t.r3);
142 CHECK_EQ(static_cast<int64_t>(0x9FFFFFFFFFFFFFFF), t.r4); 126 CHECK_EQ(static_cast<int64_t>(0x9FFFFFFFFFFFFFFF), t.r4);
143 CHECK_EQ(static_cast<int64_t>(0x9F00000000000000), t.r5); 127 CHECK_EQ(static_cast<int64_t>(0x9F00000000000000), t.r5);
144 CHECK_EQ(static_cast<int64_t>(0xDEFC000000000000), t.r6); 128 CHECK_EQ(static_cast<int64_t>(0xDEFC000000000000), t.r6);
145 CHECK_EQ(static_cast<int64_t>(0xC3151AC800000000), t.r7); 129 CHECK_EQ(static_cast<int64_t>(0xC3151AC800000000), t.r7);
146 } 130 }
147 131
148 TEST(CopyBytes) {
149 CcTest::InitializeVM();
150 Isolate* isolate = CcTest::i_isolate();
151 HandleScope handles(isolate);
152
153 const int data_size = 1 * KB;
154 size_t act_size;
155
156 // Allocate two blocks to copy data between.
157 byte* src_buffer =
158 static_cast<byte*>(v8::base::OS::Allocate(data_size, &act_size, 0));
159 CHECK(src_buffer);
160 CHECK(act_size >= static_cast<size_t>(data_size));
161 byte* dest_buffer =
162 static_cast<byte*>(v8::base::OS::Allocate(data_size, &act_size, 0));
163 CHECK(dest_buffer);
164 CHECK(act_size >= static_cast<size_t>(data_size));
165
166 // Storage for a0 and a1.
167 byte* a0_;
168 byte* a1_;
169
170 MacroAssembler assembler(isolate, NULL, 0,
171 v8::internal::CodeObjectRequired::kYes);
172 MacroAssembler* masm = &assembler;
173
174 // Code to be generated: The stuff in CopyBytes followed by a store of a0 and
175 // a1, respectively.
176 __ CopyBytes(a0, a1, a2, a3);
177 __ li(a2, Operand(reinterpret_cast<int64_t>(&a0_)));
178 __ li(a3, Operand(reinterpret_cast<int64_t>(&a1_)));
179 __ sd(a0, MemOperand(a2));
180 __ jr(ra);
181 __ sd(a1, MemOperand(a3));
182
183 CodeDesc desc;
184 masm->GetCode(&desc);
185 Handle<Code> code = isolate->factory()->NewCode(
186 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
187
188 ::F f = FUNCTION_CAST< ::F>(code->entry());
189
190 // Initialise source data with non-zero bytes.
191 for (int i = 0; i < data_size; i++) {
192 src_buffer[i] = to_non_zero(i);
193 }
194
195 const int fuzz = 11;
196
197 for (int size = 0; size < 600; size++) {
198 for (const byte* src = src_buffer; src < src_buffer + fuzz; src++) {
199 for (byte* dest = dest_buffer; dest < dest_buffer + fuzz; dest++) {
200 memset(dest_buffer, 0, data_size);
201 CHECK(dest + size < dest_buffer + data_size);
202 (void)CALL_GENERATED_CODE(isolate, f, reinterpret_cast<int64_t>(src),
203 reinterpret_cast<int64_t>(dest), size, 0, 0);
204 // a0 and a1 should point at the first byte after the copied data.
205 CHECK_EQ(src + size, a0_);
206 CHECK_EQ(dest + size, a1_);
207 // Check that we haven't written outside the target area.
208 CHECK(all_zeroes(dest_buffer, dest));
209 CHECK(all_zeroes(dest + size, dest_buffer + data_size));
210 // Check the target area.
211 CHECK_EQ(0, memcmp(src, dest, size));
212 }
213 }
214 }
215
216 // Check that the source data hasn't been clobbered.
217 for (int i = 0; i < data_size; i++) {
218 CHECK(src_buffer[i] == to_non_zero(i));
219 }
220 }
221
222
223 TEST(LoadConstants) { 132 TEST(LoadConstants) {
224 CcTest::InitializeVM(); 133 CcTest::InitializeVM();
225 Isolate* isolate = CcTest::i_isolate(); 134 Isolate* isolate = CcTest::i_isolate();
226 HandleScope handles(isolate); 135 HandleScope handles(isolate);
227 136
228 int64_t refConstants[64]; 137 int64_t refConstants[64];
229 int64_t result[64]; 138 int64_t result[64];
230 139
231 int64_t mask = 1; 140 int64_t mask = 1;
232 for (int i = 0; i < 64; i++) { 141 for (int i = 0; i < 64; i++) {
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 __ Sltu(v0, a0, Operand(imm)); 1868 __ Sltu(v0, a0, Operand(imm));
1960 })); 1869 }));
1961 CHECK_EQ(rs < rd, 1870 CHECK_EQ(rs < rd,
1962 run_Sltu(rs, rd, [](MacroAssembler* masm, 1871 run_Sltu(rs, rd, [](MacroAssembler* masm,
1963 uint64_t imm) { __ Sltu(v0, a0, a1); })); 1872 uint64_t imm) { __ Sltu(v0, a0, a1); }));
1964 } 1873 }
1965 } 1874 }
1966 } 1875 }
1967 1876
1968 #undef __ 1877 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-macro-assembler-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698