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 6015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6026 if (!result.is(eax)) { | 6026 if (!result.is(eax)) { |
6027 __ mov(eax, result); | 6027 __ mov(eax, result); |
6028 } | 6028 } |
6029 } | 6029 } |
6030 | 6030 |
6031 | 6031 |
6032 void StringHelper::GenerateHashInit(MacroAssembler* masm, | 6032 void StringHelper::GenerateHashInit(MacroAssembler* masm, |
6033 Register hash, | 6033 Register hash, |
6034 Register character, | 6034 Register character, |
6035 Register scratch) { | 6035 Register scratch) { |
6036 // hash = character + (character << 10); | 6036 int32_t seed = masm->isolate()->HasherSeed(); |
6037 __ mov(hash, character); | 6037 if (seed != 0) { |
6038 __ shl(hash, 10); | 6038 ASSERT(FLAG_randomize_string_hashes); |
6039 __ add(hash, character); | 6039 // hash = (seed + character) + ((seed + character) << 10); |
| 6040 __ lea(scratch, Operand(character, seed)); |
| 6041 __ shl(scratch, 10); |
| 6042 __ lea(hash, Operand(scratch, character, times_1, seed)); |
| 6043 } else { |
| 6044 ASSERT(!FLAG_randomize_string_hashes); |
| 6045 // hash = character + (character << 10); |
| 6046 __ mov(hash, character); |
| 6047 __ shl(hash, 10); |
| 6048 __ add(hash, character); |
| 6049 } |
6040 // hash ^= hash >> 6; | 6050 // hash ^= hash >> 6; |
6041 __ mov(scratch, hash); | 6051 __ mov(scratch, hash); |
6042 __ shr(scratch, 6); | 6052 __ shr(scratch, 6); |
6043 __ xor_(hash, scratch); | 6053 __ xor_(hash, scratch); |
6044 } | 6054 } |
6045 | 6055 |
6046 | 6056 |
6047 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, | 6057 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, |
6048 Register hash, | 6058 Register hash, |
6049 Register character, | 6059 Register character, |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7332 false); | 7342 false); |
7333 __ pop(edx); | 7343 __ pop(edx); |
7334 __ ret(0); | 7344 __ ret(0); |
7335 } | 7345 } |
7336 | 7346 |
7337 #undef __ | 7347 #undef __ |
7338 | 7348 |
7339 } } // namespace v8::internal | 7349 } } // namespace v8::internal |
7340 | 7350 |
7341 #endif // V8_TARGET_ARCH_IA32 | 7351 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |