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