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