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