Reland of "Enable inobject double fields unboxing for 64-bit archs."
authorishell <ishell@chromium.org>
Mon, 24 Nov 2014 14:54:26 +0000 (06:54 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 24 Nov 2014 14:54:38 +0000 (14:54 +0000)
Review URL: https://codereview.chromium.org/751643005

Cr-Commit-Position: refs/heads/master@{#25483}

src/globals.h
src/heap/mark-compact.cc
src/heap/objects-visiting.h
src/heap/store-buffer.cc
src/layout-descriptor-inl.h
src/layout-descriptor.h
src/objects-inl.h
src/objects.h
test/cctest/test-unboxed-doubles.cc

index 937c4ac38dcd0d42c7595cfe6e69fdcf660b2e7a..7188078ad03426143f2a6925f59d61bb6b36bb76 100644 (file)
@@ -84,7 +84,7 @@ namespace internal {
 
 // Determine whether double field unboxing feature is enabled.
 #if (V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64)
-#define V8_DOUBLE_FIELDS_UNBOXING 0
+#define V8_DOUBLE_FIELDS_UNBOXING 1
 #else
 #define V8_DOUBLE_FIELDS_UNBOXING 0
 #endif
index ef987fc77bdc3ea5aadae074a200884b62ad1641..09eba59d3331f8e04497e7c3786163f8220c791f 100644 (file)
@@ -2764,7 +2764,8 @@ void MarkCompactCollector::MigrateObject(HeapObject* dst, HeapObject* src,
 
 #if V8_DOUBLE_FIELDS_UNBOXING
       if (!may_contain_raw_values &&
-          (has_only_tagged_fields || helper.IsTagged(src_slot - src_addr)))
+          (has_only_tagged_fields ||
+           helper.IsTagged(static_cast<int>(src_slot - src_addr))))
 #else
       if (!may_contain_raw_values)
 #endif
index b25b44963627e29d20bbef280b4187b02023b6e8..30054f058afbfb413cac4336881f6f763aa01eda 100644 (file)
@@ -111,9 +111,9 @@ class StaticVisitorBase : public AllStatic {
 
   // Determine which specialized visitor should be used for given map.
   static VisitorId GetVisitorId(Map* map) {
-    return GetVisitorId(map->instance_type(), map->instance_size(),
-                        FLAG_unbox_double_fields &&
-                            !map->layout_descriptor()->IsFastPointerLayout());
+    return GetVisitorId(
+        map->instance_type(), map->instance_size(),
+        FLAG_unbox_double_fields && !map->HasFastPointerLayout());
   }
 
   // For visitors that allow specialization by size calculate VisitorId based
@@ -198,15 +198,13 @@ class BodyVisitorBase : public AllStatic {
  public:
   INLINE(static void IteratePointers(Heap* heap, HeapObject* object,
                                      int start_offset, int end_offset)) {
-    DCHECK(!FLAG_unbox_double_fields ||
-           object->map()->layout_descriptor()->IsFastPointerLayout());
+    DCHECK(!FLAG_unbox_double_fields || object->map()->HasFastPointerLayout());
     IterateRawPointers(heap, object, start_offset, end_offset);
   }
 
   INLINE(static void IterateBody(Heap* heap, HeapObject* object,
                                  int start_offset, int end_offset)) {
-    if (!FLAG_unbox_double_fields ||
-        object->map()->layout_descriptor()->IsFastPointerLayout()) {
+    if (!FLAG_unbox_double_fields || object->map()->HasFastPointerLayout()) {
       IterateRawPointers(heap, object, start_offset, end_offset);
     } else {
       IterateBodyUsingLayoutDescriptor(heap, object, start_offset, end_offset);
index 4b94a95761774a05d3b44affed0b510caec4bbcd..5fd4ce34f3aee6913c42fe3c292b1dea5f0ea8ab 100644 (file)
@@ -519,7 +519,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback,
                 if (!has_only_tagged_fields) {
                   for (Address slot = start_address; slot < end_address;
                        slot += kPointerSize) {
-                    if (helper.IsTagged(slot - obj_address)) {
+                    if (helper.IsTagged(static_cast<int>(slot - obj_address))) {
                       // TODO(ishell): call this once for contiguous region
                       // of tagged fields.
                       FindPointersToNewSpaceInRegion(slot, slot + kPointerSize,
index 6d77bcc995693186771607d8c95790a36553fa88..58fdd6e5d05a88c16e74c1149aa2ac0d6c5dc03f 100644 (file)
@@ -120,7 +120,12 @@ bool LayoutDescriptor::IsTagged(int field_index) {
 
 
 bool LayoutDescriptor::IsFastPointerLayout() {
-  return IsSmi() && (Smi::cast(this)->value() == 0);
+  return this == FastPointerLayout();
+}
+
+
+bool LayoutDescriptor::IsFastPointerLayout(Object* layout_descriptor) {
+  return layout_descriptor == FastPointerLayout();
 }
 
 
index b2c61bb1c0ae4fceb884a7827890251ff65f5c85..cc149f18a431b48a004d0fdf7827e5d07fa2d811 100644 (file)
@@ -28,6 +28,7 @@ class LayoutDescriptor : public FixedTypedArray<Uint32ArrayTraits> {
 
   // Returns true if this is a layout of the object having only tagged fields.
   V8_INLINE bool IsFastPointerLayout();
+  V8_INLINE static bool IsFastPointerLayout(Object* layout_descriptor);
 
   // Returns true if the layout descriptor is in non-Smi form.
   V8_INLINE bool IsSlowLayout();
index eb9f167527661d5708853ab6b6e177a20f16a1b4..0a85a137d8b6507e13e3263a4729c2fbd2cce2ef 100644 (file)
@@ -5241,6 +5241,12 @@ LayoutDescriptor* Map::layout_descriptor_gc_safe() {
 }
 
 
+bool Map::HasFastPointerLayout() const {
+  Object* layout_desc = READ_FIELD(this, kLayoutDecriptorOffset);
+  return LayoutDescriptor::IsFastPointerLayout(layout_desc);
+}
+
+
 void Map::UpdateDescriptors(DescriptorArray* descriptors,
                             LayoutDescriptor* layout_desc) {
   set_instance_descriptors(descriptors);
@@ -7378,8 +7384,7 @@ template<int start_offset, int end_offset, int size>
 void FixedBodyDescriptor<start_offset, end_offset, size>::IterateBody(
     HeapObject* obj,
     ObjectVisitor* v) {
-  if (!FLAG_unbox_double_fields ||
-      obj->map()->layout_descriptor()->IsFastPointerLayout()) {
+  if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) {
     v->VisitPointers(HeapObject::RawField(obj, start_offset),
                      HeapObject::RawField(obj, end_offset));
   } else {
@@ -7392,8 +7397,7 @@ template<int start_offset>
 void FlexibleBodyDescriptor<start_offset>::IterateBody(HeapObject* obj,
                                                        int object_size,
                                                        ObjectVisitor* v) {
-  if (!FLAG_unbox_double_fields ||
-      obj->map()->layout_descriptor()->IsFastPointerLayout()) {
+  if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) {
     v->VisitPointers(HeapObject::RawField(obj, start_offset),
                      HeapObject::RawField(obj, object_size));
   } else {
index b22a5be20bdc633b8c7dbbd544e5fcfe2ef037f2..911458c3cb68d47532640e8fac6e0d88034350c8 100644 (file)
@@ -5889,6 +5889,7 @@ class Map: public HeapObject {
   DECL_ACCESSORS(layout_descriptor, LayoutDescriptor)
   // |layout descriptor| accessor which can be used from GC.
   inline LayoutDescriptor* layout_descriptor_gc_safe();
+  inline bool HasFastPointerLayout() const;
 
   // |layout descriptor| accessor that is safe to call even when
   // FLAG_unbox_double_fields is disabled (in this case Map does not contain
index 33597717e1446bdfad94c9eb4f65173fd0775d83..db1aaaf5c6744fda11d1a1ed7e5cb8622988dcc1 100644 (file)
@@ -37,7 +37,7 @@ enum PropertyKind {
   PROP_SMI,
   PROP_DOUBLE,
   PROP_TAGGED,
-  PROP_KIND_NUMBER,
+  PROP_KIND_NUMBER
 };
 
 static Representation representations[PROP_KIND_NUMBER] = {
@@ -653,8 +653,8 @@ TEST(StoreBufferScanOnScavenge) {
   double boom_value = bit_cast<double>(fake_object);
 
   FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0);
-  obj->FastPropertyAtPut(field_index,
-                         *factory->NewHeapNumber(boom_value, MUTABLE));
+  Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE);
+  obj->FastPropertyAtPut(field_index, *boom_number);
 
   // Enforce scan on scavenge for the obj's page.
   MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());