Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Unified Diff: src/types.h

Issue 18587007: Type::GetName() for printing types in debugger (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/types.cc » ('j') | src/types.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index a2bcda65791646c57464a5d85a908564efc5587a..7a5397ca274ba560bde36de03c87501b4989c109 100644
--- a/src/types.h
+++ b/src/types.h
@@ -94,6 +94,40 @@ namespace internal {
// The type representation is heap-allocated, so cannot (currently) be used in
// a parallel compilation context.
+
+#define PRIMITIVE_TYPE_LIST(V) \
+ V(None, 0) \
+ V(Null, 1 << 0) \
+ V(Undefined, 1 << 1) \
+ V(Boolean, 1 << 2) \
+ V(Smi, 1 << 3) \
+ V(OtherSigned32, 1 << 4) \
+ V(Unsigned32, 1 << 5) \
+ V(Double, 1 << 6) \
+ V(Symbol, 1 << 7) \
+ V(InternalizedString, 1 << 8) \
+ V(OtherString, 1 << 9) \
+ V(Undetectable, 1 << 10) \
+ V(Array, 1 << 11) \
+ V(Function, 1 << 12) \
+ V(RegExp, 1 << 13) \
+ V(OtherObject, 1 << 14) \
+ V(Proxy, 1 << 15) \
+ V(Internal, 1 << 16) \
+ V(Oddball, kBoolean | kNull | kUndefined) \
rossberg 2013/07/03 14:52:54 Nit: Maybe insert an empty line before this one.
+ V(Signed32, kSmi | kOtherSigned32) \
+ V(Number, kSigned32 | kUnsigned32 | kDouble) \
+ V(String, kInternalizedString | kOtherString) \
+ V(UniqueName, kSymbol | kInternalizedString) \
+ V(Name, kSymbol | kString) \
+ V(NumberOrString, kNumber | kString) \
+ V(Object, kUndetectable | kArray | kFunction | kRegExp | kOtherObject) \
rossberg 2013/07/03 14:52:54 Aha, cheating with indentation!
+ V(Receiver, kObject | kProxy) \
+ V(Allocated, kDouble | kName | kReceiver) \
+ V(Any, kOddball | kNumber | kAllocated | kInternal) \
+ V(Detectable, kAllocated - kUndetectable)
+
+
class Type : public Object {
public:
static Type* None() { return from_bitset(kNone); }
rossberg 2013/07/03 14:52:54 Can't you generate all these functions from the ma
@@ -192,39 +226,26 @@ class Type : public Object {
typedef FixedArray Unioned;
enum {
- kNull = 1 << 0,
- kUndefined = 1 << 1,
- kBoolean = 1 << 2,
- kSmi = 1 << 3,
- kOtherSigned32 = 1 << 4,
- kUnsigned32 = 1 << 5,
- kDouble = 1 << 6,
- kSymbol = 1 << 7,
- kInternalizedString = 1 << 8,
- kOtherString = 1 << 9,
- kUndetectable = 1 << 10,
- kArray = 1 << 11,
- kFunction = 1 << 12,
- kRegExp = 1 << 13,
- kOtherObject = 1 << 14,
- kProxy = 1 << 15,
- kInternal = 1 << 16,
-
- kOddball = kBoolean | kNull | kUndefined,
- kSigned32 = kSmi | kOtherSigned32,
- kNumber = kSigned32 | kUnsigned32 | kDouble,
- kString = kInternalizedString | kOtherString,
- kUniqueName = kSymbol | kInternalizedString,
- kName = kSymbol | kString,
- kNumberOrString = kNumber | kString,
- kObject = kUndetectable | kArray | kFunction | kRegExp | kOtherObject,
- kReceiver = kObject | kProxy,
- kAllocated = kDouble | kName | kReceiver,
- kAny = kOddball | kNumber | kAllocated | kInternal,
- kDetectable = kAllocated - kUndetectable,
- kNone = 0
+ // Declare const for all primitive types.
+ #define DECLARE_PRIMITIVE_TYPE(type, value) k##type = (value),
+ PRIMITIVE_TYPE_LIST(DECLARE_PRIMITIVE_TYPE)
rossberg 2013/07/03 14:52:54 Nit: maybe indent this by 2
oliv 2013/07/05 12:29:06 i'd rather not, since it looks very strange if the
+ #undef DECLARE_OPCODE
+ kUnusedEOL = 0
rossberg 2013/07/03 14:52:54 What's that for?
oliv 2013/07/05 12:29:06 you cannot end the enum definition with a comma...
};
+ const char* GetPrimitiveName() {
+ switch (as_bitset()) {
rossberg 2013/07/03 14:52:54 Yeah, that does not fly. Any combination of primit
+ #define PRINT_PRIMITIVE_TYPE(type, value) \
+ case k##type: \
+ return # type;
+ PRIMITIVE_TYPE_LIST(PRINT_PRIMITIVE_TYPE)
+ #undef PRINT_PRIMITIVE_TYPE
+ default:
+ UNREACHABLE();
+ return "InvalidType";
+ }
+ }
+
bool is_bitset() { return this->IsSmi(); }
bool is_class() { return this->IsMap(); }
bool is_constant() { return this->IsBox(); }
@@ -265,6 +286,9 @@ class Type : public Object {
int ExtendUnion(Handle<Unioned> unioned, int current_size);
int ExtendIntersection(
Handle<Unioned> unioned, Handle<Type> type, int current_size);
+
+ static void PrintName(StringStream* stream, Type* type);
+ static SmartArrayPointer<const char> GetName(Type* type);
};
} } // namespace v8::internal
« no previous file with comments | « no previous file | src/types.cc » ('j') | src/types.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698