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

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

Issue 1236793010: Version 4.4.63.20 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.4
Patch Set: Created 5 years, 5 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <iostream> // NOLINT(readability/streams)
29 30
30 #include "src/v8.h" 31 #include "src/v8.h"
31 #include "test/cctest/cctest.h" 32 #include "test/cctest/cctest.h"
32 33
34 #include "src/base/utils/random-number-generator.h"
33 #include "src/macro-assembler.h" 35 #include "src/macro-assembler.h"
34 #include "src/mips64/macro-assembler-mips64.h" 36 #include "src/mips64/macro-assembler-mips64.h"
35 #include "src/mips64/simulator-mips64.h" 37 #include "src/mips64/simulator-mips64.h"
36 38
37 39
38 using namespace v8::internal; 40 using namespace v8::internal;
39 41
40 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);
41 44
42 #define __ masm-> 45 #define __ masm->
43 46
44 47
45 static byte to_non_zero(int n) { 48 static byte to_non_zero(int n) {
46 return static_cast<unsigned>(n) % 255 + 1; 49 return static_cast<unsigned>(n) % 255 + 1;
47 } 50 }
48 51
49 52
50 static bool all_zeroes(const byte* beg, const byte* end) { 53 static bool all_zeroes(const byte* beg, const byte* end) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 CodeDesc desc; 210 CodeDesc desc;
208 masm->GetCode(&desc); 211 masm->GetCode(&desc);
209 Handle<Code> code = isolate->factory()->NewCode( 212 Handle<Code> code = isolate->factory()->NewCode(
210 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 213 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
211 214
212 ::F f = FUNCTION_CAST< ::F>(code->entry()); 215 ::F f = FUNCTION_CAST< ::F>(code->entry());
213 (void) CALL_GENERATED_CODE(f, 0, 0, 0, 0, 0); 216 (void) CALL_GENERATED_CODE(f, 0, 0, 0, 0, 0);
214 // Check results. 217 // Check results.
215 } 218 }
216 219
220
221 TEST(jump_tables4) {
222 // Similar to test-assembler-mips jump_tables1, with extra test for branch
223 // trampoline required before emission of the dd table (where trampolines are
224 // blocked), and proper transition to long-branch mode.
225 // Regression test for v8:4294.
226 CcTest::InitializeVM();
227 Isolate* isolate = CcTest::i_isolate();
228 HandleScope scope(isolate);
229 MacroAssembler assembler(isolate, NULL, 0);
230 MacroAssembler* masm = &assembler;
231
232 const int kNumCases = 512;
233 int values[kNumCases];
234 isolate->random_number_generator()->NextBytes(values, sizeof(values));
235 Label labels[kNumCases];
236 Label near_start, end;
237
238 __ daddiu(sp, sp, -8);
239 __ sd(ra, MemOperand(sp));
240 if ((masm->pc_offset() & 7) == 0) {
241 __ nop();
242 }
243
244 __ mov(v0, zero_reg);
245
246 __ Branch(&end);
247 __ bind(&near_start);
248
249 // Generate slightly less than 32K instructions, which will soon require
250 // trampoline for branch distance fixup.
251 for (int i = 0; i < 32768 - 256; ++i) {
252 __ addiu(v0, v0, 1);
253 }
254
255 Label done;
256 {
257 __ BlockTrampolinePoolFor(kNumCases * 2 + 6);
258 PredictableCodeSizeScope predictable(
259 masm, (kNumCases * 2 + 6) * Assembler::kInstrSize);
260 Label here;
261
262 __ bal(&here);
263 __ dsll(at, a0, 3); // In delay slot.
264 __ bind(&here);
265 __ daddu(at, at, ra);
266 __ ld(at, MemOperand(at, 4 * Assembler::kInstrSize));
267 __ jr(at);
268 __ nop(); // Branch delay slot nop.
269 for (int i = 0; i < kNumCases; ++i) {
270 __ dd(&labels[i]);
271 }
272 }
273
274 for (int i = 0; i < kNumCases; ++i) {
275 __ bind(&labels[i]);
276 __ lui(v0, (values[i] >> 16) & 0xffff);
277 __ ori(v0, v0, values[i] & 0xffff);
278 __ Branch(&done);
279 }
280
281 __ bind(&done);
282 __ ld(ra, MemOperand(sp));
283 __ daddiu(sp, sp, 8);
284 __ jr(ra);
285 __ nop();
286
287 __ bind(&end);
288 __ Branch(&near_start);
289
290 CodeDesc desc;
291 masm->GetCode(&desc);
292 Handle<Code> code = isolate->factory()->NewCode(
293 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
294 #ifdef OBJECT_PRINT
295 code->Print(std::cout);
296 #endif
297 F1 f = FUNCTION_CAST<F1>(code->entry());
298 for (int i = 0; i < kNumCases; ++i) {
299 int64_t res =
300 reinterpret_cast<int64_t>(CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
301 ::printf("f(%d) = %" PRId64 "\n", i, res);
302 CHECK_EQ(values[i], res);
303 }
304 }
305
217 #undef __ 306 #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