jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +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" |
| 32 | #include "jsregexp.h" |
| 33 | #include "objects-visiting.h" |
| 34 | |
| 35 | namespace v8 { |
| 36 | namespace internal { |
| 37 | |
| 38 | #ifdef OBJECT_PRINT |
| 39 | |
| 40 | static const char* TypeToString(InstanceType type); |
| 41 | |
| 42 | |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 43 | void MaybeObject::Print() { |
| 44 | Print(stdout); |
| 45 | } |
| 46 | |
| 47 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 48 | void MaybeObject::Print(FILE* out) { |
| 49 | Object* this_as_object; |
| 50 | if (ToObject(&this_as_object)) { |
| 51 | if (this_as_object->IsSmi()) { |
| 52 | Smi::cast(this_as_object)->SmiPrint(out); |
| 53 | } else { |
| 54 | HeapObject::cast(this_as_object)->HeapObjectPrint(out); |
| 55 | } |
| 56 | } else { |
| 57 | Failure::cast(this)->FailurePrint(out); |
| 58 | } |
| 59 | Flush(out); |
| 60 | } |
| 61 | |
| 62 | |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 63 | void MaybeObject::PrintLn() { |
| 64 | PrintLn(stdout); |
| 65 | } |
| 66 | |
| 67 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 68 | void MaybeObject::PrintLn(FILE* out) { |
| 69 | Print(out); |
| 70 | PrintF(out, "\n"); |
| 71 | } |
| 72 | |
| 73 | |
| 74 | void HeapObject::PrintHeader(FILE* out, const char* id) { |
| 75 | PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | void HeapObject::HeapObjectPrint(FILE* out) { |
| 80 | InstanceType instance_type = map()->instance_type(); |
| 81 | |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 82 | HandleScope scope(GetIsolate()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 83 | if (instance_type < FIRST_NONSTRING_TYPE) { |
| 84 | String::cast(this)->StringPrint(out); |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | switch (instance_type) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 89 | case SYMBOL_TYPE: |
| 90 | Symbol::cast(this)->SymbolPrint(out); |
| 91 | break; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 92 | case MAP_TYPE: |
| 93 | Map::cast(this)->MapPrint(out); |
| 94 | break; |
| 95 | case HEAP_NUMBER_TYPE: |
| 96 | HeapNumber::cast(this)->HeapNumberPrint(out); |
| 97 | break; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 98 | case FIXED_DOUBLE_ARRAY_TYPE: |
| 99 | FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out); |
| 100 | break; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 101 | case FIXED_ARRAY_TYPE: |
| 102 | FixedArray::cast(this)->FixedArrayPrint(out); |
| 103 | break; |
| 104 | case BYTE_ARRAY_TYPE: |
| 105 | ByteArray::cast(this)->ByteArrayPrint(out); |
| 106 | break; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 107 | case FREE_SPACE_TYPE: |
| 108 | FreeSpace::cast(this)->FreeSpacePrint(out); |
| 109 | break; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 110 | case EXTERNAL_PIXEL_ARRAY_TYPE: |
| 111 | ExternalPixelArray::cast(this)->ExternalPixelArrayPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 112 | break; |
| 113 | case EXTERNAL_BYTE_ARRAY_TYPE: |
| 114 | ExternalByteArray::cast(this)->ExternalByteArrayPrint(out); |
| 115 | break; |
| 116 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 117 | ExternalUnsignedByteArray::cast(this) |
| 118 | ->ExternalUnsignedByteArrayPrint(out); |
| 119 | break; |
| 120 | case EXTERNAL_SHORT_ARRAY_TYPE: |
| 121 | ExternalShortArray::cast(this)->ExternalShortArrayPrint(out); |
| 122 | break; |
| 123 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 124 | ExternalUnsignedShortArray::cast(this) |
| 125 | ->ExternalUnsignedShortArrayPrint(out); |
| 126 | break; |
| 127 | case EXTERNAL_INT_ARRAY_TYPE: |
| 128 | ExternalIntArray::cast(this)->ExternalIntArrayPrint(out); |
| 129 | break; |
| 130 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 131 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out); |
| 132 | break; |
| 133 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 134 | ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out); |
| 135 | break; |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 136 | case EXTERNAL_DOUBLE_ARRAY_TYPE: |
| 137 | ExternalDoubleArray::cast(this)->ExternalDoubleArrayPrint(out); |
| 138 | break; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 139 | case FILLER_TYPE: |
| 140 | PrintF(out, "filler"); |
| 141 | break; |
| 142 | case JS_OBJECT_TYPE: // fall through |
| 143 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 144 | case JS_ARRAY_TYPE: |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 145 | case JS_GENERATOR_OBJECT_TYPE: |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 146 | case JS_REGEXP_TYPE: |
| 147 | JSObject::cast(this)->JSObjectPrint(out); |
| 148 | break; |
| 149 | case ODDBALL_TYPE: |
| 150 | Oddball::cast(this)->to_string()->Print(out); |
| 151 | break; |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 152 | case JS_MODULE_TYPE: |
| 153 | JSModule::cast(this)->JSModulePrint(out); |
| 154 | break; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 155 | case JS_FUNCTION_TYPE: |
| 156 | JSFunction::cast(this)->JSFunctionPrint(out); |
| 157 | break; |
| 158 | case JS_GLOBAL_PROXY_TYPE: |
| 159 | JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out); |
| 160 | break; |
| 161 | case JS_GLOBAL_OBJECT_TYPE: |
| 162 | JSGlobalObject::cast(this)->JSGlobalObjectPrint(out); |
| 163 | break; |
| 164 | case JS_BUILTINS_OBJECT_TYPE: |
| 165 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out); |
| 166 | break; |
| 167 | case JS_VALUE_TYPE: |
| 168 | PrintF(out, "Value wrapper around:"); |
| 169 | JSValue::cast(this)->value()->Print(out); |
| 170 | break; |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 171 | case JS_DATE_TYPE: |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 172 | JSDate::cast(this)->JSDatePrint(out); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 173 | break; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 174 | case CODE_TYPE: |
| 175 | Code::cast(this)->CodePrint(out); |
| 176 | break; |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 177 | case JS_PROXY_TYPE: |
| 178 | JSProxy::cast(this)->JSProxyPrint(out); |
| 179 | break; |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 180 | case JS_FUNCTION_PROXY_TYPE: |
| 181 | JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out); |
| 182 | break; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 183 | case JS_WEAK_MAP_TYPE: |
| 184 | JSWeakMap::cast(this)->JSWeakMapPrint(out); |
| 185 | break; |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 186 | case JS_WEAK_SET_TYPE: |
| 187 | JSWeakSet::cast(this)->JSWeakSetPrint(out); |
| 188 | break; |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 189 | case FOREIGN_TYPE: |
| 190 | Foreign::cast(this)->ForeignPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 191 | break; |
| 192 | case SHARED_FUNCTION_INFO_TYPE: |
| 193 | SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out); |
| 194 | break; |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 195 | case JS_MESSAGE_OBJECT_TYPE: |
| 196 | JSMessageObject::cast(this)->JSMessageObjectPrint(out); |
| 197 | break; |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 198 | case CELL_TYPE: |
| 199 | Cell::cast(this)->CellPrint(out); |
| 200 | break; |
| 201 | case PROPERTY_CELL_TYPE: |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 202 | PropertyCell::cast(this)->PropertyCellPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 203 | break; |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 204 | case JS_ARRAY_BUFFER_TYPE: |
| 205 | JSArrayBuffer::cast(this)->JSArrayBufferPrint(out); |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 206 | break; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 207 | case JS_TYPED_ARRAY_TYPE: |
| 208 | JSTypedArray::cast(this)->JSTypedArrayPrint(out); |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 209 | break; |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 210 | case JS_DATA_VIEW_TYPE: |
| 211 | JSDataView::cast(this)->JSDataViewPrint(out); |
| 212 | break; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 213 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 214 | case NAME##_TYPE: \ |
| 215 | Name::cast(this)->Name##Print(out); \ |
| 216 | break; |
| 217 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 218 | #undef MAKE_STRUCT_CASE |
| 219 | |
| 220 | default: |
| 221 | PrintF(out, "UNKNOWN TYPE %d", map()->instance_type()); |
| 222 | UNREACHABLE(); |
| 223 | break; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | |
| 228 | void ByteArray::ByteArrayPrint(FILE* out) { |
| 229 | PrintF(out, "byte array, data starts at %p", GetDataStartAddress()); |
| 230 | } |
| 231 | |
| 232 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 233 | void FreeSpace::FreeSpacePrint(FILE* out) { |
| 234 | PrintF(out, "free space, size %d", Size()); |
| 235 | } |
| 236 | |
| 237 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 238 | void ExternalPixelArray::ExternalPixelArrayPrint(FILE* out) { |
| 239 | PrintF(out, "external pixel array"); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | |
| 243 | void ExternalByteArray::ExternalByteArrayPrint(FILE* out) { |
| 244 | PrintF(out, "external byte array"); |
| 245 | } |
| 246 | |
| 247 | |
| 248 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) { |
| 249 | PrintF(out, "external unsigned byte array"); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | void ExternalShortArray::ExternalShortArrayPrint(FILE* out) { |
| 254 | PrintF(out, "external short array"); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) { |
| 259 | PrintF(out, "external unsigned short array"); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | void ExternalIntArray::ExternalIntArrayPrint(FILE* out) { |
| 264 | PrintF(out, "external int array"); |
| 265 | } |
| 266 | |
| 267 | |
| 268 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) { |
| 269 | PrintF(out, "external unsigned int array"); |
| 270 | } |
| 271 | |
| 272 | |
| 273 | void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { |
| 274 | PrintF(out, "external float array"); |
| 275 | } |
| 276 | |
| 277 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 278 | void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) { |
| 279 | PrintF(out, "external double array"); |
| 280 | } |
| 281 | |
| 282 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 283 | void JSObject::PrintProperties(FILE* out) { |
| 284 | if (HasFastProperties()) { |
| 285 | DescriptorArray* descs = map()->instance_descriptors(); |
verwaest@chromium.org | 06ab2ec | 2012-10-09 17:00:13 +0000 | [diff] [blame] | 286 | for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 287 | PrintF(out, " "); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 288 | descs->GetKey(i)->NamePrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 289 | PrintF(out, ": "); |
| 290 | switch (descs->GetType(i)) { |
| 291 | case FIELD: { |
| 292 | int index = descs->GetFieldIndex(i); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 293 | RawFastPropertyAt(index)->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 294 | PrintF(out, " (field at offset %d)\n", index); |
| 295 | break; |
| 296 | } |
| 297 | case CONSTANT_FUNCTION: |
| 298 | descs->GetConstantFunction(i)->ShortPrint(out); |
| 299 | PrintF(out, " (constant function)\n"); |
| 300 | break; |
| 301 | case CALLBACKS: |
| 302 | descs->GetCallbacksObject(i)->ShortPrint(out); |
| 303 | PrintF(out, " (callback)\n"); |
| 304 | break; |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 305 | case NORMAL: // only in slow mode |
| 306 | case HANDLER: // only in lookup results, not in descriptors |
| 307 | case INTERCEPTOR: // only in lookup results, not in descriptors |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 308 | // There are no transitions in the descriptor array. |
| 309 | case TRANSITION: |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 310 | case NONEXISTENT: |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 311 | UNREACHABLE(); |
| 312 | break; |
| 313 | } |
| 314 | } |
| 315 | } else { |
| 316 | property_dictionary()->Print(out); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | |
| 321 | void JSObject::PrintElements(FILE* out) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 322 | // Don't call GetElementsKind, its validation code can cause the printer to |
| 323 | // fail when debugging. |
| 324 | switch (map()->elements_kind()) { |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 325 | case FAST_HOLEY_SMI_ELEMENTS: |
| 326 | case FAST_SMI_ELEMENTS: |
| 327 | case FAST_HOLEY_ELEMENTS: |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 328 | case FAST_ELEMENTS: { |
| 329 | // Print in array notation for non-sparse arrays. |
| 330 | FixedArray* p = FixedArray::cast(elements()); |
| 331 | for (int i = 0; i < p->length(); i++) { |
| 332 | PrintF(out, " %d: ", i); |
| 333 | p->get(i)->ShortPrint(out); |
| 334 | PrintF(out, "\n"); |
| 335 | } |
| 336 | break; |
| 337 | } |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 338 | case FAST_HOLEY_DOUBLE_ELEMENTS: |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 339 | case FAST_DOUBLE_ELEMENTS: { |
| 340 | // Print in array notation for non-sparse arrays. |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 341 | if (elements()->length() > 0) { |
| 342 | FixedDoubleArray* p = FixedDoubleArray::cast(elements()); |
| 343 | for (int i = 0; i < p->length(); i++) { |
| 344 | if (p->is_the_hole(i)) { |
| 345 | PrintF(out, " %d: <the hole>", i); |
| 346 | } else { |
| 347 | PrintF(out, " %d: %g", i, p->get_scalar(i)); |
| 348 | } |
| 349 | PrintF(out, "\n"); |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 350 | } |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 351 | } |
| 352 | break; |
| 353 | } |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 354 | case EXTERNAL_PIXEL_ELEMENTS: { |
| 355 | ExternalPixelArray* p = ExternalPixelArray::cast(elements()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 356 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 357 | PrintF(out, " %d: %d\n", i, p->get_scalar(i)); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 358 | } |
| 359 | break; |
| 360 | } |
| 361 | case EXTERNAL_BYTE_ELEMENTS: { |
| 362 | ExternalByteArray* p = ExternalByteArray::cast(elements()); |
| 363 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 364 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 365 | } |
| 366 | break; |
| 367 | } |
| 368 | case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 369 | ExternalUnsignedByteArray* p = |
| 370 | ExternalUnsignedByteArray::cast(elements()); |
| 371 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 372 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 373 | } |
| 374 | break; |
| 375 | } |
| 376 | case EXTERNAL_SHORT_ELEMENTS: { |
| 377 | ExternalShortArray* p = ExternalShortArray::cast(elements()); |
| 378 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 379 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 380 | } |
| 381 | break; |
| 382 | } |
| 383 | case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { |
| 384 | ExternalUnsignedShortArray* p = |
| 385 | ExternalUnsignedShortArray::cast(elements()); |
| 386 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 387 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 388 | } |
| 389 | break; |
| 390 | } |
| 391 | case EXTERNAL_INT_ELEMENTS: { |
| 392 | ExternalIntArray* p = ExternalIntArray::cast(elements()); |
| 393 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 394 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 395 | } |
| 396 | break; |
| 397 | } |
| 398 | case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
| 399 | ExternalUnsignedIntArray* p = |
| 400 | ExternalUnsignedIntArray::cast(elements()); |
| 401 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 402 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 403 | } |
| 404 | break; |
| 405 | } |
| 406 | case EXTERNAL_FLOAT_ELEMENTS: { |
| 407 | ExternalFloatArray* p = ExternalFloatArray::cast(elements()); |
| 408 | for (int i = 0; i < p->length(); i++) { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 409 | PrintF(out, " %d: %f\n", i, p->get_scalar(i)); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 410 | } |
| 411 | break; |
| 412 | } |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 413 | case EXTERNAL_DOUBLE_ELEMENTS: { |
| 414 | ExternalDoubleArray* p = ExternalDoubleArray::cast(elements()); |
| 415 | for (int i = 0; i < p->length(); i++) { |
svenpanne@chromium.org | 83130cf | 2012-11-30 10:13:25 +0000 | [diff] [blame] | 416 | PrintF(out, " %d: %f\n", i, p->get_scalar(i)); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 417 | } |
| 418 | break; |
| 419 | } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 420 | case DICTIONARY_ELEMENTS: |
| 421 | elements()->Print(out); |
| 422 | break; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 423 | case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 424 | FixedArray* p = FixedArray::cast(elements()); |
svenpanne@chromium.org | 83130cf | 2012-11-30 10:13:25 +0000 | [diff] [blame] | 425 | PrintF(out, " parameter map:"); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 426 | for (int i = 2; i < p->length(); i++) { |
svenpanne@chromium.org | 83130cf | 2012-11-30 10:13:25 +0000 | [diff] [blame] | 427 | PrintF(out, " %d:", i - 2); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 428 | p->get(i)->ShortPrint(out); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 429 | } |
svenpanne@chromium.org | 83130cf | 2012-11-30 10:13:25 +0000 | [diff] [blame] | 430 | PrintF(out, "\n context: "); |
| 431 | p->get(0)->ShortPrint(out); |
| 432 | PrintF(out, "\n arguments: "); |
| 433 | p->get(1)->ShortPrint(out); |
| 434 | PrintF(out, "\n"); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 435 | break; |
| 436 | } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 437 | } |
| 438 | } |
| 439 | |
| 440 | |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 441 | void JSObject::PrintTransitions(FILE* out) { |
| 442 | if (!map()->HasTransitionArray()) return; |
| 443 | TransitionArray* transitions = map()->transitions(); |
| 444 | for (int i = 0; i < transitions->number_of_transitions(); i++) { |
| 445 | PrintF(out, " "); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 446 | transitions->GetKey(i)->NamePrint(out); |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 447 | PrintF(out, ": "); |
| 448 | switch (transitions->GetTargetDetails(i).type()) { |
| 449 | case FIELD: { |
| 450 | PrintF(out, " (transition to field)\n"); |
| 451 | break; |
| 452 | } |
| 453 | case CONSTANT_FUNCTION: |
| 454 | PrintF(out, " (transition to constant function)\n"); |
| 455 | break; |
| 456 | case CALLBACKS: |
| 457 | PrintF(out, " (transition to callback)\n"); |
| 458 | break; |
| 459 | // Values below are never in the target descriptor array. |
| 460 | case NORMAL: |
| 461 | case HANDLER: |
| 462 | case INTERCEPTOR: |
| 463 | case TRANSITION: |
| 464 | case NONEXISTENT: |
| 465 | UNREACHABLE(); |
| 466 | break; |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 472 | void JSObject::JSObjectPrint(FILE* out) { |
| 473 | PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 474 | PrintF(out, " - map = %p [", reinterpret_cast<void*>(map())); |
| 475 | // Don't call GetElementsKind, its validation code can cause the printer to |
| 476 | // fail when debugging. |
| 477 | PrintElementsKind(out, this->map()->elements_kind()); |
| 478 | PrintF(out, |
| 479 | "]\n - prototype = %p\n", |
| 480 | reinterpret_cast<void*>(GetPrototype())); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 481 | PrintF(out, " {\n"); |
| 482 | PrintProperties(out); |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 483 | PrintTransitions(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 484 | PrintElements(out); |
| 485 | PrintF(out, " }\n"); |
| 486 | } |
| 487 | |
| 488 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 489 | void JSModule::JSModulePrint(FILE* out) { |
| 490 | HeapObject::PrintHeader(out, "JSModule"); |
| 491 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 492 | PrintF(out, " - context = "); |
| 493 | context()->Print(out); |
danno@chromium.org | 81cac2b | 2012-07-10 11:28:27 +0000 | [diff] [blame] | 494 | PrintF(out, " - scope_info = "); |
| 495 | scope_info()->ShortPrint(out); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 496 | PrintElementsKind(out, this->map()->elements_kind()); |
| 497 | PrintF(out, " {\n"); |
| 498 | PrintProperties(out); |
| 499 | PrintElements(out); |
| 500 | PrintF(out, " }\n"); |
| 501 | } |
| 502 | |
| 503 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 504 | static const char* TypeToString(InstanceType type) { |
| 505 | switch (type) { |
| 506 | case INVALID_TYPE: return "INVALID"; |
| 507 | case MAP_TYPE: return "MAP"; |
| 508 | case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; |
| 509 | case SYMBOL_TYPE: return "SYMBOL"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 510 | case STRING_TYPE: return "TWO_BYTE_STRING"; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 511 | case ASCII_STRING_TYPE: return "ASCII_STRING"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 512 | case CONS_STRING_TYPE: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 513 | case CONS_ASCII_STRING_TYPE: |
| 514 | return "CONS_STRING"; |
| 515 | case EXTERNAL_STRING_TYPE: |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 516 | case EXTERNAL_ASCII_STRING_TYPE: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 517 | case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 518 | return "EXTERNAL_STRING"; |
| 519 | case SHORT_EXTERNAL_STRING_TYPE: |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 520 | case SHORT_EXTERNAL_ASCII_STRING_TYPE: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 521 | case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 522 | return "SHORT_EXTERNAL_STRING"; |
| 523 | case INTERNALIZED_STRING_TYPE: return "INTERNALIZED_STRING"; |
| 524 | case ASCII_INTERNALIZED_STRING_TYPE: return "ASCII_INTERNALIZED_STRING"; |
| 525 | case CONS_INTERNALIZED_STRING_TYPE: return "CONS_INTERNALIZED_STRING"; |
| 526 | case CONS_ASCII_INTERNALIZED_STRING_TYPE: |
| 527 | return "CONS_ASCII_INTERNALIZED_STRING"; |
| 528 | case EXTERNAL_INTERNALIZED_STRING_TYPE: |
| 529 | case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 530 | case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 531 | return "EXTERNAL_INTERNALIZED_STRING"; |
| 532 | case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE: |
| 533 | case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 534 | case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 535 | return "SHORT_EXTERNAL_INTERNALIZED_STRING"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 536 | case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 537 | case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 538 | case FREE_SPACE_TYPE: return "FREE_SPACE"; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 539 | case EXTERNAL_PIXEL_ARRAY_TYPE: return "EXTERNAL_PIXEL_ARRAY"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 540 | case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY"; |
| 541 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 542 | return "EXTERNAL_UNSIGNED_BYTE_ARRAY"; |
| 543 | case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY"; |
| 544 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 545 | return "EXTERNAL_UNSIGNED_SHORT_ARRAY"; |
| 546 | case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY"; |
| 547 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 548 | return "EXTERNAL_UNSIGNED_INT_ARRAY"; |
| 549 | case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY"; |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 550 | case EXTERNAL_DOUBLE_ARRAY_TYPE: return "EXTERNAL_DOUBLE_ARRAY"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 551 | case FILLER_TYPE: return "FILLER"; |
| 552 | case JS_OBJECT_TYPE: return "JS_OBJECT"; |
| 553 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
| 554 | case ODDBALL_TYPE: return "ODDBALL"; |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 555 | case CELL_TYPE: return "CELL"; |
| 556 | case PROPERTY_CELL_TYPE: return "PROPERTY_CELL"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 557 | case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 558 | case JS_GENERATOR_OBJECT_TYPE: return "JS_GENERATOR_OBJECT"; |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 559 | case JS_MODULE_TYPE: return "JS_MODULE"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 560 | case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 561 | case CODE_TYPE: return "CODE"; |
| 562 | case JS_ARRAY_TYPE: return "JS_ARRAY"; |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 563 | case JS_PROXY_TYPE: return "JS_PROXY"; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 564 | case JS_WEAK_MAP_TYPE: return "JS_WEAK_MAP"; |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 565 | case JS_WEAK_SET_TYPE: return "JS_WEAK_SET"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 566 | case JS_REGEXP_TYPE: return "JS_REGEXP"; |
| 567 | case JS_VALUE_TYPE: return "JS_VALUE"; |
| 568 | case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 569 | case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
| 570 | case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 571 | case JS_ARRAY_BUFFER_TYPE: return "JS_ARRAY_BUFFER"; |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 572 | case JS_TYPED_ARRAY_TYPE: return "JS_TYPED_ARRAY"; |
| 573 | case JS_DATA_VIEW_TYPE: return "JS_DATA_VIEW"; |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 574 | case FOREIGN_TYPE: return "FOREIGN"; |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 575 | case JS_MESSAGE_OBJECT_TYPE: return "JS_MESSAGE_OBJECT_TYPE"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 576 | #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 577 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 578 | #undef MAKE_STRUCT_CASE |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 579 | default: return "UNKNOWN"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 580 | } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 584 | void Symbol::SymbolPrint(FILE* out) { |
| 585 | HeapObject::PrintHeader(out, "Symbol"); |
| 586 | PrintF(out, " - hash: %d\n", Hash()); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 587 | PrintF(out, " - name: "); |
| 588 | name()->ShortPrint(); |
| 589 | PrintF(out, "\n"); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 593 | void Map::MapPrint(FILE* out) { |
| 594 | HeapObject::PrintHeader(out, "Map"); |
| 595 | PrintF(out, " - type: %s\n", TypeToString(instance_type())); |
| 596 | PrintF(out, " - instance size: %d\n", instance_size()); |
| 597 | PrintF(out, " - inobject properties: %d\n", inobject_properties()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 598 | PrintF(out, " - elements kind: "); |
| 599 | PrintElementsKind(out, elements_kind()); |
| 600 | PrintF(out, "\n - pre-allocated property fields: %d\n", |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 601 | pre_allocated_property_fields()); |
| 602 | PrintF(out, " - unused property fields: %d\n", unused_property_fields()); |
| 603 | if (is_hidden_prototype()) { |
| 604 | PrintF(out, " - hidden_prototype\n"); |
| 605 | } |
| 606 | if (has_named_interceptor()) { |
| 607 | PrintF(out, " - named_interceptor\n"); |
| 608 | } |
| 609 | if (has_indexed_interceptor()) { |
| 610 | PrintF(out, " - indexed_interceptor\n"); |
| 611 | } |
| 612 | if (is_undetectable()) { |
| 613 | PrintF(out, " - undetectable\n"); |
| 614 | } |
| 615 | if (has_instance_call_handler()) { |
| 616 | PrintF(out, " - instance_call_handler\n"); |
| 617 | } |
| 618 | if (is_access_check_needed()) { |
| 619 | PrintF(out, " - access_check_needed\n"); |
| 620 | } |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 621 | PrintF(out, " - back pointer: "); |
| 622 | GetBackPointer()->ShortPrint(out); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 623 | PrintF(out, "\n - instance descriptors %s#%i: ", |
| 624 | owns_descriptors() ? "(own) " : "", |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 625 | NumberOfOwnDescriptors()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 626 | instance_descriptors()->ShortPrint(out); |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 627 | if (HasTransitionArray()) { |
| 628 | PrintF(out, "\n - transitions: "); |
| 629 | transitions()->ShortPrint(out); |
| 630 | } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 631 | PrintF(out, "\n - prototype: "); |
| 632 | prototype()->ShortPrint(out); |
| 633 | PrintF(out, "\n - constructor: "); |
| 634 | constructor()->ShortPrint(out); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 635 | PrintF(out, "\n - code cache: "); |
| 636 | code_cache()->ShortPrint(out); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 637 | PrintF(out, "\n - dependent code: "); |
| 638 | dependent_code()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 639 | PrintF(out, "\n"); |
| 640 | } |
| 641 | |
| 642 | |
| 643 | void CodeCache::CodeCachePrint(FILE* out) { |
| 644 | HeapObject::PrintHeader(out, "CodeCache"); |
| 645 | PrintF(out, "\n - default_cache: "); |
| 646 | default_cache()->ShortPrint(out); |
| 647 | PrintF(out, "\n - normal_type_cache: "); |
| 648 | normal_type_cache()->ShortPrint(out); |
| 649 | } |
| 650 | |
| 651 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 652 | void PolymorphicCodeCache::PolymorphicCodeCachePrint(FILE* out) { |
| 653 | HeapObject::PrintHeader(out, "PolymorphicCodeCache"); |
| 654 | PrintF(out, "\n - cache: "); |
| 655 | cache()->ShortPrint(out); |
| 656 | } |
| 657 | |
| 658 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 659 | void TypeFeedbackInfo::TypeFeedbackInfoPrint(FILE* out) { |
| 660 | HeapObject::PrintHeader(out, "TypeFeedbackInfo"); |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 661 | PrintF(out, " - ic_total_count: %d, ic_with_type_info_count: %d\n", |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 662 | ic_total_count(), ic_with_type_info_count()); |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 663 | PrintF(out, " - type_feedback_cells: "); |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 664 | type_feedback_cells()->FixedArrayPrint(out); |
| 665 | } |
| 666 | |
| 667 | |
yangguo@chromium.org | ab30bb8 | 2012-02-24 14:41:46 +0000 | [diff] [blame] | 668 | void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(FILE* out) { |
| 669 | HeapObject::PrintHeader(out, "AliasedArgumentsEntry"); |
| 670 | PrintF(out, "\n - aliased_context_slot: %d", aliased_context_slot()); |
| 671 | } |
| 672 | |
| 673 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 674 | void FixedArray::FixedArrayPrint(FILE* out) { |
| 675 | HeapObject::PrintHeader(out, "FixedArray"); |
| 676 | PrintF(out, " - length: %d", length()); |
| 677 | for (int i = 0; i < length(); i++) { |
| 678 | PrintF(out, "\n [%d]: ", i); |
| 679 | get(i)->ShortPrint(out); |
| 680 | } |
| 681 | PrintF(out, "\n"); |
| 682 | } |
| 683 | |
| 684 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 685 | void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) { |
| 686 | HeapObject::PrintHeader(out, "FixedDoubleArray"); |
| 687 | PrintF(out, " - length: %d", length()); |
| 688 | for (int i = 0; i < length(); i++) { |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 689 | if (is_the_hole(i)) { |
| 690 | PrintF(out, "\n [%d]: <the hole>", i); |
| 691 | } else { |
| 692 | PrintF(out, "\n [%d]: %g", i, get_scalar(i)); |
| 693 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 694 | } |
| 695 | PrintF(out, "\n"); |
| 696 | } |
| 697 | |
| 698 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 699 | void JSValue::JSValuePrint(FILE* out) { |
| 700 | HeapObject::PrintHeader(out, "ValueObject"); |
| 701 | value()->Print(out); |
| 702 | } |
| 703 | |
| 704 | |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 705 | void JSMessageObject::JSMessageObjectPrint(FILE* out) { |
| 706 | HeapObject::PrintHeader(out, "JSMessageObject"); |
| 707 | PrintF(out, " - type: "); |
| 708 | type()->ShortPrint(out); |
| 709 | PrintF(out, "\n - arguments: "); |
| 710 | arguments()->ShortPrint(out); |
| 711 | PrintF(out, "\n - start_position: %d", start_position()); |
| 712 | PrintF(out, "\n - end_position: %d", end_position()); |
| 713 | PrintF(out, "\n - script: "); |
| 714 | script()->ShortPrint(out); |
| 715 | PrintF(out, "\n - stack_trace: "); |
| 716 | stack_trace()->ShortPrint(out); |
| 717 | PrintF(out, "\n - stack_frames: "); |
| 718 | stack_frames()->ShortPrint(out); |
| 719 | PrintF(out, "\n"); |
| 720 | } |
| 721 | |
| 722 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 723 | void String::StringPrint(FILE* out) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 724 | if (StringShape(this).IsInternalized()) { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 725 | PrintF(out, "#"); |
| 726 | } else if (StringShape(this).IsCons()) { |
| 727 | PrintF(out, "c\""); |
| 728 | } else { |
| 729 | PrintF(out, "\""); |
| 730 | } |
| 731 | |
| 732 | const char truncated_epilogue[] = "...<truncated>"; |
| 733 | int len = length(); |
| 734 | if (!FLAG_use_verbose_printer) { |
| 735 | if (len > 100) { |
| 736 | len = 100 - sizeof(truncated_epilogue); |
| 737 | } |
| 738 | } |
| 739 | for (int i = 0; i < len; i++) { |
| 740 | PrintF(out, "%c", Get(i)); |
| 741 | } |
| 742 | if (len != length()) { |
| 743 | PrintF(out, "%s", truncated_epilogue); |
| 744 | } |
| 745 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 746 | if (!StringShape(this).IsInternalized()) PrintF(out, "\""); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 750 | void Name::NamePrint(FILE* out) { |
| 751 | if (IsString()) |
| 752 | String::cast(this)->StringPrint(out); |
| 753 | else |
| 754 | ShortPrint(); |
| 755 | } |
| 756 | |
| 757 | |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 758 | // This method is only meant to be called from gdb for debugging purposes. |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 759 | // Since the string can also be in two-byte encoding, non-ASCII characters |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 760 | // will be ignored in the output. |
| 761 | char* String::ToAsciiArray() { |
| 762 | // Static so that subsequent calls frees previously allocated space. |
| 763 | // This also means that previous results will be overwritten. |
| 764 | static char* buffer = NULL; |
| 765 | if (buffer != NULL) free(buffer); |
| 766 | buffer = new char[length()+1]; |
jkummerow@chromium.org | 9439d1f | 2013-01-09 17:13:11 +0000 | [diff] [blame] | 767 | WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length()); |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 768 | buffer[length()] = 0; |
| 769 | return buffer; |
| 770 | } |
| 771 | |
| 772 | |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 773 | static const char* const weekdays[] = { |
| 774 | "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" |
| 775 | }; |
| 776 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 777 | |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 778 | void JSDate::JSDatePrint(FILE* out) { |
| 779 | HeapObject::PrintHeader(out, "JSDate"); |
| 780 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 781 | PrintF(out, " - value = "); |
| 782 | value()->Print(out); |
| 783 | if (!year()->IsSmi()) { |
| 784 | PrintF(out, " - time = NaN\n"); |
| 785 | } else { |
| 786 | PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n", |
| 787 | weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0], |
| 788 | year()->IsSmi() ? Smi::cast(year())->value() : -1, |
| 789 | month()->IsSmi() ? Smi::cast(month())->value() : -1, |
| 790 | day()->IsSmi() ? Smi::cast(day())->value() : -1, |
| 791 | hour()->IsSmi() ? Smi::cast(hour())->value() : -1, |
| 792 | min()->IsSmi() ? Smi::cast(min())->value() : -1, |
| 793 | sec()->IsSmi() ? Smi::cast(sec())->value() : -1); |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 798 | void JSProxy::JSProxyPrint(FILE* out) { |
| 799 | HeapObject::PrintHeader(out, "JSProxy"); |
| 800 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 801 | PrintF(out, " - handler = "); |
| 802 | handler()->Print(out); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 803 | PrintF(out, " - hash = "); |
| 804 | hash()->Print(out); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 805 | PrintF(out, "\n"); |
| 806 | } |
| 807 | |
| 808 | |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 809 | void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) { |
| 810 | HeapObject::PrintHeader(out, "JSFunctionProxy"); |
| 811 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 812 | PrintF(out, " - handler = "); |
| 813 | handler()->Print(out); |
| 814 | PrintF(out, " - call_trap = "); |
| 815 | call_trap()->Print(out); |
| 816 | PrintF(out, " - construct_trap = "); |
| 817 | construct_trap()->Print(out); |
| 818 | PrintF(out, "\n"); |
| 819 | } |
| 820 | |
| 821 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 822 | void JSWeakMap::JSWeakMapPrint(FILE* out) { |
| 823 | HeapObject::PrintHeader(out, "JSWeakMap"); |
| 824 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 825 | PrintF(out, " - table = "); |
| 826 | table()->ShortPrint(out); |
| 827 | PrintF(out, "\n"); |
| 828 | } |
| 829 | |
| 830 | |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 831 | void JSWeakSet::JSWeakSetPrint(FILE* out) { |
| 832 | HeapObject::PrintHeader(out, "JSWeakSet"); |
| 833 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 834 | PrintF(out, " - table = "); |
| 835 | table()->ShortPrint(out); |
| 836 | PrintF(out, "\n"); |
| 837 | } |
| 838 | |
| 839 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 840 | void JSArrayBuffer::JSArrayBufferPrint(FILE* out) { |
| 841 | HeapObject::PrintHeader(out, "JSArrayBuffer"); |
| 842 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 843 | PrintF(out, " - backing_store = -0x%p\n", backing_store()); |
| 844 | PrintF(out, " - byte_length = "); |
| 845 | byte_length()->ShortPrint(out); |
| 846 | PrintF(out, "\n"); |
| 847 | } |
| 848 | |
| 849 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 850 | void JSTypedArray::JSTypedArrayPrint(FILE* out) { |
| 851 | HeapObject::PrintHeader(out, "JSTypedArray"); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 852 | PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 853 | PrintF(out, " - buffer ="); |
| 854 | buffer()->ShortPrint(out); |
| 855 | PrintF(out, "\n - byte_offset = "); |
| 856 | byte_offset()->ShortPrint(out); |
| 857 | PrintF(out, "\n - byte_length = "); |
| 858 | byte_length()->ShortPrint(out); |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 859 | PrintF(out, "\n - length = "); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 860 | length()->ShortPrint(out); |
| 861 | PrintF("\n"); |
| 862 | PrintElements(out); |
| 863 | } |
| 864 | |
| 865 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 866 | void JSDataView::JSDataViewPrint(FILE* out) { |
| 867 | HeapObject::PrintHeader(out, "JSDataView"); |
| 868 | PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); |
| 869 | PrintF(out, " - buffer ="); |
| 870 | buffer()->ShortPrint(out); |
| 871 | PrintF(out, "\n - byte_offset = "); |
| 872 | byte_offset()->ShortPrint(out); |
| 873 | PrintF(out, "\n - byte_length = "); |
| 874 | byte_length()->ShortPrint(out); |
| 875 | PrintF("\n"); |
| 876 | } |
| 877 | |
| 878 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 879 | void JSFunction::JSFunctionPrint(FILE* out) { |
| 880 | HeapObject::PrintHeader(out, "Function"); |
| 881 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 882 | PrintF(out, " - initial_map = "); |
| 883 | if (has_initial_map()) { |
| 884 | initial_map()->ShortPrint(out); |
| 885 | } |
| 886 | PrintF(out, "\n - shared_info = "); |
| 887 | shared()->ShortPrint(out); |
| 888 | PrintF(out, "\n - name = "); |
| 889 | shared()->name()->Print(out); |
| 890 | PrintF(out, "\n - context = "); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 891 | context()->ShortPrint(out); |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 892 | PrintF(out, "\n - literals = "); |
| 893 | literals()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 894 | PrintF(out, "\n - code = "); |
| 895 | code()->ShortPrint(out); |
| 896 | PrintF(out, "\n"); |
| 897 | |
| 898 | PrintProperties(out); |
| 899 | PrintElements(out); |
| 900 | |
| 901 | PrintF(out, "\n"); |
| 902 | } |
| 903 | |
| 904 | |
| 905 | void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) { |
| 906 | HeapObject::PrintHeader(out, "SharedFunctionInfo"); |
| 907 | PrintF(out, " - name: "); |
| 908 | name()->ShortPrint(out); |
| 909 | PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties()); |
| 910 | PrintF(out, "\n - instance class name = "); |
| 911 | instance_class_name()->Print(out); |
| 912 | PrintF(out, "\n - code = "); |
| 913 | code()->ShortPrint(out); |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 914 | if (HasSourceCode()) { |
| 915 | PrintF(out, "\n - source code = "); |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 916 | String* source = String::cast(Script::cast(script())->source()); |
| 917 | int start = start_position(); |
| 918 | int length = end_position() - start; |
| 919 | SmartArrayPointer<char> source_string = |
| 920 | source->ToCString(DISALLOW_NULLS, |
| 921 | FAST_STRING_TRAVERSAL, |
| 922 | start, length, NULL); |
| 923 | PrintF(out, "%s", *source_string); |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 924 | } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 925 | // Script files are often large, hard to read. |
| 926 | // PrintF(out, "\n - script ="); |
| 927 | // script()->Print(out); |
| 928 | PrintF(out, "\n - function token position = %d", function_token_position()); |
| 929 | PrintF(out, "\n - start position = %d", start_position()); |
| 930 | PrintF(out, "\n - end position = %d", end_position()); |
| 931 | PrintF(out, "\n - is expression = %d", is_expression()); |
| 932 | PrintF(out, "\n - debug info = "); |
| 933 | debug_info()->ShortPrint(out); |
| 934 | PrintF(out, "\n - length = %d", length()); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 935 | PrintF(out, "\n - optimized_code_map = "); |
| 936 | optimized_code_map()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 937 | PrintF(out, "\n"); |
| 938 | } |
| 939 | |
| 940 | |
| 941 | void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) { |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 942 | PrintF(out, "global_proxy "); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 943 | JSObjectPrint(out); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 944 | PrintF(out, "native context : "); |
| 945 | native_context()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 946 | PrintF(out, "\n"); |
| 947 | } |
| 948 | |
| 949 | |
| 950 | void JSGlobalObject::JSGlobalObjectPrint(FILE* out) { |
| 951 | PrintF(out, "global "); |
| 952 | JSObjectPrint(out); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 953 | PrintF(out, "native context : "); |
| 954 | native_context()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 955 | PrintF(out, "\n"); |
| 956 | } |
| 957 | |
| 958 | |
| 959 | void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) { |
| 960 | PrintF(out, "builtins "); |
| 961 | JSObjectPrint(out); |
| 962 | } |
| 963 | |
| 964 | |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 965 | void Cell::CellPrint(FILE* out) { |
| 966 | HeapObject::PrintHeader(out, "Cell"); |
| 967 | } |
| 968 | |
| 969 | |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 970 | void PropertyCell::PropertyCellPrint(FILE* out) { |
| 971 | HeapObject::PrintHeader(out, "PropertyCell"); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | |
| 975 | void Code::CodePrint(FILE* out) { |
| 976 | HeapObject::PrintHeader(out, "Code"); |
| 977 | #ifdef ENABLE_DISASSEMBLER |
| 978 | if (FLAG_use_verbose_printer) { |
| 979 | Disassemble(NULL, out); |
| 980 | } |
| 981 | #endif |
| 982 | } |
| 983 | |
| 984 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 985 | void Foreign::ForeignPrint(FILE* out) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 986 | PrintF(out, "foreign address : %p", foreign_address()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 990 | void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(FILE* out) { |
| 991 | HeapObject::PrintHeader(out, "ExecutableAccessorInfo"); |
| 992 | PrintF(out, "\n - name: "); |
| 993 | name()->ShortPrint(out); |
| 994 | PrintF(out, "\n - flag: "); |
| 995 | flag()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 996 | PrintF(out, "\n - getter: "); |
| 997 | getter()->ShortPrint(out); |
| 998 | PrintF(out, "\n - setter: "); |
| 999 | setter()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1000 | PrintF(out, "\n - data: "); |
| 1001 | data()->ShortPrint(out); |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | |
| 1005 | void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(FILE* out) { |
| 1006 | HeapObject::PrintHeader(out, "DeclaredAccessorInfo"); |
| 1007 | PrintF(out, "\n - name: "); |
| 1008 | name()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1009 | PrintF(out, "\n - flag: "); |
| 1010 | flag()->ShortPrint(out); |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1011 | PrintF(out, "\n - descriptor: "); |
| 1012 | descriptor()->ShortPrint(out); |
| 1013 | } |
| 1014 | |
| 1015 | |
| 1016 | void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(FILE* out) { |
| 1017 | HeapObject::PrintHeader(out, "DeclaredAccessorDescriptor"); |
| 1018 | PrintF(out, "\n - internal field: "); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1019 | serialized_data()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 1023 | void Box::BoxPrint(FILE* out) { |
| 1024 | HeapObject::PrintHeader(out, "Box"); |
| 1025 | PrintF(out, "\n - value: "); |
| 1026 | value()->ShortPrint(out); |
| 1027 | } |
| 1028 | |
| 1029 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1030 | void AccessorPair::AccessorPairPrint(FILE* out) { |
| 1031 | HeapObject::PrintHeader(out, "AccessorPair"); |
| 1032 | PrintF(out, "\n - getter: "); |
| 1033 | getter()->ShortPrint(out); |
| 1034 | PrintF(out, "\n - setter: "); |
| 1035 | setter()->ShortPrint(out); |
| 1036 | } |
| 1037 | |
| 1038 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1039 | void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) { |
| 1040 | HeapObject::PrintHeader(out, "AccessCheckInfo"); |
| 1041 | PrintF(out, "\n - named_callback: "); |
| 1042 | named_callback()->ShortPrint(out); |
| 1043 | PrintF(out, "\n - indexed_callback: "); |
| 1044 | indexed_callback()->ShortPrint(out); |
| 1045 | PrintF(out, "\n - data: "); |
| 1046 | data()->ShortPrint(out); |
| 1047 | } |
| 1048 | |
| 1049 | |
| 1050 | void InterceptorInfo::InterceptorInfoPrint(FILE* out) { |
| 1051 | HeapObject::PrintHeader(out, "InterceptorInfo"); |
| 1052 | PrintF(out, "\n - getter: "); |
| 1053 | getter()->ShortPrint(out); |
| 1054 | PrintF(out, "\n - setter: "); |
| 1055 | setter()->ShortPrint(out); |
| 1056 | PrintF(out, "\n - query: "); |
| 1057 | query()->ShortPrint(out); |
| 1058 | PrintF(out, "\n - deleter: "); |
| 1059 | deleter()->ShortPrint(out); |
| 1060 | PrintF(out, "\n - enumerator: "); |
| 1061 | enumerator()->ShortPrint(out); |
| 1062 | PrintF(out, "\n - data: "); |
| 1063 | data()->ShortPrint(out); |
| 1064 | } |
| 1065 | |
| 1066 | |
| 1067 | void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) { |
| 1068 | HeapObject::PrintHeader(out, "CallHandlerInfo"); |
| 1069 | PrintF(out, "\n - callback: "); |
| 1070 | callback()->ShortPrint(out); |
| 1071 | PrintF(out, "\n - data: "); |
| 1072 | data()->ShortPrint(out); |
| 1073 | PrintF(out, "\n - call_stub_cache: "); |
| 1074 | } |
| 1075 | |
| 1076 | |
| 1077 | void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) { |
| 1078 | HeapObject::PrintHeader(out, "FunctionTemplateInfo"); |
| 1079 | PrintF(out, "\n - class name: "); |
| 1080 | class_name()->ShortPrint(out); |
| 1081 | PrintF(out, "\n - tag: "); |
| 1082 | tag()->ShortPrint(out); |
| 1083 | PrintF(out, "\n - property_list: "); |
| 1084 | property_list()->ShortPrint(out); |
| 1085 | PrintF(out, "\n - serial_number: "); |
| 1086 | serial_number()->ShortPrint(out); |
| 1087 | PrintF(out, "\n - call_code: "); |
| 1088 | call_code()->ShortPrint(out); |
| 1089 | PrintF(out, "\n - property_accessors: "); |
| 1090 | property_accessors()->ShortPrint(out); |
| 1091 | PrintF(out, "\n - prototype_template: "); |
| 1092 | prototype_template()->ShortPrint(out); |
| 1093 | PrintF(out, "\n - parent_template: "); |
| 1094 | parent_template()->ShortPrint(out); |
| 1095 | PrintF(out, "\n - named_property_handler: "); |
| 1096 | named_property_handler()->ShortPrint(out); |
| 1097 | PrintF(out, "\n - indexed_property_handler: "); |
| 1098 | indexed_property_handler()->ShortPrint(out); |
| 1099 | PrintF(out, "\n - instance_template: "); |
| 1100 | instance_template()->ShortPrint(out); |
| 1101 | PrintF(out, "\n - signature: "); |
| 1102 | signature()->ShortPrint(out); |
| 1103 | PrintF(out, "\n - access_check_info: "); |
| 1104 | access_check_info()->ShortPrint(out); |
| 1105 | PrintF(out, "\n - hidden_prototype: %s", |
| 1106 | hidden_prototype() ? "true" : "false"); |
| 1107 | PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 1108 | PrintF(out, "\n - need_access_check: %s", |
| 1109 | needs_access_check() ? "true" : "false"); |
| 1110 | } |
| 1111 | |
| 1112 | |
| 1113 | void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) { |
| 1114 | HeapObject::PrintHeader(out, "ObjectTemplateInfo"); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1115 | PrintF(out, " - tag: "); |
| 1116 | tag()->ShortPrint(out); |
| 1117 | PrintF(out, "\n - property_list: "); |
| 1118 | property_list()->ShortPrint(out); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1119 | PrintF(out, "\n - constructor: "); |
| 1120 | constructor()->ShortPrint(out); |
| 1121 | PrintF(out, "\n - internal_field_count: "); |
| 1122 | internal_field_count()->ShortPrint(out); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1123 | PrintF(out, "\n"); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | |
| 1127 | void SignatureInfo::SignatureInfoPrint(FILE* out) { |
| 1128 | HeapObject::PrintHeader(out, "SignatureInfo"); |
| 1129 | PrintF(out, "\n - receiver: "); |
| 1130 | receiver()->ShortPrint(out); |
| 1131 | PrintF(out, "\n - args: "); |
| 1132 | args()->ShortPrint(out); |
| 1133 | } |
| 1134 | |
| 1135 | |
| 1136 | void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { |
| 1137 | HeapObject::PrintHeader(out, "TypeSwitchInfo"); |
| 1138 | PrintF(out, "\n - types: "); |
| 1139 | types()->ShortPrint(out); |
| 1140 | } |
| 1141 | |
| 1142 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1143 | void AllocationSite::AllocationSitePrint(FILE* out) { |
| 1144 | HeapObject::PrintHeader(out, "AllocationSite"); |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 1145 | PrintF(out, " - weak_next: "); |
| 1146 | weak_next()->ShortPrint(out); |
| 1147 | PrintF(out, "\n"); |
| 1148 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1149 | PrintF(out, " - transition_info: "); |
| 1150 | if (transition_info()->IsCell()) { |
| 1151 | Cell* cell = Cell::cast(transition_info()); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1152 | Object* cell_contents = cell->value(); |
| 1153 | if (cell_contents->IsSmi()) { |
| 1154 | ElementsKind kind = static_cast<ElementsKind>( |
| 1155 | Smi::cast(cell_contents)->value()); |
| 1156 | PrintF(out, "Array allocation with ElementsKind "); |
| 1157 | PrintElementsKind(out, kind); |
| 1158 | PrintF(out, "\n"); |
| 1159 | return; |
| 1160 | } |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1161 | } else if (transition_info()->IsJSArray()) { |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1162 | PrintF(out, "Array literal "); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1163 | transition_info()->ShortPrint(out); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1164 | PrintF(out, "\n"); |
| 1165 | return; |
| 1166 | } |
| 1167 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1168 | PrintF(out, "unknown transition_info"); |
| 1169 | transition_info()->ShortPrint(out); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1170 | PrintF(out, "\n"); |
| 1171 | } |
| 1172 | |
| 1173 | |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 1174 | void AllocationMemento::AllocationMementoPrint(FILE* out) { |
| 1175 | HeapObject::PrintHeader(out, "AllocationMemento"); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1176 | PrintF(out, " - allocation site: "); |
| 1177 | if (IsValid()) { |
| 1178 | GetAllocationSite()->Print(); |
| 1179 | } else { |
| 1180 | PrintF(out, "<invalid>\n"); |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1185 | void Script::ScriptPrint(FILE* out) { |
| 1186 | HeapObject::PrintHeader(out, "Script"); |
| 1187 | PrintF(out, "\n - source: "); |
| 1188 | source()->ShortPrint(out); |
| 1189 | PrintF(out, "\n - name: "); |
| 1190 | name()->ShortPrint(out); |
| 1191 | PrintF(out, "\n - line_offset: "); |
| 1192 | line_offset()->ShortPrint(out); |
| 1193 | PrintF(out, "\n - column_offset: "); |
| 1194 | column_offset()->ShortPrint(out); |
| 1195 | PrintF(out, "\n - type: "); |
| 1196 | type()->ShortPrint(out); |
| 1197 | PrintF(out, "\n - id: "); |
| 1198 | id()->ShortPrint(out); |
| 1199 | PrintF(out, "\n - data: "); |
| 1200 | data()->ShortPrint(out); |
| 1201 | PrintF(out, "\n - context data: "); |
| 1202 | context_data()->ShortPrint(out); |
| 1203 | PrintF(out, "\n - wrapper: "); |
| 1204 | wrapper()->ShortPrint(out); |
| 1205 | PrintF(out, "\n - compilation type: "); |
| 1206 | compilation_type()->ShortPrint(out); |
| 1207 | PrintF(out, "\n - line ends: "); |
| 1208 | line_ends()->ShortPrint(out); |
| 1209 | PrintF(out, "\n - eval from shared: "); |
| 1210 | eval_from_shared()->ShortPrint(out); |
| 1211 | PrintF(out, "\n - eval from instructions offset: "); |
| 1212 | eval_from_instructions_offset()->ShortPrint(out); |
| 1213 | PrintF(out, "\n"); |
| 1214 | } |
| 1215 | |
| 1216 | |
| 1217 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1218 | void DebugInfo::DebugInfoPrint(FILE* out) { |
| 1219 | HeapObject::PrintHeader(out, "DebugInfo"); |
| 1220 | PrintF(out, "\n - shared: "); |
| 1221 | shared()->ShortPrint(out); |
| 1222 | PrintF(out, "\n - original_code: "); |
| 1223 | original_code()->ShortPrint(out); |
| 1224 | PrintF(out, "\n - code: "); |
| 1225 | code()->ShortPrint(out); |
| 1226 | PrintF(out, "\n - break_points: "); |
| 1227 | break_points()->Print(out); |
| 1228 | } |
| 1229 | |
| 1230 | |
| 1231 | void BreakPointInfo::BreakPointInfoPrint(FILE* out) { |
| 1232 | HeapObject::PrintHeader(out, "BreakPointInfo"); |
| 1233 | PrintF(out, "\n - code_position: %d", code_position()->value()); |
| 1234 | PrintF(out, "\n - source_position: %d", source_position()->value()); |
| 1235 | PrintF(out, "\n - statement_position: %d", statement_position()->value()); |
| 1236 | PrintF(out, "\n - break_point_objects: "); |
| 1237 | break_point_objects()->ShortPrint(out); |
| 1238 | } |
| 1239 | #endif // ENABLE_DEBUGGER_SUPPORT |
| 1240 | |
| 1241 | |
| 1242 | void DescriptorArray::PrintDescriptors(FILE* out) { |
| 1243 | PrintF(out, "Descriptor array %d\n", number_of_descriptors()); |
| 1244 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 1245 | PrintF(out, " %d: ", i); |
| 1246 | Descriptor desc; |
| 1247 | Get(i, &desc); |
| 1248 | desc.Print(out); |
| 1249 | } |
| 1250 | PrintF(out, "\n"); |
| 1251 | } |
| 1252 | |
| 1253 | |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 1254 | void TransitionArray::PrintTransitions(FILE* out) { |
| 1255 | PrintF(out, "Transition array %d\n", number_of_transitions()); |
| 1256 | for (int i = 0; i < number_of_transitions(); i++) { |
| 1257 | PrintF(out, " %d: ", i); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1258 | GetKey(i)->NamePrint(out); |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 1259 | PrintF(out, ": "); |
| 1260 | switch (GetTargetDetails(i).type()) { |
| 1261 | case FIELD: { |
| 1262 | PrintF(out, " (transition to field)\n"); |
| 1263 | break; |
| 1264 | } |
| 1265 | case CONSTANT_FUNCTION: |
| 1266 | PrintF(out, " (transition to constant function)\n"); |
| 1267 | break; |
| 1268 | case CALLBACKS: |
| 1269 | PrintF(out, " (transition to callback)\n"); |
| 1270 | break; |
| 1271 | // Values below are never in the target descriptor array. |
| 1272 | case NORMAL: |
| 1273 | case HANDLER: |
| 1274 | case INTERCEPTOR: |
| 1275 | case TRANSITION: |
| 1276 | case NONEXISTENT: |
| 1277 | UNREACHABLE(); |
| 1278 | break; |
| 1279 | } |
| 1280 | } |
| 1281 | PrintF(out, "\n"); |
| 1282 | } |
| 1283 | |
| 1284 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1285 | #endif // OBJECT_PRINT |
| 1286 | |
| 1287 | |
| 1288 | } } // namespace v8::internal |