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