Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [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 | |
| 72 | HandleScope scope; |
| 73 | if (instance_type < FIRST_NONSTRING_TYPE) { |
| 74 | String::cast(this)->StringPrint(out); |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | switch (instance_type) { |
| 79 | case MAP_TYPE: |
| 80 | Map::cast(this)->MapPrint(out); |
| 81 | break; |
| 82 | case HEAP_NUMBER_TYPE: |
| 83 | HeapNumber::cast(this)->HeapNumberPrint(out); |
| 84 | break; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 85 | case FIXED_DOUBLE_ARRAY_TYPE: |
| 86 | FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out); |
| 87 | break; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 88 | case FIXED_ARRAY_TYPE: |
| 89 | FixedArray::cast(this)->FixedArrayPrint(out); |
| 90 | break; |
| 91 | case BYTE_ARRAY_TYPE: |
| 92 | ByteArray::cast(this)->ByteArrayPrint(out); |
| 93 | break; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 94 | case FREE_SPACE_TYPE: |
| 95 | FreeSpace::cast(this)->FreeSpacePrint(out); |
| 96 | break; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 97 | case EXTERNAL_PIXEL_ARRAY_TYPE: |
| 98 | ExternalPixelArray::cast(this)->ExternalPixelArrayPrint(out); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 99 | break; |
| 100 | case EXTERNAL_BYTE_ARRAY_TYPE: |
| 101 | ExternalByteArray::cast(this)->ExternalByteArrayPrint(out); |
| 102 | break; |
| 103 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 104 | ExternalUnsignedByteArray::cast(this) |
| 105 | ->ExternalUnsignedByteArrayPrint(out); |
| 106 | break; |
| 107 | case EXTERNAL_SHORT_ARRAY_TYPE: |
| 108 | ExternalShortArray::cast(this)->ExternalShortArrayPrint(out); |
| 109 | break; |
| 110 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 111 | ExternalUnsignedShortArray::cast(this) |
| 112 | ->ExternalUnsignedShortArrayPrint(out); |
| 113 | break; |
| 114 | case EXTERNAL_INT_ARRAY_TYPE: |
| 115 | ExternalIntArray::cast(this)->ExternalIntArrayPrint(out); |
| 116 | break; |
| 117 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 118 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out); |
| 119 | break; |
| 120 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 121 | ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out); |
| 122 | break; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 123 | case EXTERNAL_DOUBLE_ARRAY_TYPE: |
| 124 | ExternalDoubleArray::cast(this)->ExternalDoubleArrayPrint(out); |
| 125 | break; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 126 | case FILLER_TYPE: |
| 127 | PrintF(out, "filler"); |
| 128 | break; |
| 129 | case JS_OBJECT_TYPE: // fall through |
| 130 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 131 | case JS_ARRAY_TYPE: |
| 132 | case JS_REGEXP_TYPE: |
| 133 | JSObject::cast(this)->JSObjectPrint(out); |
| 134 | break; |
| 135 | case ODDBALL_TYPE: |
| 136 | Oddball::cast(this)->to_string()->Print(out); |
| 137 | break; |
| 138 | case JS_FUNCTION_TYPE: |
| 139 | JSFunction::cast(this)->JSFunctionPrint(out); |
| 140 | break; |
| 141 | case JS_GLOBAL_PROXY_TYPE: |
| 142 | JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out); |
| 143 | break; |
| 144 | case JS_GLOBAL_OBJECT_TYPE: |
| 145 | JSGlobalObject::cast(this)->JSGlobalObjectPrint(out); |
| 146 | break; |
| 147 | case JS_BUILTINS_OBJECT_TYPE: |
| 148 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out); |
| 149 | break; |
| 150 | case JS_VALUE_TYPE: |
| 151 | PrintF(out, "Value wrapper around:"); |
| 152 | JSValue::cast(this)->value()->Print(out); |
| 153 | break; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 154 | case JS_DATE_TYPE: |
| 155 | JSDate::cast(this)->value()->Print(out); |
| 156 | break; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 157 | case CODE_TYPE: |
| 158 | Code::cast(this)->CodePrint(out); |
| 159 | break; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 160 | case JS_PROXY_TYPE: |
| 161 | JSProxy::cast(this)->JSProxyPrint(out); |
| 162 | break; |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 163 | case JS_FUNCTION_PROXY_TYPE: |
| 164 | JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out); |
| 165 | break; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 166 | case JS_WEAK_MAP_TYPE: |
| 167 | JSWeakMap::cast(this)->JSWeakMapPrint(out); |
| 168 | break; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 169 | case FOREIGN_TYPE: |
| 170 | Foreign::cast(this)->ForeignPrint(out); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 171 | break; |
| 172 | case SHARED_FUNCTION_INFO_TYPE: |
| 173 | SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out); |
| 174 | break; |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 175 | case JS_MESSAGE_OBJECT_TYPE: |
| 176 | JSMessageObject::cast(this)->JSMessageObjectPrint(out); |
| 177 | break; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 178 | case JS_GLOBAL_PROPERTY_CELL_TYPE: |
| 179 | JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellPrint(out); |
| 180 | break; |
| 181 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 182 | case NAME##_TYPE: \ |
| 183 | Name::cast(this)->Name##Print(out); \ |
| 184 | break; |
| 185 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 186 | #undef MAKE_STRUCT_CASE |
| 187 | |
| 188 | default: |
| 189 | PrintF(out, "UNKNOWN TYPE %d", map()->instance_type()); |
| 190 | UNREACHABLE(); |
| 191 | break; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | |
| 196 | void ByteArray::ByteArrayPrint(FILE* out) { |
| 197 | PrintF(out, "byte array, data starts at %p", GetDataStartAddress()); |
| 198 | } |
| 199 | |
| 200 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 201 | void FreeSpace::FreeSpacePrint(FILE* out) { |
| 202 | PrintF(out, "free space, size %d", Size()); |
| 203 | } |
| 204 | |
| 205 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 206 | void ExternalPixelArray::ExternalPixelArrayPrint(FILE* out) { |
| 207 | PrintF(out, "external pixel array"); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | |
| 211 | void ExternalByteArray::ExternalByteArrayPrint(FILE* out) { |
| 212 | PrintF(out, "external byte array"); |
| 213 | } |
| 214 | |
| 215 | |
| 216 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) { |
| 217 | PrintF(out, "external unsigned byte array"); |
| 218 | } |
| 219 | |
| 220 | |
| 221 | void ExternalShortArray::ExternalShortArrayPrint(FILE* out) { |
| 222 | PrintF(out, "external short array"); |
| 223 | } |
| 224 | |
| 225 | |
| 226 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) { |
| 227 | PrintF(out, "external unsigned short array"); |
| 228 | } |
| 229 | |
| 230 | |
| 231 | void ExternalIntArray::ExternalIntArrayPrint(FILE* out) { |
| 232 | PrintF(out, "external int array"); |
| 233 | } |
| 234 | |
| 235 | |
| 236 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) { |
| 237 | PrintF(out, "external unsigned int array"); |
| 238 | } |
| 239 | |
| 240 | |
| 241 | void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { |
| 242 | PrintF(out, "external float array"); |
| 243 | } |
| 244 | |
| 245 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 246 | void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) { |
| 247 | PrintF(out, "external double array"); |
| 248 | } |
| 249 | |
| 250 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 251 | void JSObject::PrintProperties(FILE* out) { |
| 252 | if (HasFastProperties()) { |
| 253 | DescriptorArray* descs = map()->instance_descriptors(); |
| 254 | for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 255 | PrintF(out, " "); |
| 256 | descs->GetKey(i)->StringPrint(out); |
| 257 | PrintF(out, ": "); |
| 258 | switch (descs->GetType(i)) { |
| 259 | case FIELD: { |
| 260 | int index = descs->GetFieldIndex(i); |
| 261 | FastPropertyAt(index)->ShortPrint(out); |
| 262 | PrintF(out, " (field at offset %d)\n", index); |
| 263 | break; |
| 264 | } |
| 265 | case CONSTANT_FUNCTION: |
| 266 | descs->GetConstantFunction(i)->ShortPrint(out); |
| 267 | PrintF(out, " (constant function)\n"); |
| 268 | break; |
| 269 | case CALLBACKS: |
| 270 | descs->GetCallbacksObject(i)->ShortPrint(out); |
| 271 | PrintF(out, " (callback)\n"); |
| 272 | break; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 273 | case ELEMENTS_TRANSITION: { |
| 274 | PrintF(out, "(elements transition to "); |
| 275 | Object* descriptor_contents = descs->GetValue(i); |
| 276 | if (descriptor_contents->IsMap()) { |
| 277 | Map* map = Map::cast(descriptor_contents); |
| 278 | PrintElementsKind(out, map->elements_kind()); |
| 279 | } else { |
| 280 | FixedArray* map_array = FixedArray::cast(descriptor_contents); |
| 281 | for (int i = 0; i < map_array->length(); ++i) { |
| 282 | Map* map = Map::cast(map_array->get(i)); |
| 283 | if (i != 0) { |
| 284 | PrintF(out, ", "); |
| 285 | } |
| 286 | PrintElementsKind(out, map->elements_kind()); |
| 287 | } |
| 288 | } |
| 289 | PrintF(out, ")\n"); |
| 290 | break; |
| 291 | } |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 292 | case MAP_TRANSITION: |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 293 | PrintF(out, "(map transition)\n"); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 294 | break; |
| 295 | case CONSTANT_TRANSITION: |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 296 | PrintF(out, "(constant transition)\n"); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 297 | break; |
| 298 | case NULL_DESCRIPTOR: |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 299 | PrintF(out, "(null descriptor)\n"); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 300 | break; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 301 | case NORMAL: // only in slow mode |
| 302 | case HANDLER: // only in lookup results, not in descriptors |
| 303 | case INTERCEPTOR: // only in lookup results, not in descriptors |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 304 | UNREACHABLE(); |
| 305 | break; |
| 306 | } |
| 307 | } |
| 308 | } else { |
| 309 | property_dictionary()->Print(out); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | void JSObject::PrintElements(FILE* out) { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 315 | // Don't call GetElementsKind, its validation code can cause the printer to |
| 316 | // fail when debugging. |
| 317 | switch (map()->elements_kind()) { |
| 318 | case FAST_SMI_ONLY_ELEMENTS: |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 319 | case FAST_ELEMENTS: { |
| 320 | // Print in array notation for non-sparse arrays. |
| 321 | FixedArray* p = FixedArray::cast(elements()); |
| 322 | for (int i = 0; i < p->length(); i++) { |
| 323 | PrintF(out, " %d: ", i); |
| 324 | p->get(i)->ShortPrint(out); |
| 325 | PrintF(out, "\n"); |
| 326 | } |
| 327 | break; |
| 328 | } |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 329 | case FAST_DOUBLE_ELEMENTS: { |
| 330 | // Print in array notation for non-sparse arrays. |
| 331 | FixedDoubleArray* p = FixedDoubleArray::cast(elements()); |
| 332 | for (int i = 0; i < p->length(); i++) { |
| 333 | if (p->is_the_hole(i)) { |
| 334 | PrintF(out, " %d: <the hole>", i); |
| 335 | } else { |
| 336 | PrintF(out, " %d: %g", i, p->get_scalar(i)); |
| 337 | } |
| 338 | PrintF(out, "\n"); |
| 339 | } |
| 340 | break; |
| 341 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 342 | case EXTERNAL_PIXEL_ELEMENTS: { |
| 343 | ExternalPixelArray* p = ExternalPixelArray::cast(elements()); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 344 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 345 | PrintF(out, " %d: %d\n", i, p->get_scalar(i)); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 346 | } |
| 347 | break; |
| 348 | } |
| 349 | case EXTERNAL_BYTE_ELEMENTS: { |
| 350 | ExternalByteArray* p = ExternalByteArray::cast(elements()); |
| 351 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 352 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 353 | } |
| 354 | break; |
| 355 | } |
| 356 | case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 357 | ExternalUnsignedByteArray* p = |
| 358 | ExternalUnsignedByteArray::cast(elements()); |
| 359 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 360 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 361 | } |
| 362 | break; |
| 363 | } |
| 364 | case EXTERNAL_SHORT_ELEMENTS: { |
| 365 | ExternalShortArray* p = ExternalShortArray::cast(elements()); |
| 366 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 367 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 368 | } |
| 369 | break; |
| 370 | } |
| 371 | case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { |
| 372 | ExternalUnsignedShortArray* p = |
| 373 | ExternalUnsignedShortArray::cast(elements()); |
| 374 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 375 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 376 | } |
| 377 | break; |
| 378 | } |
| 379 | case EXTERNAL_INT_ELEMENTS: { |
| 380 | ExternalIntArray* p = ExternalIntArray::cast(elements()); |
| 381 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 382 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 383 | } |
| 384 | break; |
| 385 | } |
| 386 | case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
| 387 | ExternalUnsignedIntArray* p = |
| 388 | ExternalUnsignedIntArray::cast(elements()); |
| 389 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 390 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get_scalar(i))); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 391 | } |
| 392 | break; |
| 393 | } |
| 394 | case EXTERNAL_FLOAT_ELEMENTS: { |
| 395 | ExternalFloatArray* p = ExternalFloatArray::cast(elements()); |
| 396 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 397 | PrintF(out, " %d: %f\n", i, p->get_scalar(i)); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 398 | } |
| 399 | break; |
| 400 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 401 | case EXTERNAL_DOUBLE_ELEMENTS: { |
| 402 | ExternalDoubleArray* p = ExternalDoubleArray::cast(elements()); |
| 403 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 404 | PrintF(out, " %d: %f\n", i, p->get_scalar(i)); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 405 | } |
| 406 | break; |
| 407 | } |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 408 | case DICTIONARY_ELEMENTS: |
| 409 | elements()->Print(out); |
| 410 | break; |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 411 | case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 412 | FixedArray* p = FixedArray::cast(elements()); |
| 413 | for (int i = 2; i < p->length(); i++) { |
| 414 | PrintF(out, " %d: ", i); |
| 415 | p->get(i)->ShortPrint(out); |
| 416 | PrintF(out, "\n"); |
| 417 | } |
| 418 | break; |
| 419 | } |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 420 | } |
| 421 | } |
| 422 | |
| 423 | |
| 424 | void JSObject::JSObjectPrint(FILE* out) { |
| 425 | PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 426 | PrintF(out, " - map = %p [", reinterpret_cast<void*>(map())); |
| 427 | // Don't call GetElementsKind, its validation code can cause the printer to |
| 428 | // fail when debugging. |
| 429 | PrintElementsKind(out, this->map()->elements_kind()); |
| 430 | PrintF(out, |
| 431 | "]\n - prototype = %p\n", |
| 432 | reinterpret_cast<void*>(GetPrototype())); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 433 | PrintF(out, " {\n"); |
| 434 | PrintProperties(out); |
| 435 | PrintElements(out); |
| 436 | PrintF(out, " }\n"); |
| 437 | } |
| 438 | |
| 439 | |
| 440 | static const char* TypeToString(InstanceType type) { |
| 441 | switch (type) { |
| 442 | case INVALID_TYPE: return "INVALID"; |
| 443 | case MAP_TYPE: return "MAP"; |
| 444 | case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; |
| 445 | case SYMBOL_TYPE: return "SYMBOL"; |
| 446 | case ASCII_SYMBOL_TYPE: return "ASCII_SYMBOL"; |
| 447 | case CONS_SYMBOL_TYPE: return "CONS_SYMBOL"; |
| 448 | case CONS_ASCII_SYMBOL_TYPE: return "CONS_ASCII_SYMBOL"; |
| 449 | case EXTERNAL_ASCII_SYMBOL_TYPE: |
| 450 | case EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE: |
| 451 | case EXTERNAL_SYMBOL_TYPE: return "EXTERNAL_SYMBOL"; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 452 | case SHORT_EXTERNAL_ASCII_SYMBOL_TYPE: |
| 453 | case SHORT_EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE: |
| 454 | case SHORT_EXTERNAL_SYMBOL_TYPE: return "SHORT_EXTERNAL_SYMBOL"; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 455 | case ASCII_STRING_TYPE: return "ASCII_STRING"; |
| 456 | case STRING_TYPE: return "TWO_BYTE_STRING"; |
| 457 | case CONS_STRING_TYPE: |
| 458 | case CONS_ASCII_STRING_TYPE: return "CONS_STRING"; |
| 459 | case EXTERNAL_ASCII_STRING_TYPE: |
| 460 | case EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: |
| 461 | case EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 462 | case SHORT_EXTERNAL_ASCII_STRING_TYPE: |
| 463 | case SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: |
| 464 | case SHORT_EXTERNAL_STRING_TYPE: return "SHORT_EXTERNAL_STRING"; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 465 | case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 466 | case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 467 | case FREE_SPACE_TYPE: return "FREE_SPACE"; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 468 | case EXTERNAL_PIXEL_ARRAY_TYPE: return "EXTERNAL_PIXEL_ARRAY"; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 469 | case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY"; |
| 470 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 471 | return "EXTERNAL_UNSIGNED_BYTE_ARRAY"; |
| 472 | case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY"; |
| 473 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 474 | return "EXTERNAL_UNSIGNED_SHORT_ARRAY"; |
| 475 | case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY"; |
| 476 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 477 | return "EXTERNAL_UNSIGNED_INT_ARRAY"; |
| 478 | case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY"; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 479 | case EXTERNAL_DOUBLE_ARRAY_TYPE: return "EXTERNAL_DOUBLE_ARRAY"; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 480 | case FILLER_TYPE: return "FILLER"; |
| 481 | case JS_OBJECT_TYPE: return "JS_OBJECT"; |
| 482 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
| 483 | case ODDBALL_TYPE: return "ODDBALL"; |
| 484 | case JS_GLOBAL_PROPERTY_CELL_TYPE: return "JS_GLOBAL_PROPERTY_CELL"; |
| 485 | case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 486 | case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 487 | case CODE_TYPE: return "CODE"; |
| 488 | case JS_ARRAY_TYPE: return "JS_ARRAY"; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 489 | case JS_PROXY_TYPE: return "JS_PROXY"; |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 490 | case JS_WEAK_MAP_TYPE: return "JS_WEAK_MAP"; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 491 | case JS_REGEXP_TYPE: return "JS_REGEXP"; |
| 492 | case JS_VALUE_TYPE: return "JS_VALUE"; |
| 493 | case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 494 | case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
| 495 | case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 496 | case FOREIGN_TYPE: return "FOREIGN"; |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 497 | case JS_MESSAGE_OBJECT_TYPE: return "JS_MESSAGE_OBJECT_TYPE"; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 498 | #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 499 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 500 | #undef MAKE_STRUCT_CASE |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 501 | default: return "UNKNOWN"; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 502 | } |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | |
| 506 | void Map::MapPrint(FILE* out) { |
| 507 | HeapObject::PrintHeader(out, "Map"); |
| 508 | PrintF(out, " - type: %s\n", TypeToString(instance_type())); |
| 509 | PrintF(out, " - instance size: %d\n", instance_size()); |
| 510 | PrintF(out, " - inobject properties: %d\n", inobject_properties()); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 511 | PrintF(out, " - elements kind: "); |
| 512 | PrintElementsKind(out, elements_kind()); |
| 513 | PrintF(out, "\n - pre-allocated property fields: %d\n", |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 514 | pre_allocated_property_fields()); |
| 515 | PrintF(out, " - unused property fields: %d\n", unused_property_fields()); |
| 516 | if (is_hidden_prototype()) { |
| 517 | PrintF(out, " - hidden_prototype\n"); |
| 518 | } |
| 519 | if (has_named_interceptor()) { |
| 520 | PrintF(out, " - named_interceptor\n"); |
| 521 | } |
| 522 | if (has_indexed_interceptor()) { |
| 523 | PrintF(out, " - indexed_interceptor\n"); |
| 524 | } |
| 525 | if (is_undetectable()) { |
| 526 | PrintF(out, " - undetectable\n"); |
| 527 | } |
| 528 | if (has_instance_call_handler()) { |
| 529 | PrintF(out, " - instance_call_handler\n"); |
| 530 | } |
| 531 | if (is_access_check_needed()) { |
| 532 | PrintF(out, " - access_check_needed\n"); |
| 533 | } |
| 534 | PrintF(out, " - instance descriptors: "); |
| 535 | instance_descriptors()->ShortPrint(out); |
| 536 | PrintF(out, "\n - prototype: "); |
| 537 | prototype()->ShortPrint(out); |
| 538 | PrintF(out, "\n - constructor: "); |
| 539 | constructor()->ShortPrint(out); |
| 540 | PrintF(out, "\n"); |
| 541 | } |
| 542 | |
| 543 | |
| 544 | void CodeCache::CodeCachePrint(FILE* out) { |
| 545 | HeapObject::PrintHeader(out, "CodeCache"); |
| 546 | PrintF(out, "\n - default_cache: "); |
| 547 | default_cache()->ShortPrint(out); |
| 548 | PrintF(out, "\n - normal_type_cache: "); |
| 549 | normal_type_cache()->ShortPrint(out); |
| 550 | } |
| 551 | |
| 552 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 553 | void PolymorphicCodeCache::PolymorphicCodeCachePrint(FILE* out) { |
| 554 | HeapObject::PrintHeader(out, "PolymorphicCodeCache"); |
| 555 | PrintF(out, "\n - cache: "); |
| 556 | cache()->ShortPrint(out); |
| 557 | } |
| 558 | |
| 559 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 560 | void TypeFeedbackInfo::TypeFeedbackInfoPrint(FILE* out) { |
| 561 | HeapObject::PrintHeader(out, "TypeFeedbackInfo"); |
| 562 | PrintF(out, "\n - ic_total_count: %d, ic_with_typeinfo_count: %d", |
| 563 | ic_total_count(), ic_with_typeinfo_count()); |
| 564 | PrintF(out, "\n - type_feedback_cells: "); |
| 565 | type_feedback_cells()->FixedArrayPrint(out); |
| 566 | } |
| 567 | |
| 568 | |
| 569 | void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(FILE* out) { |
| 570 | HeapObject::PrintHeader(out, "AliasedArgumentsEntry"); |
| 571 | PrintF(out, "\n - aliased_context_slot: %d", aliased_context_slot()); |
| 572 | } |
| 573 | |
| 574 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 575 | void FixedArray::FixedArrayPrint(FILE* out) { |
| 576 | HeapObject::PrintHeader(out, "FixedArray"); |
| 577 | PrintF(out, " - length: %d", length()); |
| 578 | for (int i = 0; i < length(); i++) { |
| 579 | PrintF(out, "\n [%d]: ", i); |
| 580 | get(i)->ShortPrint(out); |
| 581 | } |
| 582 | PrintF(out, "\n"); |
| 583 | } |
| 584 | |
| 585 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 586 | void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) { |
| 587 | HeapObject::PrintHeader(out, "FixedDoubleArray"); |
| 588 | PrintF(out, " - length: %d", length()); |
| 589 | for (int i = 0; i < length(); i++) { |
| 590 | if (is_the_hole(i)) { |
| 591 | PrintF(out, "\n [%d]: <the hole>", i); |
| 592 | } else { |
| 593 | PrintF(out, "\n [%d]: %g", i, get_scalar(i)); |
| 594 | } |
| 595 | } |
| 596 | PrintF(out, "\n"); |
| 597 | } |
| 598 | |
| 599 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 600 | void JSValue::JSValuePrint(FILE* out) { |
| 601 | HeapObject::PrintHeader(out, "ValueObject"); |
| 602 | value()->Print(out); |
| 603 | } |
| 604 | |
| 605 | |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 606 | void JSMessageObject::JSMessageObjectPrint(FILE* out) { |
| 607 | HeapObject::PrintHeader(out, "JSMessageObject"); |
| 608 | PrintF(out, " - type: "); |
| 609 | type()->ShortPrint(out); |
| 610 | PrintF(out, "\n - arguments: "); |
| 611 | arguments()->ShortPrint(out); |
| 612 | PrintF(out, "\n - start_position: %d", start_position()); |
| 613 | PrintF(out, "\n - end_position: %d", end_position()); |
| 614 | PrintF(out, "\n - script: "); |
| 615 | script()->ShortPrint(out); |
| 616 | PrintF(out, "\n - stack_trace: "); |
| 617 | stack_trace()->ShortPrint(out); |
| 618 | PrintF(out, "\n - stack_frames: "); |
| 619 | stack_frames()->ShortPrint(out); |
| 620 | PrintF(out, "\n"); |
| 621 | } |
| 622 | |
| 623 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 624 | void String::StringPrint(FILE* out) { |
| 625 | if (StringShape(this).IsSymbol()) { |
| 626 | PrintF(out, "#"); |
| 627 | } else if (StringShape(this).IsCons()) { |
| 628 | PrintF(out, "c\""); |
| 629 | } else { |
| 630 | PrintF(out, "\""); |
| 631 | } |
| 632 | |
| 633 | const char truncated_epilogue[] = "...<truncated>"; |
| 634 | int len = length(); |
| 635 | if (!FLAG_use_verbose_printer) { |
| 636 | if (len > 100) { |
| 637 | len = 100 - sizeof(truncated_epilogue); |
| 638 | } |
| 639 | } |
| 640 | for (int i = 0; i < len; i++) { |
| 641 | PrintF(out, "%c", Get(i)); |
| 642 | } |
| 643 | if (len != length()) { |
| 644 | PrintF(out, "%s", truncated_epilogue); |
| 645 | } |
| 646 | |
| 647 | if (!StringShape(this).IsSymbol()) PrintF(out, "\""); |
| 648 | } |
| 649 | |
| 650 | |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 651 | // This method is only meant to be called from gdb for debugging purposes. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 652 | // Since the string can also be in two-byte encoding, non-ASCII characters |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 653 | // will be ignored in the output. |
| 654 | char* String::ToAsciiArray() { |
| 655 | // Static so that subsequent calls frees previously allocated space. |
| 656 | // This also means that previous results will be overwritten. |
| 657 | static char* buffer = NULL; |
| 658 | if (buffer != NULL) free(buffer); |
| 659 | buffer = new char[length()+1]; |
| 660 | WriteToFlat(this, buffer, 0, length()); |
| 661 | buffer[length()] = 0; |
| 662 | return buffer; |
| 663 | } |
| 664 | |
| 665 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 666 | static const char* const weekdays[] = { |
| 667 | "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" |
| 668 | }; |
| 669 | |
| 670 | void JSDate::JSDatePrint(FILE* out) { |
| 671 | HeapObject::PrintHeader(out, "JSDate"); |
| 672 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 673 | PrintF(out, " - value = "); |
| 674 | value()->Print(out); |
| 675 | if (!year()->IsSmi()) { |
| 676 | PrintF(out, " - time = NaN\n"); |
| 677 | } else { |
| 678 | PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n", |
| 679 | weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0], |
| 680 | year()->IsSmi() ? Smi::cast(year())->value() : -1, |
| 681 | month()->IsSmi() ? Smi::cast(month())->value() : -1, |
| 682 | day()->IsSmi() ? Smi::cast(day())->value() : -1, |
| 683 | hour()->IsSmi() ? Smi::cast(hour())->value() : -1, |
| 684 | min()->IsSmi() ? Smi::cast(min())->value() : -1, |
| 685 | sec()->IsSmi() ? Smi::cast(sec())->value() : -1); |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 690 | void JSProxy::JSProxyPrint(FILE* out) { |
| 691 | HeapObject::PrintHeader(out, "JSProxy"); |
| 692 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 693 | PrintF(out, " - handler = "); |
| 694 | handler()->Print(out); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 695 | PrintF(out, " - hash = "); |
| 696 | hash()->Print(out); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 697 | PrintF(out, "\n"); |
| 698 | } |
| 699 | |
| 700 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 701 | void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) { |
| 702 | HeapObject::PrintHeader(out, "JSFunctionProxy"); |
| 703 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 704 | PrintF(out, " - handler = "); |
| 705 | handler()->Print(out); |
| 706 | PrintF(out, " - call_trap = "); |
| 707 | call_trap()->Print(out); |
| 708 | PrintF(out, " - construct_trap = "); |
| 709 | construct_trap()->Print(out); |
| 710 | PrintF(out, "\n"); |
| 711 | } |
| 712 | |
| 713 | |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 714 | void JSWeakMap::JSWeakMapPrint(FILE* out) { |
| 715 | HeapObject::PrintHeader(out, "JSWeakMap"); |
| 716 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 717 | PrintF(out, " - table = "); |
| 718 | table()->ShortPrint(out); |
| 719 | PrintF(out, "\n"); |
| 720 | } |
| 721 | |
| 722 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 723 | void JSFunction::JSFunctionPrint(FILE* out) { |
| 724 | HeapObject::PrintHeader(out, "Function"); |
| 725 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 726 | PrintF(out, " - initial_map = "); |
| 727 | if (has_initial_map()) { |
| 728 | initial_map()->ShortPrint(out); |
| 729 | } |
| 730 | PrintF(out, "\n - shared_info = "); |
| 731 | shared()->ShortPrint(out); |
| 732 | PrintF(out, "\n - name = "); |
| 733 | shared()->name()->Print(out); |
| 734 | PrintF(out, "\n - context = "); |
| 735 | unchecked_context()->ShortPrint(out); |
| 736 | PrintF(out, "\n - code = "); |
| 737 | code()->ShortPrint(out); |
| 738 | PrintF(out, "\n"); |
| 739 | |
| 740 | PrintProperties(out); |
| 741 | PrintElements(out); |
| 742 | |
| 743 | PrintF(out, "\n"); |
| 744 | } |
| 745 | |
| 746 | |
| 747 | void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) { |
| 748 | HeapObject::PrintHeader(out, "SharedFunctionInfo"); |
| 749 | PrintF(out, " - name: "); |
| 750 | name()->ShortPrint(out); |
| 751 | PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties()); |
| 752 | PrintF(out, "\n - instance class name = "); |
| 753 | instance_class_name()->Print(out); |
| 754 | PrintF(out, "\n - code = "); |
| 755 | code()->ShortPrint(out); |
| 756 | PrintF(out, "\n - source code = "); |
| 757 | GetSourceCode()->ShortPrint(out); |
| 758 | // Script files are often large, hard to read. |
| 759 | // PrintF(out, "\n - script ="); |
| 760 | // script()->Print(out); |
| 761 | PrintF(out, "\n - function token position = %d", function_token_position()); |
| 762 | PrintF(out, "\n - start position = %d", start_position()); |
| 763 | PrintF(out, "\n - end position = %d", end_position()); |
| 764 | PrintF(out, "\n - is expression = %d", is_expression()); |
| 765 | PrintF(out, "\n - debug info = "); |
| 766 | debug_info()->ShortPrint(out); |
| 767 | PrintF(out, "\n - length = %d", length()); |
| 768 | PrintF(out, "\n - has_only_simple_this_property_assignments = %d", |
| 769 | has_only_simple_this_property_assignments()); |
| 770 | PrintF(out, "\n - this_property_assignments = "); |
| 771 | this_property_assignments()->ShortPrint(out); |
| 772 | PrintF(out, "\n"); |
| 773 | } |
| 774 | |
| 775 | |
| 776 | void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) { |
| 777 | PrintF(out, "global_proxy"); |
| 778 | JSObjectPrint(out); |
| 779 | PrintF(out, "context : "); |
| 780 | context()->ShortPrint(out); |
| 781 | PrintF(out, "\n"); |
| 782 | } |
| 783 | |
| 784 | |
| 785 | void JSGlobalObject::JSGlobalObjectPrint(FILE* out) { |
| 786 | PrintF(out, "global "); |
| 787 | JSObjectPrint(out); |
| 788 | PrintF(out, "global context : "); |
| 789 | global_context()->ShortPrint(out); |
| 790 | PrintF(out, "\n"); |
| 791 | } |
| 792 | |
| 793 | |
| 794 | void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) { |
| 795 | PrintF(out, "builtins "); |
| 796 | JSObjectPrint(out); |
| 797 | } |
| 798 | |
| 799 | |
| 800 | void JSGlobalPropertyCell::JSGlobalPropertyCellPrint(FILE* out) { |
| 801 | HeapObject::PrintHeader(out, "JSGlobalPropertyCell"); |
| 802 | } |
| 803 | |
| 804 | |
| 805 | void Code::CodePrint(FILE* out) { |
| 806 | HeapObject::PrintHeader(out, "Code"); |
| 807 | #ifdef ENABLE_DISASSEMBLER |
| 808 | if (FLAG_use_verbose_printer) { |
| 809 | Disassemble(NULL, out); |
| 810 | } |
| 811 | #endif |
| 812 | } |
| 813 | |
| 814 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 815 | void Foreign::ForeignPrint(FILE* out) { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 816 | PrintF(out, "foreign address : %p", foreign_address()); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | |
| 820 | void AccessorInfo::AccessorInfoPrint(FILE* out) { |
| 821 | HeapObject::PrintHeader(out, "AccessorInfo"); |
| 822 | PrintF(out, "\n - getter: "); |
| 823 | getter()->ShortPrint(out); |
| 824 | PrintF(out, "\n - setter: "); |
| 825 | setter()->ShortPrint(out); |
| 826 | PrintF(out, "\n - name: "); |
| 827 | name()->ShortPrint(out); |
| 828 | PrintF(out, "\n - data: "); |
| 829 | data()->ShortPrint(out); |
| 830 | PrintF(out, "\n - flag: "); |
| 831 | flag()->ShortPrint(out); |
| 832 | } |
| 833 | |
| 834 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 835 | void AccessorPair::AccessorPairPrint(FILE* out) { |
| 836 | HeapObject::PrintHeader(out, "AccessorPair"); |
| 837 | PrintF(out, "\n - getter: "); |
| 838 | getter()->ShortPrint(out); |
| 839 | PrintF(out, "\n - setter: "); |
| 840 | setter()->ShortPrint(out); |
| 841 | } |
| 842 | |
| 843 | |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 844 | void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) { |
| 845 | HeapObject::PrintHeader(out, "AccessCheckInfo"); |
| 846 | PrintF(out, "\n - named_callback: "); |
| 847 | named_callback()->ShortPrint(out); |
| 848 | PrintF(out, "\n - indexed_callback: "); |
| 849 | indexed_callback()->ShortPrint(out); |
| 850 | PrintF(out, "\n - data: "); |
| 851 | data()->ShortPrint(out); |
| 852 | } |
| 853 | |
| 854 | |
| 855 | void InterceptorInfo::InterceptorInfoPrint(FILE* out) { |
| 856 | HeapObject::PrintHeader(out, "InterceptorInfo"); |
| 857 | PrintF(out, "\n - getter: "); |
| 858 | getter()->ShortPrint(out); |
| 859 | PrintF(out, "\n - setter: "); |
| 860 | setter()->ShortPrint(out); |
| 861 | PrintF(out, "\n - query: "); |
| 862 | query()->ShortPrint(out); |
| 863 | PrintF(out, "\n - deleter: "); |
| 864 | deleter()->ShortPrint(out); |
| 865 | PrintF(out, "\n - enumerator: "); |
| 866 | enumerator()->ShortPrint(out); |
| 867 | PrintF(out, "\n - data: "); |
| 868 | data()->ShortPrint(out); |
| 869 | } |
| 870 | |
| 871 | |
| 872 | void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) { |
| 873 | HeapObject::PrintHeader(out, "CallHandlerInfo"); |
| 874 | PrintF(out, "\n - callback: "); |
| 875 | callback()->ShortPrint(out); |
| 876 | PrintF(out, "\n - data: "); |
| 877 | data()->ShortPrint(out); |
| 878 | PrintF(out, "\n - call_stub_cache: "); |
| 879 | } |
| 880 | |
| 881 | |
| 882 | void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) { |
| 883 | HeapObject::PrintHeader(out, "FunctionTemplateInfo"); |
| 884 | PrintF(out, "\n - class name: "); |
| 885 | class_name()->ShortPrint(out); |
| 886 | PrintF(out, "\n - tag: "); |
| 887 | tag()->ShortPrint(out); |
| 888 | PrintF(out, "\n - property_list: "); |
| 889 | property_list()->ShortPrint(out); |
| 890 | PrintF(out, "\n - serial_number: "); |
| 891 | serial_number()->ShortPrint(out); |
| 892 | PrintF(out, "\n - call_code: "); |
| 893 | call_code()->ShortPrint(out); |
| 894 | PrintF(out, "\n - property_accessors: "); |
| 895 | property_accessors()->ShortPrint(out); |
| 896 | PrintF(out, "\n - prototype_template: "); |
| 897 | prototype_template()->ShortPrint(out); |
| 898 | PrintF(out, "\n - parent_template: "); |
| 899 | parent_template()->ShortPrint(out); |
| 900 | PrintF(out, "\n - named_property_handler: "); |
| 901 | named_property_handler()->ShortPrint(out); |
| 902 | PrintF(out, "\n - indexed_property_handler: "); |
| 903 | indexed_property_handler()->ShortPrint(out); |
| 904 | PrintF(out, "\n - instance_template: "); |
| 905 | instance_template()->ShortPrint(out); |
| 906 | PrintF(out, "\n - signature: "); |
| 907 | signature()->ShortPrint(out); |
| 908 | PrintF(out, "\n - access_check_info: "); |
| 909 | access_check_info()->ShortPrint(out); |
| 910 | PrintF(out, "\n - hidden_prototype: %s", |
| 911 | hidden_prototype() ? "true" : "false"); |
| 912 | PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 913 | PrintF(out, "\n - need_access_check: %s", |
| 914 | needs_access_check() ? "true" : "false"); |
| 915 | } |
| 916 | |
| 917 | |
| 918 | void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) { |
| 919 | HeapObject::PrintHeader(out, "ObjectTemplateInfo"); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 920 | PrintF(out, " - tag: "); |
| 921 | tag()->ShortPrint(out); |
| 922 | PrintF(out, "\n - property_list: "); |
| 923 | property_list()->ShortPrint(out); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 924 | PrintF(out, "\n - constructor: "); |
| 925 | constructor()->ShortPrint(out); |
| 926 | PrintF(out, "\n - internal_field_count: "); |
| 927 | internal_field_count()->ShortPrint(out); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 928 | PrintF(out, "\n"); |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | |
| 932 | void SignatureInfo::SignatureInfoPrint(FILE* out) { |
| 933 | HeapObject::PrintHeader(out, "SignatureInfo"); |
| 934 | PrintF(out, "\n - receiver: "); |
| 935 | receiver()->ShortPrint(out); |
| 936 | PrintF(out, "\n - args: "); |
| 937 | args()->ShortPrint(out); |
| 938 | } |
| 939 | |
| 940 | |
| 941 | void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { |
| 942 | HeapObject::PrintHeader(out, "TypeSwitchInfo"); |
| 943 | PrintF(out, "\n - types: "); |
| 944 | types()->ShortPrint(out); |
| 945 | } |
| 946 | |
| 947 | |
| 948 | void Script::ScriptPrint(FILE* out) { |
| 949 | HeapObject::PrintHeader(out, "Script"); |
| 950 | PrintF(out, "\n - source: "); |
| 951 | source()->ShortPrint(out); |
| 952 | PrintF(out, "\n - name: "); |
| 953 | name()->ShortPrint(out); |
| 954 | PrintF(out, "\n - line_offset: "); |
| 955 | line_offset()->ShortPrint(out); |
| 956 | PrintF(out, "\n - column_offset: "); |
| 957 | column_offset()->ShortPrint(out); |
| 958 | PrintF(out, "\n - type: "); |
| 959 | type()->ShortPrint(out); |
| 960 | PrintF(out, "\n - id: "); |
| 961 | id()->ShortPrint(out); |
| 962 | PrintF(out, "\n - data: "); |
| 963 | data()->ShortPrint(out); |
| 964 | PrintF(out, "\n - context data: "); |
| 965 | context_data()->ShortPrint(out); |
| 966 | PrintF(out, "\n - wrapper: "); |
| 967 | wrapper()->ShortPrint(out); |
| 968 | PrintF(out, "\n - compilation type: "); |
| 969 | compilation_type()->ShortPrint(out); |
| 970 | PrintF(out, "\n - line ends: "); |
| 971 | line_ends()->ShortPrint(out); |
| 972 | PrintF(out, "\n - eval from shared: "); |
| 973 | eval_from_shared()->ShortPrint(out); |
| 974 | PrintF(out, "\n - eval from instructions offset: "); |
| 975 | eval_from_instructions_offset()->ShortPrint(out); |
| 976 | PrintF(out, "\n"); |
| 977 | } |
| 978 | |
| 979 | |
| 980 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 981 | void DebugInfo::DebugInfoPrint(FILE* out) { |
| 982 | HeapObject::PrintHeader(out, "DebugInfo"); |
| 983 | PrintF(out, "\n - shared: "); |
| 984 | shared()->ShortPrint(out); |
| 985 | PrintF(out, "\n - original_code: "); |
| 986 | original_code()->ShortPrint(out); |
| 987 | PrintF(out, "\n - code: "); |
| 988 | code()->ShortPrint(out); |
| 989 | PrintF(out, "\n - break_points: "); |
| 990 | break_points()->Print(out); |
| 991 | } |
| 992 | |
| 993 | |
| 994 | void BreakPointInfo::BreakPointInfoPrint(FILE* out) { |
| 995 | HeapObject::PrintHeader(out, "BreakPointInfo"); |
| 996 | PrintF(out, "\n - code_position: %d", code_position()->value()); |
| 997 | PrintF(out, "\n - source_position: %d", source_position()->value()); |
| 998 | PrintF(out, "\n - statement_position: %d", statement_position()->value()); |
| 999 | PrintF(out, "\n - break_point_objects: "); |
| 1000 | break_point_objects()->ShortPrint(out); |
| 1001 | } |
| 1002 | #endif // ENABLE_DEBUGGER_SUPPORT |
| 1003 | |
| 1004 | |
| 1005 | void DescriptorArray::PrintDescriptors(FILE* out) { |
| 1006 | PrintF(out, "Descriptor array %d\n", number_of_descriptors()); |
| 1007 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 1008 | PrintF(out, " %d: ", i); |
| 1009 | Descriptor desc; |
| 1010 | Get(i, &desc); |
| 1011 | desc.Print(out); |
| 1012 | } |
| 1013 | PrintF(out, "\n"); |
| 1014 | } |
| 1015 | |
| 1016 | |
| 1017 | #endif // OBJECT_PRINT |
| 1018 | |
| 1019 | |
| 1020 | } } // namespace v8::internal |