Revision: 10351
Author:   erik.co...@gmail.com
Date:     Fri Jan  6 03:33:20 2012
Log:      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
http://code.google.com/p/v8/source/detail?r=10351

Modified:
 /branches/bleeding_edge/src/arm/builtins-arm.cc
 /branches/bleeding_edge/src/arm/deoptimizer-arm.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.h
 /branches/bleeding_edge/src/mips/builtins-mips.cc
 /branches/bleeding_edge/src/mips/deoptimizer-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.h
 /branches/bleeding_edge/src/mips/lithium-gap-resolver-mips.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.h
 /branches/bleeding_edge/test/cctest/SConscript
 /branches/bleeding_edge/test/cctest/test-hashing.cc

=======================================
--- /branches/bleeding_edge/src/arm/builtins-arm.cc     Tue Jan  3 01:39:34 2012
+++ /branches/bleeding_edge/src/arm/builtins-arm.cc     Fri Jan  6 03:33:20 2012
@@ -1082,10 +1082,7 @@
     // 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);
=======================================
--- /branches/bleeding_edge/src/arm/deoptimizer-arm.cc Wed Nov 16 00:44:30 2011 +++ /branches/bleeding_edge/src/arm/deoptimizer-arm.cc Fri Jan 6 03:33:20 2012
@@ -723,10 +723,7 @@
   __ 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
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Wed Jan 4 09:29:01 2012 +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Fri Jan 6 03:33:20 2012
@@ -396,14 +396,14 @@
 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);
 }


=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.h Wed Jan 4 09:29:01 2012 +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.h Fri Jan 6 03:33:20 2012
@@ -52,7 +52,7 @@

 // 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 @@
                                     Register map,
                                     Register scratch);

+  void InitializeRootRegister() {
+    ExternalReference roots_array_start =
+        ExternalReference::roots_array_start(isolate());
+    mov(kRootRegister, Operand(roots_array_start));
+  }
+
// ---------------------------------------------------------------------------
   // JavaScript invokes

=======================================
--- /branches/bleeding_edge/src/mips/builtins-mips.cc Wed Jan 4 01:40:47 2012 +++ /branches/bleeding_edge/src/mips/builtins-mips.cc Fri Jan 6 03:33:20 2012
@@ -1114,10 +1114,7 @@
     // 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);
=======================================
--- /branches/bleeding_edge/src/mips/deoptimizer-mips.cc Thu Nov 17 06:33:49 2011 +++ /branches/bleeding_edge/src/mips/deoptimizer-mips.cc Fri Jan 6 03:33:20 2012
@@ -733,10 +733,7 @@
     }
   }

-  // 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);
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Thu Jan 5 01:26:15 2012 +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Fri Jan 6 03:33:20 2012
@@ -148,9 +148,9 @@
   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();
=======================================
--- /branches/bleeding_edge/src/mips/lithium-gap-resolver-mips.cc Thu Jan 5 01:26:15 2012 +++ /branches/bleeding_edge/src/mips/lithium-gap-resolver-mips.cc Fri Jan 6 03:33:20 2012
@@ -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),
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.h Thu Jan 5 01:26:15 2012 +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.h Fri Jan 6 03:33:20 2012
@@ -53,13 +53,13 @@

 // 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 @@
                                     Register map,
                                     Register scratch);

+  void InitializeRootRegister() {
+    ExternalReference roots_array_start =
+        ExternalReference::roots_array_start(isolate());
+    li(kRootRegister, Operand(roots_array_start));
+  }

// -------------------------------------------------------------------------
   // JavaScript invokes.
=======================================
--- /branches/bleeding_edge/test/cctest/SConscript      Mon Dec  5 00:58:01 2011
+++ /branches/bleeding_edge/test/cctest/SConscript      Fri Jan  6 03:33:20 2012
@@ -73,6 +73,7 @@
     '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',
=======================================
--- /branches/bleeding_edge/test/cctest/test-hashing.cc Thu Dec 15 06:24:07 2011 +++ /branches/bleeding_edge/test/cctest/test-hashing.cc Fri Jan 6 03:33:20 2012
@@ -46,65 +46,71 @@

 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::GenerateHashGetHash(assm, eax, ecx);
+    StringHelper::GenerateHashAddCharacter(masm, eax, ebx, 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::GenerateHashGetHash(assm, rax, rcx);
+    StringHelper::GenerateHashAddCharacter(masm, rax, rbx, 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::GenerateHashGetHash(assm, r0);
+    StringHelper::GenerateHashAddCharacter(masm, r0, ip);
+  }
+  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::GenerateHashGetHash(assm, v0);
+    StringHelper::GenerateHashAddCharacter(masm, v0, t1);
+  }
+  StringHelper::GenerateHashGetHash(masm, v0);
+  __ pop(kRootRegister);
   __ jr(ra);
   __ nop();
 #endif
@@ -114,12 +120,12 @@
 void check(i::Vector<const char> string) {
   v8::HandleScope scope;
   v8::internal::byte buffer[2048];
-  MacroAssembler assm(Isolate::Current(), buffer, sizeof buffer);
-
-  generate(&assm, string);
+  MacroAssembler masm(Isolate::Current(), buffer, sizeof buffer);
+
+  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 @@
       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));

--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev

Reply via email to