Fix test-hashing after recent changes to string hashing.

Acriave test-hashing in SCons and buildbot runs.
Small cleanups in root register handling on ARM and MIPS.
Review URL: http://codereview.chromium.org/9110029

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10351 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2012-01-06 11:33:20 +00:00
parent c4d3a110a2
commit 4bea3b5c54
11 changed files with 64 additions and 59 deletions

View File

@ -1082,10 +1082,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Set up the context from the function argument.
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
// Set up the roots register.
ExternalReference roots_array_start =
ExternalReference::roots_array_start(masm->isolate());
__ mov(r10, Operand(roots_array_start));
__ InitializeRootRegister();
// Push the function and the receiver onto the stack.
__ push(r1);

View File

@ -723,10 +723,7 @@ void Deoptimizer::EntryGenerator::Generate() {
__ pop(ip); // remove sp
__ pop(ip); // remove lr
// Set up the roots register.
ExternalReference roots_array_start =
ExternalReference::roots_array_start(isolate);
__ mov(r10, Operand(roots_array_start));
__ InitializeRootRegister();
__ pop(ip); // remove pc
__ pop(r7); // get continuation, leave pc on stack

View File

@ -396,14 +396,14 @@ void MacroAssembler::Usat(Register dst, int satpos, const Operand& src,
void MacroAssembler::LoadRoot(Register destination,
Heap::RootListIndex index,
Condition cond) {
ldr(destination, MemOperand(roots, index << kPointerSizeLog2), cond);
ldr(destination, MemOperand(kRootRegister, index << kPointerSizeLog2), cond);
}
void MacroAssembler::StoreRoot(Register source,
Heap::RootListIndex index,
Condition cond) {
str(source, MemOperand(roots, index << kPointerSizeLog2), cond);
str(source, MemOperand(kRootRegister, index << kPointerSizeLog2), cond);
}

View File

@ -52,7 +52,7 @@ inline Operand SmiUntagOperand(Register object) {
// Give alias names to registers
const Register cp = { 8 }; // JavaScript context pointer
const Register roots = { 10 }; // Roots array pointer.
const Register kRootRegister = { 10 }; // Roots array pointer.
// Flags used for the AllocateInNewSpace functions.
enum AllocationFlags {
@ -499,6 +499,12 @@ class MacroAssembler: public Assembler {
Register map,
Register scratch);
void InitializeRootRegister() {
ExternalReference roots_array_start =
ExternalReference::roots_array_start(isolate());
mov(kRootRegister, Operand(roots_array_start));
}
// ---------------------------------------------------------------------------
// JavaScript invokes

View File

@ -1114,10 +1114,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Set up the context from the function argument.
__ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// Set up the roots register.
ExternalReference roots_array_start =
ExternalReference::roots_array_start(masm->isolate());
__ li(s6, Operand(roots_array_start));
__ InitializeRootRegister();
// Push the function and the receiver onto the stack.
__ Push(a1, a2);

View File

@ -733,10 +733,7 @@ void Deoptimizer::EntryGenerator::Generate() {
}
}
// Set up the roots register.
ExternalReference roots_array_start =
ExternalReference::roots_array_start(isolate);
__ li(roots, Operand(roots_array_start));
__ InitializeRootRegister();
__ pop(at); // Get continuation, leave pc on stack.
__ pop(ra);

View File

@ -148,9 +148,9 @@ class LCodeGen BASE_EMBEDDED {
Scope* scope() const { return scope_; }
HGraph* graph() const { return chunk_->graph(); }
Register scratch0() { return lithiumScratchReg; }
Register scratch1() { return lithiumScratchReg2; }
DoubleRegister double_scratch0() { return lithiumScratchDouble; }
Register scratch0() { return kLithiumScratchReg; }
Register scratch1() { return kLithiumScratchReg2; }
DoubleRegister double_scratch0() { return kLithiumScratchDouble; }
int GetNextEmittedBlock(int block);
LInstruction* GetNextInstruction();

View File

@ -33,8 +33,8 @@
namespace v8 {
namespace internal {
static const Register kSavedValueRegister = lithiumScratchReg;
static const DoubleRegister kSavedDoubleValueRegister = lithiumScratchDouble;
static const Register kSavedValueRegister = kLithiumScratchReg;
static const DoubleRegister kSavedDoubleValueRegister = kLithiumScratchDouble;
LGapResolver::LGapResolver(LCodeGen* owner)
: cgen_(owner),

View File

@ -53,13 +53,13 @@ class JumpTarget;
// Register aliases.
// cp is assumed to be a callee saved register.
const Register lithiumScratchReg = s3; // Scratch register.
const Register lithiumScratchReg2 = s4; // Scratch register.
const Register condReg = s5; // Simulated (partial) condition code for mips.
const Register roots = s6; // Roots array pointer.
const Register kLithiumScratchReg = s3; // Scratch register.
const Register kLithiumScratchReg2 = s4; // Scratch register.
const Register kCondReg = s5; // Simulated (partial) condition code for mips.
const Register kRootRegister = s6; // Roots array pointer.
const Register cp = s7; // JavaScript context pointer.
const Register fp = s8_fp; // Alias for fp.
const DoubleRegister lithiumScratchDouble = f30; // Double scratch register.
const DoubleRegister kLithiumScratchDouble = f30; // Double scratch register.
// Flags used for the AllocateInNewSpace functions.
enum AllocationFlags {
@ -789,6 +789,11 @@ class MacroAssembler: public Assembler {
Register map,
Register scratch);
void InitializeRootRegister() {
ExternalReference roots_array_start =
ExternalReference::roots_array_start(isolate());
li(kRootRegister, Operand(roots_array_start));
}
// -------------------------------------------------------------------------
// JavaScript invokes.

View File

@ -73,6 +73,7 @@ SOURCES = {
'test-fixed-dtoa.cc',
'test-flags.cc',
'test-func-name-inference.cc',
'test-hashing.cc',
'test-hashmap.cc',
'test-heap-profiler.cc',
'test-heap.cc',

View File

@ -46,65 +46,71 @@ typedef uint32_t (*HASH_FUNCTION)();
static v8::Persistent<v8::Context> env;
#define __ assm->
#define __ masm->
void generate(MacroAssembler* assm, i::Vector<const char> string) {
void generate(MacroAssembler* masm, i::Vector<const char> string) {
// GenerateHashInit takes the first character as an argument so it can't
// handle the zero length string.
ASSERT(string.length() > 0);
#ifdef V8_TARGET_ARCH_IA32
__ push(ebx);
__ push(ecx);
__ mov(eax, Immediate(0));
if (string.length() > 0) {
__ mov(ebx, Immediate(string.at(0)));
StringHelper::GenerateHashInit(assm, eax, ebx, ecx);
}
__ mov(ebx, Immediate(string.at(0)));
StringHelper::GenerateHashInit(masm, eax, ebx, ecx);
for (int i = 1; i < string.length(); i++) {
__ mov(ebx, Immediate(string.at(i)));
StringHelper::GenerateHashAddCharacter(assm, eax, ebx, ecx);
StringHelper::GenerateHashAddCharacter(masm, eax, ebx, ecx);
}
StringHelper::GenerateHashGetHash(assm, eax, ecx);
StringHelper::GenerateHashGetHash(masm, eax, ecx);
__ pop(ecx);
__ pop(ebx);
__ Ret();
#elif V8_TARGET_ARCH_X64
__ push(kRootRegister);
__ InitializeRootRegister();
__ push(rbx);
__ push(rcx);
__ movq(rax, Immediate(0));
if (string.length() > 0) {
__ movq(rbx, Immediate(string.at(0)));
StringHelper::GenerateHashInit(assm, rax, rbx, rcx);
}
__ movq(rbx, Immediate(string.at(0)));
StringHelper::GenerateHashInit(masm, rax, rbx, rcx);
for (int i = 1; i < string.length(); i++) {
__ movq(rbx, Immediate(string.at(i)));
StringHelper::GenerateHashAddCharacter(assm, rax, rbx, rcx);
StringHelper::GenerateHashAddCharacter(masm, rax, rbx, rcx);
}
StringHelper::GenerateHashGetHash(assm, rax, rcx);
StringHelper::GenerateHashGetHash(masm, rax, rcx);
__ pop(rcx);
__ pop(rbx);
__ pop(kRootRegister);
__ Ret();
#elif V8_TARGET_ARCH_ARM
__ push(kRootRegister);
__ InitializeRootRegister();
__ mov(r0, Operand(0));
if (string.length() > 0) {
__ mov(ip, Operand(string.at(0)));
StringHelper::GenerateHashInit(assm, r0, ip);
}
__ mov(ip, Operand(string.at(0)));
StringHelper::GenerateHashInit(masm, r0, ip);
for (int i = 1; i < string.length(); i++) {
__ mov(ip, Operand(string.at(i)));
StringHelper::GenerateHashAddCharacter(assm, r0, ip);
StringHelper::GenerateHashAddCharacter(masm, r0, ip);
}
StringHelper::GenerateHashGetHash(assm, r0);
StringHelper::GenerateHashGetHash(masm, r0);
__ pop(kRootRegister);
__ mov(pc, Operand(lr));
#elif V8_TARGET_ARCH_MIPS
__ push(kRootRegister);
__ InitializeRootRegister();
__ li(v0, Operand(0));
if (string.length() > 0) {
__ li(t1, Operand(string.at(0)));
StringHelper::GenerateHashInit(assm, v0, t1);
}
__ li(t1, Operand(string.at(0)));
StringHelper::GenerateHashInit(masm, v0, t1);
for (int i = 1; i < string.length(); i++) {
__ li(t1, Operand(string.at(i)));
StringHelper::GenerateHashAddCharacter(assm, v0, t1);
StringHelper::GenerateHashAddCharacter(masm, v0, t1);
}
StringHelper::GenerateHashGetHash(assm, v0);
StringHelper::GenerateHashGetHash(masm, v0);
__ pop(kRootRegister);
__ jr(ra);
__ nop();
#endif
@ -114,12 +120,12 @@ void generate(MacroAssembler* assm, i::Vector<const char> string) {
void check(i::Vector<const char> string) {
v8::HandleScope scope;
v8::internal::byte buffer[2048];
MacroAssembler assm(Isolate::Current(), buffer, sizeof buffer);
MacroAssembler masm(Isolate::Current(), buffer, sizeof buffer);
generate(&assm, string);
generate(&masm, string);
CodeDesc desc;
assm.GetCode(&desc);
masm.GetCode(&desc);
Code* code = Code::cast(HEAP->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
@ -156,7 +162,6 @@ TEST(StringHash) {
check_twochars(static_cast<char>(a), static_cast<char>(b));
}
}
check(i::Vector<const char>("", 0));
check(i::Vector<const char>("*", 1));
check(i::Vector<const char>(".zZ", 3));
check(i::Vector<const char>("muc", 3));