| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/property.h" | 5 #include "src/property.h" |
| 6 | 6 |
| 7 #include "src/handles-inl.h" | 7 #include "src/handles-inl.h" |
| 8 #include "src/ostreams.h" | 8 #include "src/ostreams.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 struct FastPropertyDetails { | 45 struct FastPropertyDetails { |
| 46 explicit FastPropertyDetails(const PropertyDetails& v) : details(v) {} | 46 explicit FastPropertyDetails(const PropertyDetails& v) : details(v) {} |
| 47 const PropertyDetails details; | 47 const PropertyDetails details; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 | 50 |
| 51 // Outputs PropertyDetails as a dictionary details. | 51 // Outputs PropertyDetails as a dictionary details. |
| 52 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details) { | 52 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details) { |
| 53 os << "("; | 53 os << "("; |
| 54 switch (details.type()) { | 54 if (details.location() == IN_DESCRIPTOR) { |
| 55 case FIELD: | 55 os << "immutable "; |
| 56 os << "normal: "; | |
| 57 break; | |
| 58 case CALLBACKS: | |
| 59 os << "callbacks: "; | |
| 60 break; | |
| 61 case CONSTANT: | |
| 62 UNREACHABLE(); | |
| 63 break; | |
| 64 } | 56 } |
| 65 return os << " dictionary_index: " << details.dictionary_index() | 57 os << (details.kind() == DATA ? "data" : "accessor"); |
| 58 return os << ", dictionary_index: " << details.dictionary_index() |
| 66 << ", attrs: " << details.attributes() << ")"; | 59 << ", attrs: " << details.attributes() << ")"; |
| 67 } | 60 } |
| 68 | 61 |
| 69 | 62 |
| 70 // Outputs PropertyDetails as a descriptor array details. | 63 // Outputs PropertyDetails as a descriptor array details. |
| 71 std::ostream& operator<<(std::ostream& os, | 64 std::ostream& operator<<(std::ostream& os, |
| 72 const FastPropertyDetails& details_fast) { | 65 const FastPropertyDetails& details_fast) { |
| 73 const PropertyDetails& details = details_fast.details; | 66 const PropertyDetails& details = details_fast.details; |
| 74 os << "("; | 67 os << "("; |
| 75 switch (details.type()) { | 68 if (details.location() == IN_DESCRIPTOR) { |
| 76 case CONSTANT: | 69 os << "immutable "; |
| 77 os << "constant: p: " << details.pointer(); | |
| 78 break; | |
| 79 case FIELD: | |
| 80 os << "field: " << details.representation().Mnemonic() | |
| 81 << ", field_index: " << details.field_index() | |
| 82 << ", p: " << details.pointer(); | |
| 83 break; | |
| 84 case CALLBACKS: | |
| 85 os << "callbacks: p: " << details.pointer(); | |
| 86 break; | |
| 87 } | 70 } |
| 88 return os << ", attrs: " << details.attributes() << ")"; | 71 os << (details.kind() == DATA ? "data" : "accessor"); |
| 72 if (details.location() == IN_OBJECT) { |
| 73 os << ": " << details.representation().Mnemonic() |
| 74 << ", field_index: " << details.field_index(); |
| 75 } |
| 76 return os << ", p: " << details.pointer() |
| 77 << ", attrs: " << details.attributes() << ")"; |
| 89 } | 78 } |
| 90 | 79 |
| 91 | 80 |
| 92 #ifdef OBJECT_PRINT | 81 #ifdef OBJECT_PRINT |
| 93 void PropertyDetails::Print(bool dictionary_mode) { | 82 void PropertyDetails::Print(bool dictionary_mode) { |
| 94 OFStream os(stdout); | 83 OFStream os(stdout); |
| 95 if (dictionary_mode) { | 84 if (dictionary_mode) { |
| 96 os << *this; | 85 os << *this; |
| 97 } else { | 86 } else { |
| 98 os << FastPropertyDetails(*this); | 87 os << FastPropertyDetails(*this); |
| 99 } | 88 } |
| 100 os << "\n" << std::flush; | 89 os << "\n" << std::flush; |
| 101 } | 90 } |
| 102 #endif | 91 #endif |
| 103 | 92 |
| 104 | 93 |
| 105 std::ostream& operator<<(std::ostream& os, const Descriptor& d) { | 94 std::ostream& operator<<(std::ostream& os, const Descriptor& d) { |
| 106 Object* value = *d.GetValue(); | 95 Object* value = *d.GetValue(); |
| 107 os << "Descriptor " << Brief(*d.GetKey()) << " @ " << Brief(value) << " "; | 96 os << "Descriptor " << Brief(*d.GetKey()) << " @ " << Brief(value) << " "; |
| 108 if (value->IsAccessorPair()) { | 97 if (value->IsAccessorPair()) { |
| 109 AccessorPair* pair = AccessorPair::cast(value); | 98 AccessorPair* pair = AccessorPair::cast(value); |
| 110 os << "(get: " << Brief(pair->getter()) | 99 os << "(get: " << Brief(pair->getter()) |
| 111 << ", set: " << Brief(pair->setter()) << ") "; | 100 << ", set: " << Brief(pair->setter()) << ") "; |
| 112 } | 101 } |
| 113 os << FastPropertyDetails(d.GetDetails()); | 102 os << FastPropertyDetails(d.GetDetails()); |
| 114 return os; | 103 return os; |
| 115 } | 104 } |
| 116 | 105 |
| 117 } } // namespace v8::internal | 106 } } // namespace v8::internal |
| OLD | NEW |