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