- ip register cannot be used when accessing large constants in the instruction
authoriposva@chromium.org <iposva@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 21 Oct 2008 22:40:14 +0000 (22:40 +0000)
committeriposva@chromium.org <iposva@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 21 Oct 2008 22:40:14 +0000 (22:40 +0000)
  stream. Enhance the debug code to save and restore the unused holder_reg
  at these points.
- Fix lint issues.

Review URL: http://codereview.chromium.org/8039

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

src/bootstrapper.cc
src/macro-assembler-arm.cc
src/macro-assembler-ia32.cc

index 7aba969..5875438 100644 (file)
@@ -526,7 +526,6 @@ void Genesis::CreateRoots(v8::Handle<v8::ObjectTemplate> global_template,
   }
 
   {  // --- G l o b a l ---
-
     // Step 1: create a fresh inner JSGlobalObject
     Handle<JSGlobalObject> object;
     {
index 92666af..2e957e4 100644 (file)
@@ -648,8 +648,8 @@ Register MacroAssembler::CheckMaps(JSObject* object, Register object_reg,
 
 
 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
-                                          Register scratch,
-                                          Label* miss) {
+                                            Register scratch,
+                                            Label* miss) {
   Label same_contexts;
 
   ASSERT(!holder_reg.is(scratch));
@@ -671,10 +671,15 @@ void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
 
   // Check the context is a global context.
   if (FLAG_debug_code) {
+    // TODO(119): avoid push(holder_reg)/pop(holder_reg)
+    // Cannot use ip as a temporary in this verification code. Due to the fact
+    // that ip is clobbered as part of cmp with an object Operand.
+    push(holder_reg);  // Temporarily save holder on the stack.
     // Read the first word and compare to the global_context_map.
-    ldr(ip, FieldMemOperand(scratch, HeapObject::kMapOffset));
-    cmp(ip, Operand(Factory::global_context_map()));
+    ldr(holder_reg, FieldMemOperand(scratch, HeapObject::kMapOffset));
+    cmp(holder_reg, Operand(Factory::global_context_map()));
     Check(eq, "JSGlobalObject::global_context should be a global context.");
+    pop(holder_reg);  // Restore holder.
   }
 
   // Check if both contexts are the same.
@@ -684,12 +689,19 @@ void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
 
   // Check the context is a global context.
   if (FLAG_debug_code) {
-    cmp(ip, Operand(Factory::null_value()));
+    // TODO(119): avoid push(holder_reg)/pop(holder_reg)
+    // Cannot use ip as a temporary in this verification code. Due to the fact
+    // that ip is clobbered as part of cmp with an object Operand.
+    push(holder_reg);  // Temporarily save holder on the stack.
+    mov(holder_reg, ip);  // Move ip to its holding place.
+    cmp(holder_reg, Operand(Factory::null_value()));
     Check(ne, "JSGlobalProxy::context() should not be null.");
 
-    ldr(ip, FieldMemOperand(ip, HeapObject::kMapOffset));
-    cmp(ip, Operand(Factory::global_context_map()));
+    ldr(holder_reg, FieldMemOperand(holder_reg, HeapObject::kMapOffset));
+    cmp(holder_reg, Operand(Factory::global_context_map()));
     Check(eq, "JSGlobalObject::global_context should be a global context.");
+    // Restore ip is not needed. ip is reloaded below.
+    pop(holder_reg);  // Restore holder.
     // Restore ip to holder's context.
     ldr(ip, FieldMemOperand(holder_reg, JSGlobalProxy::kContextOffset));
   }
index 667ff40..72808de 100644 (file)
@@ -560,7 +560,7 @@ void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
     mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset));
     cmp(scratch, Factory::global_context_map());
     Check(equal, "JSGlobalObject::global_context should be a global context.");
-    pop(scratch); 
+    pop(scratch);
   }
 
   // Check if both contexts are the same.