A64: Relax the register constraints for LSeqStringGetChar.
authorbaptiste.afsa@arm.com <baptiste.afsa@arm.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 13 Mar 2014 14:56:57 +0000 (14:56 +0000)
committerbaptiste.afsa@arm.com <baptiste.afsa@arm.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 13 Mar 2014 14:56:57 +0000 (14:56 +0000)
R=ulan@chromium.org

Review URL: https://codereview.chromium.org/197763006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19900 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/a64/lithium-a64.cc
src/a64/lithium-codegen-a64.cc

index 289bd3b01dad2862f0b583a1e320bb79e3b47ec9..cc785dde53212b25b4aa3f0bda4d1d0a849172d5 100644 (file)
@@ -2015,11 +2015,8 @@ LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
 
 
 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) {
-  // TODO(all): Use UseRegisterAtStart and UseRegisterOrConstantAtStart here.
-  // We cannot do it now because the debug code in the implementation changes
-  // temp.
-  LOperand* string = UseRegister(instr->string());
-  LOperand* index = UseRegisterOrConstant(instr->index());
+  LOperand* string = UseRegisterAtStart(instr->string());
+  LOperand* index = UseRegisterOrConstantAtStart(instr->index());
   LOperand* temp = TempRegister();
   LSeqStringGetChar* result =
       new(zone()) LSeqStringGetChar(string, index, temp);
index feb4862d7a8f3919e393db872200743c727b6c5f..982cd8f1d0067152aa6c4c470db0be9c94b82fa0 100644 (file)
@@ -4642,8 +4642,7 @@ MemOperand LCodeGen::BuildSeqStringOperand(Register string,
     STATIC_ASSERT(kCharSize == 1);
     return FieldMemOperand(string, SeqString::kHeaderSize + offset);
   }
-  ASSERT(!temp.is(string));
-  ASSERT(!temp.is(ToRegister(index)));
+
   if (encoding == String::ONE_BYTE_ENCODING) {
     __ Add(temp, string, Operand(ToRegister32(index), SXTW));
   } else {
@@ -4661,15 +4660,21 @@ void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) {
   Register temp = ToRegister(instr->temp());
 
   if (FLAG_debug_code) {
-    __ Ldr(temp, FieldMemOperand(string, HeapObject::kMapOffset));
-    __ Ldrb(temp, FieldMemOperand(temp, Map::kInstanceTypeOffset));
+    // Even though this lithium instruction comes with a temp register, we
+    // can't use it here because we want to use "AtStart" constraints on the
+    // inputs and the debug code here needs a scratch register.
+    UseScratchRegisterScope temps(masm());
+    Register dbg_temp = temps.AcquireX();
+
+    __ Ldr(dbg_temp, FieldMemOperand(string, HeapObject::kMapOffset));
+    __ Ldrb(dbg_temp, FieldMemOperand(dbg_temp, Map::kInstanceTypeOffset));
 
-    __ And(temp, temp,
+    __ And(dbg_temp, dbg_temp,
            Operand(kStringRepresentationMask | kStringEncodingMask));
     static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
     static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
-    __ Cmp(temp, Operand(encoding == String::ONE_BYTE_ENCODING
-                         ? one_byte_seq_type : two_byte_seq_type));
+    __ Cmp(dbg_temp, Operand(encoding == String::ONE_BYTE_ENCODING
+                             ? one_byte_seq_type : two_byte_seq_type));
     __ Check(eq, kUnexpectedStringType);
   }