| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 __ | 
| OLD | NEW | 
|---|