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