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