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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/disasm.h" | 10 #include "src/disasm.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 void Object::Print() { | 22 void Object::Print() { |
23 OFStream os(stdout); | 23 OFStream os(stdout); |
24 this->Print(os); | 24 this->Print(os); |
25 os << std::flush; | 25 os << std::flush; |
26 } | 26 } |
27 | 27 |
28 | 28 |
29 void Object::Print(std::ostream& os) { // NOLINT | 29 void Object::Print(std::ostream& os) { // NOLINT |
30 if (IsSmi()) { | 30 if (IsSmi()) { |
31 Smi::cast(this)->SmiPrint(os); | 31 os << "Smi: " << std::hex << "0x" << Smi::cast(this)->value(); |
| 32 os << std::dec << " (" << Smi::cast(this)->value() << ")\n"; |
32 } else { | 33 } else { |
33 HeapObject::cast(this)->HeapObjectPrint(os); | 34 HeapObject::cast(this)->HeapObjectPrint(os); |
34 } | 35 } |
35 } | 36 } |
36 | 37 |
37 | 38 |
38 void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT | 39 void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT |
39 os << reinterpret_cast<void*>(this) << ": ["; | 40 os << reinterpret_cast<void*>(this) << ": ["; |
40 if (id != nullptr) { | 41 if (id != nullptr) { |
41 os << id; | 42 os << id; |
42 } else { | 43 } else { |
43 os << map()->instance_type(); | 44 os << map()->instance_type(); |
44 } | 45 } |
45 os << "]"; | 46 os << "]"; |
46 } | 47 } |
47 | 48 |
48 | 49 |
49 void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT | 50 void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT |
50 InstanceType instance_type = map()->instance_type(); | 51 InstanceType instance_type = map()->instance_type(); |
51 | 52 |
52 HandleScope scope(GetIsolate()); | 53 HandleScope scope(GetIsolate()); |
53 if (instance_type < FIRST_NONSTRING_TYPE) { | 54 if (instance_type < FIRST_NONSTRING_TYPE) { |
54 String::cast(this)->StringPrint(os); | 55 String::cast(this)->StringPrint(os); |
| 56 os << "\n"; |
55 return; | 57 return; |
56 } | 58 } |
57 | 59 |
58 switch (instance_type) { | 60 switch (instance_type) { |
59 case SYMBOL_TYPE: | 61 case SYMBOL_TYPE: |
60 Symbol::cast(this)->SymbolPrint(os); | 62 Symbol::cast(this)->SymbolPrint(os); |
61 break; | 63 break; |
62 case MAP_TYPE: | 64 case MAP_TYPE: |
63 Map::cast(this)->MapPrint(os); | 65 Map::cast(this)->MapPrint(os); |
64 break; | 66 break; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 previous_value = value; | 403 previous_value = value; |
402 } | 404 } |
403 break; | 405 break; |
404 } | 406 } |
405 case FAST_HOLEY_DOUBLE_ELEMENTS: | 407 case FAST_HOLEY_DOUBLE_ELEMENTS: |
406 case FAST_DOUBLE_ELEMENTS: { | 408 case FAST_DOUBLE_ELEMENTS: { |
407 DoPrintElements<FixedDoubleArray, true>(os, elements()); | 409 DoPrintElements<FixedDoubleArray, true>(os, elements()); |
408 break; | 410 break; |
409 } | 411 } |
410 | 412 |
411 #define PRINT_ELEMENTS(Kind, Type) \ | 413 #define PRINT_ELEMENTS(Type, type, TYPE, elementType, size) \ |
412 case Kind: { \ | 414 case TYPE##_ELEMENTS: { \ |
413 DoPrintElements<Type, false>(os, elements()); \ | 415 DoPrintElements<Fixed##Type##Array, false>(os, elements()); \ |
414 break; \ | 416 break; \ |
415 } | 417 } |
416 | 418 TYPED_ARRAYS(PRINT_ELEMENTS) |
417 PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array) | |
418 PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray) | |
419 PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array) | |
420 PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array) | |
421 PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array) | |
422 PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array) | |
423 PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array) | |
424 PRINT_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array) | |
425 PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array) | |
426 | |
427 #undef PRINT_ELEMENTS | 419 #undef PRINT_ELEMENTS |
428 | 420 |
429 case DICTIONARY_ELEMENTS: | 421 case DICTIONARY_ELEMENTS: |
430 case SLOW_STRING_WRAPPER_ELEMENTS: | 422 case SLOW_STRING_WRAPPER_ELEMENTS: |
431 SeededNumberDictionary::cast(elements())->Print(os); | 423 SeededNumberDictionary::cast(elements())->Print(os); |
432 break; | 424 break; |
433 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 425 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
434 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { | 426 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { |
435 FixedArray* p = FixedArray::cast(elements()); | 427 FixedArray* p = FixedArray::cast(elements()); |
436 os << "\n parameter map:"; | 428 os << "\n parameter map:"; |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 JSObjectPrintHeader(os, this, "JSWeakSet"); | 924 JSObjectPrintHeader(os, this, "JSWeakSet"); |
933 os << "\n - table = " << Brief(table()); | 925 os << "\n - table = " << Brief(table()); |
934 JSObjectPrintBody(os, this); | 926 JSObjectPrintBody(os, this); |
935 } | 927 } |
936 | 928 |
937 | 929 |
938 void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { // NOLINT | 930 void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { // NOLINT |
939 JSObjectPrintHeader(os, this, "JSArrayBuffer"); | 931 JSObjectPrintHeader(os, this, "JSArrayBuffer"); |
940 os << "\n - backing_store = " << backing_store(); | 932 os << "\n - backing_store = " << backing_store(); |
941 os << "\n - byte_length = " << Brief(byte_length()); | 933 os << "\n - byte_length = " << Brief(byte_length()); |
942 if (was_neutered()) os << " - neutered\n"; | 934 if (was_neutered()) os << "\n - neutered"; |
943 JSObjectPrintBody(os, this, !was_neutered()); | 935 JSObjectPrintBody(os, this, !was_neutered()); |
944 } | 936 } |
945 | 937 |
946 | 938 |
947 void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { // NOLINT | 939 void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { // NOLINT |
948 JSObjectPrintHeader(os, this, "JSTypedArray"); | 940 JSObjectPrintHeader(os, this, "JSTypedArray"); |
949 os << "\n - buffer = " << Brief(buffer()); | 941 os << "\n - buffer = " << Brief(buffer()); |
950 os << "\n - byte_offset = " << Brief(byte_offset()); | 942 os << "\n - byte_offset = " << Brief(byte_offset()); |
951 os << "\n - byte_length = " << Brief(byte_length()); | 943 os << "\n - byte_length = " << Brief(byte_length()); |
952 os << "\n - length = " << Brief(length()); | 944 os << "\n - length = " << Brief(length()); |
953 if (WasNeutered()) os << " - neutered\n"; | 945 if (WasNeutered()) os << "\n - neutered"; |
954 JSObjectPrintBody(os, this, !WasNeutered()); | 946 JSObjectPrintBody(os, this, !WasNeutered()); |
955 } | 947 } |
956 | 948 |
957 | 949 |
958 void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT | 950 void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT |
959 JSObjectPrintHeader(os, this, "JSDataView"); | 951 JSObjectPrintHeader(os, this, "JSDataView"); |
960 os << "\n - buffer =" << Brief(buffer()); | 952 os << "\n - buffer =" << Brief(buffer()); |
961 os << "\n - byte_offset = " << Brief(byte_offset()); | 953 os << "\n - byte_offset = " << Brief(byte_offset()); |
962 os << "\n - byte_length = " << Brief(byte_length()); | 954 os << "\n - byte_length = " << Brief(byte_length()); |
963 if (WasNeutered()) os << " - neutered\n"; | 955 if (WasNeutered()) os << "\n - neutered"; |
964 JSObjectPrintBody(os, this, !WasNeutered()); | 956 JSObjectPrintBody(os, this, !WasNeutered()); |
965 } | 957 } |
966 | 958 |
967 | 959 |
968 void JSBoundFunction::JSBoundFunctionPrint(std::ostream& os) { // NOLINT | 960 void JSBoundFunction::JSBoundFunctionPrint(std::ostream& os) { // NOLINT |
969 JSObjectPrintHeader(os, this, "JSBoundFunction"); | 961 JSObjectPrintHeader(os, this, "JSBoundFunction"); |
970 os << "\n - bound_target_function = " << Brief(bound_target_function()); | 962 os << "\n - bound_target_function = " << Brief(bound_target_function()); |
971 os << "\n - bound_this = " << Brief(bound_this()); | 963 os << "\n - bound_this = " << Brief(bound_this()); |
972 os << "\n - bound_arguments = " << Brief(bound_arguments()); | 964 os << "\n - bound_arguments = " << Brief(bound_arguments()); |
973 JSObjectPrintBody(os, this); | 965 JSObjectPrintBody(os, this); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 printf("Not a transition array\n"); | 1538 printf("Not a transition array\n"); |
1547 } else { | 1539 } else { |
1548 reinterpret_cast<i::TransitionArray*>(object)->Print(); | 1540 reinterpret_cast<i::TransitionArray*>(object)->Print(); |
1549 } | 1541 } |
1550 } | 1542 } |
1551 | 1543 |
1552 extern void _v8_internal_Print_StackTrace() { | 1544 extern void _v8_internal_Print_StackTrace() { |
1553 i::Isolate* isolate = i::Isolate::Current(); | 1545 i::Isolate* isolate = i::Isolate::Current(); |
1554 isolate->PrintStack(stdout); | 1546 isolate->PrintStack(stdout); |
1555 } | 1547 } |
OLD | NEW |