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

Side by Side Diff: src/layout-descriptor.cc

Issue 885003002: Layout descriptor sharing issue fixed. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/layout-descriptor.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/layout-descriptor.h" 10 #include "src/layout-descriptor.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 int field_index = details.field_index(); 65 int field_index = details.field_index();
66 layout_descriptor = layout_descriptor->SetRawData(field_index); 66 layout_descriptor = layout_descriptor->SetRawData(field_index);
67 if (details.field_width_in_words() > 1) { 67 if (details.field_width_in_words() > 1) {
68 layout_descriptor = layout_descriptor->SetRawData(field_index + 1); 68 layout_descriptor = layout_descriptor->SetRawData(field_index + 1);
69 } 69 }
70 } 70 }
71 return handle(layout_descriptor, isolate); 71 return handle(layout_descriptor, isolate);
72 } 72 }
73 73
74 74
75 Handle<LayoutDescriptor> LayoutDescriptor::Append(Handle<Map> map, 75 Handle<LayoutDescriptor> LayoutDescriptor::ShareAppend(
76 PropertyDetails details) { 76 Handle<Map> map, PropertyDetails details) {
77 DCHECK(map->owns_descriptors());
77 Isolate* isolate = map->GetIsolate(); 78 Isolate* isolate = map->GetIsolate();
78 Handle<LayoutDescriptor> layout_descriptor(map->GetLayoutDescriptor(), 79 Handle<LayoutDescriptor> layout_descriptor(map->GetLayoutDescriptor(),
79 isolate); 80 isolate);
80 81
81 if (!InobjectUnboxedField(map->inobject_properties(), details)) { 82 if (!InobjectUnboxedField(map->inobject_properties(), details)) {
83 DCHECK(details.location() != kField ||
84 layout_descriptor->IsTagged(details.field_index()));
82 return layout_descriptor; 85 return layout_descriptor;
83 } 86 }
84 int field_index = details.field_index(); 87 int field_index = details.field_index();
85 layout_descriptor = LayoutDescriptor::EnsureCapacity( 88 layout_descriptor = LayoutDescriptor::EnsureCapacity(
86 isolate, layout_descriptor, field_index + details.field_width_in_words()); 89 isolate, layout_descriptor, field_index + details.field_width_in_words());
87 90
88 DisallowHeapAllocation no_allocation; 91 DisallowHeapAllocation no_allocation;
89 LayoutDescriptor* layout_desc = *layout_descriptor; 92 LayoutDescriptor* layout_desc = *layout_descriptor;
90 layout_desc = layout_desc->SetRawData(field_index); 93 layout_desc = layout_desc->SetRawData(field_index);
91 if (details.field_width_in_words() > 1) { 94 if (details.field_width_in_words() > 1) {
92 layout_desc = layout_desc->SetRawData(field_index + 1); 95 layout_desc = layout_desc->SetRawData(field_index + 1);
93 } 96 }
94 return handle(layout_desc, isolate); 97 return handle(layout_desc, isolate);
95 } 98 }
96 99
97 100
98 Handle<LayoutDescriptor> LayoutDescriptor::AppendIfFastOrUseFull( 101 Handle<LayoutDescriptor> LayoutDescriptor::AppendIfFastOrUseFull(
99 Handle<Map> map, PropertyDetails details, 102 Handle<Map> map, PropertyDetails details,
100 Handle<LayoutDescriptor> full_layout_descriptor) { 103 Handle<LayoutDescriptor> full_layout_descriptor) {
101 DisallowHeapAllocation no_allocation; 104 DisallowHeapAllocation no_allocation;
102 LayoutDescriptor* layout_descriptor = map->layout_descriptor(); 105 LayoutDescriptor* layout_descriptor = map->layout_descriptor();
103 if (layout_descriptor->IsSlowLayout()) { 106 if (layout_descriptor->IsSlowLayout()) {
104 return full_layout_descriptor; 107 return full_layout_descriptor;
105 } 108 }
106 if (!InobjectUnboxedField(map->inobject_properties(), details)) { 109 if (!InobjectUnboxedField(map->inobject_properties(), details)) {
110 DCHECK(details.location() != kField ||
111 layout_descriptor->IsTagged(details.field_index()));
107 return handle(layout_descriptor, map->GetIsolate()); 112 return handle(layout_descriptor, map->GetIsolate());
108 } 113 }
109 int field_index = details.field_index(); 114 int field_index = details.field_index();
110 int new_capacity = field_index + details.field_width_in_words(); 115 int new_capacity = field_index + details.field_width_in_words();
111 if (new_capacity > layout_descriptor->capacity()) { 116 if (new_capacity > layout_descriptor->capacity()) {
112 // Current map's layout descriptor runs out of space, so use the full 117 // Current map's layout descriptor runs out of space, so use the full
113 // layout descriptor. 118 // layout descriptor.
114 return full_layout_descriptor; 119 return full_layout_descriptor;
115 } 120 }
116 121
117 layout_descriptor = layout_descriptor->SetRawData(field_index); 122 layout_descriptor = layout_descriptor->SetRawData(field_index);
118 if (details.field_width_in_words() > 1) { 123 if (details.field_width_in_words() > 1) {
119 layout_descriptor = layout_descriptor->SetRawData(field_index + 1); 124 layout_descriptor = layout_descriptor->SetRawData(field_index + 1);
120 } 125 }
121 return handle(layout_descriptor, map->GetIsolate()); 126 return handle(layout_descriptor, map->GetIsolate());
122 } 127 }
123 128
124 129
125 Handle<LayoutDescriptor> LayoutDescriptor::EnsureCapacity( 130 Handle<LayoutDescriptor> LayoutDescriptor::EnsureCapacity(
126 Isolate* isolate, Handle<LayoutDescriptor> layout_descriptor, 131 Isolate* isolate, Handle<LayoutDescriptor> layout_descriptor,
127 int new_capacity) { 132 int new_capacity) {
128 int old_capacity = layout_descriptor->capacity(); 133 int old_capacity = layout_descriptor->capacity();
129 if (new_capacity <= old_capacity) { 134 if (new_capacity <= old_capacity) {
130 // Nothing to do with layout in Smi-form.
131 return layout_descriptor; 135 return layout_descriptor;
132 } 136 }
133 Handle<LayoutDescriptor> new_layout_descriptor = 137 Handle<LayoutDescriptor> new_layout_descriptor =
134 LayoutDescriptor::New(isolate, new_capacity); 138 LayoutDescriptor::New(isolate, new_capacity);
135 DCHECK(new_layout_descriptor->IsSlowLayout()); 139 DCHECK(new_layout_descriptor->IsSlowLayout());
136 140
137 if (layout_descriptor->IsSlowLayout()) { 141 if (layout_descriptor->IsSlowLayout()) {
138 memcpy(new_layout_descriptor->DataPtr(), layout_descriptor->DataPtr(), 142 memcpy(new_layout_descriptor->DataPtr(), layout_descriptor->DataPtr(),
139 layout_descriptor->DataSize()); 143 layout_descriptor->DataSize());
140 return new_layout_descriptor; 144 return new_layout_descriptor;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 DCHECK(offset_in_bytes < *out_end_of_contiguous_region_offset); 251 DCHECK(offset_in_bytes < *out_end_of_contiguous_region_offset);
248 return true; 252 return true;
249 } 253 }
250 *out_end_of_contiguous_region_offset = 254 *out_end_of_contiguous_region_offset =
251 offset_in_bytes + sequence_length * kPointerSize; 255 offset_in_bytes + sequence_length * kPointerSize;
252 DCHECK(offset_in_bytes < *out_end_of_contiguous_region_offset); 256 DCHECK(offset_in_bytes < *out_end_of_contiguous_region_offset);
253 return tagged; 257 return tagged;
254 } 258 }
255 } 259 }
256 } // namespace v8::internal 260 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/layout-descriptor.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698