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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 8512004: Fixing generated hash function on all platforms. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 | « src/mips/code-stubs-mips.h ('k') | src/x64/code-stubs-x64.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 5444 matching lines...) Expand 10 before | Expand all | Expand 10 after
5455 5455
5456 5456
5457 void StringCharAtGenerator::GenerateSlow( 5457 void StringCharAtGenerator::GenerateSlow(
5458 MacroAssembler* masm, 5458 MacroAssembler* masm,
5459 const RuntimeCallHelper& call_helper) { 5459 const RuntimeCallHelper& call_helper) {
5460 char_code_at_generator_.GenerateSlow(masm, call_helper); 5460 char_code_at_generator_.GenerateSlow(masm, call_helper);
5461 char_from_code_generator_.GenerateSlow(masm, call_helper); 5461 char_from_code_generator_.GenerateSlow(masm, call_helper);
5462 } 5462 }
5463 5463
5464 5464
5465 class StringHelper : public AllStatic {
5466 public:
5467 // Generate code for copying characters using a simple loop. This should only
5468 // be used in places where the number of characters is small and the
5469 // additional setup and checking in GenerateCopyCharactersLong adds too much
5470 // overhead. Copying of overlapping regions is not supported.
5471 // Dest register ends at the position after the last character written.
5472 static void GenerateCopyCharacters(MacroAssembler* masm,
5473 Register dest,
5474 Register src,
5475 Register count,
5476 Register scratch,
5477 bool ascii);
5478
5479 // Generate code for copying a large number of characters. This function
5480 // is allowed to spend extra time setting up conditions to make copying
5481 // faster. Copying of overlapping regions is not supported.
5482 // Dest register ends at the position after the last character written.
5483 static void GenerateCopyCharactersLong(MacroAssembler* masm,
5484 Register dest,
5485 Register src,
5486 Register count,
5487 Register scratch1,
5488 Register scratch2,
5489 Register scratch3,
5490 Register scratch4,
5491 Register scratch5,
5492 int flags);
5493
5494
5495 // Probe the symbol table for a two character string. If the string is
5496 // not found by probing a jump to the label not_found is performed. This jump
5497 // does not guarantee that the string is not in the symbol table. If the
5498 // string is found the code falls through with the string in register r0.
5499 // Contents of both c1 and c2 registers are modified. At the exit c1 is
5500 // guaranteed to contain halfword with low and high bytes equal to
5501 // initial contents of c1 and c2 respectively.
5502 static void GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm,
5503 Register c1,
5504 Register c2,
5505 Register scratch1,
5506 Register scratch2,
5507 Register scratch3,
5508 Register scratch4,
5509 Register scratch5,
5510 Label* not_found);
5511
5512 // Generate string hash.
5513 static void GenerateHashInit(MacroAssembler* masm,
5514 Register hash,
5515 Register character);
5516
5517 static void GenerateHashAddCharacter(MacroAssembler* masm,
5518 Register hash,
5519 Register character);
5520
5521 static void GenerateHashGetHash(MacroAssembler* masm,
5522 Register hash);
5523
5524 private:
5525 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
5526 };
5527
5528
5529 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, 5465 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm,
5530 Register dest, 5466 Register dest,
5531 Register src, 5467 Register src,
5532 Register count, 5468 Register count,
5533 Register scratch, 5469 Register scratch,
5534 bool ascii) { 5470 bool ascii) {
5535 Label loop; 5471 Label loop;
5536 Label done; 5472 Label done;
5537 // This loop just copies one character at a time, as it is only used for 5473 // This loop just copies one character at a time, as it is only used for
5538 // very short strings. 5474 // very short strings.
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
5812 } 5748 }
5813 5749
5814 5750
5815 void StringHelper::GenerateHashInit(MacroAssembler* masm, 5751 void StringHelper::GenerateHashInit(MacroAssembler* masm,
5816 Register hash, 5752 Register hash,
5817 Register character) { 5753 Register character) {
5818 // hash = character + (character << 10); 5754 // hash = character + (character << 10);
5819 __ sll(hash, character, 10); 5755 __ sll(hash, character, 10);
5820 __ addu(hash, hash, character); 5756 __ addu(hash, hash, character);
5821 // hash ^= hash >> 6; 5757 // hash ^= hash >> 6;
5822 __ sra(at, hash, 6); 5758 __ srl(at, hash, 6);
5823 __ xor_(hash, hash, at); 5759 __ xor_(hash, hash, at);
5824 } 5760 }
5825 5761
5826 5762
5827 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, 5763 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm,
5828 Register hash, 5764 Register hash,
5829 Register character) { 5765 Register character) {
5830 // hash += character; 5766 // hash += character;
5831 __ addu(hash, hash, character); 5767 __ addu(hash, hash, character);
5832 // hash += hash << 10; 5768 // hash += hash << 10;
5833 __ sll(at, hash, 10); 5769 __ sll(at, hash, 10);
5834 __ addu(hash, hash, at); 5770 __ addu(hash, hash, at);
5835 // hash ^= hash >> 6; 5771 // hash ^= hash >> 6;
5836 __ sra(at, hash, 6); 5772 __ srl(at, hash, 6);
5837 __ xor_(hash, hash, at); 5773 __ xor_(hash, hash, at);
5838 } 5774 }
5839 5775
5840 5776
5841 void StringHelper::GenerateHashGetHash(MacroAssembler* masm, 5777 void StringHelper::GenerateHashGetHash(MacroAssembler* masm,
5842 Register hash) { 5778 Register hash) {
5843 // hash += hash << 3; 5779 // hash += hash << 3;
5844 __ sll(at, hash, 3); 5780 __ sll(at, hash, 3);
5845 __ addu(hash, hash, at); 5781 __ addu(hash, hash, at);
5846 // hash ^= hash >> 11; 5782 // hash ^= hash >> 11;
5847 __ sra(at, hash, 11); 5783 __ srl(at, hash, 11);
5848 __ xor_(hash, hash, at); 5784 __ xor_(hash, hash, at);
5849 // hash += hash << 15; 5785 // hash += hash << 15;
5850 __ sll(at, hash, 15); 5786 __ sll(at, hash, 15);
5851 __ addu(hash, hash, at); 5787 __ addu(hash, hash, at);
5852 5788
5789 uint32_t kHashShiftCutOffMask = (1 << (32 - String::kHashShift)) - 1;
5790 __ li(at, Operand(kHashShiftCutOffMask));
5791 __ and_(hash, hash, at);
5792
5853 // if (hash == 0) hash = 27; 5793 // if (hash == 0) hash = 27;
5854 __ ori(at, zero_reg, 27); 5794 __ ori(at, zero_reg, 27);
5855 __ movz(hash, at, hash); 5795 __ movz(hash, at, hash);
5856 } 5796 }
5857 5797
5858 5798
5859 void SubStringStub::Generate(MacroAssembler* masm) { 5799 void SubStringStub::Generate(MacroAssembler* masm) {
5860 Label sub_string_runtime; 5800 Label sub_string_runtime;
5861 // Stack frame on entry. 5801 // Stack frame on entry.
5862 // ra: return address 5802 // ra: return address
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
7459 7399
7460 // Fall through when we need to inform the incremental marker. 7400 // Fall through when we need to inform the incremental marker.
7461 } 7401 }
7462 7402
7463 7403
7464 #undef __ 7404 #undef __
7465 7405
7466 } } // namespace v8::internal 7406 } } // namespace v8::internal
7467 7407
7468 #endif // V8_TARGET_ARCH_MIPS 7408 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698