| 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 "src/disasm.h" | 7 #include "src/disasm.h" |
| 8 #include "src/disassembler.h" | 8 #include "src/disassembler.h" |
| 9 #include "src/interpreter/bytecodes.h" | 9 #include "src/interpreter/bytecodes.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 void Object::Print(std::ostream& os) { // NOLINT | 26 void Object::Print(std::ostream& os) { // NOLINT |
| 27 if (IsSmi()) { | 27 if (IsSmi()) { |
| 28 Smi::cast(this)->SmiPrint(os); | 28 Smi::cast(this)->SmiPrint(os); |
| 29 } else { | 29 } else { |
| 30 HeapObject::cast(this)->HeapObjectPrint(os); | 30 HeapObject::cast(this)->HeapObjectPrint(os); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 | 34 |
| 35 void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT | 35 void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT |
| 36 os << reinterpret_cast<void*>(this) << ": [" << id << "]\n"; | 36 os << "" << reinterpret_cast<void*>(this) << ": [" << id << "]\n"; |
| 37 } | 37 } |
| 38 | 38 |
| 39 | 39 |
| 40 void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT | 40 void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT |
| 41 InstanceType instance_type = map()->instance_type(); | 41 InstanceType instance_type = map()->instance_type(); |
| 42 | 42 |
| 43 HandleScope scope(GetIsolate()); | 43 HandleScope scope(GetIsolate()); |
| 44 if (instance_type < FIRST_NONSTRING_TYPE) { | 44 if (instance_type < FIRST_NONSTRING_TYPE) { |
| 45 String::cast(this)->StringPrint(os); | 45 String::cast(this)->StringPrint(os); |
| 46 return; | 46 return; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 case JS_GLOBAL_PROXY_TYPE: | 110 case JS_GLOBAL_PROXY_TYPE: |
| 111 JSGlobalProxy::cast(this)->JSGlobalProxyPrint(os); | 111 JSGlobalProxy::cast(this)->JSGlobalProxyPrint(os); |
| 112 break; | 112 break; |
| 113 case JS_GLOBAL_OBJECT_TYPE: | 113 case JS_GLOBAL_OBJECT_TYPE: |
| 114 JSGlobalObject::cast(this)->JSGlobalObjectPrint(os); | 114 JSGlobalObject::cast(this)->JSGlobalObjectPrint(os); |
| 115 break; | 115 break; |
| 116 case JS_BUILTINS_OBJECT_TYPE: | 116 case JS_BUILTINS_OBJECT_TYPE: |
| 117 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(os); | 117 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(os); |
| 118 break; | 118 break; |
| 119 case JS_VALUE_TYPE: | 119 case JS_VALUE_TYPE: |
| 120 JSValue::cast(this)->JSValuePrint(os); | 120 os << "Value wrapper around:"; |
| 121 JSValue::cast(this)->value()->Print(os); |
| 121 break; | 122 break; |
| 122 case JS_DATE_TYPE: | 123 case JS_DATE_TYPE: |
| 123 JSDate::cast(this)->JSDatePrint(os); | 124 JSDate::cast(this)->JSDatePrint(os); |
| 124 break; | 125 break; |
| 125 case CODE_TYPE: | 126 case CODE_TYPE: |
| 126 Code::cast(this)->CodePrint(os); | 127 Code::cast(this)->CodePrint(os); |
| 127 break; | 128 break; |
| 128 case JS_PROXY_TYPE: | 129 case JS_PROXY_TYPE: |
| 129 JSProxy::cast(this)->JSProxyPrint(os); | 130 JSProxy::cast(this)->JSProxyPrint(os); |
| 130 break; | 131 break; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 os << " " << (i - 2) << ":" << Brief(p->get(i)); | 381 os << " " << (i - 2) << ":" << Brief(p->get(i)); |
| 381 } | 382 } |
| 382 os << "\n context: " << Brief(p->get(0)) | 383 os << "\n context: " << Brief(p->get(0)) |
| 383 << "\n arguments: " << Brief(p->get(1)) << "\n"; | 384 << "\n arguments: " << Brief(p->get(1)) << "\n"; |
| 384 break; | 385 break; |
| 385 } | 386 } |
| 386 } | 387 } |
| 387 } | 388 } |
| 388 | 389 |
| 389 | 390 |
| 390 static void JSObjectPrintHeader(std::ostream& os, JSObject* obj, | 391 void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT |
| 391 const char* id) { // NOLINT | 392 HeapObject::PrintHeader(os, "JSObject"); |
| 392 obj->PrintHeader(os, id); | |
| 393 // Don't call GetElementsKind, its validation code can cause the printer to | 393 // Don't call GetElementsKind, its validation code can cause the printer to |
| 394 // fail when debugging. | 394 // fail when debugging. |
| 395 PrototypeIterator iter(obj->GetIsolate(), obj); | 395 PrototypeIterator iter(GetIsolate(), this); |
| 396 os << " - map = " << reinterpret_cast<void*>(obj->map()) << " [" | 396 os << " - map = " << reinterpret_cast<void*>(map()) << " [" |
| 397 << ElementsKindToString(obj->map()->elements_kind()) | 397 << ElementsKindToString(this->map()->elements_kind()) |
| 398 << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent()); | 398 << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent()) |
| 399 } | 399 << "\n {\n"; |
| 400 | 400 PrintProperties(os); |
| 401 | 401 PrintTransitions(os); |
| 402 static void JSObjectPrintBody(std::ostream& os, JSObject* obj) { // NOLINT | 402 PrintElements(os); |
| 403 os << "\n {\n"; | |
| 404 obj->PrintProperties(os); | |
| 405 obj->PrintTransitions(os); | |
| 406 obj->PrintElements(os); | |
| 407 os << " }\n"; | 403 os << " }\n"; |
| 408 } | 404 } |
| 409 | 405 |
| 410 | 406 |
| 411 void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT | |
| 412 JSObjectPrintHeader(os, this, "JSObject"); | |
| 413 JSObjectPrintBody(os, this); | |
| 414 } | |
| 415 | |
| 416 | |
| 417 void JSModule::JSModulePrint(std::ostream& os) { // NOLINT | 407 void JSModule::JSModulePrint(std::ostream& os) { // NOLINT |
| 418 HeapObject::PrintHeader(os, "JSModule"); | 408 HeapObject::PrintHeader(os, "JSModule"); |
| 419 os << " - map = " << reinterpret_cast<void*>(map()) << "\n" | 409 os << " - map = " << reinterpret_cast<void*>(map()) << "\n" |
| 420 << " - context = "; | 410 << " - context = "; |
| 421 context()->Print(os); | 411 context()->Print(os); |
| 422 os << " - scope_info = " << Brief(scope_info()) | 412 os << " - scope_info = " << Brief(scope_info()) |
| 423 << ElementsKindToString(this->map()->elements_kind()) << " {\n"; | 413 << ElementsKindToString(this->map()->elements_kind()) << " {\n"; |
| 424 PrintProperties(os); | 414 PrintProperties(os); |
| 425 PrintElements(os); | 415 PrintElements(os); |
| 426 os << " }\n"; | 416 os << " }\n"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if (is_dictionary_map()) os << " - dictionary_map\n"; | 454 if (is_dictionary_map()) os << " - dictionary_map\n"; |
| 465 if (is_hidden_prototype()) os << " - hidden_prototype\n"; | 455 if (is_hidden_prototype()) os << " - hidden_prototype\n"; |
| 466 if (has_named_interceptor()) os << " - named_interceptor\n"; | 456 if (has_named_interceptor()) os << " - named_interceptor\n"; |
| 467 if (has_indexed_interceptor()) os << " - indexed_interceptor\n"; | 457 if (has_indexed_interceptor()) os << " - indexed_interceptor\n"; |
| 468 if (is_undetectable()) os << " - undetectable\n"; | 458 if (is_undetectable()) os << " - undetectable\n"; |
| 469 if (is_callable()) os << " - callable\n"; | 459 if (is_callable()) os << " - callable\n"; |
| 470 if (is_constructor()) os << " - constructor\n"; | 460 if (is_constructor()) os << " - constructor\n"; |
| 471 if (is_access_check_needed()) os << " - access_check_needed\n"; | 461 if (is_access_check_needed()) os << " - access_check_needed\n"; |
| 472 if (!is_extensible()) os << " - non-extensible\n"; | 462 if (!is_extensible()) os << " - non-extensible\n"; |
| 473 if (is_observed()) os << " - observed\n"; | 463 if (is_observed()) os << " - observed\n"; |
| 474 if (is_strong()) os << " - strong_map\n"; | |
| 475 if (is_prototype_map()) { | 464 if (is_prototype_map()) { |
| 476 os << " - prototype_map\n"; | 465 os << " - prototype_map\n"; |
| 477 os << " - prototype info: " << Brief(prototype_info()); | 466 os << " - prototype info: " << Brief(prototype_info()); |
| 478 } else { | 467 } else { |
| 479 os << " - back pointer: " << Brief(GetBackPointer()); | 468 os << " - back pointer: " << Brief(GetBackPointer()); |
| 480 } | 469 } |
| 481 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "") | 470 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "") |
| 482 << "#" << NumberOfOwnDescriptors() << ": " | 471 << "#" << NumberOfOwnDescriptors() << ": " |
| 483 << Brief(instance_descriptors()); | 472 << Brief(instance_descriptors()); |
| 484 if (FLAG_unbox_double_fields) { | 473 if (FLAG_unbox_double_fields) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 for (int i = 0; i < entry_size; i++) { | 627 for (int i = 0; i < entry_size; i++) { |
| 639 int index = GetIndex(slot) + i; | 628 int index = GetIndex(slot) + i; |
| 640 os << "\n [" << index << "]: " << Brief(get(index)); | 629 os << "\n [" << index << "]: " << Brief(get(index)); |
| 641 } | 630 } |
| 642 } | 631 } |
| 643 os << "\n"; | 632 os << "\n"; |
| 644 } | 633 } |
| 645 | 634 |
| 646 | 635 |
| 647 void JSValue::JSValuePrint(std::ostream& os) { // NOLINT | 636 void JSValue::JSValuePrint(std::ostream& os) { // NOLINT |
| 648 JSObjectPrintHeader(os, this, "JSValue"); | 637 HeapObject::PrintHeader(os, "ValueObject"); |
| 649 os << "\n - value = " << Brief(value()); | 638 value()->Print(os); |
| 650 JSObjectPrintBody(os, this); | |
| 651 } | 639 } |
| 652 | 640 |
| 653 | 641 |
| 654 void JSMessageObject::JSMessageObjectPrint(std::ostream& os) { // NOLINT | 642 void JSMessageObject::JSMessageObjectPrint(std::ostream& os) { // NOLINT |
| 655 JSObjectPrintHeader(os, this, "JSMessageObject"); | 643 HeapObject::PrintHeader(os, "JSMessageObject"); |
| 656 os << "\n - type: " << type(); | 644 os << " - type: " << type(); |
| 657 os << "\n - arguments: " << Brief(argument()); | 645 os << "\n - arguments: " << Brief(argument()); |
| 658 os << "\n - start_position: " << start_position(); | 646 os << "\n - start_position: " << start_position(); |
| 659 os << "\n - end_position: " << end_position(); | 647 os << "\n - end_position: " << end_position(); |
| 660 os << "\n - script: " << Brief(script()); | 648 os << "\n - script: " << Brief(script()); |
| 661 os << "\n - stack_frames: " << Brief(stack_frames()); | 649 os << "\n - stack_frames: " << Brief(stack_frames()); |
| 662 JSObjectPrintBody(os, this); | 650 os << "\n"; |
| 663 } | 651 } |
| 664 | 652 |
| 665 | 653 |
| 666 void String::StringPrint(std::ostream& os) { // NOLINT | 654 void String::StringPrint(std::ostream& os) { // NOLINT |
| 667 if (StringShape(this).IsInternalized()) { | 655 if (StringShape(this).IsInternalized()) { |
| 668 os << "#"; | 656 os << "#"; |
| 669 } else if (StringShape(this).IsCons()) { | 657 } else if (StringShape(this).IsCons()) { |
| 670 os << "c\""; | 658 os << "c\""; |
| 671 } else { | 659 } else { |
| 672 os << "\""; | 660 os << "\""; |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 } | 1321 } |
| 1334 } | 1322 } |
| 1335 | 1323 |
| 1336 | 1324 |
| 1337 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT | 1325 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT |
| 1338 TransitionArray::PrintTransitions(os, map()->raw_transitions()); | 1326 TransitionArray::PrintTransitions(os, map()->raw_transitions()); |
| 1339 } | 1327 } |
| 1340 #endif // defined(DEBUG) || defined(OBJECT_PRINT) | 1328 #endif // defined(DEBUG) || defined(OBJECT_PRINT) |
| 1341 } // namespace internal | 1329 } // namespace internal |
| 1342 } // namespace v8 | 1330 } // namespace v8 |
| OLD | NEW |