Addressed review comment by Kasper:
authoriposva@chromium.org <iposva@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 16 Oct 2008 05:58:09 +0000 (05:58 +0000)
committeriposva@chromium.org <iposva@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 16 Oct 2008 05:58:09 +0000 (05:58 +0000)
- Factor out property load from CALL_IC and LOAD_IC.

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

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

src/stub-cache-arm.cc
src/stub-cache-ia32.cc
src/stub-cache.h

index 4187f529e4cd49f64668a86cbb9264d9ec8d943a..5bcc6b01fece02a5643b4ee10dbbe6822ec7679c 100644 (file)
@@ -148,6 +148,27 @@ void StubCompiler::GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm,
 }
 
 
+// Load a fast property out of a holder object (src). In-object properties
+// are loaded directly otherwise the property is loaded from the properties
+// fixed array.
+void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
+                                            Register dst, Register src,
+                                            JSObject* holder, int index) {
+  // Adjust for the number of properties stored in the holder.
+  index -= holder->map()->inobject_properties();
+  if (index < 0) {
+    // Get the property straight out of the holder.
+    int offset = holder->map()->instance_size() + (index * kPointerSize);
+    __ ldr(dst, FieldMemOperand(src, offset));
+  } else {
+    // Calculate the offset into the properties array.
+    int offset = index * kPointerSize + Array::kHeaderSize;
+    __ ldr(dst, FieldMemOperand(src, JSObject::kPropertiesOffset));
+    __ ldr(dst, FieldMemOperand(dst, offset));
+  }
+}
+
+
 #undef __
 
 #define __ masm()->
@@ -208,20 +229,7 @@ Object* CallStubCompiler::CompileCallField(Object* object,
   // Do the right check and compute the holder register.
   Register reg =
       __ CheckMaps(JSObject::cast(object), r1, holder, r3, r2, &miss);
-
-  // Adjust for the number of properties stored in the holder.
-  index -= holder->map()->inobject_properties();
-  if (index < 0) {
-    // Get the property straight out of the holder.
-    int offset = holder->map()->instance_size() + (index * kPointerSize);
-    __ ldr(r1, FieldMemOperand(reg, offset));
-  } else {
-    // Get the properties array of the holder and get the function from
-    // the field.
-    int offset = index * kPointerSize + Array::kHeaderSize;
-    __ ldr(r1, FieldMemOperand(reg, JSObject::kPropertiesOffset));
-    __ ldr(r1, FieldMemOperand(r1, offset));
-  }
+  GenerateFastPropertyLoad(masm(), r1, reg, holder, index);
 
   // Check that the function really is a function.
   __ tst(r1, Operand(kSmiTagMask));
@@ -619,20 +627,7 @@ Object* LoadStubCompiler::CompileLoadField(JSObject* object,
 
   // Check that the maps haven't changed.
   Register reg = __ CheckMaps(object, r0, holder, r3, r1, &miss);
-
-  // Adjust for the number of properties stored in the holder.
-  index -= holder->map()->inobject_properties();
-  if (index < 0) {
-    // Get the property straight out of the holder.
-    int offset = holder->map()->instance_size() + (index * kPointerSize);
-    __ ldr(r0, FieldMemOperand(reg, offset));
-  } else {
-    // Get the properties array of the holder.
-    __ ldr(r3, FieldMemOperand(reg, JSObject::kPropertiesOffset));
-    // Return the value from the properties array.
-    int offset = index * kPointerSize + Array::kHeaderSize;
-    __ ldr(r0, FieldMemOperand(r3, offset));
-  }
+  GenerateFastPropertyLoad(masm(), r0, reg, holder, index);
   __ Ret();
 
   // Handle load cache miss.
index b4eefc609257a4812df55b9b48b3c82b2a5d64cc..01526dac89c7a6cd560ad55806d0a959a577eca2 100644 (file)
@@ -238,6 +238,27 @@ void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm,
 }
 
 
+// Load a fast property out of a holder object (src). In-object properties
+// are loaded directly otherwise the property is loaded from the properties
+// fixed array.
+void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
+                              Register dst, Register src,
+                              JSObject* holder, int index) {
+  // Adjust for the number of properties stored in the holder.
+  index -= holder->map()->inobject_properties();
+  if (index < 0) {
+    // Get the property straight out of the holder.
+    int offset = holder->map()->instance_size() + (index * kPointerSize);
+    __ mov(dst, FieldOperand(src, offset));
+  } else {
+    // Calculate the offset into the properties array.
+    int offset = index * kPointerSize + Array::kHeaderSize;
+    __ mov(dst, FieldOperand(src, JSObject::kPropertiesOffset));
+    __ mov(dst, FieldOperand(dst, offset));
+  }
+}
+
+
 void StubCompiler::GenerateLoadField(MacroAssembler* masm,
                                      JSObject* object,
                                      JSObject* holder,
@@ -254,19 +275,8 @@ void StubCompiler::GenerateLoadField(MacroAssembler* masm,
   Register reg =
       __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label);
 
-  // Adjust for the number of properties stored in the holder.
-  index -= holder->map()->inobject_properties();
-  if (index < 0) {
-    // Get the property straight out of the holder.
-    int offset = holder->map()->instance_size() + (index * kPointerSize);
-    __ mov(eax, FieldOperand(reg, offset));
-  } else {
-    // Get the properties array of the holder.
-    __ mov(scratch1, FieldOperand(reg, JSObject::kPropertiesOffset));
-    // Return the value from the properties array.
-    int offset = index * kPointerSize + Array::kHeaderSize;
-    __ mov(eax, FieldOperand(scratch1, offset));
-  }
+  // Get the value from the properties.
+  GenerateFastPropertyLoad(masm, eax, reg, holder, index);
   __ ret(0);
 }
 
@@ -499,19 +509,7 @@ Object* CallStubCompiler::CompileCallField(Object* object,
   Register reg =
       __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss);
 
-  // Adjust for the number of properties stored in the holder.
-  index -= holder->map()->inobject_properties();
-  if (index < 0) {
-    // Get the property straight out of the holder.
-    int offset = holder->map()->instance_size() + (index * kPointerSize);
-    __ mov(edi, FieldOperand(reg, offset));
-  } else {
-    // Get the properties array of the holder and get the function from
-    // the field.
-    int offset = index * kPointerSize + Array::kHeaderSize;
-    __ mov(edi, FieldOperand(reg, JSObject::kPropertiesOffset));
-    __ mov(edi, FieldOperand(edi, offset));
-  }
+  GenerateFastPropertyLoad(masm(), edi, reg, holder, index);
 
   // Check that the function really is a function.
   __ test(edi, Immediate(kSmiTagMask));
index 4bf13d9e1d9ac840816abb1c9374fb6c45c7d9a8..4fb78da4b0e9097ca4a6b3d683c1075e403505af 100644 (file)
@@ -301,6 +301,9 @@ class StubCompiler BASE_EMBEDDED {
   static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm,
                                                   int index,
                                                   Register prototype);
+  static void GenerateFastPropertyLoad(MacroAssembler* masm,
+                                       Register dst, Register src,
+                                       JSObject* holder, int index);
   static void GenerateLoadField(MacroAssembler* masm,
                                 JSObject* object,
                                 JSObject* holder,