Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: src/layout-descriptor-inl.h

Issue 1033273005: Layout descriptor must be trimmed when corresponding descriptors array is trimmed to stay in sync. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/layout-descriptor-inl.h
diff --git a/src/layout-descriptor-inl.h b/src/layout-descriptor-inl.h
index ceee09a8105603102d201b8d812cc7f0ec194325..248bd00f2fe93ee19477ae90b37cd7b9d0b13344 100644
--- a/src/layout-descriptor-inl.h
+++ b/src/layout-descriptor-inl.h
@@ -154,6 +154,61 @@ LayoutDescriptor* LayoutDescriptor::cast_gc_safe(Object* object) {
}
+int LayoutDescriptor::CalculateCapacity(Map* map, DescriptorArray* descriptors,
+ int num_descriptors) {
+ int inobject_properties = map->inobject_properties();
+ if (inobject_properties == 0) return 0;
+
+ DCHECK(num_descriptors <= descriptors->number_of_descriptors());
Toon Verwaest 2015/03/30 11:42:25 _LE
Igor Sheludko 2015/03/30 16:01:29 Done.
+
+ int layout_descriptor_length;
+ const int kMaxWordsPerField = kDoubleSize / kPointerSize;
+
+ if (num_descriptors <= kSmiValueSize / kMaxWordsPerField) {
+ // Even in the "worst" case (all fields are doubles) it would fit into
+ // a Smi, so no need to calculate length.
+ layout_descriptor_length = kSmiValueSize;
+
+ } else {
+ layout_descriptor_length = 0;
+
+ for (int i = 0; i < num_descriptors; i++) {
+ PropertyDetails details = descriptors->GetDetails(i);
+ if (!InobjectUnboxedField(inobject_properties, details)) continue;
+ int field_index = details.field_index();
+ int field_width_in_words = details.field_width_in_words();
+ layout_descriptor_length =
+ Max(layout_descriptor_length, field_index + field_width_in_words);
+ }
+ }
+ layout_descriptor_length = Min(layout_descriptor_length, inobject_properties);
+ return layout_descriptor_length;
+}
+
+
+LayoutDescriptor* LayoutDescriptor::Initialize(
+ LayoutDescriptor* layout_descriptor, Map* map, DescriptorArray* descriptors,
+ int num_descriptors) {
+ DisallowHeapAllocation no_allocation;
+ int inobject_properties = map->inobject_properties();
+
+ for (int i = 0; i < num_descriptors; i++) {
+ PropertyDetails details = descriptors->GetDetails(i);
+ if (!InobjectUnboxedField(inobject_properties, details)) {
+ DCHECK(details.location() != kField ||
+ layout_descriptor->IsTagged(details.field_index()));
+ continue;
+ }
+ int field_index = details.field_index();
+ layout_descriptor = layout_descriptor->SetRawData(field_index);
+ if (details.field_width_in_words() > 1) {
+ layout_descriptor = layout_descriptor->SetRawData(field_index + 1);
+ }
+ }
+ return layout_descriptor;
+}
+
+
// InobjectPropertiesHelper is a helper class for querying whether inobject
// property at offset is Double or not.
LayoutDescriptorHelper::LayoutDescriptorHelper(Map* map)

Powered by Google App Engine
This is Rietveld 408576698