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