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

Side by Side Diff: test/cctest/test-macro-assembler-mips.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-assembler-mips64.cc ('k') | test/cctest/test-macro-assembler-mips64.cc » ('j') | 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/base/utils/random-number-generator.h"
31 #include "test/cctest/cctest.h"
32
33 #include "src/macro-assembler.h" 32 #include "src/macro-assembler.h"
34 #include "src/mips/macro-assembler-mips.h" 33 #include "src/mips/macro-assembler-mips.h"
35 #include "src/mips/simulator-mips.h" 34 #include "src/mips/simulator-mips.h"
35 #include "src/v8.h"
36 #include "test/cctest/cctest.h"
36 37
37 38
38 using namespace v8::internal; 39 using namespace v8::internal;
39 40
40 typedef void* (*F)(int x, int y, int p2, int p3, int p4); 41 typedef void* (*F)(int x, int y, int p2, int p3, int p4);
42 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4);
41 43
42 #define __ masm-> 44 #define __ masm->
43 45
44 46
45 static byte to_non_zero(int n) { 47 static byte to_non_zero(int n) {
46 return static_cast<unsigned>(n) % 255 + 1; 48 return static_cast<unsigned>(n) % 255 + 1;
47 } 49 }
48 50
49 51
50 static bool all_zeroes(const byte* beg, const byte* end) { 52 static bool all_zeroes(const byte* beg, const byte* end) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 TEST(NaN1) { 169 TEST(NaN1) {
168 TestNaN( 170 TestNaN(
169 "var result;" 171 "var result;"
170 "for (var i = 0; i < 2; i++) {" 172 "for (var i = 0; i < 2; i++) {"
171 " result = [NaN];" 173 " result = [NaN];"
172 "}" 174 "}"
173 "result;"); 175 "result;");
174 } 176 }
175 177
176 178
179 TEST(jump_tables4) {
180 // Similar to test-assembler-mips jump_tables1, with extra test for branch
181 // trampoline required before emission of the dd table (where trampolines are
182 // blocked), and proper transition to long-branch mode.
183 // Regression test for v8:4294.
184 CcTest::InitializeVM();
185 Isolate* isolate = CcTest::i_isolate();
186 HandleScope scope(isolate);
187 MacroAssembler assembler(isolate, NULL, 0);
188 MacroAssembler* masm = &assembler;
189
190 const int kNumCases = 512;
191 int values[kNumCases];
192 isolate->random_number_generator()->NextBytes(values, sizeof(values));
193 Label labels[kNumCases];
194 Label near_start, end;
195
196 __ addiu(sp, sp, -4);
197 __ sw(ra, MemOperand(sp));
198
199 __ mov(v0, zero_reg);
200
201 __ Branch(&end);
202 __ bind(&near_start);
203
204 // Generate slightly less than 32K instructions, which will soon require
205 // trampoline for branch distance fixup.
206 for (int i = 0; i < 32768 - 256; ++i) {
207 __ addiu(v0, v0, 1);
208 }
209
210 Label done;
211 {
212 __ BlockTrampolinePoolFor(kNumCases + 6);
213 PredictableCodeSizeScope predictable(
214 masm, (kNumCases + 6) * Assembler::kInstrSize);
215 Label here;
216
217 __ bal(&here);
218 __ sll(at, a0, 2); // In delay slot.
219 __ bind(&here);
220 __ addu(at, at, ra);
221 __ lw(at, MemOperand(at, 4 * Assembler::kInstrSize));
222 __ jr(at);
223 __ nop(); // Branch delay slot nop.
224 for (int i = 0; i < kNumCases; ++i) {
225 __ dd(&labels[i]);
226 }
227 }
228
229 for (int i = 0; i < kNumCases; ++i) {
230 __ bind(&labels[i]);
231 __ lui(v0, (values[i] >> 16) & 0xffff);
232 __ ori(v0, v0, values[i] & 0xffff);
233 __ Branch(&done);
234 }
235
236 __ bind(&done);
237 __ lw(ra, MemOperand(sp));
238 __ addiu(sp, sp, 4);
239 __ jr(ra);
240 __ nop();
241
242 __ bind(&end);
243 __ Branch(&near_start);
244
245 CodeDesc desc;
246 masm->GetCode(&desc);
247 Handle<Code> code = isolate->factory()->NewCode(
248 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
249 #ifdef OBJECT_PRINT
250 code->Print(std::cout);
251 #endif
252 F1 f = FUNCTION_CAST<F1>(code->entry());
253 for (int i = 0; i < kNumCases; ++i) {
254 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
255 ::printf("f(%d) = %d\n", i, res);
256 CHECK_EQ(values[i], res);
257 }
258 }
259
260
177 #undef __ 261 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-mips64.cc ('k') | test/cctest/test-macro-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698