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