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: src/x64/code-stubs-x64.cc

Issue 9086006: Randomize the seed used for string hashing. This helps guard against (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 11 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
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 4940 matching lines...) Expand 10 before | Expand all | Expand 10 after
4951 if (!result.is(rax)) { 4951 if (!result.is(rax)) {
4952 __ movq(rax, result); 4952 __ movq(rax, result);
4953 } 4953 }
4954 } 4954 }
4955 4955
4956 4956
4957 void StringHelper::GenerateHashInit(MacroAssembler* masm, 4957 void StringHelper::GenerateHashInit(MacroAssembler* masm,
4958 Register hash, 4958 Register hash,
4959 Register character, 4959 Register character,
4960 Register scratch) { 4960 Register scratch) {
4961 // hash = character + (character << 10); 4961 // hash = (seed + character) + ((seed + character) << 10);
4962 __ movl(hash, character); 4962 __ LoadRoot(scratch, Heap::kStringHashSeedRootIndex);
4963 __ shll(hash, Immediate(10)); 4963 __ SmiToInteger32(scratch, scratch);
4964 __ addl(hash, character); 4964 __ addl(scratch, character);
4965 __ movl(hash, scratch);
4966 __ shll(scratch, Immediate(10));
4967 __ addl(hash, scratch);
4965 // hash ^= hash >> 6; 4968 // hash ^= hash >> 6;
4966 __ movl(scratch, hash); 4969 __ movl(scratch, hash);
4967 __ shrl(scratch, Immediate(6)); 4970 __ shrl(scratch, Immediate(6));
4968 __ xorl(hash, scratch); 4971 __ xorl(hash, scratch);
4969 } 4972 }
4970 4973
4971 4974
4972 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, 4975 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm,
4973 Register hash, 4976 Register hash,
4974 Register character, 4977 Register character,
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
6231 xmm0, 6234 xmm0,
6232 &slow_elements); 6235 &slow_elements);
6233 __ ret(0); 6236 __ ret(0);
6234 } 6237 }
6235 6238
6236 #undef __ 6239 #undef __
6237 6240
6238 } } // namespace v8::internal 6241 } } // namespace v8::internal
6239 6242
6240 #endif // V8_TARGET_ARCH_X64 6243 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698