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