- Inlined JSArray::SetContent.
authorbak@chromium.org <bak@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 10 Oct 2008 10:27:44 +0000 (10:27 +0000)
committerbak@chromium.org <bak@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 10 Oct 2008 10:27:44 +0000 (10:27 +0000)
- Implemented Runtime_KeyedGetProperty to make slow case faster.

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

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

src/ic-ia32.cc
src/objects-inl.h
src/objects.cc
src/objects.h
src/property.h
src/runtime.cc
src/runtime.h

index 9e36c89..3b12f29 100644 (file)
@@ -245,7 +245,7 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
   // Slow case: Load name and receiver from stack and jump to runtime.
   __ bind(&slow);
   __ IncrementCounter(&Counters::keyed_load_generic_slow, 1);
-  KeyedLoadIC::Generate(masm, ExternalReference(Runtime::kGetProperty));
+  KeyedLoadIC::Generate(masm, ExternalReference(Runtime::kKeyedGetProperty));
   // Check if the key is a symbol that is not an array index.
   __ bind(&check_string);
   __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
index 5f45c2f..34b9c15 100644 (file)
@@ -2240,6 +2240,12 @@ void Map::ClearCodeCache() {
 }
 
 
+void JSArray::SetContent(FixedArray* storage) {
+  set_length(Smi::FromInt(storage->length()));
+  set_elements(storage);
+}
+
+
 #undef CAST_ACCESSOR
 #undef INT_ACCESSORS
 #undef SMI_ACCESSORS
index 8af6baf..693e1db 100644 (file)
@@ -4381,12 +4381,6 @@ Object* JSArray::Initialize(int capacity) {
 }
 
 
-void JSArray::SetContent(FixedArray* storage) {
-  set_length(Smi::FromInt(storage->length()));
-  set_elements(storage);
-}
-
-
 // Computes the new capacity when expanding the elements of a JSObject.
 static int NewElementsCapacity(int old_capacity) {
   // (old_capacity + 50%) + 16
index aa270a2..abb2a06 100644 (file)
@@ -3534,7 +3534,7 @@ class JSArray: public JSObject {
   Object* Initialize(int capacity);
 
   // Set the content of the array to the content of storage.
-  void SetContent(FixedArray* storage);
+  inline void SetContent(FixedArray* storage);
 
   // Support for sorting
   Object* RemoveHoles();
index 4b6de3a..1c9b0d2 100644 (file)
@@ -198,7 +198,6 @@ class LookupResult BASE_EMBEDDED {
     lookup_type_ = NOT_FOUND;
   }
 
-
   JSObject* holder() {
     ASSERT(IsValid());
     return holder_;
index 77ec25c..f3fb849 100644 (file)
@@ -1453,6 +1453,29 @@ static Object* Runtime_GetProperty(Arguments args) {
 }
 
 
+
+// KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric
+static Object* Runtime_KeyedGetProperty(Arguments args) {
+  NoHandleAllocation ha;
+  ASSERT(args.length() == 2);
+
+  Object* receiver = args[0];
+  Object* key = args[1];
+  if (receiver->IsJSObject() &&
+      key->IsString() &&
+      !JSObject::cast(receiver)->HasFastProperties()) {
+    Dictionary* dictionary = JSObject::cast(receiver)->property_dictionary();
+    int entry = dictionary->FindStringEntry(String::cast(key));
+    if ((entry != DescriptorArray::kNotFound)
+        && (dictionary->DetailsAt(entry).type() == NORMAL)) {
+      return dictionary->ValueAt(entry);
+    }
+  }
+  return Runtime::GetObjectProperty(args.at<Object>(0),
+                                    args.at<Object>(1));
+}
+
+
 Object* Runtime::SetObjectProperty(Handle<Object> object,
                                    Handle<Object> key,
                                    Handle<Object> value,
index 3704a1d..100077b 100644 (file)
@@ -40,6 +40,7 @@ namespace v8 { namespace internal {
 #define RUNTIME_FUNCTION_LIST_ALWAYS(F) \
   /* Property access */ \
   F(GetProperty, 2) \
+  F(KeyedGetProperty, 2) \
   F(DeleteProperty, 2) \
   F(HasLocalProperty, 2) \
   F(HasProperty, 2) \