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