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