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

Side by Side Diff: test/cctest/test-hashing.cc

Issue 146213004: A64: Synchronize with r16849. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-global-object.cc ('k') | test/cctest/test-heap.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 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 __ pop(kRootRegister); 178 __ pop(kRootRegister);
179 __ jr(ra); 179 __ jr(ra);
180 __ nop(); 180 __ nop();
181 #else 181 #else
182 #error Unsupported architecture. 182 #error Unsupported architecture.
183 #endif 183 #endif
184 } 184 }
185 185
186 186
187 void check(i::Vector<const uint8_t> string) { 187 void check(i::Vector<const uint8_t> string) {
188 Isolate* isolate = Isolate::Current(); 188 Isolate* isolate = CcTest::i_isolate();
189 Factory* factory = isolate->factory(); 189 Factory* factory = isolate->factory();
190 HandleScope scope(isolate); 190 HandleScope scope(isolate);
191 191
192 v8::internal::byte buffer[2048]; 192 v8::internal::byte buffer[2048];
193 MacroAssembler masm(isolate, buffer, sizeof buffer); 193 MacroAssembler masm(isolate, buffer, sizeof buffer);
194 194
195 generate(&masm, string); 195 generate(&masm, string);
196 196
197 CodeDesc desc; 197 CodeDesc desc;
198 masm.GetCode(&desc); 198 masm.GetCode(&desc);
(...skipping 16 matching lines...) Expand all
215 CHECK(runtime_hash == codegen_hash); 215 CHECK(runtime_hash == codegen_hash);
216 } 216 }
217 217
218 218
219 void check(i::Vector<const char> s) { 219 void check(i::Vector<const char> s) {
220 check(i::Vector<const uint8_t>::cast(s)); 220 check(i::Vector<const uint8_t>::cast(s));
221 } 221 }
222 222
223 223
224 void check(uint32_t key) { 224 void check(uint32_t key) {
225 Isolate* isolate = Isolate::Current(); 225 Isolate* isolate = CcTest::i_isolate();
226 Factory* factory = isolate->factory(); 226 Factory* factory = isolate->factory();
227 HandleScope scope(isolate); 227 HandleScope scope(isolate);
228 228
229 v8::internal::byte buffer[2048]; 229 v8::internal::byte buffer[2048];
230 MacroAssembler masm(Isolate::Current(), buffer, sizeof buffer); 230 MacroAssembler masm(CcTest::i_isolate(), buffer, sizeof buffer);
231 231
232 generate(&masm, key); 232 generate(&masm, key);
233 233
234 CodeDesc desc; 234 CodeDesc desc;
235 masm.GetCode(&desc); 235 masm.GetCode(&desc);
236 Handle<Object> undefined(isolate->heap()->undefined_value(), isolate); 236 Handle<Object> undefined(isolate->heap()->undefined_value(), isolate);
237 Handle<Code> code = factory->NewCode(desc, 237 Handle<Code> code = factory->NewCode(desc,
238 Code::ComputeFlags(Code::STUB), 238 Code::ComputeFlags(Code::STUB),
239 undefined); 239 undefined);
240 CHECK(code->IsCode()); 240 CHECK(code->IsCode());
(...skipping 16 matching lines...) Expand all
257 check(i::Vector<const uint8_t>(ab, 2)); 257 check(i::Vector<const uint8_t>(ab, 2));
258 } 258 }
259 259
260 260
261 static uint32_t PseudoRandom(uint32_t i, uint32_t j) { 261 static uint32_t PseudoRandom(uint32_t i, uint32_t j) {
262 return ~(~((i * 781) ^ (j * 329))); 262 return ~(~((i * 781) ^ (j * 329)));
263 } 263 }
264 264
265 265
266 TEST(StringHash) { 266 TEST(StringHash) {
267 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 267 v8::Isolate* isolate = CcTest::isolate();
268 v8::HandleScope handle_scope(isolate); 268 v8::HandleScope handle_scope(isolate);
269 v8::Context::Scope context_scope(v8::Context::New(isolate)); 269 v8::Context::Scope context_scope(v8::Context::New(isolate));
270 270
271 for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) { 271 for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) {
272 // Numbers are hashed differently. 272 // Numbers are hashed differently.
273 if (a >= '0' && a <= '9') continue; 273 if (a >= '0' && a <= '9') continue;
274 for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) { 274 for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) {
275 if (b >= '0' && b <= '9') continue; 275 if (b >= '0' && b <= '9') continue;
276 check_twochars(a, b); 276 check_twochars(a, b);
277 } 277 }
278 } 278 }
279 check(i::Vector<const char>("*", 1)); 279 check(i::Vector<const char>("*", 1));
280 check(i::Vector<const char>(".zZ", 3)); 280 check(i::Vector<const char>(".zZ", 3));
281 check(i::Vector<const char>("muc", 3)); 281 check(i::Vector<const char>("muc", 3));
282 check(i::Vector<const char>("(>'_')>", 7)); 282 check(i::Vector<const char>("(>'_')>", 7));
283 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21)); 283 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21));
284 } 284 }
285 285
286 286
287 TEST(NumberHash) { 287 TEST(NumberHash) {
288 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 288 v8::Isolate* isolate = CcTest::isolate();
289 v8::HandleScope handle_scope(isolate); 289 v8::HandleScope handle_scope(isolate);
290 v8::Context::Scope context_scope(v8::Context::New(isolate)); 290 v8::Context::Scope context_scope(v8::Context::New(isolate));
291 291
292 // Some specific numbers 292 // Some specific numbers
293 for (uint32_t key = 0; key < 42; key += 7) { 293 for (uint32_t key = 0; key < 42; key += 7) {
294 check(key); 294 check(key);
295 } 295 }
296 296
297 // Some pseudo-random numbers 297 // Some pseudo-random numbers
298 static const uint32_t kLimit = 1000; 298 static const uint32_t kLimit = 1000;
299 for (uint32_t i = 0; i < 5; i++) { 299 for (uint32_t i = 0; i < 5; i++) {
300 for (uint32_t j = 0; j < 5; j++) { 300 for (uint32_t j = 0; j < 5; j++) {
301 check(PseudoRandom(i, j) % kLimit); 301 check(PseudoRandom(i, j) % kLimit);
302 } 302 }
303 } 303 }
304 } 304 }
305 305
306 #undef __ 306 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-global-object.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698