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