Revision: 17221
Author:   [email protected]
Date:     Tue Oct 15 15:06:04 2013 UTC
Log:      Simplify array element access in Hydrogen.

No change in functionality intended.

[email protected]

Review URL: https://codereview.chromium.org/26986004
http://code.google.com/p/v8/source/detail?r=17221

Modified:
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Tue Oct 15 14:52:58 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc     Tue Oct 15 15:06:04 2013 UTC
@@ -1311,9 +1311,9 @@

     // Load the key.
     HValue* key_index = Add<HShl>(hash, graph()->GetConstant1());
-    HValue* key = AddFastElementAccess(number_string_cache, key_index,
-                                       NULL, NULL, FAST_ELEMENTS, false,
-                                       ALLOW_RETURN_HOLE, STANDARD_STORE);
+    HValue* key = Add<HLoadKeyed>(number_string_cache, key_index,
+                                  static_cast<HValue*>(NULL),
+                                  FAST_ELEMENTS, ALLOW_RETURN_HOLE);

     // Check if object == key.
     IfBuilder if_objectiskey(this);
@@ -1343,9 +1343,9 @@

       // Load the key.
       HValue* key_index = Add<HShl>(hash, graph()->GetConstant1());
-      HValue* key = AddFastElementAccess(number_string_cache, key_index,
-                                        NULL, NULL, FAST_ELEMENTS, false,
-                                        ALLOW_RETURN_HOLE, STANDARD_STORE);
+      HValue* key = Add<HLoadKeyed>(number_string_cache, key_index,
+                                    static_cast<HValue*>(NULL),
+                                    FAST_ELEMENTS, ALLOW_RETURN_HOLE);

       // Check if key is a heap number.
       IfBuilder if_keyisnumber(this);
@@ -1380,9 +1380,9 @@
   // Load the value in case of cache hit.
   HValue* key_index = Pop();
   HValue* value_index = Add<HAdd>(key_index, graph()->GetConstant1());
-  HValue* value = AddFastElementAccess(number_string_cache, value_index,
-                                      NULL, NULL, FAST_ELEMENTS, false,
-                                      ALLOW_RETURN_HOLE, STANDARD_STORE);
+  HValue* value = Add<HLoadKeyed>(number_string_cache, value_index,
+                                  static_cast<HValue*>(NULL),
+                                  FAST_ELEMENTS, ALLOW_RETURN_HOLE);
   AddIncrementCounter(isolate()->counters()->number_to_string_native());

   if_found.CaptureContinuation(continuation);
@@ -1470,7 +1470,7 @@
       HValue* bounds_check = negative_checker.If<HCompareNumericAndBranch>(
           key, graph()->GetConstant0(), Token::GTE);
       negative_checker.Then();
-      HInstruction* result = AddExternalArrayElementAccess(
+      HInstruction* result = AddElementAccess(
external_elements, key, val, bounds_check, elements_kind, is_store);
       negative_checker.ElseDeopt("Negative key encountered");
       length_checker.End();
@@ -1480,7 +1480,7 @@
       checked_key = Add<HBoundsCheck>(key, length);
       HLoadExternalArrayPointer* external_elements =
           Add<HLoadExternalArrayPointer>(elements);
-      return AddExternalArrayElementAccess(
+      return AddElementAccess(
           external_elements, checked_key, val,
           checked_object, elements_kind, is_store);
     }
@@ -1513,14 +1513,13 @@
                                             elements_kind, length);
       } else {
         HCheckMaps* check_cow_map = Add<HCheckMaps>(
-            elements, isolate()->factory()->fixed_array_map(),
-            top_info());
+            elements, isolate()->factory()->fixed_array_map(), top_info());
         check_cow_map->ClearGVNFlag(kDependsOnElementsKind);
       }
     }
   }
-  return AddFastElementAccess(elements, checked_key, val, checked_object,
- elements_kind, is_store, load_mode, store_mode);
+  return AddElementAccess(elements, checked_key, val, checked_object,
+                          elements_kind, is_store, load_mode);
 }


@@ -1610,85 +1609,31 @@
 }


-HInstruction* HGraphBuilder::AddExternalArrayElementAccess(
-    HValue* external_elements,
+HInstruction* HGraphBuilder::AddElementAccess(
+    HValue* elements,
     HValue* checked_key,
     HValue* val,
     HValue* dependency,
     ElementsKind elements_kind,
-    bool is_store) {
+    bool is_store,
+    LoadKeyedHoleMode load_mode) {
   if (is_store) {
     ASSERT(val != NULL);
-    switch (elements_kind) {
-      case EXTERNAL_PIXEL_ELEMENTS: {
-        val = Add<HClampToUint8>(val);
-        break;
-      }
-      case EXTERNAL_BYTE_ELEMENTS:
-      case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
-      case EXTERNAL_SHORT_ELEMENTS:
-      case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
-      case EXTERNAL_INT_ELEMENTS:
-      case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
-        break;
-      }
-      case EXTERNAL_FLOAT_ELEMENTS:
-      case EXTERNAL_DOUBLE_ELEMENTS:
-        break;
-      case FAST_SMI_ELEMENTS:
-      case FAST_ELEMENTS:
-      case FAST_DOUBLE_ELEMENTS:
-      case FAST_HOLEY_SMI_ELEMENTS:
-      case FAST_HOLEY_ELEMENTS:
-      case FAST_HOLEY_DOUBLE_ELEMENTS:
-      case DICTIONARY_ELEMENTS:
-      case NON_STRICT_ARGUMENTS_ELEMENTS:
-        UNREACHABLE();
-        break;
+    if (elements_kind == EXTERNAL_PIXEL_ELEMENTS) {
+      val = Add<HClampToUint8>(val);
     }
- return Add<HStoreKeyed>(external_elements, checked_key, val, elements_kind);
-  } else {
-    ASSERT(val == NULL);
-    HLoadKeyed* load = Add<HLoadKeyed>(external_elements,
-                                       checked_key,
-                                       dependency,
-                                       elements_kind);
-    if (FLAG_opt_safe_uint32_operations &&
-        elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) {
-      graph()->RecordUint32Instruction(load);
-    }
-    return load;
+    return Add<HStoreKeyed>(elements, checked_key, val, elements_kind);
   }
-}

-
-HInstruction* HGraphBuilder::AddFastElementAccess(
-    HValue* elements,
-    HValue* checked_key,
-    HValue* val,
-    HValue* load_dependency,
-    ElementsKind elements_kind,
-    bool is_store,
-    LoadKeyedHoleMode load_mode,
-    KeyedAccessStoreMode store_mode) {
-  if (is_store) {
-    ASSERT(val != NULL);
-    switch (elements_kind) {
-      case FAST_SMI_ELEMENTS:
-      case FAST_HOLEY_SMI_ELEMENTS:
-      case FAST_ELEMENTS:
-      case FAST_HOLEY_ELEMENTS:
-      case FAST_DOUBLE_ELEMENTS:
-      case FAST_HOLEY_DOUBLE_ELEMENTS:
-        return Add<HStoreKeyed>(elements, checked_key, val, elements_kind);
-      default:
-        UNREACHABLE();
-        return NULL;
-    }
+  ASSERT(!is_store);
+  ASSERT(val == NULL);
+  HLoadKeyed* load = Add<HLoadKeyed>(
+      elements, checked_key, dependency, elements_kind, load_mode);
+  if (FLAG_opt_safe_uint32_operations &&
+      elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) {
+    graph()->RecordUint32Instruction(load);
   }
-  // It's an element load (!is_store).
-  return Add<HLoadKeyed>(
-      elements, checked_key, load_dependency, elements_kind, load_mode);
+  return load;
 }


@@ -5139,8 +5084,7 @@
     HValue* key = environment()->ExpressionStackAt(1);
     HValue* object = environment()->ExpressionStackAt(2);
     bool has_side_effects = false;
-    HandleKeyedElementAccess(object, key, value, expr, return_id,
-                             expr->position(),
+    HandleKeyedElementAccess(object, key, value, expr, expr->position(),
                              true,  // is_store
                              &has_side_effects);
     Drop(3);
@@ -5689,7 +5633,6 @@
     HValue* key,
     HValue* val,
     SmallMapList* maps,
-    BailoutId ast_id,
     int position,
     bool is_store,
     KeyedAccessStoreMode store_mode,
@@ -5821,7 +5764,6 @@
     HValue* key,
     HValue* val,
     Expression* expr,
-    BailoutId ast_id,
     int position,
     bool is_store,
     bool* has_side_effects) {
@@ -5844,7 +5786,7 @@
     }
   } else if (types != NULL && !types->is_empty()) {
     return HandlePolymorphicElementAccess(
-        obj, key, val, types, ast_id, position, is_store,
+        obj, key, val, types, position, is_store,
         expr->GetStoreMode(), has_side_effects);
   } else {
     if (is_store) {
@@ -6033,7 +5975,7 @@

     bool has_side_effects = false;
     HValue* load = HandleKeyedElementAccess(
-        obj, key, NULL, expr, ast_id, position,
+        obj, key, NULL, expr, position,
         false,  // is_store
         &has_side_effects);
     if (has_side_effects) {
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Tue Oct 15 14:52:58 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.h      Tue Oct 15 15:06:04 2013 UTC
@@ -1253,23 +1253,14 @@
       LoadKeyedHoleMode load_mode,
       KeyedAccessStoreMode store_mode);

-  HInstruction* AddExternalArrayElementAccess(
-      HValue* external_elements,
-      HValue* checked_key,
-      HValue* val,
-      HValue* dependency,
-      ElementsKind elements_kind,
-      bool is_store);
-
-  HInstruction* AddFastElementAccess(
+  HInstruction* AddElementAccess(
       HValue* elements,
       HValue* checked_key,
       HValue* val,
       HValue* dependency,
       ElementsKind elements_kind,
       bool is_store,
-      LoadKeyedHoleMode load_mode,
-      KeyedAccessStoreMode store_mode);
+      LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE);

HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value);
@@ -2196,7 +2187,6 @@
                                          HValue* key,
                                          HValue* val,
                                          SmallMapList* maps,
-                                         BailoutId ast_id,
                                          int position,
                                          bool is_store,
                                          KeyedAccessStoreMode store_mode,
@@ -2206,7 +2196,6 @@
                                    HValue* key,
                                    HValue* val,
                                    Expression* expr,
-                                   BailoutId ast_id,
                                    int position,
                                    bool is_store,
                                    bool* has_side_effects);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to