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