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