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