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

Side by Side Diff: src/objects-inl.h

Issue 2126613002: making heap verification more aggressive (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding additional validation Created 4 years, 5 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/objects-debug.cc ('k') | src/runtime/runtime-literals.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 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 return obj->IsJSFunction(); 789 return obj->IsJSFunction();
790 } 790 }
791 791
792 792
793 TYPE_CHECKER(Code, CODE_TYPE) 793 TYPE_CHECKER(Code, CODE_TYPE)
794 TYPE_CHECKER(Oddball, ODDBALL_TYPE) 794 TYPE_CHECKER(Oddball, ODDBALL_TYPE)
795 TYPE_CHECKER(Cell, CELL_TYPE) 795 TYPE_CHECKER(Cell, CELL_TYPE)
796 TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE) 796 TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
797 TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE) 797 TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE)
798 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE) 798 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE)
799 TYPE_CHECKER(JSArgumentsObject, JS_ARGUMENTS_TYPE)
799 TYPE_CHECKER(JSDate, JS_DATE_TYPE) 800 TYPE_CHECKER(JSDate, JS_DATE_TYPE)
800 TYPE_CHECKER(JSError, JS_ERROR_TYPE) 801 TYPE_CHECKER(JSError, JS_ERROR_TYPE)
801 TYPE_CHECKER(JSGeneratorObject, JS_GENERATOR_OBJECT_TYPE) 802 TYPE_CHECKER(JSGeneratorObject, JS_GENERATOR_OBJECT_TYPE)
802 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) 803 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
803 TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE) 804 TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE)
804 TYPE_CHECKER(JSValue, JS_VALUE_TYPE) 805 TYPE_CHECKER(JSValue, JS_VALUE_TYPE)
805 806
806 bool HeapObject::IsAbstractCode() const { 807 bool HeapObject::IsAbstractCode() const {
807 return IsBytecodeArray() || IsCode(); 808 return IsBytecodeArray() || IsCode();
808 } 809 }
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 DCHECK(IsFixedArray()); 2349 DCHECK(IsFixedArray());
2349 DCHECK_GE(index, 0); 2350 DCHECK_GE(index, 0);
2350 DCHECK_LT(index, this->length()); 2351 DCHECK_LT(index, this->length());
2351 int offset = kHeaderSize + index * kPointerSize; 2352 int offset = kHeaderSize + index * kPointerSize;
2352 WRITE_FIELD(this, offset, value); 2353 WRITE_FIELD(this, offset, value);
2353 WRITE_BARRIER(GetHeap(), this, offset, value); 2354 WRITE_BARRIER(GetHeap(), this, offset, value);
2354 } 2355 }
2355 2356
2356 2357
2357 double FixedDoubleArray::get_scalar(int index) { 2358 double FixedDoubleArray::get_scalar(int index) {
2358 DCHECK(map() != GetHeap()->fixed_cow_array_map() && 2359 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map());
2359 map() != GetHeap()->fixed_array_map()); 2360 DCHECK_NE(GetHeap()->fixed_array_map(), map());
2360 DCHECK(index >= 0 && index < this->length()); 2361 DCHECK(index >= 0 && index < this->length());
2361 DCHECK(!is_the_hole(index)); 2362 DCHECK(!is_the_hole(index));
2362 return READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); 2363 return READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize);
2363 } 2364 }
2364 2365
2365 2366
2366 uint64_t FixedDoubleArray::get_representation(int index) { 2367 uint64_t FixedDoubleArray::get_representation(int index) {
2367 DCHECK(map() != GetHeap()->fixed_cow_array_map() && 2368 DCHECK_NE(GetHeap()->fixed_cow_array_map(), map());
2368 map() != GetHeap()->fixed_array_map()); 2369 DCHECK_NE(GetHeap()->fixed_array_map(), map());
2369 DCHECK(index >= 0 && index < this->length()); 2370 DCHECK(index >= 0 && index < this->length());
2370 int offset = kHeaderSize + index * kDoubleSize; 2371 int offset = kHeaderSize + index * kDoubleSize;
2371 return READ_UINT64_FIELD(this, offset); 2372 return READ_UINT64_FIELD(this, offset);
2372 } 2373 }
2373 2374
2374 Handle<Object> FixedDoubleArray::get(FixedDoubleArray* array, int index, 2375 Handle<Object> FixedDoubleArray::get(FixedDoubleArray* array, int index,
2375 Isolate* isolate) { 2376 Isolate* isolate) {
2376 if (array->is_the_hole(index)) { 2377 if (array->is_the_hole(index)) {
2377 return isolate->factory()->the_hole_value(); 2378 return isolate->factory()->the_hole_value();
2378 } else { 2379 } else {
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 CAST_ACCESSOR(FixedDoubleArray) 3201 CAST_ACCESSOR(FixedDoubleArray)
3201 CAST_ACCESSOR(FixedTypedArrayBase) 3202 CAST_ACCESSOR(FixedTypedArrayBase)
3202 CAST_ACCESSOR(Float32x4) 3203 CAST_ACCESSOR(Float32x4)
3203 CAST_ACCESSOR(Foreign) 3204 CAST_ACCESSOR(Foreign)
3204 CAST_ACCESSOR(GlobalDictionary) 3205 CAST_ACCESSOR(GlobalDictionary)
3205 CAST_ACCESSOR(HandlerTable) 3206 CAST_ACCESSOR(HandlerTable)
3206 CAST_ACCESSOR(HeapObject) 3207 CAST_ACCESSOR(HeapObject)
3207 CAST_ACCESSOR(Int16x8) 3208 CAST_ACCESSOR(Int16x8)
3208 CAST_ACCESSOR(Int32x4) 3209 CAST_ACCESSOR(Int32x4)
3209 CAST_ACCESSOR(Int8x16) 3210 CAST_ACCESSOR(Int8x16)
3211 CAST_ACCESSOR(JSArgumentsObject)
3210 CAST_ACCESSOR(JSArray) 3212 CAST_ACCESSOR(JSArray)
3211 CAST_ACCESSOR(JSArrayBuffer) 3213 CAST_ACCESSOR(JSArrayBuffer)
3212 CAST_ACCESSOR(JSArrayBufferView) 3214 CAST_ACCESSOR(JSArrayBufferView)
3213 CAST_ACCESSOR(JSBoundFunction) 3215 CAST_ACCESSOR(JSBoundFunction)
3214 CAST_ACCESSOR(JSDataView) 3216 CAST_ACCESSOR(JSDataView)
3215 CAST_ACCESSOR(JSDate) 3217 CAST_ACCESSOR(JSDate)
3216 CAST_ACCESSOR(JSFunction) 3218 CAST_ACCESSOR(JSFunction)
3217 CAST_ACCESSOR(JSGeneratorObject) 3219 CAST_ACCESSOR(JSGeneratorObject)
3218 CAST_ACCESSOR(JSGlobalObject) 3220 CAST_ACCESSOR(JSGlobalObject)
3219 CAST_ACCESSOR(JSGlobalProxy) 3221 CAST_ACCESSOR(JSGlobalProxy)
(...skipping 3641 matching lines...) Expand 10 before | Expand all | Expand 10 after
6861 6863
6862 void JSRegExp::SetDataAt(int index, Object* value) { 6864 void JSRegExp::SetDataAt(int index, Object* value) {
6863 DCHECK(TypeTag() != NOT_COMPILED); 6865 DCHECK(TypeTag() != NOT_COMPILED);
6864 DCHECK(index >= kDataIndex); // Only implementation data can be set this way. 6866 DCHECK(index >= kDataIndex); // Only implementation data can be set this way.
6865 FixedArray::cast(data())->set(index, value); 6867 FixedArray::cast(data())->set(index, value);
6866 } 6868 }
6867 6869
6868 6870
6869 ElementsKind JSObject::GetElementsKind() { 6871 ElementsKind JSObject::GetElementsKind() {
6870 ElementsKind kind = map()->elements_kind(); 6872 ElementsKind kind = map()->elements_kind();
6871 #if VERIFY_HEAP && DEBUG
6872 FixedArrayBase* fixed_array =
6873 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset));
6874
6875 // If a GC was caused while constructing this object, the elements
6876 // pointer may point to a one pointer filler map.
6877 if (ElementsAreSafeToExamine()) {
6878 Map* map = fixed_array->map();
6879 if (IsFastSmiOrObjectElementsKind(kind)) {
6880 DCHECK(map == GetHeap()->fixed_array_map() ||
6881 map == GetHeap()->fixed_cow_array_map());
6882 } else if (IsFastDoubleElementsKind(kind)) {
6883 DCHECK(fixed_array->IsFixedDoubleArray() ||
6884 fixed_array == GetHeap()->empty_fixed_array());
6885 } else if (kind == DICTIONARY_ELEMENTS) {
6886 DCHECK(fixed_array->IsFixedArray());
6887 DCHECK(fixed_array->IsDictionary());
6888 } else {
6889 DCHECK(kind > DICTIONARY_ELEMENTS);
6890 }
6891 DCHECK(!IsSloppyArgumentsElements(kind) ||
6892 (elements()->IsFixedArray() && elements()->length() >= 2));
6893 }
6894 #endif
6895 return kind; 6873 return kind;
6896 } 6874 }
6897 6875
6898 6876
6899 bool JSObject::HasFastObjectElements() { 6877 bool JSObject::HasFastObjectElements() {
6900 return IsFastObjectElementsKind(GetElementsKind()); 6878 return IsFastObjectElementsKind(GetElementsKind());
6901 } 6879 }
6902 6880
6903 6881
6904 bool JSObject::HasFastSmiElements() { 6882 bool JSObject::HasFastSmiElements() {
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
8105 #undef WRITE_INT64_FIELD 8083 #undef WRITE_INT64_FIELD
8106 #undef READ_BYTE_FIELD 8084 #undef READ_BYTE_FIELD
8107 #undef WRITE_BYTE_FIELD 8085 #undef WRITE_BYTE_FIELD
8108 #undef NOBARRIER_READ_BYTE_FIELD 8086 #undef NOBARRIER_READ_BYTE_FIELD
8109 #undef NOBARRIER_WRITE_BYTE_FIELD 8087 #undef NOBARRIER_WRITE_BYTE_FIELD
8110 8088
8111 } // namespace internal 8089 } // namespace internal
8112 } // namespace v8 8090 } // namespace v8
8113 8091
8114 #endif // V8_OBJECTS_INL_H_ 8092 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/runtime/runtime-literals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698