| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 break; | 88 break; |
| 89 case HEAP_NUMBER_TYPE: | 89 case HEAP_NUMBER_TYPE: |
| 90 HeapNumber::cast(this)->HeapNumberVerify(); | 90 HeapNumber::cast(this)->HeapNumberVerify(); |
| 91 break; | 91 break; |
| 92 case FIXED_ARRAY_TYPE: | 92 case FIXED_ARRAY_TYPE: |
| 93 FixedArray::cast(this)->FixedArrayVerify(); | 93 FixedArray::cast(this)->FixedArrayVerify(); |
| 94 break; | 94 break; |
| 95 case FIXED_DOUBLE_ARRAY_TYPE: | 95 case FIXED_DOUBLE_ARRAY_TYPE: |
| 96 FixedDoubleArray::cast(this)->FixedDoubleArrayVerify(); | 96 FixedDoubleArray::cast(this)->FixedDoubleArrayVerify(); |
| 97 break; | 97 break; |
| 98 case CONSTANT_POOL_ARRAY_TYPE: |
| 99 ConstantPoolArray::cast(this)->ConstantPoolArrayVerify(); |
| 100 break; |
| 98 case BYTE_ARRAY_TYPE: | 101 case BYTE_ARRAY_TYPE: |
| 99 ByteArray::cast(this)->ByteArrayVerify(); | 102 ByteArray::cast(this)->ByteArrayVerify(); |
| 100 break; | 103 break; |
| 101 case FREE_SPACE_TYPE: | 104 case FREE_SPACE_TYPE: |
| 102 FreeSpace::cast(this)->FreeSpaceVerify(); | 105 FreeSpace::cast(this)->FreeSpaceVerify(); |
| 103 break; | 106 break; |
| 104 case EXTERNAL_PIXEL_ARRAY_TYPE: | 107 case EXTERNAL_PIXEL_ARRAY_TYPE: |
| 105 ExternalPixelArray::cast(this)->ExternalPixelArrayVerify(); | 108 ExternalPixelArray::cast(this)->ExternalPixelArrayVerify(); |
| 106 break; | 109 break; |
| 107 case EXTERNAL_BYTE_ARRAY_TYPE: | 110 case EXTERNAL_BYTE_ARRAY_TYPE: |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 void ExternalFloatArray::ExternalFloatArrayVerify() { | 299 void ExternalFloatArray::ExternalFloatArrayVerify() { |
| 297 CHECK(IsExternalFloatArray()); | 300 CHECK(IsExternalFloatArray()); |
| 298 } | 301 } |
| 299 | 302 |
| 300 | 303 |
| 301 void ExternalDoubleArray::ExternalDoubleArrayVerify() { | 304 void ExternalDoubleArray::ExternalDoubleArrayVerify() { |
| 302 CHECK(IsExternalDoubleArray()); | 305 CHECK(IsExternalDoubleArray()); |
| 303 } | 306 } |
| 304 | 307 |
| 305 | 308 |
| 309 bool JSObject::ElementsAreSafeToExamine() { |
| 310 return (FLAG_use_gvn && FLAG_use_allocation_folding) || |
| 311 reinterpret_cast<Map*>(elements()) != |
| 312 GetHeap()->one_pointer_filler_map(); |
| 313 } |
| 314 |
| 315 |
| 306 void JSObject::JSObjectVerify() { | 316 void JSObject::JSObjectVerify() { |
| 307 VerifyHeapPointer(properties()); | 317 VerifyHeapPointer(properties()); |
| 308 VerifyHeapPointer(elements()); | 318 VerifyHeapPointer(elements()); |
| 309 | 319 |
| 310 if (GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS) { | 320 if (GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS) { |
| 311 CHECK(this->elements()->IsFixedArray()); | 321 CHECK(this->elements()->IsFixedArray()); |
| 312 CHECK_GE(this->elements()->length(), 2); | 322 CHECK_GE(this->elements()->length(), 2); |
| 313 } | 323 } |
| 314 | 324 |
| 315 if (HasFastProperties()) { | 325 if (HasFastProperties()) { |
| 316 CHECK_EQ(map()->unused_property_fields(), | 326 CHECK_EQ(map()->unused_property_fields(), |
| 317 (map()->inobject_properties() + properties()->length() - | 327 (map()->inobject_properties() + properties()->length() - |
| 318 map()->NextFreePropertyIndex())); | 328 map()->NextFreePropertyIndex())); |
| 319 DescriptorArray* descriptors = map()->instance_descriptors(); | 329 DescriptorArray* descriptors = map()->instance_descriptors(); |
| 320 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { | 330 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { |
| 321 if (descriptors->GetDetails(i).type() == FIELD) { | 331 if (descriptors->GetDetails(i).type() == FIELD) { |
| 322 Representation r = descriptors->GetDetails(i).representation(); | 332 Representation r = descriptors->GetDetails(i).representation(); |
| 323 int field = descriptors->GetFieldIndex(i); | 333 int field = descriptors->GetFieldIndex(i); |
| 324 Object* value = RawFastPropertyAt(field); | 334 Object* value = RawFastPropertyAt(field); |
| 325 if (r.IsDouble()) ASSERT(value->IsHeapNumber()); | 335 if (r.IsDouble()) ASSERT(value->IsHeapNumber()); |
| 326 if (value->IsUninitialized()) continue; | 336 if (value->IsUninitialized()) continue; |
| 327 if (r.IsSmi()) ASSERT(value->IsSmi()); | 337 if (r.IsSmi()) ASSERT(value->IsSmi()); |
| 328 if (r.IsHeapObject()) ASSERT(value->IsHeapObject()); | 338 if (r.IsHeapObject()) ASSERT(value->IsHeapObject()); |
| 329 } | 339 } |
| 330 } | 340 } |
| 331 } | 341 } |
| 332 | 342 |
| 333 // If a GC was caused while constructing this object, the elements | 343 // If a GC was caused while constructing this object, the elements |
| 334 // pointer may point to a one pointer filler map. | 344 // pointer may point to a one pointer filler map. |
| 335 if ((FLAG_use_gvn && FLAG_use_allocation_folding) || | 345 if (ElementsAreSafeToExamine()) { |
| 336 (reinterpret_cast<Map*>(elements()) != | |
| 337 GetHeap()->one_pointer_filler_map())) { | |
| 338 CHECK_EQ((map()->has_fast_smi_or_object_elements() || | 346 CHECK_EQ((map()->has_fast_smi_or_object_elements() || |
| 339 (elements() == GetHeap()->empty_fixed_array())), | 347 (elements() == GetHeap()->empty_fixed_array())), |
| 340 (elements()->map() == GetHeap()->fixed_array_map() || | 348 (elements()->map() == GetHeap()->fixed_array_map() || |
| 341 elements()->map() == GetHeap()->fixed_cow_array_map())); | 349 elements()->map() == GetHeap()->fixed_cow_array_map())); |
| 342 CHECK(map()->has_fast_object_elements() == HasFastObjectElements()); | 350 CHECK(map()->has_fast_object_elements() == HasFastObjectElements()); |
| 343 } | 351 } |
| 344 } | 352 } |
| 345 | 353 |
| 346 | 354 |
| 347 void Map::MapVerify() { | 355 void Map::MapVerify() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 double value = get_scalar(i); | 440 double value = get_scalar(i); |
| 433 CHECK(!std::isnan(value) || | 441 CHECK(!std::isnan(value) || |
| 434 (BitCast<uint64_t>(value) == | 442 (BitCast<uint64_t>(value) == |
| 435 BitCast<uint64_t>(canonical_not_the_hole_nan_as_double())) || | 443 BitCast<uint64_t>(canonical_not_the_hole_nan_as_double())) || |
| 436 ((BitCast<uint64_t>(value) & Double::kSignMask) != 0)); | 444 ((BitCast<uint64_t>(value) & Double::kSignMask) != 0)); |
| 437 } | 445 } |
| 438 } | 446 } |
| 439 } | 447 } |
| 440 | 448 |
| 441 | 449 |
| 450 void ConstantPoolArray::ConstantPoolArrayVerify() { |
| 451 CHECK(IsConstantPoolArray()); |
| 452 } |
| 453 |
| 454 |
| 442 void JSGeneratorObject::JSGeneratorObjectVerify() { | 455 void JSGeneratorObject::JSGeneratorObjectVerify() { |
| 443 // In an expression like "new g()", there can be a point where a generator | 456 // In an expression like "new g()", there can be a point where a generator |
| 444 // object is allocated but its fields are all undefined, as it hasn't yet been | 457 // object is allocated but its fields are all undefined, as it hasn't yet been |
| 445 // initialized by the generator. Hence these weak checks. | 458 // initialized by the generator. Hence these weak checks. |
| 446 VerifyObjectField(kFunctionOffset); | 459 VerifyObjectField(kFunctionOffset); |
| 447 VerifyObjectField(kContextOffset); | 460 VerifyObjectField(kContextOffset); |
| 448 VerifyObjectField(kReceiverOffset); | 461 VerifyObjectField(kReceiverOffset); |
| 449 VerifyObjectField(kOperandStackOffset); | 462 VerifyObjectField(kOperandStackOffset); |
| 450 VerifyObjectField(kContinuationOffset); | 463 VerifyObjectField(kContinuationOffset); |
| 451 VerifyObjectField(kStackHandlerIndexOffset); | 464 VerifyObjectField(kStackHandlerIndexOffset); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 } | 696 } |
| 684 } | 697 } |
| 685 } | 698 } |
| 686 | 699 |
| 687 | 700 |
| 688 void JSArray::JSArrayVerify() { | 701 void JSArray::JSArrayVerify() { |
| 689 JSObjectVerify(); | 702 JSObjectVerify(); |
| 690 CHECK(length()->IsNumber() || length()->IsUndefined()); | 703 CHECK(length()->IsNumber() || length()->IsUndefined()); |
| 691 // If a GC was caused while constructing this array, the elements | 704 // If a GC was caused while constructing this array, the elements |
| 692 // pointer may point to a one pointer filler map. | 705 // pointer may point to a one pointer filler map. |
| 693 if ((FLAG_use_gvn && FLAG_use_allocation_folding) || | 706 if (ElementsAreSafeToExamine()) { |
| 694 (reinterpret_cast<Map*>(elements()) != | |
| 695 GetHeap()->one_pointer_filler_map())) { | |
| 696 CHECK(elements()->IsUndefined() || | 707 CHECK(elements()->IsUndefined() || |
| 697 elements()->IsFixedArray() || | 708 elements()->IsFixedArray() || |
| 698 elements()->IsFixedDoubleArray()); | 709 elements()->IsFixedDoubleArray()); |
| 699 } | 710 } |
| 700 } | 711 } |
| 701 | 712 |
| 702 | 713 |
| 703 void JSSet::JSSetVerify() { | 714 void JSSet::JSSetVerify() { |
| 704 CHECK(IsJSSet()); | 715 CHECK(IsJSSet()); |
| 705 JSObjectVerify(); | 716 JSObjectVerify(); |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 for (int i = 0; i < number_of_transitions(); ++i) { | 1199 for (int i = 0; i < number_of_transitions(); ++i) { |
| 1189 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false; | 1200 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false; |
| 1190 } | 1201 } |
| 1191 return true; | 1202 return true; |
| 1192 } | 1203 } |
| 1193 | 1204 |
| 1194 | 1205 |
| 1195 #endif // DEBUG | 1206 #endif // DEBUG |
| 1196 | 1207 |
| 1197 } } // namespace v8::internal | 1208 } } // namespace v8::internal |
| OLD | NEW |