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

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

Issue 1149863005: Move hash code from hidden string to a private symbol (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix merge Created 5 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
« no previous file with comments | « test/cctest/test-api.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 HASH_FUNCTION hash = FUNCTION_CAST<HASH_FUNCTION>(code->entry()); 125 HASH_FUNCTION hash = FUNCTION_CAST<HASH_FUNCTION>(code->entry());
126 #ifdef USE_SIMULATOR 126 #ifdef USE_SIMULATOR
127 uint32_t codegen_hash = static_cast<uint32_t>( 127 uint32_t codegen_hash = static_cast<uint32_t>(
128 reinterpret_cast<uintptr_t>(CALL_GENERATED_CODE(hash, 0, 0, 0, 0, 0))); 128 reinterpret_cast<uintptr_t>(CALL_GENERATED_CODE(hash, 0, 0, 0, 0, 0)));
129 #else 129 #else
130 uint32_t codegen_hash = hash(); 130 uint32_t codegen_hash = hash();
131 #endif 131 #endif
132 132
133 uint32_t runtime_hash = ComputeIntegerHash(key, isolate->heap()->HashSeed()); 133 uint32_t runtime_hash = ComputeIntegerHash(key, isolate->heap()->HashSeed());
134 CHECK(runtime_hash == codegen_hash); 134 CHECK_EQ(runtime_hash, codegen_hash);
135 } 135 }
136 136
137 137
138 static uint32_t PseudoRandom(uint32_t i, uint32_t j) { 138 static uint32_t PseudoRandom(uint32_t i, uint32_t j) {
139 return ~(~((i * 781) ^ (j * 329))); 139 return ~(~((i * 781) ^ (j * 329)));
140 } 140 }
141 141
142 142
143 TEST(NumberHash) { 143 TEST(NumberHash) {
144 v8::Isolate* isolate = CcTest::isolate(); 144 v8::Isolate* isolate = CcTest::isolate();
145 v8::HandleScope handle_scope(isolate); 145 v8::HandleScope handle_scope(isolate);
146 v8::Context::Scope context_scope(v8::Context::New(isolate)); 146 v8::Context::Scope context_scope(v8::Context::New(isolate));
147 147
148 // Some specific numbers 148 // Some specific numbers
149 for (uint32_t key = 0; key < 42; key += 7) { 149 for (uint32_t key = 0; key < 42; key += 7) {
150 check(key); 150 check(key);
151 } 151 }
152 152
153 // Some pseudo-random numbers 153 // Some pseudo-random numbers
154 static const uint32_t kLimit = 1000; 154 static const uint32_t kLimit = 1000;
155 for (uint32_t i = 0; i < 5; i++) { 155 for (uint32_t i = 0; i < 5; i++) {
156 for (uint32_t j = 0; j < 5; j++) { 156 for (uint32_t j = 0; j < 5; j++) {
157 check(PseudoRandom(i, j) % kLimit); 157 check(PseudoRandom(i, j) % kLimit);
158 } 158 }
159 } 159 }
160 } 160 }
161 161
162 #undef __ 162 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698