| 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/disasm.h" | 8 #include "src/disasm.h" |
| 9 #include "src/disassembler.h" | 9 #include "src/disassembler.h" |
| 10 #include "src/field-type.h" | 10 #include "src/field-type.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 CHECK(p->IsHeapObject()); | 204 CHECK(p->IsHeapObject()); |
| 205 HeapObject* ho = HeapObject::cast(p); | 205 HeapObject* ho = HeapObject::cast(p); |
| 206 CHECK(ho->GetHeap()->Contains(ho)); | 206 CHECK(ho->GetHeap()->Contains(ho)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 | 209 |
| 210 void Symbol::SymbolVerify() { | 210 void Symbol::SymbolVerify() { |
| 211 CHECK(IsSymbol()); | 211 CHECK(IsSymbol()); |
| 212 CHECK(HasHashCode()); | 212 CHECK(HasHashCode()); |
| 213 CHECK(Hash() > 0u); | 213 CHECK(Hash() > 0u); |
| 214 CHECK(name()->IsUndefined() || name()->IsString()); | 214 CHECK(name()->IsUndefined(GetIsolate()) || name()->IsString()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 | 217 |
| 218 void HeapNumber::HeapNumberVerify() { | 218 void HeapNumber::HeapNumberVerify() { |
| 219 CHECK(IsHeapNumber() || IsMutableHeapNumber()); | 219 CHECK(IsHeapNumber() || IsMutableHeapNumber()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 void Simd128Value::Simd128ValueVerify() { CHECK(IsSimd128Value()); } | 223 void Simd128Value::Simd128ValueVerify() { CHECK(IsSimd128Value()); } |
| 224 | 224 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 map()->NextFreePropertyIndex(); | 282 map()->NextFreePropertyIndex(); |
| 283 if (map()->unused_property_fields() != actual_unused_property_fields) { | 283 if (map()->unused_property_fields() != actual_unused_property_fields) { |
| 284 // This could actually happen in the middle of StoreTransitionStub | 284 // This could actually happen in the middle of StoreTransitionStub |
| 285 // when the new extended backing store is already set into the object and | 285 // when the new extended backing store is already set into the object and |
| 286 // the allocation of the MutableHeapNumber triggers GC (in this case map | 286 // the allocation of the MutableHeapNumber triggers GC (in this case map |
| 287 // is not updated yet). | 287 // is not updated yet). |
| 288 CHECK_EQ(map()->unused_property_fields(), | 288 CHECK_EQ(map()->unused_property_fields(), |
| 289 actual_unused_property_fields - JSObject::kFieldsAdded); | 289 actual_unused_property_fields - JSObject::kFieldsAdded); |
| 290 } | 290 } |
| 291 DescriptorArray* descriptors = map()->instance_descriptors(); | 291 DescriptorArray* descriptors = map()->instance_descriptors(); |
| 292 Isolate* isolate = GetIsolate(); |
| 292 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { | 293 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { |
| 293 if (descriptors->GetDetails(i).type() == DATA) { | 294 if (descriptors->GetDetails(i).type() == DATA) { |
| 294 Representation r = descriptors->GetDetails(i).representation(); | 295 Representation r = descriptors->GetDetails(i).representation(); |
| 295 FieldIndex index = FieldIndex::ForDescriptor(map(), i); | 296 FieldIndex index = FieldIndex::ForDescriptor(map(), i); |
| 296 if (IsUnboxedDoubleField(index)) { | 297 if (IsUnboxedDoubleField(index)) { |
| 297 DCHECK(r.IsDouble()); | 298 DCHECK(r.IsDouble()); |
| 298 continue; | 299 continue; |
| 299 } | 300 } |
| 300 Object* value = RawFastPropertyAt(index); | 301 Object* value = RawFastPropertyAt(index); |
| 301 if (r.IsDouble()) DCHECK(value->IsMutableHeapNumber()); | 302 if (r.IsDouble()) DCHECK(value->IsMutableHeapNumber()); |
| 302 if (value->IsUninitialized()) continue; | 303 if (value->IsUninitialized()) continue; |
| 303 if (r.IsSmi()) DCHECK(value->IsSmi()); | 304 if (r.IsSmi()) DCHECK(value->IsSmi()); |
| 304 if (r.IsHeapObject()) DCHECK(value->IsHeapObject()); | 305 if (r.IsHeapObject()) DCHECK(value->IsHeapObject()); |
| 305 FieldType* field_type = descriptors->GetFieldType(i); | 306 FieldType* field_type = descriptors->GetFieldType(i); |
| 306 bool type_is_none = field_type->IsNone(); | 307 bool type_is_none = field_type->IsNone(); |
| 307 bool type_is_any = field_type->IsAny(); | 308 bool type_is_any = field_type->IsAny(); |
| 308 if (r.IsNone()) { | 309 if (r.IsNone()) { |
| 309 CHECK(type_is_none); | 310 CHECK(type_is_none); |
| 310 } else if (!type_is_any && !(type_is_none && r.IsHeapObject())) { | 311 } else if (!type_is_any && !(type_is_none && r.IsHeapObject())) { |
| 311 // If allocation folding is off then GC could happen during inner | 312 // If allocation folding is off then GC could happen during inner |
| 312 // object literal creation and we will end up having and undefined | 313 // object literal creation and we will end up having and undefined |
| 313 // value that does not match the field type. | 314 // value that does not match the field type. |
| 314 CHECK(!field_type->NowStable() || field_type->NowContains(value) || | 315 CHECK(!field_type->NowStable() || field_type->NowContains(value) || |
| 315 (!FLAG_use_allocation_folding && value->IsUndefined())); | 316 (!FLAG_use_allocation_folding && value->IsUndefined(isolate))); |
| 316 } | 317 } |
| 317 } | 318 } |
| 318 } | 319 } |
| 319 } | 320 } |
| 320 | 321 |
| 321 // If a GC was caused while constructing this object, the elements | 322 // If a GC was caused while constructing this object, the elements |
| 322 // pointer may point to a one pointer filler map. | 323 // pointer may point to a one pointer filler map. |
| 323 if (ElementsAreSafeToExamine()) { | 324 if (ElementsAreSafeToExamine()) { |
| 324 CHECK_EQ((map()->has_fast_smi_or_object_elements() || | 325 CHECK_EQ((map()->has_fast_smi_or_object_elements() || |
| 325 (elements() == GetHeap()->empty_fixed_array()) || | 326 (elements() == GetHeap()->empty_fixed_array()) || |
| 326 HasFastStringWrapperElements()), | 327 HasFastStringWrapperElements()), |
| 327 (elements()->map() == GetHeap()->fixed_array_map() || | 328 (elements()->map() == GetHeap()->fixed_array_map() || |
| 328 elements()->map() == GetHeap()->fixed_cow_array_map())); | 329 elements()->map() == GetHeap()->fixed_cow_array_map())); |
| 329 CHECK(map()->has_fast_object_elements() == HasFastObjectElements()); | 330 CHECK(map()->has_fast_object_elements() == HasFastObjectElements()); |
| 330 } | 331 } |
| 331 } | 332 } |
| 332 | 333 |
| 333 | 334 |
| 334 void Map::MapVerify() { | 335 void Map::MapVerify() { |
| 335 Heap* heap = GetHeap(); | 336 Heap* heap = GetHeap(); |
| 336 CHECK(!heap->InNewSpace(this)); | 337 CHECK(!heap->InNewSpace(this)); |
| 337 CHECK(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); | 338 CHECK(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
| 338 CHECK(instance_size() == kVariableSizeSentinel || | 339 CHECK(instance_size() == kVariableSizeSentinel || |
| 339 (kPointerSize <= instance_size() && | 340 (kPointerSize <= instance_size() && |
| 340 instance_size() < heap->Capacity())); | 341 instance_size() < heap->Capacity())); |
| 341 CHECK(GetBackPointer()->IsUndefined() || | 342 CHECK(GetBackPointer()->IsUndefined(heap->isolate()) || |
| 342 !Map::cast(GetBackPointer())->is_stable()); | 343 !Map::cast(GetBackPointer())->is_stable()); |
| 343 VerifyHeapPointer(prototype()); | 344 VerifyHeapPointer(prototype()); |
| 344 VerifyHeapPointer(instance_descriptors()); | 345 VerifyHeapPointer(instance_descriptors()); |
| 345 SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates()); | 346 SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates()); |
| 346 SLOW_DCHECK(TransitionArray::IsSortedNoDuplicates(this)); | 347 SLOW_DCHECK(TransitionArray::IsSortedNoDuplicates(this)); |
| 347 SLOW_DCHECK(TransitionArray::IsConsistentWithBackPointers(this)); | 348 SLOW_DCHECK(TransitionArray::IsConsistentWithBackPointers(this)); |
| 348 // TODO(ishell): turn it back to SLOW_DCHECK. | 349 // TODO(ishell): turn it back to SLOW_DCHECK. |
| 349 CHECK(!FLAG_unbox_double_fields || | 350 CHECK(!FLAG_unbox_double_fields || |
| 350 layout_descriptor()->IsConsistentWithMap(this)); | 351 layout_descriptor()->IsConsistentWithMap(this)); |
| 351 } | 352 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 406 } |
| 406 } | 407 } |
| 407 | 408 |
| 408 | 409 |
| 409 void TransitionArray::TransitionArrayVerify() { | 410 void TransitionArray::TransitionArrayVerify() { |
| 410 for (int i = 0; i < length(); i++) { | 411 for (int i = 0; i < length(); i++) { |
| 411 Object* e = get(i); | 412 Object* e = get(i); |
| 412 VerifyPointer(e); | 413 VerifyPointer(e); |
| 413 } | 414 } |
| 414 CHECK_LE(LengthFor(number_of_transitions()), length()); | 415 CHECK_LE(LengthFor(number_of_transitions()), length()); |
| 415 CHECK(next_link()->IsUndefined() || next_link()->IsSmi() || | 416 CHECK(next_link()->IsUndefined(GetIsolate()) || next_link()->IsSmi() || |
| 416 next_link()->IsTransitionArray()); | 417 next_link()->IsTransitionArray()); |
| 417 } | 418 } |
| 418 | 419 |
| 419 | 420 |
| 420 void JSGeneratorObject::JSGeneratorObjectVerify() { | 421 void JSGeneratorObject::JSGeneratorObjectVerify() { |
| 421 // In an expression like "new g()", there can be a point where a generator | 422 // In an expression like "new g()", there can be a point where a generator |
| 422 // object is allocated but its fields are all undefined, as it hasn't yet been | 423 // object is allocated but its fields are all undefined, as it hasn't yet been |
| 423 // initialized by the generator. Hence these weak checks. | 424 // initialized by the generator. Hence these weak checks. |
| 424 VerifyObjectField(kFunctionOffset); | 425 VerifyObjectField(kFunctionOffset); |
| 425 VerifyObjectField(kContextOffset); | 426 VerifyObjectField(kContextOffset); |
| 426 VerifyObjectField(kReceiverOffset); | 427 VerifyObjectField(kReceiverOffset); |
| 427 VerifyObjectField(kOperandStackOffset); | 428 VerifyObjectField(kOperandStackOffset); |
| 428 VerifyObjectField(kContinuationOffset); | 429 VerifyObjectField(kContinuationOffset); |
| 429 } | 430 } |
| 430 | 431 |
| 431 | 432 |
| 432 void JSModule::JSModuleVerify() { | 433 void JSModule::JSModuleVerify() { |
| 433 VerifyObjectField(kContextOffset); | 434 VerifyObjectField(kContextOffset); |
| 434 VerifyObjectField(kScopeInfoOffset); | 435 VerifyObjectField(kScopeInfoOffset); |
| 435 CHECK(context()->IsUndefined() || | 436 CHECK(context()->IsUndefined(GetIsolate()) || |
| 436 Context::cast(context())->IsModuleContext()); | 437 Context::cast(context())->IsModuleContext()); |
| 437 } | 438 } |
| 438 | 439 |
| 439 | 440 |
| 440 void JSValue::JSValueVerify() { | 441 void JSValue::JSValueVerify() { |
| 441 Object* v = value(); | 442 Object* v = value(); |
| 442 if (v->IsHeapObject()) { | 443 if (v->IsHeapObject()) { |
| 443 VerifyHeapPointer(v); | 444 VerifyHeapPointer(v); |
| 444 } | 445 } |
| 445 } | 446 } |
| 446 | 447 |
| 447 | 448 |
| 448 void JSDate::JSDateVerify() { | 449 void JSDate::JSDateVerify() { |
| 449 if (value()->IsHeapObject()) { | 450 if (value()->IsHeapObject()) { |
| 450 VerifyHeapPointer(value()); | 451 VerifyHeapPointer(value()); |
| 451 } | 452 } |
| 452 CHECK(value()->IsUndefined() || value()->IsSmi() || value()->IsHeapNumber()); | 453 Isolate* isolate = GetIsolate(); |
| 453 CHECK(year()->IsUndefined() || year()->IsSmi() || year()->IsNaN()); | 454 CHECK(value()->IsUndefined(isolate) || value()->IsSmi() || |
| 454 CHECK(month()->IsUndefined() || month()->IsSmi() || month()->IsNaN()); | 455 value()->IsHeapNumber()); |
| 455 CHECK(day()->IsUndefined() || day()->IsSmi() || day()->IsNaN()); | 456 CHECK(year()->IsUndefined(isolate) || year()->IsSmi() || year()->IsNaN()); |
| 456 CHECK(weekday()->IsUndefined() || weekday()->IsSmi() || weekday()->IsNaN()); | 457 CHECK(month()->IsUndefined(isolate) || month()->IsSmi() || month()->IsNaN()); |
| 457 CHECK(hour()->IsUndefined() || hour()->IsSmi() || hour()->IsNaN()); | 458 CHECK(day()->IsUndefined(isolate) || day()->IsSmi() || day()->IsNaN()); |
| 458 CHECK(min()->IsUndefined() || min()->IsSmi() || min()->IsNaN()); | 459 CHECK(weekday()->IsUndefined(isolate) || weekday()->IsSmi() || |
| 459 CHECK(sec()->IsUndefined() || sec()->IsSmi() || sec()->IsNaN()); | 460 weekday()->IsNaN()); |
| 460 CHECK(cache_stamp()->IsUndefined() || | 461 CHECK(hour()->IsUndefined(isolate) || hour()->IsSmi() || hour()->IsNaN()); |
| 461 cache_stamp()->IsSmi() || | 462 CHECK(min()->IsUndefined(isolate) || min()->IsSmi() || min()->IsNaN()); |
| 463 CHECK(sec()->IsUndefined(isolate) || sec()->IsSmi() || sec()->IsNaN()); |
| 464 CHECK(cache_stamp()->IsUndefined(isolate) || cache_stamp()->IsSmi() || |
| 462 cache_stamp()->IsNaN()); | 465 cache_stamp()->IsNaN()); |
| 463 | 466 |
| 464 if (month()->IsSmi()) { | 467 if (month()->IsSmi()) { |
| 465 int month = Smi::cast(this->month())->value(); | 468 int month = Smi::cast(this->month())->value(); |
| 466 CHECK(0 <= month && month <= 11); | 469 CHECK(0 <= month && month <= 11); |
| 467 } | 470 } |
| 468 if (day()->IsSmi()) { | 471 if (day()->IsSmi()) { |
| 469 int day = Smi::cast(this->day())->value(); | 472 int day = Smi::cast(this->day())->value(); |
| 470 CHECK(1 <= day && day <= 31); | 473 CHECK(1 <= day && day <= 31); |
| 471 } | 474 } |
| 472 if (hour()->IsSmi()) { | 475 if (hour()->IsSmi()) { |
| 473 int hour = Smi::cast(this->hour())->value(); | 476 int hour = Smi::cast(this->hour())->value(); |
| 474 CHECK(0 <= hour && hour <= 23); | 477 CHECK(0 <= hour && hour <= 23); |
| 475 } | 478 } |
| 476 if (min()->IsSmi()) { | 479 if (min()->IsSmi()) { |
| 477 int min = Smi::cast(this->min())->value(); | 480 int min = Smi::cast(this->min())->value(); |
| 478 CHECK(0 <= min && min <= 59); | 481 CHECK(0 <= min && min <= 59); |
| 479 } | 482 } |
| 480 if (sec()->IsSmi()) { | 483 if (sec()->IsSmi()) { |
| 481 int sec = Smi::cast(this->sec())->value(); | 484 int sec = Smi::cast(this->sec())->value(); |
| 482 CHECK(0 <= sec && sec <= 59); | 485 CHECK(0 <= sec && sec <= 59); |
| 483 } | 486 } |
| 484 if (weekday()->IsSmi()) { | 487 if (weekday()->IsSmi()) { |
| 485 int weekday = Smi::cast(this->weekday())->value(); | 488 int weekday = Smi::cast(this->weekday())->value(); |
| 486 CHECK(0 <= weekday && weekday <= 6); | 489 CHECK(0 <= weekday && weekday <= 6); |
| 487 } | 490 } |
| 488 if (cache_stamp()->IsSmi()) { | 491 if (cache_stamp()->IsSmi()) { |
| 489 CHECK(Smi::cast(cache_stamp())->value() <= | 492 CHECK(Smi::cast(cache_stamp())->value() <= |
| 490 Smi::cast(GetIsolate()->date_cache()->stamp())->value()); | 493 Smi::cast(isolate->date_cache()->stamp())->value()); |
| 491 } | 494 } |
| 492 } | 495 } |
| 493 | 496 |
| 494 | 497 |
| 495 void JSMessageObject::JSMessageObjectVerify() { | 498 void JSMessageObject::JSMessageObjectVerify() { |
| 496 CHECK(IsJSMessageObject()); | 499 CHECK(IsJSMessageObject()); |
| 497 VerifyObjectField(kStartPositionOffset); | 500 VerifyObjectField(kStartPositionOffset); |
| 498 VerifyObjectField(kEndPositionOffset); | 501 VerifyObjectField(kEndPositionOffset); |
| 499 VerifyObjectField(kArgumentsOffset); | 502 VerifyObjectField(kArgumentsOffset); |
| 500 VerifyObjectField(kScriptOffset); | 503 VerifyObjectField(kScriptOffset); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 CHECK_EQ(IsConstructor(), bound_target_function()->IsConstructor()); | 551 CHECK_EQ(IsConstructor(), bound_target_function()->IsConstructor()); |
| 549 } | 552 } |
| 550 | 553 |
| 551 | 554 |
| 552 void JSFunction::JSFunctionVerify() { | 555 void JSFunction::JSFunctionVerify() { |
| 553 CHECK(IsJSFunction()); | 556 CHECK(IsJSFunction()); |
| 554 VerifyObjectField(kPrototypeOrInitialMapOffset); | 557 VerifyObjectField(kPrototypeOrInitialMapOffset); |
| 555 VerifyObjectField(kNextFunctionLinkOffset); | 558 VerifyObjectField(kNextFunctionLinkOffset); |
| 556 CHECK(code()->IsCode()); | 559 CHECK(code()->IsCode()); |
| 557 CHECK(next_function_link() == NULL || | 560 CHECK(next_function_link() == NULL || |
| 558 next_function_link()->IsUndefined() || | 561 next_function_link()->IsUndefined(GetIsolate()) || |
| 559 next_function_link()->IsJSFunction()); | 562 next_function_link()->IsJSFunction()); |
| 560 CHECK(map()->is_callable()); | 563 CHECK(map()->is_callable()); |
| 561 } | 564 } |
| 562 | 565 |
| 563 | 566 |
| 564 void SharedFunctionInfo::SharedFunctionInfoVerify() { | 567 void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 565 CHECK(IsSharedFunctionInfo()); | 568 CHECK(IsSharedFunctionInfo()); |
| 566 VerifyObjectField(kNameOffset); | 569 VerifyObjectField(kNameOffset); |
| 567 VerifyObjectField(kCodeOffset); | 570 VerifyObjectField(kCodeOffset); |
| 568 VerifyObjectField(kOptimizedCodeMapOffset); | 571 VerifyObjectField(kOptimizedCodeMapOffset); |
| 569 VerifyObjectField(kFeedbackMetadataOffset); | 572 VerifyObjectField(kFeedbackMetadataOffset); |
| 570 VerifyObjectField(kScopeInfoOffset); | 573 VerifyObjectField(kScopeInfoOffset); |
| 571 VerifyObjectField(kInstanceClassNameOffset); | 574 VerifyObjectField(kInstanceClassNameOffset); |
| 572 CHECK(function_data()->IsUndefined() || IsApiFunction() || | 575 CHECK(function_data()->IsUndefined(GetIsolate()) || IsApiFunction() || |
| 573 HasBuiltinFunctionId() || HasBytecodeArray()); | 576 HasBuiltinFunctionId() || HasBytecodeArray()); |
| 574 VerifyObjectField(kFunctionDataOffset); | 577 VerifyObjectField(kFunctionDataOffset); |
| 575 VerifyObjectField(kScriptOffset); | 578 VerifyObjectField(kScriptOffset); |
| 576 VerifyObjectField(kDebugInfoOffset); | 579 VerifyObjectField(kDebugInfoOffset); |
| 577 } | 580 } |
| 578 | 581 |
| 579 | 582 |
| 580 void JSGlobalProxy::JSGlobalProxyVerify() { | 583 void JSGlobalProxy::JSGlobalProxyVerify() { |
| 581 CHECK(IsJSGlobalProxy()); | 584 CHECK(IsJSGlobalProxy()); |
| 582 JSObjectVerify(); | 585 JSObjectVerify(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 CHECK(DependentCode::cast(table->Lookup(key_obj)) | 704 CHECK(DependentCode::cast(table->Lookup(key_obj)) |
| 702 ->Contains(DependentCode::kWeakCodeGroup, cell)); | 705 ->Contains(DependentCode::kWeakCodeGroup, cell)); |
| 703 } | 706 } |
| 704 } | 707 } |
| 705 } | 708 } |
| 706 } | 709 } |
| 707 | 710 |
| 708 | 711 |
| 709 void JSArray::JSArrayVerify() { | 712 void JSArray::JSArrayVerify() { |
| 710 JSObjectVerify(); | 713 JSObjectVerify(); |
| 711 CHECK(length()->IsNumber() || length()->IsUndefined()); | 714 Isolate* isolate = GetIsolate(); |
| 715 CHECK(length()->IsNumber() || length()->IsUndefined(isolate)); |
| 712 // If a GC was caused while constructing this array, the elements | 716 // If a GC was caused while constructing this array, the elements |
| 713 // pointer may point to a one pointer filler map. | 717 // pointer may point to a one pointer filler map. |
| 714 if (ElementsAreSafeToExamine()) { | 718 if (ElementsAreSafeToExamine()) { |
| 715 CHECK(elements()->IsUndefined() || | 719 CHECK(elements()->IsUndefined(isolate) || elements()->IsFixedArray() || |
| 716 elements()->IsFixedArray() || | |
| 717 elements()->IsFixedDoubleArray()); | 720 elements()->IsFixedDoubleArray()); |
| 718 } | 721 } |
| 719 } | 722 } |
| 720 | 723 |
| 721 | 724 |
| 722 void JSSet::JSSetVerify() { | 725 void JSSet::JSSetVerify() { |
| 723 CHECK(IsJSSet()); | 726 CHECK(IsJSSet()); |
| 724 JSObjectVerify(); | 727 JSObjectVerify(); |
| 725 VerifyHeapPointer(table()); | 728 VerifyHeapPointer(table()); |
| 726 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined()); | 729 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined(GetIsolate())); |
| 727 // TODO(arv): Verify OrderedHashTable too. | 730 // TODO(arv): Verify OrderedHashTable too. |
| 728 } | 731 } |
| 729 | 732 |
| 730 | 733 |
| 731 void JSMap::JSMapVerify() { | 734 void JSMap::JSMapVerify() { |
| 732 CHECK(IsJSMap()); | 735 CHECK(IsJSMap()); |
| 733 JSObjectVerify(); | 736 JSObjectVerify(); |
| 734 VerifyHeapPointer(table()); | 737 VerifyHeapPointer(table()); |
| 735 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined()); | 738 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined(GetIsolate())); |
| 736 // TODO(arv): Verify OrderedHashTable too. | 739 // TODO(arv): Verify OrderedHashTable too. |
| 737 } | 740 } |
| 738 | 741 |
| 739 | 742 |
| 740 void JSSetIterator::JSSetIteratorVerify() { | 743 void JSSetIterator::JSSetIteratorVerify() { |
| 741 CHECK(IsJSSetIterator()); | 744 CHECK(IsJSSetIterator()); |
| 742 JSObjectVerify(); | 745 JSObjectVerify(); |
| 743 VerifyHeapPointer(table()); | 746 VerifyHeapPointer(table()); |
| 744 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined()); | 747 Isolate* isolate = GetIsolate(); |
| 745 CHECK(index()->IsSmi() || index()->IsUndefined()); | 748 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined(isolate)); |
| 746 CHECK(kind()->IsSmi() || kind()->IsUndefined()); | 749 CHECK(index()->IsSmi() || index()->IsUndefined(isolate)); |
| 750 CHECK(kind()->IsSmi() || kind()->IsUndefined(isolate)); |
| 747 } | 751 } |
| 748 | 752 |
| 749 | 753 |
| 750 void JSMapIterator::JSMapIteratorVerify() { | 754 void JSMapIterator::JSMapIteratorVerify() { |
| 751 CHECK(IsJSMapIterator()); | 755 CHECK(IsJSMapIterator()); |
| 752 JSObjectVerify(); | 756 JSObjectVerify(); |
| 753 VerifyHeapPointer(table()); | 757 VerifyHeapPointer(table()); |
| 754 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined()); | 758 Isolate* isolate = GetIsolate(); |
| 755 CHECK(index()->IsSmi() || index()->IsUndefined()); | 759 CHECK(table()->IsOrderedHashTable() || table()->IsUndefined(isolate)); |
| 756 CHECK(kind()->IsSmi() || kind()->IsUndefined()); | 760 CHECK(index()->IsSmi() || index()->IsUndefined(isolate)); |
| 761 CHECK(kind()->IsSmi() || kind()->IsUndefined(isolate)); |
| 757 } | 762 } |
| 758 | 763 |
| 759 | 764 |
| 760 void JSWeakMap::JSWeakMapVerify() { | 765 void JSWeakMap::JSWeakMapVerify() { |
| 761 CHECK(IsJSWeakMap()); | 766 CHECK(IsJSWeakMap()); |
| 762 JSObjectVerify(); | 767 JSObjectVerify(); |
| 763 VerifyHeapPointer(table()); | 768 VerifyHeapPointer(table()); |
| 764 CHECK(table()->IsHashTable() || table()->IsUndefined()); | 769 CHECK(table()->IsHashTable() || table()->IsUndefined(GetIsolate())); |
| 765 } | 770 } |
| 766 | 771 |
| 767 | 772 |
| 768 void JSWeakSet::JSWeakSetVerify() { | 773 void JSWeakSet::JSWeakSetVerify() { |
| 769 CHECK(IsJSWeakSet()); | 774 CHECK(IsJSWeakSet()); |
| 770 JSObjectVerify(); | 775 JSObjectVerify(); |
| 771 VerifyHeapPointer(table()); | 776 VerifyHeapPointer(table()); |
| 772 CHECK(table()->IsHashTable() || table()->IsUndefined()); | 777 CHECK(table()->IsHashTable() || table()->IsUndefined(GetIsolate())); |
| 773 } | 778 } |
| 774 | 779 |
| 775 | 780 |
| 776 void JSRegExp::JSRegExpVerify() { | 781 void JSRegExp::JSRegExpVerify() { |
| 777 JSObjectVerify(); | 782 JSObjectVerify(); |
| 778 CHECK(data()->IsUndefined() || data()->IsFixedArray()); | 783 Isolate* isolate = GetIsolate(); |
| 784 CHECK(data()->IsUndefined(isolate) || data()->IsFixedArray()); |
| 779 switch (TypeTag()) { | 785 switch (TypeTag()) { |
| 780 case JSRegExp::ATOM: { | 786 case JSRegExp::ATOM: { |
| 781 FixedArray* arr = FixedArray::cast(data()); | 787 FixedArray* arr = FixedArray::cast(data()); |
| 782 CHECK(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); | 788 CHECK(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 783 break; | 789 break; |
| 784 } | 790 } |
| 785 case JSRegExp::IRREGEXP: { | 791 case JSRegExp::IRREGEXP: { |
| 786 bool is_native = RegExpImpl::UsesNativeRegExp(); | 792 bool is_native = RegExpImpl::UsesNativeRegExp(); |
| 787 | 793 |
| 788 FixedArray* arr = FixedArray::cast(data()); | 794 FixedArray* arr = FixedArray::cast(data()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 804 Object* uc16_saved = arr->get(JSRegExp::kIrregexpUC16CodeSavedIndex); | 810 Object* uc16_saved = arr->get(JSRegExp::kIrregexpUC16CodeSavedIndex); |
| 805 CHECK(uc16_saved->IsSmi() || uc16_saved->IsString() || | 811 CHECK(uc16_saved->IsSmi() || uc16_saved->IsString() || |
| 806 uc16_saved->IsCode()); | 812 uc16_saved->IsCode()); |
| 807 | 813 |
| 808 CHECK(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); | 814 CHECK(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 809 CHECK(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); | 815 CHECK(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
| 810 break; | 816 break; |
| 811 } | 817 } |
| 812 default: | 818 default: |
| 813 CHECK_EQ(JSRegExp::NOT_COMPILED, TypeTag()); | 819 CHECK_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 814 CHECK(data()->IsUndefined()); | 820 CHECK(data()->IsUndefined(isolate)); |
| 815 break; | 821 break; |
| 816 } | 822 } |
| 817 } | 823 } |
| 818 | 824 |
| 819 | 825 |
| 820 void JSProxy::JSProxyVerify() { | 826 void JSProxy::JSProxyVerify() { |
| 821 CHECK(IsJSProxy()); | 827 CHECK(IsJSProxy()); |
| 822 VerifyPointer(target()); | 828 VerifyPointer(target()); |
| 823 VerifyPointer(handler()); | 829 VerifyPointer(handler()); |
| 830 Isolate* isolate = GetIsolate(); |
| 824 CHECK_EQ(target()->IsCallable(), map()->is_callable()); | 831 CHECK_EQ(target()->IsCallable(), map()->is_callable()); |
| 825 CHECK_EQ(target()->IsConstructor(), map()->is_constructor()); | 832 CHECK_EQ(target()->IsConstructor(), map()->is_constructor()); |
| 826 CHECK(hash()->IsSmi() || hash()->IsUndefined()); | 833 CHECK(hash()->IsSmi() || hash()->IsUndefined(isolate)); |
| 827 CHECK(map()->prototype()->IsNull()); | 834 CHECK(map()->prototype()->IsNull()); |
| 828 // There should be no properties on a Proxy. | 835 // There should be no properties on a Proxy. |
| 829 CHECK_EQ(0, map()->NumberOfOwnDescriptors()); | 836 CHECK_EQ(0, map()->NumberOfOwnDescriptors()); |
| 830 } | 837 } |
| 831 | 838 |
| 832 | 839 |
| 833 void JSArrayBuffer::JSArrayBufferVerify() { | 840 void JSArrayBuffer::JSArrayBufferVerify() { |
| 834 CHECK(IsJSArrayBuffer()); | 841 CHECK(IsJSArrayBuffer()); |
| 835 JSObjectVerify(); | 842 JSObjectVerify(); |
| 836 VerifyPointer(byte_length()); | 843 VerifyPointer(byte_length()); |
| 837 CHECK(byte_length()->IsSmi() || byte_length()->IsHeapNumber() | 844 CHECK(byte_length()->IsSmi() || byte_length()->IsHeapNumber() || |
| 838 || byte_length()->IsUndefined()); | 845 byte_length()->IsUndefined(GetIsolate())); |
| 839 } | 846 } |
| 840 | 847 |
| 841 | 848 |
| 842 void JSArrayBufferView::JSArrayBufferViewVerify() { | 849 void JSArrayBufferView::JSArrayBufferViewVerify() { |
| 843 CHECK(IsJSArrayBufferView()); | 850 CHECK(IsJSArrayBufferView()); |
| 844 JSObjectVerify(); | 851 JSObjectVerify(); |
| 845 VerifyPointer(buffer()); | 852 VerifyPointer(buffer()); |
| 846 CHECK(buffer()->IsJSArrayBuffer() || buffer()->IsUndefined() | 853 Isolate* isolate = GetIsolate(); |
| 847 || buffer() == Smi::FromInt(0)); | 854 CHECK(buffer()->IsJSArrayBuffer() || buffer()->IsUndefined(isolate) || |
| 855 buffer() == Smi::FromInt(0)); |
| 848 | 856 |
| 849 VerifyPointer(raw_byte_offset()); | 857 VerifyPointer(raw_byte_offset()); |
| 850 CHECK(raw_byte_offset()->IsSmi() || raw_byte_offset()->IsHeapNumber() || | 858 CHECK(raw_byte_offset()->IsSmi() || raw_byte_offset()->IsHeapNumber() || |
| 851 raw_byte_offset()->IsUndefined()); | 859 raw_byte_offset()->IsUndefined(isolate)); |
| 852 | 860 |
| 853 VerifyPointer(raw_byte_length()); | 861 VerifyPointer(raw_byte_length()); |
| 854 CHECK(raw_byte_length()->IsSmi() || raw_byte_length()->IsHeapNumber() || | 862 CHECK(raw_byte_length()->IsSmi() || raw_byte_length()->IsHeapNumber() || |
| 855 raw_byte_length()->IsUndefined()); | 863 raw_byte_length()->IsUndefined(isolate)); |
| 856 } | 864 } |
| 857 | 865 |
| 858 | 866 |
| 859 void JSTypedArray::JSTypedArrayVerify() { | 867 void JSTypedArray::JSTypedArrayVerify() { |
| 860 CHECK(IsJSTypedArray()); | 868 CHECK(IsJSTypedArray()); |
| 861 JSArrayBufferViewVerify(); | 869 JSArrayBufferViewVerify(); |
| 862 VerifyPointer(raw_length()); | 870 VerifyPointer(raw_length()); |
| 863 CHECK(raw_length()->IsSmi() || raw_length()->IsHeapNumber() || | 871 CHECK(raw_length()->IsSmi() || raw_length()->IsHeapNumber() || |
| 864 raw_length()->IsUndefined()); | 872 raw_length()->IsUndefined(GetIsolate())); |
| 865 | 873 |
| 866 VerifyPointer(elements()); | 874 VerifyPointer(elements()); |
| 867 } | 875 } |
| 868 | 876 |
| 869 | 877 |
| 870 void JSDataView::JSDataViewVerify() { | 878 void JSDataView::JSDataViewVerify() { |
| 871 CHECK(IsJSDataView()); | 879 CHECK(IsJSDataView()); |
| 872 JSArrayBufferViewVerify(); | 880 JSArrayBufferViewVerify(); |
| 873 } | 881 } |
| 874 | 882 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 VerifyPointer(source()); | 1004 VerifyPointer(source()); |
| 997 VerifyPointer(name()); | 1005 VerifyPointer(name()); |
| 998 VerifyPointer(wrapper()); | 1006 VerifyPointer(wrapper()); |
| 999 VerifyPointer(line_ends()); | 1007 VerifyPointer(line_ends()); |
| 1000 } | 1008 } |
| 1001 | 1009 |
| 1002 | 1010 |
| 1003 void NormalizedMapCache::NormalizedMapCacheVerify() { | 1011 void NormalizedMapCache::NormalizedMapCacheVerify() { |
| 1004 FixedArray::cast(this)->FixedArrayVerify(); | 1012 FixedArray::cast(this)->FixedArrayVerify(); |
| 1005 if (FLAG_enable_slow_asserts) { | 1013 if (FLAG_enable_slow_asserts) { |
| 1014 Isolate* isolate = GetIsolate(); |
| 1006 for (int i = 0; i < length(); i++) { | 1015 for (int i = 0; i < length(); i++) { |
| 1007 Object* e = FixedArray::get(i); | 1016 Object* e = FixedArray::get(i); |
| 1008 if (e->IsMap()) { | 1017 if (e->IsMap()) { |
| 1009 Map::cast(e)->DictionaryMapVerify(); | 1018 Map::cast(e)->DictionaryMapVerify(); |
| 1010 } else { | 1019 } else { |
| 1011 CHECK(e->IsUndefined()); | 1020 CHECK(e->IsUndefined(isolate)); |
| 1012 } | 1021 } |
| 1013 } | 1022 } |
| 1014 } | 1023 } |
| 1015 } | 1024 } |
| 1016 | 1025 |
| 1017 | 1026 |
| 1018 void DebugInfo::DebugInfoVerify() { | 1027 void DebugInfo::DebugInfoVerify() { |
| 1019 CHECK(IsDebugInfo()); | 1028 CHECK(IsDebugInfo()); |
| 1020 VerifyPointer(shared()); | 1029 VerifyPointer(shared()); |
| 1021 VerifyPointer(abstract_code()); | 1030 VerifyPointer(abstract_code()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 case FAST_SMI_ELEMENTS: | 1064 case FAST_SMI_ELEMENTS: |
| 1056 case FAST_HOLEY_DOUBLE_ELEMENTS: | 1065 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 1057 case FAST_DOUBLE_ELEMENTS: | 1066 case FAST_DOUBLE_ELEMENTS: |
| 1058 case FAST_HOLEY_ELEMENTS: | 1067 case FAST_HOLEY_ELEMENTS: |
| 1059 case FAST_ELEMENTS: | 1068 case FAST_ELEMENTS: |
| 1060 case FAST_STRING_WRAPPER_ELEMENTS: { | 1069 case FAST_STRING_WRAPPER_ELEMENTS: { |
| 1061 info->number_of_objects_with_fast_elements_++; | 1070 info->number_of_objects_with_fast_elements_++; |
| 1062 int holes = 0; | 1071 int holes = 0; |
| 1063 FixedArray* e = FixedArray::cast(elements()); | 1072 FixedArray* e = FixedArray::cast(elements()); |
| 1064 int len = e->length(); | 1073 int len = e->length(); |
| 1065 Heap* heap = GetHeap(); | 1074 Isolate* isolate = GetIsolate(); |
| 1066 for (int i = 0; i < len; i++) { | 1075 for (int i = 0; i < len; i++) { |
| 1067 if (e->get(i) == heap->the_hole_value()) holes++; | 1076 if (e->get(i)->IsTheHole(isolate)) holes++; |
| 1068 } | 1077 } |
| 1069 info->number_of_fast_used_elements_ += len - holes; | 1078 info->number_of_fast_used_elements_ += len - holes; |
| 1070 info->number_of_fast_unused_elements_ += holes; | 1079 info->number_of_fast_unused_elements_ += holes; |
| 1071 break; | 1080 break; |
| 1072 } | 1081 } |
| 1073 | 1082 |
| 1074 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 1083 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 1075 case TYPE##_ELEMENTS: | 1084 case TYPE##_ELEMENTS: |
| 1076 | 1085 |
| 1077 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 1086 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 | 1325 |
| 1317 // Both are done at the same time. | 1326 // Both are done at the same time. |
| 1318 CHECK_EQ(new_it.done(), old_it.done()); | 1327 CHECK_EQ(new_it.done(), old_it.done()); |
| 1319 } | 1328 } |
| 1320 | 1329 |
| 1321 | 1330 |
| 1322 #endif // DEBUG | 1331 #endif // DEBUG |
| 1323 | 1332 |
| 1324 } // namespace internal | 1333 } // namespace internal |
| 1325 } // namespace v8 | 1334 } // namespace v8 |
| OLD | NEW |