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; |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame^] | 167 | case JS_FUNCTION_PROXY_TYPE: |
| 168 | JSFunctionProxy::cast(this)->JSFunctionProxyVerify(); |
| 169 | break; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 170 | case FOREIGN_TYPE: |
| 171 | Foreign::cast(this)->ForeignVerify(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 172 | break; |
| 173 | case SHARED_FUNCTION_INFO_TYPE: |
| 174 | SharedFunctionInfo::cast(this)->SharedFunctionInfoVerify(); |
| 175 | break; |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 176 | case JS_MESSAGE_OBJECT_TYPE: |
| 177 | JSMessageObject::cast(this)->JSMessageObjectVerify(); |
| 178 | break; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 179 | |
| 180 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 181 | case NAME##_TYPE: \ |
| 182 | Name::cast(this)->Name##Verify(); \ |
| 183 | break; |
| 184 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 185 | #undef MAKE_STRUCT_CASE |
| 186 | |
| 187 | default: |
| 188 | UNREACHABLE(); |
| 189 | break; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | |
| 194 | void HeapObject::VerifyHeapPointer(Object* p) { |
| 195 | ASSERT(p->IsHeapObject()); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 196 | ASSERT(HEAP->Contains(HeapObject::cast(p))); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | |
| 200 | void HeapNumber::HeapNumberVerify() { |
| 201 | ASSERT(IsHeapNumber()); |
| 202 | } |
| 203 | |
| 204 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 205 | void ByteArray::ByteArrayVerify() { |
| 206 | ASSERT(IsByteArray()); |
| 207 | } |
| 208 | |
| 209 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 210 | void ExternalPixelArray::ExternalPixelArrayVerify() { |
| 211 | ASSERT(IsExternalPixelArray()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 215 | void ExternalByteArray::ExternalByteArrayVerify() { |
| 216 | ASSERT(IsExternalByteArray()); |
| 217 | } |
| 218 | |
| 219 | |
| 220 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayVerify() { |
| 221 | ASSERT(IsExternalUnsignedByteArray()); |
| 222 | } |
| 223 | |
| 224 | |
| 225 | void ExternalShortArray::ExternalShortArrayVerify() { |
| 226 | ASSERT(IsExternalShortArray()); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayVerify() { |
| 231 | ASSERT(IsExternalUnsignedShortArray()); |
| 232 | } |
| 233 | |
| 234 | |
| 235 | void ExternalIntArray::ExternalIntArrayVerify() { |
| 236 | ASSERT(IsExternalIntArray()); |
| 237 | } |
| 238 | |
| 239 | |
| 240 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayVerify() { |
| 241 | ASSERT(IsExternalUnsignedIntArray()); |
| 242 | } |
| 243 | |
| 244 | |
| 245 | void ExternalFloatArray::ExternalFloatArrayVerify() { |
| 246 | ASSERT(IsExternalFloatArray()); |
| 247 | } |
| 248 | |
| 249 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 250 | void ExternalDoubleArray::ExternalDoubleArrayVerify() { |
| 251 | ASSERT(IsExternalDoubleArray()); |
| 252 | } |
| 253 | |
| 254 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 255 | void JSObject::JSObjectVerify() { |
| 256 | VerifyHeapPointer(properties()); |
| 257 | VerifyHeapPointer(elements()); |
| 258 | if (HasFastProperties()) { |
| 259 | CHECK_EQ(map()->unused_property_fields(), |
| 260 | (map()->inobject_properties() + properties()->length() - |
| 261 | map()->NextFreePropertyIndex())); |
| 262 | } |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame^] | 263 | ASSERT_EQ(map()->has_fast_elements(), |
| 264 | (elements()->map() == GetHeap()->fixed_array_map() || |
| 265 | elements()->map() == GetHeap()->fixed_cow_array_map())); |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 266 | ASSERT(map()->has_fast_elements() == HasFastElements()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 270 | void Map::MapVerify() { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 271 | ASSERT(!HEAP->InNewSpace(this)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 272 | ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
Steve Block | 791712a | 2010-08-27 10:21:07 +0100 | [diff] [blame] | 273 | ASSERT(instance_size() == kVariableSizeSentinel || |
| 274 | (kPointerSize <= instance_size() && |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 275 | instance_size() < HEAP->Capacity())); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 276 | VerifyHeapPointer(prototype()); |
| 277 | VerifyHeapPointer(instance_descriptors()); |
| 278 | } |
| 279 | |
| 280 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 281 | void Map::SharedMapVerify() { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 282 | MapVerify(); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 283 | ASSERT(is_shared()); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 284 | ASSERT(instance_descriptors()->IsEmpty()); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 285 | ASSERT_EQ(0, pre_allocated_property_fields()); |
| 286 | ASSERT_EQ(0, unused_property_fields()); |
| 287 | ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), |
| 288 | visitor_id()); |
| 289 | } |
| 290 | |
| 291 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 292 | void CodeCache::CodeCacheVerify() { |
| 293 | VerifyHeapPointer(default_cache()); |
| 294 | VerifyHeapPointer(normal_type_cache()); |
| 295 | ASSERT(default_cache()->IsFixedArray()); |
| 296 | ASSERT(normal_type_cache()->IsUndefined() |
| 297 | || normal_type_cache()->IsCodeCacheHashTable()); |
| 298 | } |
| 299 | |
| 300 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 301 | void PolymorphicCodeCache::PolymorphicCodeCacheVerify() { |
| 302 | VerifyHeapPointer(cache()); |
| 303 | ASSERT(cache()->IsUndefined() || cache()->IsPolymorphicCodeCacheHashTable()); |
| 304 | } |
| 305 | |
| 306 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 307 | void FixedArray::FixedArrayVerify() { |
| 308 | for (int i = 0; i < length(); i++) { |
| 309 | Object* e = get(i); |
| 310 | if (e->IsHeapObject()) { |
| 311 | VerifyHeapPointer(e); |
| 312 | } else { |
| 313 | e->Verify(); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 319 | void FixedDoubleArray::FixedDoubleArrayVerify() { |
| 320 | for (int i = 0; i < length(); i++) { |
| 321 | if (!is_the_hole(i)) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 322 | double value = get_scalar(i); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 323 | ASSERT(!isnan(value) || |
| 324 | (BitCast<uint64_t>(value) == |
| 325 | BitCast<uint64_t>(canonical_not_the_hole_nan_as_double()))); |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 331 | void JSValue::JSValueVerify() { |
| 332 | Object* v = value(); |
| 333 | if (v->IsHeapObject()) { |
| 334 | VerifyHeapPointer(v); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 339 | void JSMessageObject::JSMessageObjectVerify() { |
| 340 | CHECK(IsJSMessageObject()); |
| 341 | CHECK(type()->IsString()); |
| 342 | CHECK(arguments()->IsJSArray()); |
| 343 | VerifyObjectField(kStartPositionOffset); |
| 344 | VerifyObjectField(kEndPositionOffset); |
| 345 | VerifyObjectField(kArgumentsOffset); |
| 346 | VerifyObjectField(kScriptOffset); |
| 347 | VerifyObjectField(kStackTraceOffset); |
| 348 | VerifyObjectField(kStackFramesOffset); |
| 349 | } |
| 350 | |
| 351 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 352 | void String::StringVerify() { |
| 353 | CHECK(IsString()); |
| 354 | CHECK(length() >= 0 && length() <= Smi::kMaxValue); |
| 355 | if (IsSymbol()) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 356 | CHECK(!HEAP->InNewSpace(this)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 357 | } |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 358 | if (IsConsString()) { |
| 359 | ConsString::cast(this)->ConsStringVerify(); |
| 360 | } else if (IsSlicedString()) { |
| 361 | SlicedString::cast(this)->SlicedStringVerify(); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | |
| 366 | void ConsString::ConsStringVerify() { |
| 367 | CHECK(this->first()->IsString()); |
| 368 | CHECK(this->second() == GetHeap()->empty_string() || |
| 369 | this->second()->IsString()); |
| 370 | CHECK(this->length() >= String::kMinNonFlatLength); |
| 371 | if (this->IsFlat()) { |
| 372 | // A flat cons can only be created by String::SlowTryFlatten. |
| 373 | // Afterwards, the first part may be externalized. |
| 374 | CHECK(this->first()->IsSeqString() || this->first()->IsExternalString()); |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | |
| 379 | void SlicedString::SlicedStringVerify() { |
| 380 | CHECK(!this->parent()->IsConsString()); |
| 381 | CHECK(!this->parent()->IsSlicedString()); |
| 382 | CHECK(this->length() >= SlicedString::kMinLength); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 386 | void JSFunction::JSFunctionVerify() { |
| 387 | CHECK(IsJSFunction()); |
| 388 | VerifyObjectField(kPrototypeOrInitialMapOffset); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 389 | VerifyObjectField(kNextFunctionLinkOffset); |
| 390 | CHECK(next_function_link()->IsUndefined() || |
| 391 | next_function_link()->IsJSFunction()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 395 | void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 396 | CHECK(IsSharedFunctionInfo()); |
| 397 | VerifyObjectField(kNameOffset); |
| 398 | VerifyObjectField(kCodeOffset); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 399 | VerifyObjectField(kScopeInfoOffset); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 400 | VerifyObjectField(kInstanceClassNameOffset); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 401 | VerifyObjectField(kFunctionDataOffset); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 402 | VerifyObjectField(kScriptOffset); |
| 403 | VerifyObjectField(kDebugInfoOffset); |
| 404 | } |
| 405 | |
| 406 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 407 | void JSGlobalProxy::JSGlobalProxyVerify() { |
| 408 | CHECK(IsJSGlobalProxy()); |
| 409 | JSObjectVerify(); |
| 410 | VerifyObjectField(JSGlobalProxy::kContextOffset); |
| 411 | // Make sure that this object has no properties, elements. |
| 412 | CHECK_EQ(0, properties()->length()); |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 413 | CHECK(HasFastElements()); |
| 414 | CHECK_EQ(0, FixedArray::cast(elements())->length()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 418 | void JSGlobalObject::JSGlobalObjectVerify() { |
| 419 | CHECK(IsJSGlobalObject()); |
| 420 | JSObjectVerify(); |
| 421 | for (int i = GlobalObject::kBuiltinsOffset; |
| 422 | i < JSGlobalObject::kSize; |
| 423 | i += kPointerSize) { |
| 424 | VerifyObjectField(i); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 429 | void JSBuiltinsObject::JSBuiltinsObjectVerify() { |
| 430 | CHECK(IsJSBuiltinsObject()); |
| 431 | JSObjectVerify(); |
| 432 | for (int i = GlobalObject::kBuiltinsOffset; |
| 433 | i < JSBuiltinsObject::kSize; |
| 434 | i += kPointerSize) { |
| 435 | VerifyObjectField(i); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | |
| 440 | void Oddball::OddballVerify() { |
| 441 | CHECK(IsOddball()); |
| 442 | VerifyHeapPointer(to_string()); |
| 443 | Object* number = to_number(); |
| 444 | if (number->IsHeapObject()) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 445 | ASSERT(number == HEAP->nan_value()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 446 | } else { |
| 447 | ASSERT(number->IsSmi()); |
| 448 | int value = Smi::cast(number)->value(); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 449 | // Hidden oddballs have negative smis. |
| 450 | const int kLeastHiddenOddballNumber = -4; |
| 451 | ASSERT(value <= 1); |
| 452 | ASSERT(value >= kLeastHiddenOddballNumber); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
| 456 | |
| 457 | void JSGlobalPropertyCell::JSGlobalPropertyCellVerify() { |
| 458 | CHECK(IsJSGlobalPropertyCell()); |
| 459 | VerifyObjectField(kValueOffset); |
| 460 | } |
| 461 | |
| 462 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 463 | void Code::CodeVerify() { |
| 464 | CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 465 | kCodeAlignment)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 466 | Address last_gc_pc = NULL; |
| 467 | for (RelocIterator it(this); !it.done(); it.next()) { |
| 468 | it.rinfo()->Verify(); |
| 469 | // Ensure that GC will not iterate twice over the same pointer. |
| 470 | if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { |
| 471 | CHECK(it.rinfo()->pc() != last_gc_pc); |
| 472 | last_gc_pc = it.rinfo()->pc(); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | |
| 478 | void JSArray::JSArrayVerify() { |
| 479 | JSObjectVerify(); |
| 480 | ASSERT(length()->IsNumber() || length()->IsUndefined()); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 481 | ASSERT(elements()->IsUndefined() || |
| 482 | elements()->IsFixedArray() || |
| 483 | elements()->IsFixedDoubleArray()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 487 | void JSWeakMap::JSWeakMapVerify() { |
| 488 | CHECK(IsJSWeakMap()); |
| 489 | JSObjectVerify(); |
| 490 | VerifyHeapPointer(table()); |
| 491 | ASSERT(table()->IsHashTable()); |
| 492 | } |
| 493 | |
| 494 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 495 | void JSRegExp::JSRegExpVerify() { |
| 496 | JSObjectVerify(); |
| 497 | ASSERT(data()->IsUndefined() || data()->IsFixedArray()); |
| 498 | switch (TypeTag()) { |
| 499 | case JSRegExp::ATOM: { |
| 500 | FixedArray* arr = FixedArray::cast(data()); |
| 501 | ASSERT(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 502 | break; |
| 503 | } |
| 504 | case JSRegExp::IRREGEXP: { |
| 505 | bool is_native = RegExpImpl::UsesNativeRegExp(); |
| 506 | |
| 507 | FixedArray* arr = FixedArray::cast(data()); |
| 508 | Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 509 | // Smi : Not compiled yet (-1) or code prepared for flushing. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 510 | // JSObject: Compilation error. |
| 511 | // Code/ByteArray: Compiled code. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 512 | ASSERT(ascii_data->IsSmi() || |
| 513 | (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray())); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 514 | Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 515 | ASSERT(uc16_data->IsSmi() || |
| 516 | (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray())); |
| 517 | |
| 518 | Object* ascii_saved = arr->get(JSRegExp::kIrregexpASCIICodeSavedIndex); |
| 519 | ASSERT(ascii_saved->IsSmi() || ascii_saved->IsString() || |
| 520 | ascii_saved->IsCode()); |
| 521 | Object* uc16_saved = arr->get(JSRegExp::kIrregexpUC16CodeSavedIndex); |
| 522 | ASSERT(uc16_saved->IsSmi() || uc16_saved->IsString() || |
| 523 | uc16_saved->IsCode()); |
| 524 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 525 | ASSERT(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 526 | ASSERT(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
| 527 | break; |
| 528 | } |
| 529 | default: |
| 530 | ASSERT_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 531 | ASSERT(data()->IsUndefined()); |
| 532 | break; |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 537 | void JSProxy::JSProxyVerify() { |
| 538 | ASSERT(IsJSProxy()); |
| 539 | VerifyPointer(handler()); |
| 540 | } |
| 541 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame^] | 542 | |
| 543 | void JSFunctionProxy::JSFunctionProxyVerify() { |
| 544 | ASSERT(IsJSFunctionProxy()); |
| 545 | JSProxyVerify(); |
| 546 | VerifyPointer(call_trap()); |
| 547 | VerifyPointer(construct_trap()); |
| 548 | } |
| 549 | |
| 550 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 551 | void Foreign::ForeignVerify() { |
| 552 | ASSERT(IsForeign()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | |
| 556 | void AccessorInfo::AccessorInfoVerify() { |
| 557 | CHECK(IsAccessorInfo()); |
| 558 | VerifyPointer(getter()); |
| 559 | VerifyPointer(setter()); |
| 560 | VerifyPointer(name()); |
| 561 | VerifyPointer(data()); |
| 562 | VerifyPointer(flag()); |
| 563 | } |
| 564 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 565 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 566 | void AccessCheckInfo::AccessCheckInfoVerify() { |
| 567 | CHECK(IsAccessCheckInfo()); |
| 568 | VerifyPointer(named_callback()); |
| 569 | VerifyPointer(indexed_callback()); |
| 570 | VerifyPointer(data()); |
| 571 | } |
| 572 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 573 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 574 | void InterceptorInfo::InterceptorInfoVerify() { |
| 575 | CHECK(IsInterceptorInfo()); |
| 576 | VerifyPointer(getter()); |
| 577 | VerifyPointer(setter()); |
| 578 | VerifyPointer(query()); |
| 579 | VerifyPointer(deleter()); |
| 580 | VerifyPointer(enumerator()); |
| 581 | VerifyPointer(data()); |
| 582 | } |
| 583 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 584 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 585 | void CallHandlerInfo::CallHandlerInfoVerify() { |
| 586 | CHECK(IsCallHandlerInfo()); |
| 587 | VerifyPointer(callback()); |
| 588 | VerifyPointer(data()); |
| 589 | } |
| 590 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 591 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 592 | void TemplateInfo::TemplateInfoVerify() { |
| 593 | VerifyPointer(tag()); |
| 594 | VerifyPointer(property_list()); |
| 595 | } |
| 596 | |
| 597 | void FunctionTemplateInfo::FunctionTemplateInfoVerify() { |
| 598 | CHECK(IsFunctionTemplateInfo()); |
| 599 | TemplateInfoVerify(); |
| 600 | VerifyPointer(serial_number()); |
| 601 | VerifyPointer(call_code()); |
| 602 | VerifyPointer(property_accessors()); |
| 603 | VerifyPointer(prototype_template()); |
| 604 | VerifyPointer(parent_template()); |
| 605 | VerifyPointer(named_property_handler()); |
| 606 | VerifyPointer(indexed_property_handler()); |
| 607 | VerifyPointer(instance_template()); |
| 608 | VerifyPointer(signature()); |
| 609 | VerifyPointer(access_check_info()); |
| 610 | } |
| 611 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 612 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 613 | void ObjectTemplateInfo::ObjectTemplateInfoVerify() { |
| 614 | CHECK(IsObjectTemplateInfo()); |
| 615 | TemplateInfoVerify(); |
| 616 | VerifyPointer(constructor()); |
| 617 | VerifyPointer(internal_field_count()); |
| 618 | } |
| 619 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 620 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 621 | void SignatureInfo::SignatureInfoVerify() { |
| 622 | CHECK(IsSignatureInfo()); |
| 623 | VerifyPointer(receiver()); |
| 624 | VerifyPointer(args()); |
| 625 | } |
| 626 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 627 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 628 | void TypeSwitchInfo::TypeSwitchInfoVerify() { |
| 629 | CHECK(IsTypeSwitchInfo()); |
| 630 | VerifyPointer(types()); |
| 631 | } |
| 632 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 633 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 634 | void Script::ScriptVerify() { |
| 635 | CHECK(IsScript()); |
| 636 | VerifyPointer(source()); |
| 637 | VerifyPointer(name()); |
| 638 | line_offset()->SmiVerify(); |
| 639 | column_offset()->SmiVerify(); |
| 640 | VerifyPointer(data()); |
| 641 | VerifyPointer(wrapper()); |
| 642 | type()->SmiVerify(); |
| 643 | VerifyPointer(line_ends()); |
| 644 | VerifyPointer(id()); |
| 645 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 646 | |
| 647 | |
| 648 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 649 | void DebugInfo::DebugInfoVerify() { |
| 650 | CHECK(IsDebugInfo()); |
| 651 | VerifyPointer(shared()); |
| 652 | VerifyPointer(original_code()); |
| 653 | VerifyPointer(code()); |
| 654 | VerifyPointer(break_points()); |
| 655 | } |
| 656 | |
| 657 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 658 | void BreakPointInfo::BreakPointInfoVerify() { |
| 659 | CHECK(IsBreakPointInfo()); |
| 660 | code_position()->SmiVerify(); |
| 661 | source_position()->SmiVerify(); |
| 662 | statement_position()->SmiVerify(); |
| 663 | VerifyPointer(break_point_objects()); |
| 664 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 665 | #endif // ENABLE_DEBUGGER_SUPPORT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 666 | |
| 667 | |
| 668 | void JSObject::IncrementSpillStatistics(SpillInformation* info) { |
| 669 | info->number_of_objects_++; |
| 670 | // Named properties |
| 671 | if (HasFastProperties()) { |
| 672 | info->number_of_objects_with_fast_properties_++; |
| 673 | info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 674 | info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 675 | } else { |
| 676 | StringDictionary* dict = property_dictionary(); |
| 677 | info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 678 | info->number_of_slow_unused_properties_ += |
| 679 | dict->Capacity() - dict->NumberOfElements(); |
| 680 | } |
| 681 | // Indexed properties |
| 682 | switch (GetElementsKind()) { |
| 683 | case FAST_ELEMENTS: { |
| 684 | info->number_of_objects_with_fast_elements_++; |
| 685 | int holes = 0; |
| 686 | FixedArray* e = FixedArray::cast(elements()); |
| 687 | int len = e->length(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 688 | Heap* heap = HEAP; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 689 | for (int i = 0; i < len; i++) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 690 | if (e->get(i) == heap->the_hole_value()) holes++; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 691 | } |
| 692 | info->number_of_fast_used_elements_ += len - holes; |
| 693 | info->number_of_fast_unused_elements_ += holes; |
| 694 | break; |
| 695 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 696 | case EXTERNAL_PIXEL_ELEMENTS: { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 697 | info->number_of_objects_with_fast_elements_++; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 698 | ExternalPixelArray* e = ExternalPixelArray::cast(elements()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 699 | info->number_of_fast_used_elements_ += e->length(); |
| 700 | break; |
| 701 | } |
| 702 | case DICTIONARY_ELEMENTS: { |
| 703 | NumberDictionary* dict = element_dictionary(); |
| 704 | info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 705 | info->number_of_slow_unused_elements_ += |
| 706 | dict->Capacity() - dict->NumberOfElements(); |
| 707 | break; |
| 708 | } |
| 709 | default: |
| 710 | UNREACHABLE(); |
| 711 | break; |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | |
| 716 | void JSObject::SpillInformation::Clear() { |
| 717 | number_of_objects_ = 0; |
| 718 | number_of_objects_with_fast_properties_ = 0; |
| 719 | number_of_objects_with_fast_elements_ = 0; |
| 720 | number_of_fast_used_fields_ = 0; |
| 721 | number_of_fast_unused_fields_ = 0; |
| 722 | number_of_slow_used_properties_ = 0; |
| 723 | number_of_slow_unused_properties_ = 0; |
| 724 | number_of_fast_used_elements_ = 0; |
| 725 | number_of_fast_unused_elements_ = 0; |
| 726 | number_of_slow_used_elements_ = 0; |
| 727 | number_of_slow_unused_elements_ = 0; |
| 728 | } |
| 729 | |
| 730 | void JSObject::SpillInformation::Print() { |
| 731 | PrintF("\n JSObject Spill Statistics (#%d):\n", number_of_objects_); |
| 732 | |
| 733 | PrintF(" - fast properties (#%d): %d (used) %d (unused)\n", |
| 734 | number_of_objects_with_fast_properties_, |
| 735 | number_of_fast_used_fields_, number_of_fast_unused_fields_); |
| 736 | |
| 737 | PrintF(" - slow properties (#%d): %d (used) %d (unused)\n", |
| 738 | number_of_objects_ - number_of_objects_with_fast_properties_, |
| 739 | number_of_slow_used_properties_, number_of_slow_unused_properties_); |
| 740 | |
| 741 | PrintF(" - fast elements (#%d): %d (used) %d (unused)\n", |
| 742 | number_of_objects_with_fast_elements_, |
| 743 | number_of_fast_used_elements_, number_of_fast_unused_elements_); |
| 744 | |
| 745 | PrintF(" - slow elements (#%d): %d (used) %d (unused)\n", |
| 746 | number_of_objects_ - number_of_objects_with_fast_elements_, |
| 747 | number_of_slow_used_elements_, number_of_slow_unused_elements_); |
| 748 | |
| 749 | PrintF("\n"); |
| 750 | } |
| 751 | |
| 752 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 753 | bool DescriptorArray::IsSortedNoDuplicates() { |
| 754 | String* current_key = NULL; |
| 755 | uint32_t current = 0; |
| 756 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 757 | String* key = GetKey(i); |
| 758 | if (key == current_key) { |
| 759 | PrintDescriptors(); |
| 760 | return false; |
| 761 | } |
| 762 | current_key = key; |
| 763 | uint32_t hash = GetKey(i)->Hash(); |
| 764 | if (hash < current) { |
| 765 | PrintDescriptors(); |
| 766 | return false; |
| 767 | } |
| 768 | current = hash; |
| 769 | } |
| 770 | return true; |
| 771 | } |
| 772 | |
| 773 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 774 | void JSFunctionResultCache::JSFunctionResultCacheVerify() { |
| 775 | JSFunction::cast(get(kFactoryIndex))->Verify(); |
| 776 | |
| 777 | int size = Smi::cast(get(kCacheSizeIndex))->value(); |
| 778 | ASSERT(kEntriesIndex <= size); |
| 779 | ASSERT(size <= length()); |
| 780 | ASSERT_EQ(0, size % kEntrySize); |
| 781 | |
| 782 | int finger = Smi::cast(get(kFingerIndex))->value(); |
| 783 | ASSERT(kEntriesIndex <= finger); |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 784 | ASSERT((finger < size) || (finger == kEntriesIndex && finger == size)); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 785 | ASSERT_EQ(0, finger % kEntrySize); |
| 786 | |
| 787 | if (FLAG_enable_slow_asserts) { |
| 788 | for (int i = kEntriesIndex; i < size; i++) { |
| 789 | ASSERT(!get(i)->IsTheHole()); |
| 790 | get(i)->Verify(); |
| 791 | } |
| 792 | for (int i = size; i < length(); i++) { |
| 793 | ASSERT(get(i)->IsTheHole()); |
| 794 | get(i)->Verify(); |
| 795 | } |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 800 | void NormalizedMapCache::NormalizedMapCacheVerify() { |
| 801 | FixedArray::cast(this)->Verify(); |
| 802 | if (FLAG_enable_slow_asserts) { |
| 803 | for (int i = 0; i < length(); i++) { |
| 804 | Object* e = get(i); |
| 805 | if (e->IsMap()) { |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 806 | Map::cast(e)->SharedMapVerify(); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 807 | } else { |
| 808 | ASSERT(e->IsUndefined()); |
| 809 | } |
| 810 | } |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 815 | #endif // DEBUG |
| 816 | |
| 817 | } } // namespace v8::internal |