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