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

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

Issue 14947005: fix nosnapshot test failure in 14793004, do not deprecate function (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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-decls.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 29 matching lines...) Expand all
40 40
41 #ifdef USE_SIMULATOR 41 #ifdef USE_SIMULATOR
42 #include "simulator.h" 42 #include "simulator.h"
43 #endif 43 #endif
44 44
45 using namespace v8::internal; 45 using namespace v8::internal;
46 46
47 47
48 typedef uint32_t (*HASH_FUNCTION)(); 48 typedef uint32_t (*HASH_FUNCTION)();
49 49
50 static v8::Persistent<v8::Context> env;
51
52 #define __ masm-> 50 #define __ masm->
53 51
54 52
55 void generate(MacroAssembler* masm, i::Vector<const uint8_t> string) { 53 void generate(MacroAssembler* masm, i::Vector<const uint8_t> string) {
56 // GenerateHashInit takes the first character as an argument so it can't 54 // GenerateHashInit takes the first character as an argument so it can't
57 // handle the zero length string. 55 // handle the zero length string.
58 ASSERT(string.length() > 0); 56 ASSERT(string.length() > 0);
59 #ifdef V8_TARGET_ARCH_IA32 57 #ifdef V8_TARGET_ARCH_IA32
60 __ push(ebx); 58 __ push(ebx);
61 __ push(ecx); 59 __ push(ecx);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 check(i::Vector<const uint8_t>(ab, 2)); 226 check(i::Vector<const uint8_t>(ab, 2));
229 } 227 }
230 228
231 229
232 static uint32_t PseudoRandom(uint32_t i, uint32_t j) { 230 static uint32_t PseudoRandom(uint32_t i, uint32_t j) {
233 return ~(~((i * 781) ^ (j * 329))); 231 return ~(~((i * 781) ^ (j * 329)));
234 } 232 }
235 233
236 234
237 TEST(StringHash) { 235 TEST(StringHash) {
238 if (env.IsEmpty()) env = v8::Context::New(); 236 v8::Isolate* isolate = v8::Isolate::GetCurrent();
237 v8::HandleScope handle_scope(isolate);
238 v8::Context::Scope context_scope(v8::Context::New(isolate));
239
239 for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) { 240 for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) {
240 // Numbers are hashed differently. 241 // Numbers are hashed differently.
241 if (a >= '0' && a <= '9') continue; 242 if (a >= '0' && a <= '9') continue;
242 for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) { 243 for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) {
243 if (b >= '0' && b <= '9') continue; 244 if (b >= '0' && b <= '9') continue;
244 check_twochars(a, b); 245 check_twochars(a, b);
245 } 246 }
246 } 247 }
247 check(i::Vector<const char>("*", 1)); 248 check(i::Vector<const char>("*", 1));
248 check(i::Vector<const char>(".zZ", 3)); 249 check(i::Vector<const char>(".zZ", 3));
249 check(i::Vector<const char>("muc", 3)); 250 check(i::Vector<const char>("muc", 3));
250 check(i::Vector<const char>("(>'_')>", 7)); 251 check(i::Vector<const char>("(>'_')>", 7));
251 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21)); 252 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21));
252 } 253 }
253 254
254 255
255 TEST(NumberHash) { 256 TEST(NumberHash) {
256 if (env.IsEmpty()) env = v8::Context::New(); 257 v8::Isolate* isolate = v8::Isolate::GetCurrent();
258 v8::HandleScope handle_scope(isolate);
259 v8::Context::Scope context_scope(v8::Context::New(isolate));
257 260
258 // Some specific numbers 261 // Some specific numbers
259 for (uint32_t key = 0; key < 42; key += 7) { 262 for (uint32_t key = 0; key < 42; key += 7) {
260 check(key); 263 check(key);
261 } 264 }
262 265
263 // Some pseudo-random numbers 266 // Some pseudo-random numbers
264 static const uint32_t kLimit = 1000; 267 static const uint32_t kLimit = 1000;
265 for (uint32_t i = 0; i < 5; i++) { 268 for (uint32_t i = 0; i < 5; i++) {
266 for (uint32_t j = 0; j < 5; j++) { 269 for (uint32_t j = 0; j < 5; j++) {
267 check(PseudoRandom(i, j) % kLimit); 270 check(PseudoRandom(i, j) % kLimit);
268 } 271 }
269 } 272 }
270 } 273 }
271 274
272 #undef __ 275 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-decls.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698