Revision: 10310
Author:   [email protected]
Date:     Fri Dec 30 05:42:21 2011
Log:      Rollback 10309

[email protected]
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/8968042
http://code.google.com/p/v8/source/detail?r=10310

Deleted:
 /branches/bleeding_edge/test/mjsunit/regress/regress-1849.js
Modified:
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/test/mjsunit/regress/regress-95113.js

=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-1849.js Fri Dec 30 04:54:23 2011
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-//       notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-//       copyright notice, this list of conditions and the following
-//       disclaimer in the documentation and/or other materials provided
-//       with the distribution.
-//     * Neither the name of Google Inc. nor the names of its
-//       contributors may be used to endorse or promote products derived
-//       from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// See: http://code.google.com/p/v8/issues/detail?id=1878
-
-// Flags: --allow-natives-syntax
-
-var count = 1e5;
-var arr = new Array(count);
-assertFalse(%HasFastDoubleElements(arr));
-for (var i = 0; i < count; i++) {
-  arr[i] = 0;
-}
-assertFalse(%HasFastDoubleElements(arr));
-assertTrue(%HasFastSmiOnlyElements(arr));
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Fri Dec 30 04:54:23 2011
+++ /branches/bleeding_edge/src/objects-inl.h   Fri Dec 30 05:42:21 2011
@@ -1219,7 +1219,7 @@
         map != heap->free_space_map()) {
       for (int i = 0; i < fixed_array->length(); i++) {
         Object* current = fixed_array->get(i);
-        ASSERT(current->IsSmi() || current->IsTheHole());
+        ASSERT(current->IsSmi() || current == heap->the_hole_value());
       }
     }
   }
=======================================
--- /branches/bleeding_edge/src/objects.cc      Fri Dec 30 04:54:23 2011
+++ /branches/bleeding_edge/src/objects.cc      Fri Dec 30 05:42:21 2011
@@ -8188,13 +8188,10 @@
   Map* new_map = NULL;
   if (elements()->map() != heap->non_strict_arguments_elements_map()) {
     Object* object;
- // The resized array has FAST_SMI_ONLY_ELEMENTS if the capacity mode forces - // it, or if it's allowed and the old elements array contained only SMIs.
     bool has_fast_smi_only_elements =
-        (set_capacity_mode == kForceSmiOnlyElements) ||
-        ((set_capacity_mode == kAllowSmiOnlyElements) &&
-         (elements()->map()->has_fast_smi_only_elements() ||
-          elements() == heap->empty_fixed_array()));
+        (set_capacity_mode == kAllowSmiOnlyElements) &&
+        (elements()->map()->has_fast_smi_only_elements() ||
+         elements() == heap->empty_fixed_array());
     ElementsKind elements_kind = has_fast_smi_only_elements
         ? FAST_SMI_ONLY_ELEMENTS
         : FAST_ELEMENTS;
@@ -9244,20 +9241,11 @@
     } else {
       new_length = dictionary->max_number_key() + 1;
     }
-    SetFastElementsCapacityMode set_capacity_mode = FLAG_smi_only_arrays
-        ? kAllowSmiOnlyElements
-        : kDontAllowSmiOnlyElements;
-    bool has_smi_only_elements = false;
-    bool should_convert_to_fast_double_elements =
-        ShouldConvertToFastDoubleElements(&has_smi_only_elements);
-    if (has_smi_only_elements) {
-      set_capacity_mode = kForceSmiOnlyElements;
-    }
-    MaybeObject* result = should_convert_to_fast_double_elements
+    MaybeObject* result = CanConvertToFastDoubleElements()
         ? SetFastDoubleElementsCapacityAndLength(new_length, new_length)
         : SetFastElementsCapacityAndLength(new_length,
                                            new_length,
-                                           set_capacity_mode);
+                                           kDontAllowSmiOnlyElements);
     if (result->IsFailure()) return result;
 #ifdef DEBUG
     if (FLAG_trace_normalization) {
@@ -9736,25 +9724,17 @@
 }


-bool JSObject::ShouldConvertToFastDoubleElements(
-    bool* has_smi_only_elements) {
-  *has_smi_only_elements = false;
+bool JSObject::CanConvertToFastDoubleElements() {
   if (FLAG_unbox_double_arrays) {
     ASSERT(HasDictionaryElements());
     NumberDictionary* dictionary = NumberDictionary::cast(elements());
-    bool found_double = false;
     for (int i = 0; i < dictionary->Capacity(); i++) {
       Object* key = dictionary->KeyAt(i);
       if (key->IsNumber()) {
-        Object* value = dictionary->ValueAt(i);
-        if (!value->IsNumber()) return false;
-        if (!value->IsSmi()) {
-          found_double = true;
-        }
+        if (!dictionary->ValueAt(i)->IsNumber()) return false;
       }
     }
-    *has_smi_only_elements = !found_double;
-    return found_double;
+    return true;
   } else {
     return false;
   }
=======================================
--- /branches/bleeding_edge/src/objects.h       Fri Dec 30 04:54:23 2011
+++ /branches/bleeding_edge/src/objects.h       Fri Dec 30 05:42:21 2011
@@ -1644,9 +1644,8 @@
   // elements.
   bool ShouldConvertToFastElements();
// Returns true if the elements of JSObject contains only values that can be - // represented in a FixedDoubleArray and has at least one value that can only
-  // be represented as a double and not a Smi.
-  bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements);
+  // represented in a FixedDoubleArray.
+  bool CanConvertToFastDoubleElements();

   // Tells whether the index'th element is present.
   bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index);
@@ -1709,7 +1708,6 @@

   enum SetFastElementsCapacityMode {
     kAllowSmiOnlyElements,
-    kForceSmiOnlyElements,
     kDontAllowSmiOnlyElements
   };

=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-95113.js Fri Dec 30 04:54:23 2011 +++ /branches/bleeding_edge/test/mjsunit/regress/regress-95113.js Fri Dec 30 05:42:21 2011
@@ -32,7 +32,7 @@
   var i = 0;
   while (!%HasFastDoubleElements(a)) {
     a[i] = i;
-    i += 0.5;
+    i++;
   }
   assertTrue(%HasFastDoubleElements(a));
   a.length = 1;

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to