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

Side by Side Diff: src/layout-descriptor-inl.h

Issue 726713003: LayoutDescriptorHelper is now able to calculate the length of contiguous regions of tagged/non-tagg… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 6 years 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.cc ('k') | src/objects-inl.h » ('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 #ifndef V8_LAYOUT_DESCRIPTOR_INL_H_ 5 #ifndef V8_LAYOUT_DESCRIPTOR_INL_H_
6 #define V8_LAYOUT_DESCRIPTOR_INL_H_ 6 #define V8_LAYOUT_DESCRIPTOR_INL_H_
7 7
8 #include "src/layout-descriptor.h" 8 #include "src/layout-descriptor.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return details.field_index() < inobject_properties; 46 return details.field_index() < inobject_properties;
47 } 47 }
48 48
49 49
50 LayoutDescriptor* LayoutDescriptor::FastPointerLayout() { 50 LayoutDescriptor* LayoutDescriptor::FastPointerLayout() {
51 return LayoutDescriptor::FromSmi(Smi::FromInt(0)); 51 return LayoutDescriptor::FromSmi(Smi::FromInt(0));
52 } 52 }
53 53
54 54
55 bool LayoutDescriptor::GetIndexes(int field_index, int* layout_word_index, 55 bool LayoutDescriptor::GetIndexes(int field_index, int* layout_word_index,
56 uint32_t* layout_mask) { 56 int* layout_bit_index) {
57 if (static_cast<unsigned>(field_index) >= static_cast<unsigned>(capacity())) { 57 if (static_cast<unsigned>(field_index) >= static_cast<unsigned>(capacity())) {
58 return false; 58 return false;
59 } 59 }
60 60
61 *layout_word_index = field_index / kNumberOfBits; 61 *layout_word_index = field_index / kNumberOfBits;
62 CHECK((!IsSmi() && (*layout_word_index < length())) || 62 CHECK((!IsSmi() && (*layout_word_index < length())) ||
63 (IsSmi() && (*layout_word_index < 1))); 63 (IsSmi() && (*layout_word_index < 1)));
64 64
65 int layout_bit_index = field_index % kNumberOfBits; 65 *layout_bit_index = field_index % kNumberOfBits;
66 *layout_mask = static_cast<uint32_t>(1) << layout_bit_index;
67 return true; 66 return true;
68 } 67 }
69 68
70 69
71 LayoutDescriptor* LayoutDescriptor::SetTagged(int field_index, bool tagged) { 70 LayoutDescriptor* LayoutDescriptor::SetTagged(int field_index, bool tagged) {
72 int layout_word_index; 71 int layout_word_index;
73 uint32_t layout_mask; 72 int layout_bit_index;
74 73
75 if (!GetIndexes(field_index, &layout_word_index, &layout_mask)) { 74 if (!GetIndexes(field_index, &layout_word_index, &layout_bit_index)) {
76 CHECK(false); 75 CHECK(false);
77 return this; 76 return this;
78 } 77 }
78 uint32_t layout_mask = static_cast<uint32_t>(1) << layout_bit_index;
79 79
80 if (IsSlowLayout()) { 80 if (IsSlowLayout()) {
81 uint32_t value = get_scalar(layout_word_index); 81 uint32_t value = get_scalar(layout_word_index);
82 if (tagged) { 82 if (tagged) {
83 value &= ~layout_mask; 83 value &= ~layout_mask;
84 } else { 84 } else {
85 value |= layout_mask; 85 value |= layout_mask;
86 } 86 }
87 set(layout_word_index, value); 87 set(layout_word_index, value);
88 return this; 88 return this;
89 } else { 89 } else {
90 uint32_t value = static_cast<uint32_t>(Smi::cast(this)->value()); 90 uint32_t value = static_cast<uint32_t>(Smi::cast(this)->value());
91 if (tagged) { 91 if (tagged) {
92 value &= ~layout_mask; 92 value &= ~layout_mask;
93 } else { 93 } else {
94 value |= layout_mask; 94 value |= layout_mask;
95 } 95 }
96 return LayoutDescriptor::FromSmi(Smi::FromInt(static_cast<int>(value))); 96 return LayoutDescriptor::FromSmi(Smi::FromInt(static_cast<int>(value)));
97 } 97 }
98 } 98 }
99 99
100 100
101 bool LayoutDescriptor::IsTagged(int field_index) { 101 bool LayoutDescriptor::IsTagged(int field_index) {
102 if (IsFastPointerLayout()) return true; 102 if (IsFastPointerLayout()) return true;
103 103
104 int layout_word_index; 104 int layout_word_index;
105 uint32_t layout_mask; 105 int layout_bit_index;
106 106
107 if (!GetIndexes(field_index, &layout_word_index, &layout_mask)) { 107 if (!GetIndexes(field_index, &layout_word_index, &layout_bit_index)) {
108 // All bits after Out of bounds queries 108 // All bits after Out of bounds queries
109 return true; 109 return true;
110 } 110 }
111 uint32_t layout_mask = static_cast<uint32_t>(1) << layout_bit_index;
111 112
112 if (IsSlowLayout()) { 113 if (IsSlowLayout()) {
113 uint32_t value = get_scalar(layout_word_index); 114 uint32_t value = get_scalar(layout_word_index);
114 return (value & layout_mask) == 0; 115 return (value & layout_mask) == 0;
115 } else { 116 } else {
116 uint32_t value = static_cast<uint32_t>(Smi::cast(this)->value()); 117 uint32_t value = static_cast<uint32_t>(Smi::cast(this)->value());
117 return (value & layout_mask) == 0; 118 return (value & layout_mask) == 0;
118 } 119 }
119 } 120 }
120 121
(...skipping 27 matching lines...) Expand all
148 if (map_word.IsForwardingAddress()) { 149 if (map_word.IsForwardingAddress()) {
149 // Mark-compact has already moved layout descriptor. 150 // Mark-compact has already moved layout descriptor.
150 object = map_word.ToForwardingAddress(); 151 object = map_word.ToForwardingAddress();
151 } 152 }
152 return LayoutDescriptor::cast(object); 153 return LayoutDescriptor::cast(object);
153 } 154 }
154 155
155 156
156 // InobjectPropertiesHelper is a helper class for querying whether inobject 157 // InobjectPropertiesHelper is a helper class for querying whether inobject
157 // property at offset is Double or not. 158 // property at offset is Double or not.
158 InobjectPropertiesHelper::InobjectPropertiesHelper(Map* map) 159 LayoutDescriptorHelper::LayoutDescriptorHelper(Map* map)
159 : all_fields_tagged_(true), 160 : all_fields_tagged_(true),
160 header_size_(0), 161 header_size_(0),
161 layout_descriptor_(LayoutDescriptor::FastPointerLayout()) { 162 layout_descriptor_(LayoutDescriptor::FastPointerLayout()) {
162 if (!FLAG_unbox_double_fields) return; 163 if (!FLAG_unbox_double_fields) return;
163 164
164 layout_descriptor_ = map->layout_descriptor_gc_safe(); 165 layout_descriptor_ = map->layout_descriptor_gc_safe();
165 if (layout_descriptor_->IsFastPointerLayout()) { 166 if (layout_descriptor_->IsFastPointerLayout()) {
166 return; 167 return;
167 } 168 }
168 169
169 int inobject_properties = map->inobject_properties(); 170 int inobject_properties = map->inobject_properties();
170 DCHECK(inobject_properties > 0); 171 DCHECK(inobject_properties > 0);
171 header_size_ = map->instance_size() - (inobject_properties * kPointerSize); 172 header_size_ = map->instance_size() - (inobject_properties * kPointerSize);
172 DCHECK(header_size_ >= 0); 173 DCHECK(header_size_ >= 0);
173 174
174 all_fields_tagged_ = false; 175 all_fields_tagged_ = false;
175 } 176 }
176 177
177 178
178 bool InobjectPropertiesHelper::IsTagged(int offset_in_bytes) { 179 bool LayoutDescriptorHelper::IsTagged(int offset_in_bytes) {
179 DCHECK(IsAligned(offset_in_bytes, kPointerSize)); 180 DCHECK(IsAligned(offset_in_bytes, kPointerSize));
180 if (all_fields_tagged_) return true; 181 if (all_fields_tagged_) return true;
181 // Object headers do not contain non-tagged fields. 182 // Object headers do not contain non-tagged fields.
182 if (offset_in_bytes < header_size_) return true; 183 if (offset_in_bytes < header_size_) return true;
183 int field_index = (offset_in_bytes - header_size_) / kPointerSize; 184 int field_index = (offset_in_bytes - header_size_) / kPointerSize;
184 185
185 return layout_descriptor_->IsTagged(field_index); 186 return layout_descriptor_->IsTagged(field_index);
186 } 187 }
187 } 188 }
188 } // namespace v8::internal 189 } // namespace v8::internal
189 190
190 #endif // V8_LAYOUT_DESCRIPTOR_INL_H_ 191 #endif // V8_LAYOUT_DESCRIPTOR_INL_H_
OLDNEW
« no previous file with comments | « src/layout-descriptor.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698