| 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 #if V8_TARGET_ARCH_IA32 | 54 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 __ pop(kRootRegister); | 129 __ pop(kRootRegister); |
| 130 __ jr(ra); | 130 __ jr(ra); |
| 131 __ nop(); | 131 __ nop(); |
| 132 #else | 132 #else |
| 133 #error Unsupported architecture. | 133 #error Unsupported architecture. |
| 134 #endif | 134 #endif |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 void generate(MacroAssembler* masm, uint32_t key) { | 138 void generate(MacroAssembler* masm, uint32_t key) { |
| 139 #if V8_TARGET_ARCH_IA32 | 139 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
| 140 __ push(ebx); | 140 __ push(ebx); |
| 141 __ mov(eax, Immediate(key)); | 141 __ mov(eax, Immediate(key)); |
| 142 __ GetNumberHash(eax, ebx); | 142 __ GetNumberHash(eax, ebx); |
| 143 __ pop(ebx); | 143 __ pop(ebx); |
| 144 __ Ret(); | 144 __ Ret(); |
| 145 #elif V8_TARGET_ARCH_X64 | 145 #elif V8_TARGET_ARCH_X64 |
| 146 __ pushq(kRootRegister); | 146 __ pushq(kRootRegister); |
| 147 __ InitializeRootRegister(); | 147 __ InitializeRootRegister(); |
| 148 __ pushq(rbx); | 148 __ pushq(rbx); |
| 149 __ movp(rax, Immediate(key)); | 149 __ movp(rax, Immediate(key)); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // Some pseudo-random numbers | 298 // Some pseudo-random numbers |
| 299 static const uint32_t kLimit = 1000; | 299 static const uint32_t kLimit = 1000; |
| 300 for (uint32_t i = 0; i < 5; i++) { | 300 for (uint32_t i = 0; i < 5; i++) { |
| 301 for (uint32_t j = 0; j < 5; j++) { | 301 for (uint32_t j = 0; j < 5; j++) { |
| 302 check(PseudoRandom(i, j) % kLimit); | 302 check(PseudoRandom(i, j) % kLimit); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 | 306 |
| 307 #undef __ | 307 #undef __ |
| OLD | NEW |