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