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