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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 typedef uint32_t (*HASH_FUNCTION)(); | 45 typedef uint32_t (*HASH_FUNCTION)(); |
46 | 46 |
47 #define __ masm-> | 47 #define __ masm-> |
48 | 48 |
49 | 49 |
50 void generate(MacroAssembler* masm, i::Vector<const uint8_t> string) { | 50 void generate(MacroAssembler* masm, i::Vector<const uint8_t> string) { |
51 // GenerateHashInit takes the first character as an argument so it can't | 51 // GenerateHashInit takes the first character as an argument so it can't |
52 // handle the zero length string. | 52 // handle the zero length string. |
53 ASSERT(string.length() > 0); | 53 ASSERT(string.length() > 0); |
54 #ifdef V8_TARGET_ARCH_IA32 | 54 #if V8_TARGET_ARCH_IA32 |
55 __ push(ebx); | 55 __ push(ebx); |
56 __ push(ecx); | 56 __ push(ecx); |
57 __ mov(eax, Immediate(0)); | 57 __ mov(eax, Immediate(0)); |
58 __ mov(ebx, Immediate(string.at(0))); | 58 __ mov(ebx, Immediate(string.at(0))); |
59 StringHelper::GenerateHashInit(masm, eax, ebx, ecx); | 59 StringHelper::GenerateHashInit(masm, eax, ebx, ecx); |
60 for (int i = 1; i < string.length(); i++) { | 60 for (int i = 1; i < string.length(); i++) { |
61 __ mov(ebx, Immediate(string.at(i))); | 61 __ mov(ebx, Immediate(string.at(i))); |
62 StringHelper::GenerateHashAddCharacter(masm, eax, ebx, ecx); | 62 StringHelper::GenerateHashAddCharacter(masm, eax, ebx, ecx); |
63 } | 63 } |
64 StringHelper::GenerateHashGetHash(masm, eax, ecx); | 64 StringHelper::GenerateHashGetHash(masm, eax, ecx); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 StringHelper::GenerateHashGetHash(masm, v0); | 110 StringHelper::GenerateHashGetHash(masm, v0); |
111 __ pop(kRootRegister); | 111 __ pop(kRootRegister); |
112 __ jr(ra); | 112 __ jr(ra); |
113 __ nop(); | 113 __ nop(); |
114 #endif | 114 #endif |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 void generate(MacroAssembler* masm, uint32_t key) { | 118 void generate(MacroAssembler* masm, uint32_t key) { |
119 #ifdef V8_TARGET_ARCH_IA32 | 119 #if V8_TARGET_ARCH_IA32 |
120 __ push(ebx); | 120 __ push(ebx); |
121 __ mov(eax, Immediate(key)); | 121 __ mov(eax, Immediate(key)); |
122 __ GetNumberHash(eax, ebx); | 122 __ GetNumberHash(eax, ebx); |
123 __ pop(ebx); | 123 __ pop(ebx); |
124 __ Ret(); | 124 __ Ret(); |
125 #elif V8_TARGET_ARCH_X64 | 125 #elif V8_TARGET_ARCH_X64 |
126 __ push(kRootRegister); | 126 __ push(kRootRegister); |
127 __ InitializeRootRegister(); | 127 __ InitializeRootRegister(); |
128 __ push(rbx); | 128 __ push(rbx); |
129 __ movq(rax, Immediate(key)); | 129 __ movq(rax, Immediate(key)); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // Some pseudo-random numbers | 263 // Some pseudo-random numbers |
264 static const uint32_t kLimit = 1000; | 264 static const uint32_t kLimit = 1000; |
265 for (uint32_t i = 0; i < 5; i++) { | 265 for (uint32_t i = 0; i < 5; i++) { |
266 for (uint32_t j = 0; j < 5; j++) { | 266 for (uint32_t j = 0; j < 5; j++) { |
267 check(PseudoRandom(i, j) % kLimit); | 267 check(PseudoRandom(i, j) % kLimit); |
268 } | 268 } |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 #undef __ | 272 #undef __ |
OLD | NEW |