[cleanup] Remove unused MacroAssembler::GetNumberHash.
R=yangguo@chromium.org Bug: Change-Id: I1174bd88c252a0c9d16dca270088a0100ac4eb35 Reviewed-on: https://chromium-review.googlesource.com/584869 Commit-Queue: Georg Neis <neis@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#46902}
This commit is contained in:
parent
905aae9af1
commit
9e02f326a0
@ -1765,38 +1765,6 @@ void MacroAssembler::PopStackHandler() {
|
||||
}
|
||||
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
void MacroAssembler::GetNumberHash(Register t0, Register scratch) {
|
||||
// First of all we assign the hash seed to scratch.
|
||||
LoadRoot(scratch, Heap::kHashSeedRootIndex);
|
||||
SmiUntag(scratch);
|
||||
|
||||
// Xor original key with a seed.
|
||||
eor(t0, t0, Operand(scratch));
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync
|
||||
// with ComputeIntegerHash in utils.h.
|
||||
//
|
||||
// hash = ~hash + (hash << 15);
|
||||
mvn(scratch, Operand(t0));
|
||||
add(t0, scratch, Operand(t0, LSL, 15));
|
||||
// hash = hash ^ (hash >> 12);
|
||||
eor(t0, t0, Operand(t0, LSR, 12));
|
||||
// hash = hash + (hash << 2);
|
||||
add(t0, t0, Operand(t0, LSL, 2));
|
||||
// hash = hash ^ (hash >> 4);
|
||||
eor(t0, t0, Operand(t0, LSR, 4));
|
||||
// hash = hash * 2057;
|
||||
mov(scratch, Operand(t0, LSL, 11));
|
||||
add(t0, t0, Operand(t0, LSL, 3));
|
||||
add(t0, t0, scratch);
|
||||
// hash = hash ^ (hash >> 16);
|
||||
eor(t0, t0, Operand(t0, LSR, 16));
|
||||
bic(t0, t0, Operand(0xc0000000u));
|
||||
}
|
||||
|
||||
void MacroAssembler::Allocate(int object_size,
|
||||
Register result,
|
||||
Register scratch1,
|
||||
|
@ -804,8 +804,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support
|
||||
|
||||
void GetNumberHash(Register t0, Register scratch);
|
||||
|
||||
inline void MarkCode(NopMarkerTypes type) {
|
||||
nop(type);
|
||||
}
|
||||
|
@ -3253,41 +3253,6 @@ bool TurboAssembler::AllowThisStubCall(CodeStub* stub) {
|
||||
return has_frame() || !stub->SometimesSetsUpAFrame();
|
||||
}
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
void MacroAssembler::GetNumberHash(Register key, Register scratch) {
|
||||
DCHECK(!AreAliased(key, scratch));
|
||||
|
||||
// Xor original key with a seed.
|
||||
LoadRoot(scratch, Heap::kHashSeedRootIndex);
|
||||
Eor(key, key, Operand::UntagSmi(scratch));
|
||||
|
||||
// The algorithm uses 32-bit integer values.
|
||||
key = key.W();
|
||||
scratch = scratch.W();
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync
|
||||
// with ComputeIntegerHash in utils.h.
|
||||
//
|
||||
// hash = ~hash + (hash <<1 15);
|
||||
Mvn(scratch, key);
|
||||
Add(key, scratch, Operand(key, LSL, 15));
|
||||
// hash = hash ^ (hash >> 12);
|
||||
Eor(key, key, Operand(key, LSR, 12));
|
||||
// hash = hash + (hash << 2);
|
||||
Add(key, key, Operand(key, LSL, 2));
|
||||
// hash = hash ^ (hash >> 4);
|
||||
Eor(key, key, Operand(key, LSR, 4));
|
||||
// hash = hash * 2057;
|
||||
Mov(scratch, Operand(key, LSL, 11));
|
||||
Add(key, key, Operand(key, LSL, 3));
|
||||
Add(key, key, scratch);
|
||||
// hash = hash ^ (hash >> 16);
|
||||
Eor(key, key, Operand(key, LSR, 16));
|
||||
Bic(key, key, Operand(0xc0000000u));
|
||||
}
|
||||
|
||||
void MacroAssembler::RememberedSetHelper(Register object, // For debug tests.
|
||||
Register address,
|
||||
Register scratch1,
|
||||
|
@ -2077,13 +2077,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
Label* if_any_set,
|
||||
Label* fall_through);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support.
|
||||
|
||||
// Hash the interger value in 'key' register.
|
||||
// It uses the same algorithm as ComputeIntegerHash in utils.h.
|
||||
void GetNumberHash(Register key, Register scratch);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Frames.
|
||||
|
||||
|
@ -966,50 +966,6 @@ void MacroAssembler::PopStackHandler() {
|
||||
}
|
||||
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
//
|
||||
// Note: r0 will contain hash code
|
||||
void MacroAssembler::GetNumberHash(Register r0, Register scratch) {
|
||||
// Xor original key with a seed.
|
||||
if (serializer_enabled()) {
|
||||
ExternalReference roots_array_start =
|
||||
ExternalReference::roots_array_start(isolate());
|
||||
mov(scratch, Immediate(Heap::kHashSeedRootIndex));
|
||||
mov(scratch,
|
||||
Operand::StaticArray(scratch, times_pointer_size, roots_array_start));
|
||||
SmiUntag(scratch);
|
||||
xor_(r0, scratch);
|
||||
} else {
|
||||
int32_t seed = isolate()->heap()->HashSeed();
|
||||
xor_(r0, Immediate(seed));
|
||||
}
|
||||
|
||||
// hash = ~hash + (hash << 15);
|
||||
mov(scratch, r0);
|
||||
not_(r0);
|
||||
shl(scratch, 15);
|
||||
add(r0, scratch);
|
||||
// hash = hash ^ (hash >> 12);
|
||||
mov(scratch, r0);
|
||||
shr(scratch, 12);
|
||||
xor_(r0, scratch);
|
||||
// hash = hash + (hash << 2);
|
||||
lea(r0, Operand(r0, r0, times_4, 0));
|
||||
// hash = hash ^ (hash >> 4);
|
||||
mov(scratch, r0);
|
||||
shr(scratch, 4);
|
||||
xor_(r0, scratch);
|
||||
// hash = hash * 2057;
|
||||
imul(r0, r0, 2057);
|
||||
// hash = hash ^ (hash >> 16);
|
||||
mov(scratch, r0);
|
||||
shr(scratch, 16);
|
||||
xor_(r0, scratch);
|
||||
and_(r0, 0x3fffffff);
|
||||
}
|
||||
|
||||
void MacroAssembler::LoadAllocationTopHelper(Register result,
|
||||
Register scratch,
|
||||
AllocationFlags flags) {
|
||||
|
@ -688,11 +688,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// Unlink the stack handler on top of the stack from the stack handler chain.
|
||||
void PopStackHandler();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support
|
||||
|
||||
void GetNumberHash(Register r0, Register scratch);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Allocation support
|
||||
|
||||
|
@ -408,50 +408,6 @@ void MacroAssembler::RememberedSetHelper(Register object, // For debug tests.
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Allocation support.
|
||||
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
void MacroAssembler::GetNumberHash(Register reg0, Register scratch) {
|
||||
// First of all we assign the hash seed to scratch.
|
||||
LoadRoot(scratch, Heap::kHashSeedRootIndex);
|
||||
SmiUntag(scratch);
|
||||
|
||||
// Xor original key with a seed.
|
||||
xor_(reg0, reg0, scratch);
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync
|
||||
// with ComputeIntegerHash in utils.h.
|
||||
//
|
||||
// hash = ~hash + (hash << 15);
|
||||
nor(scratch, reg0, zero_reg);
|
||||
Lsa(reg0, scratch, reg0, 15);
|
||||
|
||||
// hash = hash ^ (hash >> 12);
|
||||
srl(at, reg0, 12);
|
||||
xor_(reg0, reg0, at);
|
||||
|
||||
// hash = hash + (hash << 2);
|
||||
Lsa(reg0, reg0, reg0, 2);
|
||||
|
||||
// hash = hash ^ (hash >> 4);
|
||||
srl(at, reg0, 4);
|
||||
xor_(reg0, reg0, at);
|
||||
|
||||
// hash = hash * 2057;
|
||||
sll(scratch, reg0, 11);
|
||||
Lsa(reg0, reg0, reg0, 3);
|
||||
addu(reg0, reg0, scratch);
|
||||
|
||||
// hash = hash ^ (hash >> 16);
|
||||
srl(at, reg0, 16);
|
||||
xor_(reg0, reg0, at);
|
||||
And(reg0, reg0, Operand(0x3fffffff));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Instruction macros.
|
||||
|
||||
|
@ -1012,8 +1012,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support.
|
||||
|
||||
void GetNumberHash(Register reg0, Register scratch);
|
||||
|
||||
inline void MarkCode(NopMarkerTypes type) { nop(type); }
|
||||
|
||||
// Check if the given instruction is a 'type' marker.
|
||||
|
@ -423,51 +423,6 @@ void MacroAssembler::RememberedSetHelper(Register object, // For debug tests.
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Allocation support.
|
||||
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
void MacroAssembler::GetNumberHash(Register reg0, Register scratch) {
|
||||
// First of all we assign the hash seed to scratch.
|
||||
LoadRoot(scratch, Heap::kHashSeedRootIndex);
|
||||
SmiUntag(scratch);
|
||||
|
||||
// Xor original key with a seed.
|
||||
xor_(reg0, reg0, scratch);
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync
|
||||
// with ComputeIntegerHash in utils.h.
|
||||
//
|
||||
// hash = ~hash + (hash << 15);
|
||||
// The algorithm uses 32-bit integer values.
|
||||
nor(scratch, reg0, zero_reg);
|
||||
Lsa(reg0, scratch, reg0, 15);
|
||||
|
||||
// hash = hash ^ (hash >> 12);
|
||||
srl(at, reg0, 12);
|
||||
xor_(reg0, reg0, at);
|
||||
|
||||
// hash = hash + (hash << 2);
|
||||
Lsa(reg0, reg0, reg0, 2);
|
||||
|
||||
// hash = hash ^ (hash >> 4);
|
||||
srl(at, reg0, 4);
|
||||
xor_(reg0, reg0, at);
|
||||
|
||||
// hash = hash * 2057;
|
||||
sll(scratch, reg0, 11);
|
||||
Lsa(reg0, reg0, reg0, 3);
|
||||
addu(reg0, reg0, scratch);
|
||||
|
||||
// hash = hash ^ (hash >> 16);
|
||||
srl(at, reg0, 16);
|
||||
xor_(reg0, reg0, at);
|
||||
And(reg0, reg0, Operand(0x3fffffff));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Instruction macros.
|
||||
|
||||
|
@ -1080,8 +1080,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support.
|
||||
|
||||
void GetNumberHash(Register reg0, Register scratch);
|
||||
|
||||
inline void MarkCode(NopMarkerTypes type) { nop(type); }
|
||||
|
||||
// Check if the given instruction is a 'type' marker.
|
||||
|
@ -1516,46 +1516,6 @@ void MacroAssembler::PopStackHandler() {
|
||||
}
|
||||
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
void MacroAssembler::GetNumberHash(Register t0, Register scratch) {
|
||||
// First of all we assign the hash seed to scratch.
|
||||
LoadRoot(scratch, Heap::kHashSeedRootIndex);
|
||||
SmiUntag(scratch);
|
||||
|
||||
// Xor original key with a seed.
|
||||
xor_(t0, t0, scratch);
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync
|
||||
// with ComputeIntegerHash in utils.h.
|
||||
//
|
||||
// hash = ~hash + (hash << 15);
|
||||
notx(scratch, t0);
|
||||
slwi(t0, t0, Operand(15));
|
||||
add(t0, scratch, t0);
|
||||
// hash = hash ^ (hash >> 12);
|
||||
srwi(scratch, t0, Operand(12));
|
||||
xor_(t0, t0, scratch);
|
||||
// hash = hash + (hash << 2);
|
||||
slwi(scratch, t0, Operand(2));
|
||||
add(t0, t0, scratch);
|
||||
// hash = hash ^ (hash >> 4);
|
||||
srwi(scratch, t0, Operand(4));
|
||||
xor_(t0, t0, scratch);
|
||||
// hash = hash * 2057;
|
||||
mr(r0, t0);
|
||||
slwi(scratch, t0, Operand(3));
|
||||
add(t0, t0, scratch);
|
||||
slwi(scratch, r0, Operand(11));
|
||||
add(t0, t0, scratch);
|
||||
// hash = hash ^ (hash >> 16);
|
||||
srwi(scratch, t0, Operand(16));
|
||||
xor_(t0, t0, scratch);
|
||||
// hash & 0x3fffffff
|
||||
ExtractBitRange(t0, t0, 29, 0);
|
||||
}
|
||||
|
||||
void MacroAssembler::Allocate(int object_size, Register result,
|
||||
Register scratch1, Register scratch2,
|
||||
Label* gc_required, AllocationFlags flags) {
|
||||
|
@ -873,8 +873,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support
|
||||
|
||||
void GetNumberHash(Register t0, Register scratch);
|
||||
|
||||
inline void MarkCode(NopMarkerTypes type) { nop(type); }
|
||||
|
||||
// Check if the given instruction is a 'type' marker.
|
||||
@ -886,7 +884,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
return IsNop(instr, type);
|
||||
}
|
||||
|
||||
|
||||
static inline int GetCodeMarker(Instr instr) {
|
||||
int dst_reg_offset = 12;
|
||||
int dst_mask = 0xf << dst_reg_offset;
|
||||
|
@ -1480,47 +1480,6 @@ void MacroAssembler::PopStackHandler() {
|
||||
StoreP(r3, MemOperand(ip));
|
||||
}
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
void MacroAssembler::GetNumberHash(Register t0, Register scratch) {
|
||||
// First of all we assign the hash seed to scratch.
|
||||
LoadRoot(scratch, Heap::kHashSeedRootIndex);
|
||||
SmiUntag(scratch);
|
||||
|
||||
// Xor original key with a seed.
|
||||
XorP(t0, scratch);
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync
|
||||
// with ComputeIntegerHash in utils.h.
|
||||
//
|
||||
// hash = ~hash + (hash << 15);
|
||||
LoadRR(scratch, t0);
|
||||
NotP(scratch);
|
||||
sll(t0, Operand(15));
|
||||
AddP(t0, scratch, t0);
|
||||
// hash = hash ^ (hash >> 12);
|
||||
ShiftRight(scratch, t0, Operand(12));
|
||||
XorP(t0, scratch);
|
||||
// hash = hash + (hash << 2);
|
||||
ShiftLeft(scratch, t0, Operand(2));
|
||||
AddP(t0, t0, scratch);
|
||||
// hash = hash ^ (hash >> 4);
|
||||
ShiftRight(scratch, t0, Operand(4));
|
||||
XorP(t0, scratch);
|
||||
// hash = hash * 2057;
|
||||
LoadRR(r0, t0);
|
||||
ShiftLeft(scratch, t0, Operand(3));
|
||||
AddP(t0, t0, scratch);
|
||||
ShiftLeft(scratch, r0, Operand(11));
|
||||
AddP(t0, t0, scratch);
|
||||
// hash = hash ^ (hash >> 16);
|
||||
ShiftRight(scratch, t0, Operand(16));
|
||||
XorP(t0, scratch);
|
||||
// hash & 0x3fffffff
|
||||
ExtractBitRange(t0, t0, 29, 0);
|
||||
}
|
||||
|
||||
void MacroAssembler::Allocate(int object_size, Register result,
|
||||
Register scratch1, Register scratch2,
|
||||
Label* gc_required, AllocationFlags flags) {
|
||||
|
@ -1233,8 +1233,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support
|
||||
|
||||
void GetNumberHash(Register t0, Register scratch);
|
||||
|
||||
inline void MarkCode(NopMarkerTypes type) { nop(type); }
|
||||
|
||||
// Check if the given instruction is a 'type' marker.
|
||||
|
@ -4046,44 +4046,6 @@ void MacroAssembler::LeaveExitFrameEpilogue(bool restore_context) {
|
||||
}
|
||||
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync with
|
||||
// ComputeIntegerHash in utils.h and KeyedLoadGenericStub in
|
||||
// code-stub-hydrogen.cc
|
||||
void MacroAssembler::GetNumberHash(Register r0, Register scratch) {
|
||||
// First of all we assign the hash seed to scratch.
|
||||
LoadRoot(scratch, Heap::kHashSeedRootIndex);
|
||||
SmiToInteger32(scratch, scratch);
|
||||
|
||||
// Xor original key with a seed.
|
||||
xorl(r0, scratch);
|
||||
|
||||
// Compute the hash code from the untagged key. This must be kept in sync
|
||||
// with ComputeIntegerHash in utils.h.
|
||||
//
|
||||
// hash = ~hash + (hash << 15);
|
||||
movl(scratch, r0);
|
||||
notl(r0);
|
||||
shll(scratch, Immediate(15));
|
||||
addl(r0, scratch);
|
||||
// hash = hash ^ (hash >> 12);
|
||||
movl(scratch, r0);
|
||||
shrl(scratch, Immediate(12));
|
||||
xorl(r0, scratch);
|
||||
// hash = hash + (hash << 2);
|
||||
leal(r0, Operand(r0, r0, times_4, 0));
|
||||
// hash = hash ^ (hash >> 4);
|
||||
movl(scratch, r0);
|
||||
shrl(scratch, Immediate(4));
|
||||
xorl(r0, scratch);
|
||||
// hash = hash * 2057;
|
||||
imull(r0, r0, Immediate(2057));
|
||||
// hash = hash ^ (hash >> 16);
|
||||
movl(scratch, r0);
|
||||
shrl(scratch, Immediate(16));
|
||||
xorl(r0, scratch);
|
||||
andl(r0, Immediate(0x3fffffff));
|
||||
}
|
||||
|
||||
void MacroAssembler::LoadAllocationTopHelper(Register result,
|
||||
Register scratch,
|
||||
AllocationFlags flags) {
|
||||
|
@ -1265,11 +1265,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// Unlink the stack handler on top of the stack from the stack handler chain.
|
||||
void PopStackHandler();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inline caching support
|
||||
|
||||
void GetNumberHash(Register r0, Register scratch);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Allocation support
|
||||
|
||||
|
@ -144,7 +144,6 @@ v8_executable("cctest") {
|
||||
"test-func-name-inference.cc",
|
||||
"test-global-handles.cc",
|
||||
"test-global-object.cc",
|
||||
"test-hashing.cc",
|
||||
"test-hashmap.cc",
|
||||
"test-heap-profiler.cc",
|
||||
"test-identity-map.cc",
|
||||
|
@ -162,7 +162,6 @@
|
||||
'test-func-name-inference.cc',
|
||||
'test-global-handles.cc',
|
||||
'test-global-object.cc',
|
||||
'test-hashing.cc',
|
||||
'test-hashmap.cc',
|
||||
'test-heap-profiler.cc',
|
||||
'test-identity-map.cc',
|
||||
|
@ -1,173 +0,0 @@
|
||||
// Copyright 2011 the V8 project authors. All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/factory.h"
|
||||
#include "src/macro-assembler-inl.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/v8.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
|
||||
#ifdef USE_SIMULATOR
|
||||
#include "src/simulator.h"
|
||||
#endif
|
||||
|
||||
using namespace v8::internal;
|
||||
|
||||
|
||||
typedef uint32_t (*HASH_FUNCTION)();
|
||||
|
||||
#define __ masm->
|
||||
|
||||
|
||||
void generate(MacroAssembler* masm, uint32_t key) {
|
||||
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
|
||||
__ push(ebx);
|
||||
__ mov(eax, Immediate(key));
|
||||
__ GetNumberHash(eax, ebx);
|
||||
__ pop(ebx);
|
||||
__ Ret();
|
||||
#elif V8_TARGET_ARCH_X64
|
||||
__ pushq(kRootRegister);
|
||||
__ InitializeRootRegister();
|
||||
__ pushq(rbx);
|
||||
__ movp(rax, Immediate(key));
|
||||
__ GetNumberHash(rax, rbx);
|
||||
__ popq(rbx);
|
||||
__ popq(kRootRegister);
|
||||
__ Ret();
|
||||
#elif V8_TARGET_ARCH_ARM
|
||||
__ push(kRootRegister);
|
||||
__ InitializeRootRegister();
|
||||
__ mov(r0, Operand(key));
|
||||
__ GetNumberHash(r0, ip);
|
||||
__ pop(kRootRegister);
|
||||
__ mov(pc, Operand(lr));
|
||||
#elif V8_TARGET_ARCH_ARM64
|
||||
// The ARM64 assembler usually uses jssp (x28) as a stack pointer, but only
|
||||
// csp is initialized by the calling (C++) code.
|
||||
Register old_stack_pointer = __ StackPointer();
|
||||
__ SetStackPointer(csp);
|
||||
__ Push(root, xzr);
|
||||
__ InitializeRootRegister();
|
||||
__ Mov(x0, key);
|
||||
__ GetNumberHash(x0, x10);
|
||||
__ Pop(xzr, root);
|
||||
__ Ret();
|
||||
__ SetStackPointer(old_stack_pointer);
|
||||
#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
|
||||
__ push(kRootRegister);
|
||||
__ InitializeRootRegister();
|
||||
__ li(v0, Operand(key));
|
||||
__ GetNumberHash(v0, t1);
|
||||
__ pop(kRootRegister);
|
||||
__ jr(ra);
|
||||
__ nop();
|
||||
#elif V8_TARGET_ARCH_S390
|
||||
__ push(kRootRegister);
|
||||
__ push(ip);
|
||||
__ InitializeRootRegister();
|
||||
__ lhi(r2, Operand(key));
|
||||
__ GetNumberHash(r2, ip);
|
||||
__ pop(ip);
|
||||
__ pop(kRootRegister);
|
||||
__ Ret();
|
||||
#elif V8_TARGET_ARCH_PPC
|
||||
__ function_descriptor();
|
||||
__ push(kRootRegister);
|
||||
__ InitializeRootRegister();
|
||||
__ li(r3, Operand(key));
|
||||
__ GetNumberHash(r3, ip);
|
||||
__ pop(kRootRegister);
|
||||
__ blr();
|
||||
#else
|
||||
#error Unsupported architecture.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void check(uint32_t key) {
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
Factory* factory = isolate->factory();
|
||||
HandleScope scope(isolate);
|
||||
|
||||
v8::internal::byte buffer[2048];
|
||||
MacroAssembler masm(CcTest::i_isolate(), buffer, sizeof(buffer),
|
||||
v8::internal::CodeObjectRequired::kYes);
|
||||
|
||||
generate(&masm, key);
|
||||
|
||||
CodeDesc desc;
|
||||
masm.GetCode(isolate, &desc);
|
||||
Handle<Object> undefined(isolate->heap()->undefined_value(), isolate);
|
||||
Handle<Code> code = factory->NewCode(desc,
|
||||
Code::ComputeFlags(Code::STUB),
|
||||
undefined);
|
||||
CHECK(code->IsCode());
|
||||
|
||||
HASH_FUNCTION hash = FUNCTION_CAST<HASH_FUNCTION>(code->entry());
|
||||
#ifdef USE_SIMULATOR
|
||||
uint32_t codegen_hash = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(
|
||||
CALL_GENERATED_CODE(isolate, hash, 0, 0, 0, 0, 0)));
|
||||
#else
|
||||
uint32_t codegen_hash = hash();
|
||||
#endif
|
||||
|
||||
uint32_t runtime_hash = ComputeIntegerHash(key, isolate->heap()->HashSeed());
|
||||
CHECK_EQ(runtime_hash, codegen_hash);
|
||||
}
|
||||
|
||||
|
||||
static uint32_t PseudoRandom(uint32_t i, uint32_t j) {
|
||||
return ~(~((i * 781) ^ (j * 329)));
|
||||
}
|
||||
|
||||
|
||||
TEST(NumberHash) {
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Context::Scope context_scope(v8::Context::New(isolate));
|
||||
|
||||
// Some specific numbers
|
||||
for (uint32_t key = 0; key < 42; key += 7) {
|
||||
check(key);
|
||||
}
|
||||
|
||||
// Some pseudo-random numbers
|
||||
static const uint32_t kLimit = 1000;
|
||||
for (uint32_t i = 0; i < 5; i++) {
|
||||
for (uint32_t j = 0; j < 5; j++) {
|
||||
check(PseudoRandom(i, j) % kLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef __
|
Loading…
Reference in New Issue
Block a user