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

Side by Side Diff: test/cctest/test-macro-assembler-mips.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-arm.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
(...skipping 26 matching lines...) Expand all
37 37
38 38
39 using namespace v8::internal; 39 using namespace v8::internal;
40 40
41 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); 42 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4);
43 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); 43 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4);
44 44
45 #define __ masm-> 45 #define __ masm->
46 46
47
48 static byte to_non_zero(int n) {
49 return static_cast<unsigned>(n) % 255 + 1;
50 }
51
52
53 static bool all_zeroes(const byte* beg, const byte* end) {
54 CHECK(beg);
55 CHECK(beg <= end);
56 while (beg < end) {
57 if (*beg++ != 0)
58 return false;
59 }
60 return true;
61 }
62
63 TEST(BYTESWAP) { 47 TEST(BYTESWAP) {
64 CcTest::InitializeVM(); 48 CcTest::InitializeVM();
65 Isolate* isolate = CcTest::i_isolate(); 49 Isolate* isolate = CcTest::i_isolate();
66 HandleScope handles(isolate); 50 HandleScope handles(isolate);
67 51
68 struct T { 52 struct T {
69 int32_t r1; 53 int32_t r1;
70 int32_t r2; 54 int32_t r2;
71 int32_t r3; 55 int32_t r3;
72 int32_t r4; 56 int32_t r4;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); 103 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
120 USE(dummy); 104 USE(dummy);
121 105
122 CHECK_EQ(static_cast<int32_t>(0xC3151A78), t.r1); 106 CHECK_EQ(static_cast<int32_t>(0xC3151A78), t.r1);
123 CHECK_EQ(static_cast<int32_t>(0xDE2C0000), t.r2); 107 CHECK_EQ(static_cast<int32_t>(0xDE2C0000), t.r2);
124 CHECK_EQ(static_cast<int32_t>(0x9FFFFFFF), t.r3); 108 CHECK_EQ(static_cast<int32_t>(0x9FFFFFFF), t.r3);
125 CHECK_EQ(static_cast<int32_t>(0x9F000000), t.r4); 109 CHECK_EQ(static_cast<int32_t>(0x9F000000), t.r4);
126 CHECK_EQ(static_cast<int32_t>(0xDE2C0000), t.r5); 110 CHECK_EQ(static_cast<int32_t>(0xDE2C0000), t.r5);
127 } 111 }
128 112
129 TEST(CopyBytes) {
130 CcTest::InitializeVM();
131 Isolate* isolate = CcTest::i_isolate();
132 HandleScope handles(isolate);
133
134 const int data_size = 1 * KB;
135 size_t act_size;
136
137 // Allocate two blocks to copy data between.
138 byte* src_buffer =
139 static_cast<byte*>(v8::base::OS::Allocate(data_size, &act_size, 0));
140 CHECK(src_buffer);
141 CHECK(act_size >= static_cast<size_t>(data_size));
142 byte* dest_buffer =
143 static_cast<byte*>(v8::base::OS::Allocate(data_size, &act_size, 0));
144 CHECK(dest_buffer);
145 CHECK(act_size >= static_cast<size_t>(data_size));
146
147 // Storage for a0 and a1.
148 byte* a0_;
149 byte* a1_;
150
151 MacroAssembler assembler(isolate, NULL, 0,
152 v8::internal::CodeObjectRequired::kYes);
153 MacroAssembler* masm = &assembler;
154
155 // Code to be generated: The stuff in CopyBytes followed by a store of a0 and
156 // a1, respectively.
157 __ CopyBytes(a0, a1, a2, a3);
158 __ li(a2, Operand(reinterpret_cast<int>(&a0_)));
159 __ li(a3, Operand(reinterpret_cast<int>(&a1_)));
160 __ sw(a0, MemOperand(a2));
161 __ jr(ra);
162 __ sw(a1, MemOperand(a3));
163
164 CodeDesc desc;
165 masm->GetCode(&desc);
166 Handle<Code> code = isolate->factory()->NewCode(
167 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
168
169 ::F f = FUNCTION_CAST< ::F>(code->entry());
170
171 // Initialise source data with non-zero bytes.
172 for (int i = 0; i < data_size; i++) {
173 src_buffer[i] = to_non_zero(i);
174 }
175
176 const int fuzz = 11;
177
178 for (int size = 0; size < 600; size++) {
179 for (const byte* src = src_buffer; src < src_buffer + fuzz; src++) {
180 for (byte* dest = dest_buffer; dest < dest_buffer + fuzz; dest++) {
181 memset(dest_buffer, 0, data_size);
182 CHECK(dest + size < dest_buffer + data_size);
183 (void)CALL_GENERATED_CODE(isolate, f, reinterpret_cast<int>(src),
184 reinterpret_cast<int>(dest), size, 0, 0);
185 // a0 and a1 should point at the first byte after the copied data.
186 CHECK_EQ(src + size, a0_);
187 CHECK_EQ(dest + size, a1_);
188 // Check that we haven't written outside the target area.
189 CHECK(all_zeroes(dest_buffer, dest));
190 CHECK(all_zeroes(dest + size, dest_buffer + data_size));
191 // Check the target area.
192 CHECK_EQ(0, memcmp(src, dest, size));
193 }
194 }
195 }
196
197 // Check that the source data hasn't been clobbered.
198 for (int i = 0; i < data_size; i++) {
199 CHECK(src_buffer[i] == to_non_zero(i));
200 }
201 }
202
203
204 static void TestNaN(const char *code) { 113 static void TestNaN(const char *code) {
205 // NaN value is different on MIPS and x86 architectures, and TEST(NaNx) 114 // NaN value is different on MIPS and x86 architectures, and TEST(NaNx)
206 // tests checks the case where a x86 NaN value is serialized into the 115 // tests checks the case where a x86 NaN value is serialized into the
207 // snapshot on the simulator during cross compilation. 116 // snapshot on the simulator during cross compilation.
208 v8::HandleScope scope(CcTest::isolate()); 117 v8::HandleScope scope(CcTest::isolate());
209 v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION); 118 v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION);
210 v8::Context::Scope context_scope(context); 119 v8::Context::Scope context_scope(context);
211 120
212 v8::Local<v8::Script> script = 121 v8::Local<v8::Script> script =
213 v8::Script::Compile(context, v8_str(code)).ToLocalChecked(); 122 v8::Script::Compile(context, v8_str(code)).ToLocalChecked();
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 __ Sltu(v0, a0, Operand(imm)); 1262 __ Sltu(v0, a0, Operand(imm));
1354 })); 1263 }));
1355 CHECK_EQ(rs < rd, 1264 CHECK_EQ(rs < rd,
1356 run_Sltu(rs, rd, [](MacroAssembler* masm, 1265 run_Sltu(rs, rd, [](MacroAssembler* masm,
1357 uint32_t imm) { __ Sltu(v0, a0, a1); })); 1266 uint32_t imm) { __ Sltu(v0, a0, a1); }));
1358 } 1267 }
1359 } 1268 }
1360 } 1269 }
1361 1270
1362 #undef __ 1271 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-macro-assembler-arm.cc ('k') | test/cctest/test-macro-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698