Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
| 30 | #include "disassembler.h" |
| 31 | #include "disasm.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 32 | #include "jsregexp.h" |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 33 | #include "objects-visiting.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 34 | |
| 35 | namespace v8 { |
| 36 | namespace internal { |
| 37 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 38 | #ifdef DEBUG |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 39 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 40 | void MaybeObject::Verify() { |
| 41 | Object* this_as_object; |
| 42 | if (ToObject(&this_as_object)) { |
| 43 | if (this_as_object->IsSmi()) { |
| 44 | Smi::cast(this_as_object)->SmiVerify(); |
| 45 | } else { |
| 46 | HeapObject::cast(this_as_object)->HeapObjectVerify(); |
| 47 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 48 | } else { |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 49 | Failure::cast(this)->FailureVerify(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
| 53 | |
| 54 | void Object::VerifyPointer(Object* p) { |
| 55 | if (p->IsHeapObject()) { |
| 56 | HeapObject::VerifyHeapPointer(p); |
| 57 | } else { |
| 58 | ASSERT(p->IsSmi()); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | |
| 63 | void Smi::SmiVerify() { |
| 64 | ASSERT(IsSmi()); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | void Failure::FailureVerify() { |
| 69 | ASSERT(IsFailure()); |
| 70 | } |
| 71 | |
| 72 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 73 | void HeapObject::HeapObjectVerify() { |
| 74 | InstanceType instance_type = map()->instance_type(); |
| 75 | |
| 76 | if (instance_type < FIRST_NONSTRING_TYPE) { |
| 77 | String::cast(this)->StringVerify(); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | switch (instance_type) { |
| 82 | case MAP_TYPE: |
| 83 | Map::cast(this)->MapVerify(); |
| 84 | break; |
| 85 | case HEAP_NUMBER_TYPE: |
| 86 | HeapNumber::cast(this)->HeapNumberVerify(); |
| 87 | break; |
| 88 | case FIXED_ARRAY_TYPE: |
| 89 | FixedArray::cast(this)->FixedArrayVerify(); |
| 90 | break; |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 91 | case FIXED_DOUBLE_ARRAY_TYPE: |
| 92 | FixedDoubleArray::cast(this)->FixedDoubleArrayVerify(); |
| 93 | break; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 94 | case BYTE_ARRAY_TYPE: |
| 95 | ByteArray::cast(this)->ByteArrayVerify(); |
| 96 | break; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 97 | case EXTERNAL_PIXEL_ARRAY_TYPE: |
| 98 | ExternalPixelArray::cast(this)->ExternalPixelArrayVerify(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 99 | break; |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 100 | case EXTERNAL_BYTE_ARRAY_TYPE: |
| 101 | ExternalByteArray::cast(this)->ExternalByteArrayVerify(); |
| 102 | break; |
| 103 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 104 | ExternalUnsignedByteArray::cast(this)->ExternalUnsignedByteArrayVerify(); |
| 105 | break; |
| 106 | case EXTERNAL_SHORT_ARRAY_TYPE: |
| 107 | ExternalShortArray::cast(this)->ExternalShortArrayVerify(); |
| 108 | break; |
| 109 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 110 | ExternalUnsignedShortArray::cast(this)-> |
| 111 | ExternalUnsignedShortArrayVerify(); |
| 112 | break; |
| 113 | case EXTERNAL_INT_ARRAY_TYPE: |
| 114 | ExternalIntArray::cast(this)->ExternalIntArrayVerify(); |
| 115 | break; |
| 116 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 117 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayVerify(); |
| 118 | break; |
| 119 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 120 | ExternalFloatArray::cast(this)->ExternalFloatArrayVerify(); |
| 121 | break; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 122 | case EXTERNAL_DOUBLE_ARRAY_TYPE: |
| 123 | ExternalDoubleArray::cast(this)->ExternalDoubleArrayVerify(); |
| 124 | break; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 125 | case CODE_TYPE: |
| 126 | Code::cast(this)->CodeVerify(); |
| 127 | break; |
| 128 | case ODDBALL_TYPE: |
| 129 | Oddball::cast(this)->OddballVerify(); |
| 130 | break; |
| 131 | case JS_OBJECT_TYPE: |
| 132 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 133 | JSObject::cast(this)->JSObjectVerify(); |
| 134 | break; |
| 135 | case JS_VALUE_TYPE: |
| 136 | JSValue::cast(this)->JSValueVerify(); |
| 137 | break; |
| 138 | case JS_FUNCTION_TYPE: |
| 139 | JSFunction::cast(this)->JSFunctionVerify(); |
| 140 | break; |
| 141 | case JS_GLOBAL_PROXY_TYPE: |
| 142 | JSGlobalProxy::cast(this)->JSGlobalProxyVerify(); |
| 143 | break; |
| 144 | case JS_GLOBAL_OBJECT_TYPE: |
| 145 | JSGlobalObject::cast(this)->JSGlobalObjectVerify(); |
| 146 | break; |
| 147 | case JS_BUILTINS_OBJECT_TYPE: |
| 148 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectVerify(); |
| 149 | break; |
| 150 | case JS_GLOBAL_PROPERTY_CELL_TYPE: |
| 151 | JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellVerify(); |
| 152 | break; |
| 153 | case JS_ARRAY_TYPE: |
| 154 | JSArray::cast(this)->JSArrayVerify(); |
| 155 | break; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame^] | 156 | case JS_WEAK_MAP_TYPE: |
| 157 | JSWeakMap::cast(this)->JSWeakMapVerify(); |
| 158 | break; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 159 | case JS_REGEXP_TYPE: |
| 160 | JSRegExp::cast(this)->JSRegExpVerify(); |
| 161 | break; |
| 162 | case FILLER_TYPE: |
| 163 | break; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 164 | case JS_PROXY_TYPE: |
| 165 | JSProxy::cast(this)->JSProxyVerify(); |
| 166 | break; |
| 167 | case FOREIGN_TYPE: |
| 168 | Foreign::cast(this)->ForeignVerify(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 169 | break; |
| 170 | case SHARED_FUNCTION_INFO_TYPE: |
| 171 | SharedFunctionInfo::cast(this)->SharedFunctionInfoVerify(); |
| 172 | break; |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 173 | case JS_MESSAGE_OBJECT_TYPE: |
| 174 | JSMessageObject::cast(this)->JSMessageObjectVerify(); |
| 175 | break; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 176 | |
| 177 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 178 | case NAME##_TYPE: \ |
| 179 | Name::cast(this)->Name##Verify(); \ |
| 180 | break; |
| 181 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 182 | #undef MAKE_STRUCT_CASE |
| 183 | |
| 184 | default: |
| 185 | UNREACHABLE(); |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | |
| 191 | void HeapObject::VerifyHeapPointer(Object* p) { |
| 192 | ASSERT(p->IsHeapObject()); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 193 | ASSERT(HEAP->Contains(HeapObject::cast(p))); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | |
| 197 | void HeapNumber::HeapNumberVerify() { |
| 198 | ASSERT(IsHeapNumber()); |
| 199 | } |
| 200 | |
| 201 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 202 | void ByteArray::ByteArrayVerify() { |
| 203 | ASSERT(IsByteArray()); |
| 204 | } |
| 205 | |
| 206 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 207 | void ExternalPixelArray::ExternalPixelArrayVerify() { |
| 208 | ASSERT(IsExternalPixelArray()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 212 | void ExternalByteArray::ExternalByteArrayVerify() { |
| 213 | ASSERT(IsExternalByteArray()); |
| 214 | } |
| 215 | |
| 216 | |
| 217 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayVerify() { |
| 218 | ASSERT(IsExternalUnsignedByteArray()); |
| 219 | } |
| 220 | |
| 221 | |
| 222 | void ExternalShortArray::ExternalShortArrayVerify() { |
| 223 | ASSERT(IsExternalShortArray()); |
| 224 | } |
| 225 | |
| 226 | |
| 227 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayVerify() { |
| 228 | ASSERT(IsExternalUnsignedShortArray()); |
| 229 | } |
| 230 | |
| 231 | |
| 232 | void ExternalIntArray::ExternalIntArrayVerify() { |
| 233 | ASSERT(IsExternalIntArray()); |
| 234 | } |
| 235 | |
| 236 | |
| 237 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayVerify() { |
| 238 | ASSERT(IsExternalUnsignedIntArray()); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | void ExternalFloatArray::ExternalFloatArrayVerify() { |
| 243 | ASSERT(IsExternalFloatArray()); |
| 244 | } |
| 245 | |
| 246 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 247 | void ExternalDoubleArray::ExternalDoubleArrayVerify() { |
| 248 | ASSERT(IsExternalDoubleArray()); |
| 249 | } |
| 250 | |
| 251 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 252 | void JSObject::JSObjectVerify() { |
| 253 | VerifyHeapPointer(properties()); |
| 254 | VerifyHeapPointer(elements()); |
| 255 | if (HasFastProperties()) { |
| 256 | CHECK_EQ(map()->unused_property_fields(), |
| 257 | (map()->inobject_properties() + properties()->length() - |
| 258 | map()->NextFreePropertyIndex())); |
| 259 | } |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 260 | ASSERT(map()->has_fast_elements() == |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 261 | (elements()->map() == GetHeap()->fixed_array_map() || |
| 262 | elements()->map() == GetHeap()->fixed_cow_array_map())); |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 263 | ASSERT(map()->has_fast_elements() == HasFastElements()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 267 | void Map::MapVerify() { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 268 | ASSERT(!HEAP->InNewSpace(this)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 269 | ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
Steve Block | 791712a | 2010-08-27 10:21:07 +0100 | [diff] [blame] | 270 | ASSERT(instance_size() == kVariableSizeSentinel || |
| 271 | (kPointerSize <= instance_size() && |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 272 | instance_size() < HEAP->Capacity())); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 273 | VerifyHeapPointer(prototype()); |
| 274 | VerifyHeapPointer(instance_descriptors()); |
| 275 | } |
| 276 | |
| 277 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 278 | void Map::SharedMapVerify() { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 279 | MapVerify(); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 280 | ASSERT(is_shared()); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 281 | ASSERT(instance_descriptors()->IsEmpty()); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 282 | ASSERT_EQ(0, pre_allocated_property_fields()); |
| 283 | ASSERT_EQ(0, unused_property_fields()); |
| 284 | ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), |
| 285 | visitor_id()); |
| 286 | } |
| 287 | |
| 288 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 289 | void CodeCache::CodeCacheVerify() { |
| 290 | VerifyHeapPointer(default_cache()); |
| 291 | VerifyHeapPointer(normal_type_cache()); |
| 292 | ASSERT(default_cache()->IsFixedArray()); |
| 293 | ASSERT(normal_type_cache()->IsUndefined() |
| 294 | || normal_type_cache()->IsCodeCacheHashTable()); |
| 295 | } |
| 296 | |
| 297 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 298 | void PolymorphicCodeCache::PolymorphicCodeCacheVerify() { |
| 299 | VerifyHeapPointer(cache()); |
| 300 | ASSERT(cache()->IsUndefined() || cache()->IsPolymorphicCodeCacheHashTable()); |
| 301 | } |
| 302 | |
| 303 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 304 | void FixedArray::FixedArrayVerify() { |
| 305 | for (int i = 0; i < length(); i++) { |
| 306 | Object* e = get(i); |
| 307 | if (e->IsHeapObject()) { |
| 308 | VerifyHeapPointer(e); |
| 309 | } else { |
| 310 | e->Verify(); |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 316 | void FixedDoubleArray::FixedDoubleArrayVerify() { |
| 317 | for (int i = 0; i < length(); i++) { |
| 318 | if (!is_the_hole(i)) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame^] | 319 | double value = get_scalar(i); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 320 | ASSERT(!isnan(value) || |
| 321 | (BitCast<uint64_t>(value) == |
| 322 | BitCast<uint64_t>(canonical_not_the_hole_nan_as_double()))); |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 328 | void JSValue::JSValueVerify() { |
| 329 | Object* v = value(); |
| 330 | if (v->IsHeapObject()) { |
| 331 | VerifyHeapPointer(v); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 336 | void JSMessageObject::JSMessageObjectVerify() { |
| 337 | CHECK(IsJSMessageObject()); |
| 338 | CHECK(type()->IsString()); |
| 339 | CHECK(arguments()->IsJSArray()); |
| 340 | VerifyObjectField(kStartPositionOffset); |
| 341 | VerifyObjectField(kEndPositionOffset); |
| 342 | VerifyObjectField(kArgumentsOffset); |
| 343 | VerifyObjectField(kScriptOffset); |
| 344 | VerifyObjectField(kStackTraceOffset); |
| 345 | VerifyObjectField(kStackFramesOffset); |
| 346 | } |
| 347 | |
| 348 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 349 | void String::StringVerify() { |
| 350 | CHECK(IsString()); |
| 351 | CHECK(length() >= 0 && length() <= Smi::kMaxValue); |
| 352 | if (IsSymbol()) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 353 | CHECK(!HEAP->InNewSpace(this)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 354 | } |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame^] | 355 | if (IsConsString()) { |
| 356 | ConsString::cast(this)->ConsStringVerify(); |
| 357 | } else if (IsSlicedString()) { |
| 358 | SlicedString::cast(this)->SlicedStringVerify(); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | |
| 363 | void ConsString::ConsStringVerify() { |
| 364 | CHECK(this->first()->IsString()); |
| 365 | CHECK(this->second() == GetHeap()->empty_string() || |
| 366 | this->second()->IsString()); |
| 367 | CHECK(this->length() >= String::kMinNonFlatLength); |
| 368 | if (this->IsFlat()) { |
| 369 | // A flat cons can only be created by String::SlowTryFlatten. |
| 370 | // Afterwards, the first part may be externalized. |
| 371 | CHECK(this->first()->IsSeqString() || this->first()->IsExternalString()); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | |
| 376 | void SlicedString::SlicedStringVerify() { |
| 377 | CHECK(!this->parent()->IsConsString()); |
| 378 | CHECK(!this->parent()->IsSlicedString()); |
| 379 | CHECK(this->length() >= SlicedString::kMinLength); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 383 | void JSFunction::JSFunctionVerify() { |
| 384 | CHECK(IsJSFunction()); |
| 385 | VerifyObjectField(kPrototypeOrInitialMapOffset); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 386 | VerifyObjectField(kNextFunctionLinkOffset); |
| 387 | CHECK(next_function_link()->IsUndefined() || |
| 388 | next_function_link()->IsJSFunction()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 392 | void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 393 | CHECK(IsSharedFunctionInfo()); |
| 394 | VerifyObjectField(kNameOffset); |
| 395 | VerifyObjectField(kCodeOffset); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 396 | VerifyObjectField(kScopeInfoOffset); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 397 | VerifyObjectField(kInstanceClassNameOffset); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 398 | VerifyObjectField(kFunctionDataOffset); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 399 | VerifyObjectField(kScriptOffset); |
| 400 | VerifyObjectField(kDebugInfoOffset); |
| 401 | } |
| 402 | |
| 403 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 404 | void JSGlobalProxy::JSGlobalProxyVerify() { |
| 405 | CHECK(IsJSGlobalProxy()); |
| 406 | JSObjectVerify(); |
| 407 | VerifyObjectField(JSGlobalProxy::kContextOffset); |
| 408 | // Make sure that this object has no properties, elements. |
| 409 | CHECK_EQ(0, properties()->length()); |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 410 | CHECK(HasFastElements()); |
| 411 | CHECK_EQ(0, FixedArray::cast(elements())->length()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 415 | void JSGlobalObject::JSGlobalObjectVerify() { |
| 416 | CHECK(IsJSGlobalObject()); |
| 417 | JSObjectVerify(); |
| 418 | for (int i = GlobalObject::kBuiltinsOffset; |
| 419 | i < JSGlobalObject::kSize; |
| 420 | i += kPointerSize) { |
| 421 | VerifyObjectField(i); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 426 | void JSBuiltinsObject::JSBuiltinsObjectVerify() { |
| 427 | CHECK(IsJSBuiltinsObject()); |
| 428 | JSObjectVerify(); |
| 429 | for (int i = GlobalObject::kBuiltinsOffset; |
| 430 | i < JSBuiltinsObject::kSize; |
| 431 | i += kPointerSize) { |
| 432 | VerifyObjectField(i); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | |
| 437 | void Oddball::OddballVerify() { |
| 438 | CHECK(IsOddball()); |
| 439 | VerifyHeapPointer(to_string()); |
| 440 | Object* number = to_number(); |
| 441 | if (number->IsHeapObject()) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 442 | ASSERT(number == HEAP->nan_value()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 443 | } else { |
| 444 | ASSERT(number->IsSmi()); |
| 445 | int value = Smi::cast(number)->value(); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 446 | // Hidden oddballs have negative smis. |
| 447 | const int kLeastHiddenOddballNumber = -4; |
| 448 | ASSERT(value <= 1); |
| 449 | ASSERT(value >= kLeastHiddenOddballNumber); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | |
| 453 | |
| 454 | void JSGlobalPropertyCell::JSGlobalPropertyCellVerify() { |
| 455 | CHECK(IsJSGlobalPropertyCell()); |
| 456 | VerifyObjectField(kValueOffset); |
| 457 | } |
| 458 | |
| 459 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 460 | void Code::CodeVerify() { |
| 461 | CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 462 | kCodeAlignment)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 463 | Address last_gc_pc = NULL; |
| 464 | for (RelocIterator it(this); !it.done(); it.next()) { |
| 465 | it.rinfo()->Verify(); |
| 466 | // Ensure that GC will not iterate twice over the same pointer. |
| 467 | if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { |
| 468 | CHECK(it.rinfo()->pc() != last_gc_pc); |
| 469 | last_gc_pc = it.rinfo()->pc(); |
| 470 | } |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | |
| 475 | void JSArray::JSArrayVerify() { |
| 476 | JSObjectVerify(); |
| 477 | ASSERT(length()->IsNumber() || length()->IsUndefined()); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 478 | ASSERT(elements()->IsUndefined() || |
| 479 | elements()->IsFixedArray() || |
| 480 | elements()->IsFixedDoubleArray()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame^] | 484 | void JSWeakMap::JSWeakMapVerify() { |
| 485 | CHECK(IsJSWeakMap()); |
| 486 | JSObjectVerify(); |
| 487 | VerifyHeapPointer(table()); |
| 488 | ASSERT(table()->IsHashTable()); |
| 489 | } |
| 490 | |
| 491 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 492 | void JSRegExp::JSRegExpVerify() { |
| 493 | JSObjectVerify(); |
| 494 | ASSERT(data()->IsUndefined() || data()->IsFixedArray()); |
| 495 | switch (TypeTag()) { |
| 496 | case JSRegExp::ATOM: { |
| 497 | FixedArray* arr = FixedArray::cast(data()); |
| 498 | ASSERT(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 499 | break; |
| 500 | } |
| 501 | case JSRegExp::IRREGEXP: { |
| 502 | bool is_native = RegExpImpl::UsesNativeRegExp(); |
| 503 | |
| 504 | FixedArray* arr = FixedArray::cast(data()); |
| 505 | Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 506 | // Smi : Not compiled yet (-1) or code prepared for flushing. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 507 | // JSObject: Compilation error. |
| 508 | // Code/ByteArray: Compiled code. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 509 | ASSERT(ascii_data->IsSmi() || |
| 510 | (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray())); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 511 | Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 512 | ASSERT(uc16_data->IsSmi() || |
| 513 | (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray())); |
| 514 | |
| 515 | Object* ascii_saved = arr->get(JSRegExp::kIrregexpASCIICodeSavedIndex); |
| 516 | ASSERT(ascii_saved->IsSmi() || ascii_saved->IsString() || |
| 517 | ascii_saved->IsCode()); |
| 518 | Object* uc16_saved = arr->get(JSRegExp::kIrregexpUC16CodeSavedIndex); |
| 519 | ASSERT(uc16_saved->IsSmi() || uc16_saved->IsString() || |
| 520 | uc16_saved->IsCode()); |
| 521 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 522 | ASSERT(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 523 | ASSERT(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
| 524 | break; |
| 525 | } |
| 526 | default: |
| 527 | ASSERT_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 528 | ASSERT(data()->IsUndefined()); |
| 529 | break; |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 534 | void JSProxy::JSProxyVerify() { |
| 535 | ASSERT(IsJSProxy()); |
| 536 | VerifyPointer(handler()); |
| 537 | } |
| 538 | |
| 539 | void Foreign::ForeignVerify() { |
| 540 | ASSERT(IsForeign()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | |
| 544 | void AccessorInfo::AccessorInfoVerify() { |
| 545 | CHECK(IsAccessorInfo()); |
| 546 | VerifyPointer(getter()); |
| 547 | VerifyPointer(setter()); |
| 548 | VerifyPointer(name()); |
| 549 | VerifyPointer(data()); |
| 550 | VerifyPointer(flag()); |
| 551 | } |
| 552 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 553 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 554 | void AccessCheckInfo::AccessCheckInfoVerify() { |
| 555 | CHECK(IsAccessCheckInfo()); |
| 556 | VerifyPointer(named_callback()); |
| 557 | VerifyPointer(indexed_callback()); |
| 558 | VerifyPointer(data()); |
| 559 | } |
| 560 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 561 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 562 | void InterceptorInfo::InterceptorInfoVerify() { |
| 563 | CHECK(IsInterceptorInfo()); |
| 564 | VerifyPointer(getter()); |
| 565 | VerifyPointer(setter()); |
| 566 | VerifyPointer(query()); |
| 567 | VerifyPointer(deleter()); |
| 568 | VerifyPointer(enumerator()); |
| 569 | VerifyPointer(data()); |
| 570 | } |
| 571 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 572 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 573 | void CallHandlerInfo::CallHandlerInfoVerify() { |
| 574 | CHECK(IsCallHandlerInfo()); |
| 575 | VerifyPointer(callback()); |
| 576 | VerifyPointer(data()); |
| 577 | } |
| 578 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 579 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 580 | void TemplateInfo::TemplateInfoVerify() { |
| 581 | VerifyPointer(tag()); |
| 582 | VerifyPointer(property_list()); |
| 583 | } |
| 584 | |
| 585 | void FunctionTemplateInfo::FunctionTemplateInfoVerify() { |
| 586 | CHECK(IsFunctionTemplateInfo()); |
| 587 | TemplateInfoVerify(); |
| 588 | VerifyPointer(serial_number()); |
| 589 | VerifyPointer(call_code()); |
| 590 | VerifyPointer(property_accessors()); |
| 591 | VerifyPointer(prototype_template()); |
| 592 | VerifyPointer(parent_template()); |
| 593 | VerifyPointer(named_property_handler()); |
| 594 | VerifyPointer(indexed_property_handler()); |
| 595 | VerifyPointer(instance_template()); |
| 596 | VerifyPointer(signature()); |
| 597 | VerifyPointer(access_check_info()); |
| 598 | } |
| 599 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 600 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 601 | void ObjectTemplateInfo::ObjectTemplateInfoVerify() { |
| 602 | CHECK(IsObjectTemplateInfo()); |
| 603 | TemplateInfoVerify(); |
| 604 | VerifyPointer(constructor()); |
| 605 | VerifyPointer(internal_field_count()); |
| 606 | } |
| 607 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 608 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 609 | void SignatureInfo::SignatureInfoVerify() { |
| 610 | CHECK(IsSignatureInfo()); |
| 611 | VerifyPointer(receiver()); |
| 612 | VerifyPointer(args()); |
| 613 | } |
| 614 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 615 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 616 | void TypeSwitchInfo::TypeSwitchInfoVerify() { |
| 617 | CHECK(IsTypeSwitchInfo()); |
| 618 | VerifyPointer(types()); |
| 619 | } |
| 620 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 621 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 622 | void Script::ScriptVerify() { |
| 623 | CHECK(IsScript()); |
| 624 | VerifyPointer(source()); |
| 625 | VerifyPointer(name()); |
| 626 | line_offset()->SmiVerify(); |
| 627 | column_offset()->SmiVerify(); |
| 628 | VerifyPointer(data()); |
| 629 | VerifyPointer(wrapper()); |
| 630 | type()->SmiVerify(); |
| 631 | VerifyPointer(line_ends()); |
| 632 | VerifyPointer(id()); |
| 633 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 634 | |
| 635 | |
| 636 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 637 | void DebugInfo::DebugInfoVerify() { |
| 638 | CHECK(IsDebugInfo()); |
| 639 | VerifyPointer(shared()); |
| 640 | VerifyPointer(original_code()); |
| 641 | VerifyPointer(code()); |
| 642 | VerifyPointer(break_points()); |
| 643 | } |
| 644 | |
| 645 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 646 | void BreakPointInfo::BreakPointInfoVerify() { |
| 647 | CHECK(IsBreakPointInfo()); |
| 648 | code_position()->SmiVerify(); |
| 649 | source_position()->SmiVerify(); |
| 650 | statement_position()->SmiVerify(); |
| 651 | VerifyPointer(break_point_objects()); |
| 652 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 653 | #endif // ENABLE_DEBUGGER_SUPPORT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 654 | |
| 655 | |
| 656 | void JSObject::IncrementSpillStatistics(SpillInformation* info) { |
| 657 | info->number_of_objects_++; |
| 658 | // Named properties |
| 659 | if (HasFastProperties()) { |
| 660 | info->number_of_objects_with_fast_properties_++; |
| 661 | info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 662 | info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 663 | } else { |
| 664 | StringDictionary* dict = property_dictionary(); |
| 665 | info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 666 | info->number_of_slow_unused_properties_ += |
| 667 | dict->Capacity() - dict->NumberOfElements(); |
| 668 | } |
| 669 | // Indexed properties |
| 670 | switch (GetElementsKind()) { |
| 671 | case FAST_ELEMENTS: { |
| 672 | info->number_of_objects_with_fast_elements_++; |
| 673 | int holes = 0; |
| 674 | FixedArray* e = FixedArray::cast(elements()); |
| 675 | int len = e->length(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 676 | Heap* heap = HEAP; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 677 | for (int i = 0; i < len; i++) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 678 | if (e->get(i) == heap->the_hole_value()) holes++; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 679 | } |
| 680 | info->number_of_fast_used_elements_ += len - holes; |
| 681 | info->number_of_fast_unused_elements_ += holes; |
| 682 | break; |
| 683 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 684 | case EXTERNAL_PIXEL_ELEMENTS: { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 685 | info->number_of_objects_with_fast_elements_++; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 686 | ExternalPixelArray* e = ExternalPixelArray::cast(elements()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 687 | info->number_of_fast_used_elements_ += e->length(); |
| 688 | break; |
| 689 | } |
| 690 | case DICTIONARY_ELEMENTS: { |
| 691 | NumberDictionary* dict = element_dictionary(); |
| 692 | info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 693 | info->number_of_slow_unused_elements_ += |
| 694 | dict->Capacity() - dict->NumberOfElements(); |
| 695 | break; |
| 696 | } |
| 697 | default: |
| 698 | UNREACHABLE(); |
| 699 | break; |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | |
| 704 | void JSObject::SpillInformation::Clear() { |
| 705 | number_of_objects_ = 0; |
| 706 | number_of_objects_with_fast_properties_ = 0; |
| 707 | number_of_objects_with_fast_elements_ = 0; |
| 708 | number_of_fast_used_fields_ = 0; |
| 709 | number_of_fast_unused_fields_ = 0; |
| 710 | number_of_slow_used_properties_ = 0; |
| 711 | number_of_slow_unused_properties_ = 0; |
| 712 | number_of_fast_used_elements_ = 0; |
| 713 | number_of_fast_unused_elements_ = 0; |
| 714 | number_of_slow_used_elements_ = 0; |
| 715 | number_of_slow_unused_elements_ = 0; |
| 716 | } |
| 717 | |
| 718 | void JSObject::SpillInformation::Print() { |
| 719 | PrintF("\n JSObject Spill Statistics (#%d):\n", number_of_objects_); |
| 720 | |
| 721 | PrintF(" - fast properties (#%d): %d (used) %d (unused)\n", |
| 722 | number_of_objects_with_fast_properties_, |
| 723 | number_of_fast_used_fields_, number_of_fast_unused_fields_); |
| 724 | |
| 725 | PrintF(" - slow properties (#%d): %d (used) %d (unused)\n", |
| 726 | number_of_objects_ - number_of_objects_with_fast_properties_, |
| 727 | number_of_slow_used_properties_, number_of_slow_unused_properties_); |
| 728 | |
| 729 | PrintF(" - fast elements (#%d): %d (used) %d (unused)\n", |
| 730 | number_of_objects_with_fast_elements_, |
| 731 | number_of_fast_used_elements_, number_of_fast_unused_elements_); |
| 732 | |
| 733 | PrintF(" - slow elements (#%d): %d (used) %d (unused)\n", |
| 734 | number_of_objects_ - number_of_objects_with_fast_elements_, |
| 735 | number_of_slow_used_elements_, number_of_slow_unused_elements_); |
| 736 | |
| 737 | PrintF("\n"); |
| 738 | } |
| 739 | |
| 740 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 741 | bool DescriptorArray::IsSortedNoDuplicates() { |
| 742 | String* current_key = NULL; |
| 743 | uint32_t current = 0; |
| 744 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 745 | String* key = GetKey(i); |
| 746 | if (key == current_key) { |
| 747 | PrintDescriptors(); |
| 748 | return false; |
| 749 | } |
| 750 | current_key = key; |
| 751 | uint32_t hash = GetKey(i)->Hash(); |
| 752 | if (hash < current) { |
| 753 | PrintDescriptors(); |
| 754 | return false; |
| 755 | } |
| 756 | current = hash; |
| 757 | } |
| 758 | return true; |
| 759 | } |
| 760 | |
| 761 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 762 | void JSFunctionResultCache::JSFunctionResultCacheVerify() { |
| 763 | JSFunction::cast(get(kFactoryIndex))->Verify(); |
| 764 | |
| 765 | int size = Smi::cast(get(kCacheSizeIndex))->value(); |
| 766 | ASSERT(kEntriesIndex <= size); |
| 767 | ASSERT(size <= length()); |
| 768 | ASSERT_EQ(0, size % kEntrySize); |
| 769 | |
| 770 | int finger = Smi::cast(get(kFingerIndex))->value(); |
| 771 | ASSERT(kEntriesIndex <= finger); |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 772 | ASSERT((finger < size) || (finger == kEntriesIndex && finger == size)); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 773 | ASSERT_EQ(0, finger % kEntrySize); |
| 774 | |
| 775 | if (FLAG_enable_slow_asserts) { |
| 776 | for (int i = kEntriesIndex; i < size; i++) { |
| 777 | ASSERT(!get(i)->IsTheHole()); |
| 778 | get(i)->Verify(); |
| 779 | } |
| 780 | for (int i = size; i < length(); i++) { |
| 781 | ASSERT(get(i)->IsTheHole()); |
| 782 | get(i)->Verify(); |
| 783 | } |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 788 | void NormalizedMapCache::NormalizedMapCacheVerify() { |
| 789 | FixedArray::cast(this)->Verify(); |
| 790 | if (FLAG_enable_slow_asserts) { |
| 791 | for (int i = 0; i < length(); i++) { |
| 792 | Object* e = get(i); |
| 793 | if (e->IsMap()) { |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 794 | Map::cast(e)->SharedMapVerify(); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 795 | } else { |
| 796 | ASSERT(e->IsUndefined()); |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 803 | #endif // DEBUG |
| 804 | |
| 805 | } } // namespace v8::internal |