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