fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +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" |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 32 | #include "jsregexp.h" |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 33 | #include "objects-visiting.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 35 | namespace v8 { |
| 36 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 38 | #ifdef DEBUG |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 39 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [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 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 48 | } else { |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 49 | Failure::cast(this)->FailureVerify(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +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 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +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; |
| 91 | case BYTE_ARRAY_TYPE: |
| 92 | ByteArray::cast(this)->ByteArrayVerify(); |
| 93 | break; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 94 | case EXTERNAL_PIXEL_ARRAY_TYPE: |
| 95 | ExternalPixelArray::cast(this)->ExternalPixelArrayVerify(); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 96 | break; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 97 | case EXTERNAL_BYTE_ARRAY_TYPE: |
| 98 | ExternalByteArray::cast(this)->ExternalByteArrayVerify(); |
| 99 | break; |
| 100 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 101 | ExternalUnsignedByteArray::cast(this)->ExternalUnsignedByteArrayVerify(); |
| 102 | break; |
| 103 | case EXTERNAL_SHORT_ARRAY_TYPE: |
| 104 | ExternalShortArray::cast(this)->ExternalShortArrayVerify(); |
| 105 | break; |
| 106 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 107 | ExternalUnsignedShortArray::cast(this)-> |
| 108 | ExternalUnsignedShortArrayVerify(); |
| 109 | break; |
| 110 | case EXTERNAL_INT_ARRAY_TYPE: |
| 111 | ExternalIntArray::cast(this)->ExternalIntArrayVerify(); |
| 112 | break; |
| 113 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 114 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayVerify(); |
| 115 | break; |
| 116 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 117 | ExternalFloatArray::cast(this)->ExternalFloatArrayVerify(); |
| 118 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 119 | case CODE_TYPE: |
| 120 | Code::cast(this)->CodeVerify(); |
| 121 | break; |
| 122 | case ODDBALL_TYPE: |
| 123 | Oddball::cast(this)->OddballVerify(); |
| 124 | break; |
| 125 | case JS_OBJECT_TYPE: |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 126 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 127 | JSObject::cast(this)->JSObjectVerify(); |
| 128 | break; |
| 129 | case JS_VALUE_TYPE: |
| 130 | JSValue::cast(this)->JSValueVerify(); |
| 131 | break; |
| 132 | case JS_FUNCTION_TYPE: |
| 133 | JSFunction::cast(this)->JSFunctionVerify(); |
| 134 | break; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 135 | case JS_GLOBAL_PROXY_TYPE: |
| 136 | JSGlobalProxy::cast(this)->JSGlobalProxyVerify(); |
| 137 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 138 | case JS_GLOBAL_OBJECT_TYPE: |
| 139 | JSGlobalObject::cast(this)->JSGlobalObjectVerify(); |
| 140 | break; |
| 141 | case JS_BUILTINS_OBJECT_TYPE: |
| 142 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectVerify(); |
| 143 | break; |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 144 | case JS_GLOBAL_PROPERTY_CELL_TYPE: |
| 145 | JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellVerify(); |
| 146 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 147 | case JS_ARRAY_TYPE: |
| 148 | JSArray::cast(this)->JSArrayVerify(); |
| 149 | break; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 150 | case JS_REGEXP_TYPE: |
| 151 | JSRegExp::cast(this)->JSRegExpVerify(); |
| 152 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 153 | case FILLER_TYPE: |
| 154 | break; |
| 155 | case PROXY_TYPE: |
| 156 | Proxy::cast(this)->ProxyVerify(); |
| 157 | break; |
| 158 | case SHARED_FUNCTION_INFO_TYPE: |
| 159 | SharedFunctionInfo::cast(this)->SharedFunctionInfoVerify(); |
| 160 | break; |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 161 | case JS_MESSAGE_OBJECT_TYPE: |
| 162 | JSMessageObject::cast(this)->JSMessageObjectVerify(); |
| 163 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 164 | |
| 165 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 166 | case NAME##_TYPE: \ |
| 167 | Name::cast(this)->Name##Verify(); \ |
| 168 | break; |
| 169 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 170 | #undef MAKE_STRUCT_CASE |
| 171 | |
| 172 | default: |
| 173 | UNREACHABLE(); |
| 174 | break; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | |
| 179 | void HeapObject::VerifyHeapPointer(Object* p) { |
| 180 | ASSERT(p->IsHeapObject()); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 181 | ASSERT(HEAP->Contains(HeapObject::cast(p))); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | |
| 185 | void HeapNumber::HeapNumberVerify() { |
| 186 | ASSERT(IsHeapNumber()); |
| 187 | } |
| 188 | |
| 189 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 190 | void ByteArray::ByteArrayVerify() { |
| 191 | ASSERT(IsByteArray()); |
| 192 | } |
| 193 | |
| 194 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 195 | void ExternalPixelArray::ExternalPixelArrayVerify() { |
| 196 | ASSERT(IsExternalPixelArray()); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 200 | void ExternalByteArray::ExternalByteArrayVerify() { |
| 201 | ASSERT(IsExternalByteArray()); |
| 202 | } |
| 203 | |
| 204 | |
| 205 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayVerify() { |
| 206 | ASSERT(IsExternalUnsignedByteArray()); |
| 207 | } |
| 208 | |
| 209 | |
| 210 | void ExternalShortArray::ExternalShortArrayVerify() { |
| 211 | ASSERT(IsExternalShortArray()); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayVerify() { |
| 216 | ASSERT(IsExternalUnsignedShortArray()); |
| 217 | } |
| 218 | |
| 219 | |
| 220 | void ExternalIntArray::ExternalIntArrayVerify() { |
| 221 | ASSERT(IsExternalIntArray()); |
| 222 | } |
| 223 | |
| 224 | |
| 225 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayVerify() { |
| 226 | ASSERT(IsExternalUnsignedIntArray()); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | void ExternalFloatArray::ExternalFloatArrayVerify() { |
| 231 | ASSERT(IsExternalFloatArray()); |
| 232 | } |
| 233 | |
| 234 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 235 | void JSObject::JSObjectVerify() { |
| 236 | VerifyHeapPointer(properties()); |
| 237 | VerifyHeapPointer(elements()); |
| 238 | if (HasFastProperties()) { |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 239 | CHECK_EQ(map()->unused_property_fields(), |
| 240 | (map()->inobject_properties() + properties()->length() - |
| 241 | map()->NextFreePropertyIndex())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 242 | } |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 243 | ASSERT(map()->has_fast_elements() == |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 244 | (elements()->map() == GetHeap()->fixed_array_map() || |
| 245 | elements()->map() == GetHeap()->fixed_cow_array_map())); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 246 | ASSERT(map()->has_fast_elements() == HasFastElements()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 250 | void Map::MapVerify() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 251 | ASSERT(!HEAP->InNewSpace(this)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 252 | ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
erik.corry@gmail.com | 145eff5 | 2010-08-23 11:36:18 +0000 | [diff] [blame] | 253 | ASSERT(instance_size() == kVariableSizeSentinel || |
| 254 | (kPointerSize <= instance_size() && |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 255 | instance_size() < HEAP->Capacity())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 256 | VerifyHeapPointer(prototype()); |
| 257 | VerifyHeapPointer(instance_descriptors()); |
| 258 | } |
| 259 | |
| 260 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 261 | void Map::SharedMapVerify() { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 262 | MapVerify(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 263 | ASSERT(is_shared()); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 264 | ASSERT_EQ(GetHeap()->empty_descriptor_array(), instance_descriptors()); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 265 | ASSERT_EQ(0, pre_allocated_property_fields()); |
| 266 | ASSERT_EQ(0, unused_property_fields()); |
| 267 | ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), |
| 268 | visitor_id()); |
| 269 | } |
| 270 | |
| 271 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 272 | void CodeCache::CodeCacheVerify() { |
| 273 | VerifyHeapPointer(default_cache()); |
| 274 | VerifyHeapPointer(normal_type_cache()); |
| 275 | ASSERT(default_cache()->IsFixedArray()); |
| 276 | ASSERT(normal_type_cache()->IsUndefined() |
| 277 | || normal_type_cache()->IsCodeCacheHashTable()); |
| 278 | } |
| 279 | |
| 280 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 281 | void FixedArray::FixedArrayVerify() { |
| 282 | for (int i = 0; i < length(); i++) { |
| 283 | Object* e = get(i); |
| 284 | if (e->IsHeapObject()) { |
| 285 | VerifyHeapPointer(e); |
| 286 | } else { |
| 287 | e->Verify(); |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 293 | void JSValue::JSValueVerify() { |
| 294 | Object* v = value(); |
| 295 | if (v->IsHeapObject()) { |
| 296 | VerifyHeapPointer(v); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 301 | void JSMessageObject::JSMessageObjectVerify() { |
| 302 | CHECK(IsJSMessageObject()); |
| 303 | CHECK(type()->IsString()); |
| 304 | CHECK(arguments()->IsJSArray()); |
| 305 | VerifyObjectField(kStartPositionOffset); |
| 306 | VerifyObjectField(kEndPositionOffset); |
| 307 | VerifyObjectField(kArgumentsOffset); |
| 308 | VerifyObjectField(kScriptOffset); |
| 309 | VerifyObjectField(kStackTraceOffset); |
| 310 | VerifyObjectField(kStackFramesOffset); |
| 311 | } |
| 312 | |
| 313 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 314 | void String::StringVerify() { |
| 315 | CHECK(IsString()); |
| 316 | CHECK(length() >= 0 && length() <= Smi::kMaxValue); |
| 317 | if (IsSymbol()) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 318 | CHECK(!HEAP->InNewSpace(this)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
| 322 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 323 | void JSFunction::JSFunctionVerify() { |
| 324 | CHECK(IsJSFunction()); |
| 325 | VerifyObjectField(kPrototypeOrInitialMapOffset); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 326 | VerifyObjectField(kNextFunctionLinkOffset); |
| 327 | CHECK(next_function_link()->IsUndefined() || |
| 328 | next_function_link()->IsJSFunction()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 332 | void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 333 | CHECK(IsSharedFunctionInfo()); |
| 334 | VerifyObjectField(kNameOffset); |
| 335 | VerifyObjectField(kCodeOffset); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 336 | VerifyObjectField(kScopeInfoOffset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 337 | VerifyObjectField(kInstanceClassNameOffset); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 338 | VerifyObjectField(kFunctionDataOffset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 339 | VerifyObjectField(kScriptOffset); |
| 340 | VerifyObjectField(kDebugInfoOffset); |
| 341 | } |
| 342 | |
| 343 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 344 | void JSGlobalProxy::JSGlobalProxyVerify() { |
| 345 | CHECK(IsJSGlobalProxy()); |
| 346 | JSObjectVerify(); |
| 347 | VerifyObjectField(JSGlobalProxy::kContextOffset); |
| 348 | // Make sure that this object has no properties, elements. |
| 349 | CHECK_EQ(0, properties()->length()); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 350 | CHECK(HasFastElements()); |
| 351 | CHECK_EQ(0, FixedArray::cast(elements())->length()); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 355 | void JSGlobalObject::JSGlobalObjectVerify() { |
| 356 | CHECK(IsJSGlobalObject()); |
| 357 | JSObjectVerify(); |
| 358 | for (int i = GlobalObject::kBuiltinsOffset; |
| 359 | i < JSGlobalObject::kSize; |
| 360 | i += kPointerSize) { |
| 361 | VerifyObjectField(i); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 366 | void JSBuiltinsObject::JSBuiltinsObjectVerify() { |
| 367 | CHECK(IsJSBuiltinsObject()); |
| 368 | JSObjectVerify(); |
| 369 | for (int i = GlobalObject::kBuiltinsOffset; |
| 370 | i < JSBuiltinsObject::kSize; |
| 371 | i += kPointerSize) { |
| 372 | VerifyObjectField(i); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | |
| 377 | void Oddball::OddballVerify() { |
| 378 | CHECK(IsOddball()); |
| 379 | VerifyHeapPointer(to_string()); |
| 380 | Object* number = to_number(); |
| 381 | if (number->IsHeapObject()) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 382 | ASSERT(number == HEAP->nan_value()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 383 | } else { |
| 384 | ASSERT(number->IsSmi()); |
| 385 | int value = Smi::cast(number)->value(); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 386 | // Hidden oddballs have negative smis. |
| 387 | const int kLeastHiddenOddballNumber = -4; |
| 388 | ASSERT(value <= 1); |
| 389 | ASSERT(value >= kLeastHiddenOddballNumber); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | |
| 393 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 394 | void JSGlobalPropertyCell::JSGlobalPropertyCellVerify() { |
| 395 | CHECK(IsJSGlobalPropertyCell()); |
| 396 | VerifyObjectField(kValueOffset); |
| 397 | } |
| 398 | |
| 399 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 400 | void Code::CodeVerify() { |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 401 | CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 402 | kCodeAlignment)); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 403 | Address last_gc_pc = NULL; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 404 | for (RelocIterator it(this); !it.done(); it.next()) { |
| 405 | it.rinfo()->Verify(); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 406 | // Ensure that GC will not iterate twice over the same pointer. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 407 | if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 408 | CHECK(it.rinfo()->pc() != last_gc_pc); |
| 409 | last_gc_pc = it.rinfo()->pc(); |
| 410 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | |
| 414 | |
| 415 | void JSArray::JSArrayVerify() { |
| 416 | JSObjectVerify(); |
| 417 | ASSERT(length()->IsNumber() || length()->IsUndefined()); |
| 418 | ASSERT(elements()->IsUndefined() || elements()->IsFixedArray()); |
| 419 | } |
| 420 | |
| 421 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 422 | void JSRegExp::JSRegExpVerify() { |
| 423 | JSObjectVerify(); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 424 | ASSERT(data()->IsUndefined() || data()->IsFixedArray()); |
| 425 | switch (TypeTag()) { |
| 426 | case JSRegExp::ATOM: { |
| 427 | FixedArray* arr = FixedArray::cast(data()); |
| 428 | ASSERT(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 429 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 430 | } |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 431 | case JSRegExp::IRREGEXP: { |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 432 | bool is_native = RegExpImpl::UsesNativeRegExp(); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 433 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 434 | FixedArray* arr = FixedArray::cast(data()); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 435 | Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex); |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 436 | // TheHole : Not compiled yet. |
| 437 | // JSObject: Compilation error. |
| 438 | // Code/ByteArray: Compiled code. |
| 439 | ASSERT(ascii_data->IsTheHole() || ascii_data->IsJSObject() || |
| 440 | (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray())); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 441 | Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 442 | ASSERT(uc16_data->IsTheHole() || uc16_data->IsJSObject() || |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 443 | (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray())); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 444 | ASSERT(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 445 | ASSERT(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 446 | break; |
| 447 | } |
| 448 | default: |
| 449 | ASSERT_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 450 | ASSERT(data()->IsUndefined()); |
| 451 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 452 | } |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 456 | void Proxy::ProxyVerify() { |
| 457 | ASSERT(IsProxy()); |
| 458 | } |
| 459 | |
| 460 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 461 | void AccessorInfo::AccessorInfoVerify() { |
| 462 | CHECK(IsAccessorInfo()); |
| 463 | VerifyPointer(getter()); |
| 464 | VerifyPointer(setter()); |
| 465 | VerifyPointer(name()); |
| 466 | VerifyPointer(data()); |
| 467 | VerifyPointer(flag()); |
| 468 | } |
| 469 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 470 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 471 | void AccessCheckInfo::AccessCheckInfoVerify() { |
| 472 | CHECK(IsAccessCheckInfo()); |
| 473 | VerifyPointer(named_callback()); |
| 474 | VerifyPointer(indexed_callback()); |
| 475 | VerifyPointer(data()); |
| 476 | } |
| 477 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 478 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 479 | void InterceptorInfo::InterceptorInfoVerify() { |
| 480 | CHECK(IsInterceptorInfo()); |
| 481 | VerifyPointer(getter()); |
| 482 | VerifyPointer(setter()); |
| 483 | VerifyPointer(query()); |
| 484 | VerifyPointer(deleter()); |
| 485 | VerifyPointer(enumerator()); |
| 486 | VerifyPointer(data()); |
| 487 | } |
| 488 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 489 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 490 | void CallHandlerInfo::CallHandlerInfoVerify() { |
| 491 | CHECK(IsCallHandlerInfo()); |
| 492 | VerifyPointer(callback()); |
| 493 | VerifyPointer(data()); |
| 494 | } |
| 495 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 496 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 497 | void TemplateInfo::TemplateInfoVerify() { |
| 498 | VerifyPointer(tag()); |
| 499 | VerifyPointer(property_list()); |
| 500 | } |
| 501 | |
| 502 | void FunctionTemplateInfo::FunctionTemplateInfoVerify() { |
| 503 | CHECK(IsFunctionTemplateInfo()); |
| 504 | TemplateInfoVerify(); |
| 505 | VerifyPointer(serial_number()); |
| 506 | VerifyPointer(call_code()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 507 | VerifyPointer(property_accessors()); |
| 508 | VerifyPointer(prototype_template()); |
| 509 | VerifyPointer(parent_template()); |
| 510 | VerifyPointer(named_property_handler()); |
| 511 | VerifyPointer(indexed_property_handler()); |
| 512 | VerifyPointer(instance_template()); |
| 513 | VerifyPointer(signature()); |
| 514 | VerifyPointer(access_check_info()); |
| 515 | } |
| 516 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 517 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 518 | void ObjectTemplateInfo::ObjectTemplateInfoVerify() { |
| 519 | CHECK(IsObjectTemplateInfo()); |
| 520 | TemplateInfoVerify(); |
| 521 | VerifyPointer(constructor()); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 522 | VerifyPointer(internal_field_count()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 523 | } |
| 524 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 525 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 526 | void SignatureInfo::SignatureInfoVerify() { |
| 527 | CHECK(IsSignatureInfo()); |
| 528 | VerifyPointer(receiver()); |
| 529 | VerifyPointer(args()); |
| 530 | } |
| 531 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 532 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 533 | void TypeSwitchInfo::TypeSwitchInfoVerify() { |
| 534 | CHECK(IsTypeSwitchInfo()); |
| 535 | VerifyPointer(types()); |
| 536 | } |
| 537 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 538 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 539 | void Script::ScriptVerify() { |
| 540 | CHECK(IsScript()); |
| 541 | VerifyPointer(source()); |
| 542 | VerifyPointer(name()); |
| 543 | line_offset()->SmiVerify(); |
| 544 | column_offset()->SmiVerify(); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 545 | VerifyPointer(data()); |
| 546 | VerifyPointer(wrapper()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 547 | type()->SmiVerify(); |
sgjesse@chromium.org | 499aaa5 | 2009-11-30 08:07:20 +0000 | [diff] [blame] | 548 | VerifyPointer(line_ends()); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 549 | VerifyPointer(id()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 550 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 551 | |
| 552 | |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 553 | #ifdef ENABLE_DEBUGGER_SUPPORT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 554 | void DebugInfo::DebugInfoVerify() { |
| 555 | CHECK(IsDebugInfo()); |
| 556 | VerifyPointer(shared()); |
| 557 | VerifyPointer(original_code()); |
| 558 | VerifyPointer(code()); |
| 559 | VerifyPointer(break_points()); |
| 560 | } |
| 561 | |
| 562 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 563 | void BreakPointInfo::BreakPointInfoVerify() { |
| 564 | CHECK(IsBreakPointInfo()); |
| 565 | code_position()->SmiVerify(); |
| 566 | source_position()->SmiVerify(); |
| 567 | statement_position()->SmiVerify(); |
| 568 | VerifyPointer(break_point_objects()); |
| 569 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 570 | #endif // ENABLE_DEBUGGER_SUPPORT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 571 | |
| 572 | |
| 573 | void JSObject::IncrementSpillStatistics(SpillInformation* info) { |
| 574 | info->number_of_objects_++; |
| 575 | // Named properties |
| 576 | if (HasFastProperties()) { |
| 577 | info->number_of_objects_with_fast_properties_++; |
| 578 | info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 579 | info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 580 | } else { |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 581 | StringDictionary* dict = property_dictionary(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 582 | info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 583 | info->number_of_slow_unused_properties_ += |
| 584 | dict->Capacity() - dict->NumberOfElements(); |
| 585 | } |
| 586 | // Indexed properties |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 587 | switch (GetElementsKind()) { |
| 588 | case FAST_ELEMENTS: { |
| 589 | info->number_of_objects_with_fast_elements_++; |
| 590 | int holes = 0; |
| 591 | FixedArray* e = FixedArray::cast(elements()); |
| 592 | int len = e->length(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 593 | Heap* heap = HEAP; |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 594 | for (int i = 0; i < len; i++) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame^] | 595 | if (e->get(i) == heap->the_hole_value()) holes++; |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 596 | } |
| 597 | info->number_of_fast_used_elements_ += len - holes; |
| 598 | info->number_of_fast_unused_elements_ += holes; |
| 599 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 600 | } |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 601 | case EXTERNAL_PIXEL_ELEMENTS: { |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 602 | info->number_of_objects_with_fast_elements_++; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 603 | ExternalPixelArray* e = ExternalPixelArray::cast(elements()); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 604 | info->number_of_fast_used_elements_ += e->length(); |
| 605 | break; |
| 606 | } |
| 607 | case DICTIONARY_ELEMENTS: { |
| 608 | NumberDictionary* dict = element_dictionary(); |
| 609 | info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 610 | info->number_of_slow_unused_elements_ += |
| 611 | dict->Capacity() - dict->NumberOfElements(); |
| 612 | break; |
| 613 | } |
| 614 | default: |
| 615 | UNREACHABLE(); |
| 616 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 617 | } |
| 618 | } |
| 619 | |
| 620 | |
| 621 | void JSObject::SpillInformation::Clear() { |
| 622 | number_of_objects_ = 0; |
| 623 | number_of_objects_with_fast_properties_ = 0; |
| 624 | number_of_objects_with_fast_elements_ = 0; |
| 625 | number_of_fast_used_fields_ = 0; |
| 626 | number_of_fast_unused_fields_ = 0; |
| 627 | number_of_slow_used_properties_ = 0; |
| 628 | number_of_slow_unused_properties_ = 0; |
| 629 | number_of_fast_used_elements_ = 0; |
| 630 | number_of_fast_unused_elements_ = 0; |
| 631 | number_of_slow_used_elements_ = 0; |
| 632 | number_of_slow_unused_elements_ = 0; |
| 633 | } |
| 634 | |
| 635 | void JSObject::SpillInformation::Print() { |
| 636 | PrintF("\n JSObject Spill Statistics (#%d):\n", number_of_objects_); |
| 637 | |
| 638 | PrintF(" - fast properties (#%d): %d (used) %d (unused)\n", |
| 639 | number_of_objects_with_fast_properties_, |
| 640 | number_of_fast_used_fields_, number_of_fast_unused_fields_); |
| 641 | |
| 642 | PrintF(" - slow properties (#%d): %d (used) %d (unused)\n", |
| 643 | number_of_objects_ - number_of_objects_with_fast_properties_, |
| 644 | number_of_slow_used_properties_, number_of_slow_unused_properties_); |
| 645 | |
| 646 | PrintF(" - fast elements (#%d): %d (used) %d (unused)\n", |
| 647 | number_of_objects_with_fast_elements_, |
| 648 | number_of_fast_used_elements_, number_of_fast_unused_elements_); |
| 649 | |
| 650 | PrintF(" - slow elements (#%d): %d (used) %d (unused)\n", |
| 651 | number_of_objects_ - number_of_objects_with_fast_elements_, |
| 652 | number_of_slow_used_elements_, number_of_slow_unused_elements_); |
| 653 | |
| 654 | PrintF("\n"); |
| 655 | } |
| 656 | |
| 657 | |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 658 | bool DescriptorArray::IsSortedNoDuplicates() { |
| 659 | String* current_key = NULL; |
| 660 | uint32_t current = 0; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 661 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 662 | String* key = GetKey(i); |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 663 | if (key == current_key) { |
| 664 | PrintDescriptors(); |
| 665 | return false; |
| 666 | } |
| 667 | current_key = key; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 668 | uint32_t hash = GetKey(i)->Hash(); |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 669 | if (hash < current) { |
| 670 | PrintDescriptors(); |
| 671 | return false; |
| 672 | } |
| 673 | current = hash; |
| 674 | } |
| 675 | return true; |
| 676 | } |
| 677 | |
| 678 | |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 679 | void JSFunctionResultCache::JSFunctionResultCacheVerify() { |
| 680 | JSFunction::cast(get(kFactoryIndex))->Verify(); |
| 681 | |
| 682 | int size = Smi::cast(get(kCacheSizeIndex))->value(); |
| 683 | ASSERT(kEntriesIndex <= size); |
| 684 | ASSERT(size <= length()); |
| 685 | ASSERT_EQ(0, size % kEntrySize); |
| 686 | |
| 687 | int finger = Smi::cast(get(kFingerIndex))->value(); |
| 688 | ASSERT(kEntriesIndex <= finger); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 689 | ASSERT((finger < size) || (finger == kEntriesIndex && finger == size)); |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 690 | ASSERT_EQ(0, finger % kEntrySize); |
| 691 | |
| 692 | if (FLAG_enable_slow_asserts) { |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 693 | for (int i = kEntriesIndex; i < size; i++) { |
| 694 | ASSERT(!get(i)->IsTheHole()); |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 695 | get(i)->Verify(); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 696 | } |
| 697 | for (int i = size; i < length(); i++) { |
| 698 | ASSERT(get(i)->IsTheHole()); |
| 699 | get(i)->Verify(); |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 705 | void NormalizedMapCache::NormalizedMapCacheVerify() { |
| 706 | FixedArray::cast(this)->Verify(); |
| 707 | if (FLAG_enable_slow_asserts) { |
| 708 | for (int i = 0; i < length(); i++) { |
| 709 | Object* e = get(i); |
| 710 | if (e->IsMap()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 711 | Map::cast(e)->SharedMapVerify(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 712 | } else { |
| 713 | ASSERT(e->IsUndefined()); |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 720 | #endif // DEBUG |
| 721 | |
| 722 | } } // namespace v8::internal |