| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/disasm.h" | 7 #include "src/disasm.h" |
| 8 #include "src/disassembler.h" | 8 #include "src/disassembler.h" |
| 9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
| 10 #include "src/jsregexp.h" | 10 #include "src/jsregexp.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // the allocation of the MutableHeapNumber triggers GC (in this case map | 268 // the allocation of the MutableHeapNumber triggers GC (in this case map |
| 269 // is not updated yet). | 269 // is not updated yet). |
| 270 CHECK_EQ(map()->unused_property_fields(), | 270 CHECK_EQ(map()->unused_property_fields(), |
| 271 actual_unused_property_fields - JSObject::kFieldsAdded); | 271 actual_unused_property_fields - JSObject::kFieldsAdded); |
| 272 } | 272 } |
| 273 DescriptorArray* descriptors = map()->instance_descriptors(); | 273 DescriptorArray* descriptors = map()->instance_descriptors(); |
| 274 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { | 274 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { |
| 275 if (descriptors->GetDetails(i).type() == FIELD) { | 275 if (descriptors->GetDetails(i).type() == FIELD) { |
| 276 Representation r = descriptors->GetDetails(i).representation(); | 276 Representation r = descriptors->GetDetails(i).representation(); |
| 277 FieldIndex index = FieldIndex::ForDescriptor(map(), i); | 277 FieldIndex index = FieldIndex::ForDescriptor(map(), i); |
| 278 if (IsUnboxedDoubleField(index)) { |
| 279 DCHECK(r.IsDouble()); |
| 280 continue; |
| 281 } |
| 278 Object* value = RawFastPropertyAt(index); | 282 Object* value = RawFastPropertyAt(index); |
| 279 if (r.IsDouble()) DCHECK(value->IsMutableHeapNumber()); | 283 if (r.IsDouble()) DCHECK(value->IsMutableHeapNumber()); |
| 280 if (value->IsUninitialized()) continue; | 284 if (value->IsUninitialized()) continue; |
| 281 if (r.IsSmi()) DCHECK(value->IsSmi()); | 285 if (r.IsSmi()) DCHECK(value->IsSmi()); |
| 282 if (r.IsHeapObject()) DCHECK(value->IsHeapObject()); | 286 if (r.IsHeapObject()) DCHECK(value->IsHeapObject()); |
| 283 HeapType* field_type = descriptors->GetFieldType(i); | 287 HeapType* field_type = descriptors->GetFieldType(i); |
| 284 if (r.IsNone()) { | 288 if (r.IsNone()) { |
| 285 CHECK(field_type->Is(HeapType::None())); | 289 CHECK(field_type->Is(HeapType::None())); |
| 286 } else if (!HeapType::Any()->Is(field_type)) { | 290 } else if (!HeapType::Any()->Is(field_type)) { |
| 287 CHECK(!field_type->NowStable() || field_type->NowContains(value)); | 291 CHECK(!field_type->NowStable() || field_type->NowContains(value)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 309 CHECK(instance_size() == kVariableSizeSentinel || | 313 CHECK(instance_size() == kVariableSizeSentinel || |
| 310 (kPointerSize <= instance_size() && | 314 (kPointerSize <= instance_size() && |
| 311 instance_size() < heap->Capacity())); | 315 instance_size() < heap->Capacity())); |
| 312 VerifyHeapPointer(prototype()); | 316 VerifyHeapPointer(prototype()); |
| 313 VerifyHeapPointer(instance_descriptors()); | 317 VerifyHeapPointer(instance_descriptors()); |
| 314 SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates()); | 318 SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates()); |
| 315 if (HasTransitionArray()) { | 319 if (HasTransitionArray()) { |
| 316 SLOW_DCHECK(transitions()->IsSortedNoDuplicates()); | 320 SLOW_DCHECK(transitions()->IsSortedNoDuplicates()); |
| 317 SLOW_DCHECK(transitions()->IsConsistentWithBackPointers(this)); | 321 SLOW_DCHECK(transitions()->IsConsistentWithBackPointers(this)); |
| 318 } | 322 } |
| 323 SLOW_DCHECK(!FLAG_unbox_double_fields || |
| 324 layout_descriptor()->IsConsistentWithMap(this)); |
| 319 } | 325 } |
| 320 | 326 |
| 321 | 327 |
| 322 void Map::DictionaryMapVerify() { | 328 void Map::DictionaryMapVerify() { |
| 323 MapVerify(); | 329 MapVerify(); |
| 324 CHECK(is_dictionary_map()); | 330 CHECK(is_dictionary_map()); |
| 325 CHECK(instance_descriptors()->IsEmpty()); | 331 CHECK(instance_descriptors()->IsEmpty()); |
| 326 CHECK_EQ(0, pre_allocated_property_fields()); | 332 CHECK_EQ(0, pre_allocated_property_fields()); |
| 327 CHECK_EQ(0, unused_property_fields()); | 333 CHECK_EQ(0, unused_property_fields()); |
| 328 CHECK_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), | 334 CHECK_EQ(StaticVisitorBase::GetVisitorId(this), visitor_id()); |
| 329 visitor_id()); | |
| 330 } | 335 } |
| 331 | 336 |
| 332 | 337 |
| 333 void Map::VerifyOmittedMapChecks() { | 338 void Map::VerifyOmittedMapChecks() { |
| 334 if (!FLAG_omit_map_checks_for_leaf_maps) return; | 339 if (!FLAG_omit_map_checks_for_leaf_maps) return; |
| 335 if (!is_stable() || | 340 if (!is_stable() || |
| 336 is_deprecated() || | 341 is_deprecated() || |
| 337 HasTransitionArray() || | 342 HasTransitionArray() || |
| 338 is_dictionary_map()) { | 343 is_dictionary_map()) { |
| 339 CHECK_EQ(0, dependent_code()->number_of_entries( | 344 CHECK_EQ(0, dependent_code()->number_of_entries( |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 OFStream os(stdout); | 1179 OFStream os(stdout); |
| 1175 PrintDescriptors(os); | 1180 PrintDescriptors(os); |
| 1176 return false; | 1181 return false; |
| 1177 } | 1182 } |
| 1178 current = hash; | 1183 current = hash; |
| 1179 } | 1184 } |
| 1180 return true; | 1185 return true; |
| 1181 } | 1186 } |
| 1182 | 1187 |
| 1183 | 1188 |
| 1189 bool LayoutDescriptor::IsConsistentWithMap(Map* map) { |
| 1190 if (FLAG_unbox_double_fields) { |
| 1191 DescriptorArray* descriptors = map->instance_descriptors(); |
| 1192 int nof_descriptors = map->NumberOfOwnDescriptors(); |
| 1193 for (int i = 0; i < nof_descriptors; i++) { |
| 1194 PropertyDetails details = descriptors->GetDetails(i); |
| 1195 if (details.type() != FIELD) continue; |
| 1196 FieldIndex field_index = FieldIndex::ForDescriptor(map, i); |
| 1197 bool tagged_expected = |
| 1198 !field_index.is_inobject() || !details.representation().IsDouble(); |
| 1199 for (int bit = 0; bit < details.field_width_in_words(); bit++) { |
| 1200 bool tagged_actual = IsTagged(details.field_index() + bit); |
| 1201 DCHECK_EQ(tagged_expected, tagged_actual); |
| 1202 if (tagged_actual != tagged_expected) return false; |
| 1203 } |
| 1204 } |
| 1205 } |
| 1206 return true; |
| 1207 } |
| 1208 |
| 1209 |
| 1184 bool TransitionArray::IsSortedNoDuplicates(int valid_entries) { | 1210 bool TransitionArray::IsSortedNoDuplicates(int valid_entries) { |
| 1185 DCHECK(valid_entries == -1); | 1211 DCHECK(valid_entries == -1); |
| 1186 Name* current_key = NULL; | 1212 Name* current_key = NULL; |
| 1187 uint32_t current = 0; | 1213 uint32_t current = 0; |
| 1188 for (int i = 0; i < number_of_transitions(); i++) { | 1214 for (int i = 0; i < number_of_transitions(); i++) { |
| 1189 Name* key = GetSortedKey(i); | 1215 Name* key = GetSortedKey(i); |
| 1190 if (key == current_key) { | 1216 if (key == current_key) { |
| 1191 OFStream os(stdout); | 1217 OFStream os(stdout); |
| 1192 PrintTransitions(os); | 1218 PrintTransitions(os); |
| 1193 return false; | 1219 return false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1214 for (int i = 0; i < number_of_transitions(); ++i) { | 1240 for (int i = 0; i < number_of_transitions(); ++i) { |
| 1215 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false; | 1241 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false; |
| 1216 } | 1242 } |
| 1217 return true; | 1243 return true; |
| 1218 } | 1244 } |
| 1219 | 1245 |
| 1220 | 1246 |
| 1221 #endif // DEBUG | 1247 #endif // DEBUG |
| 1222 | 1248 |
| 1223 } } // namespace v8::internal | 1249 } } // namespace v8::internal |
| OLD | NEW |