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

Side by Side Diff: Source/platform/heap/Visitor.h

Issue 1270043002: Remove HasInlinedTraceMethod<T>. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/wtf/Deque.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // with the Windows compiler which instantiates even unused variables. This caus es problems 62 // with the Windows compiler which instantiates even unused variables. This caus es problems
63 // in header files where we have only forward declarations of classes. 63 // in header files where we have only forward declarations of classes.
64 template<typename T, void (T::*method)(Visitor*)> 64 template<typename T, void (T::*method)(Visitor*)>
65 struct TraceMethodDelegate { 65 struct TraceMethodDelegate {
66 static void trampoline(Visitor* visitor, void* self) 66 static void trampoline(Visitor* visitor, void* self)
67 { 67 {
68 (reinterpret_cast<T*>(self)->*method)(visitor); 68 (reinterpret_cast<T*>(self)->*method)(visitor);
69 } 69 }
70 }; 70 };
71 71
72 // HasInlinedTraceMethod<T>::value is true for T supporting
73 // T::trace(InlinedGlobalMarkingVisitor).
74 // The template works by checking if T::HasInlinedTraceMethodMarker type is
75 // available using SFINAE. The HasInlinedTraceMethodMarker type is defined
76 // by DECLARE_TRACE and DEFINE_INLINE_TRACE helper macros, which are used to
77 // define trace methods supporting both inlined/uninlined tracing.
78 template <typename T>
79 struct HasInlinedTraceMethod {
80 private:
81 typedef char YesType;
82 struct NoType {
83 char padding[8];
84 };
85
86 template <typename U> static YesType checkMarker(typename U::HasInlinedTrace MethodMarker*);
87 template <typename U> static NoType checkMarker(...);
88 public:
89 static const bool value = sizeof(checkMarker<T>(nullptr)) == sizeof(YesType) ;
90 };
91
92 #define DECLARE_TRACE_IMPL(maybevirtual) \ 72 #define DECLARE_TRACE_IMPL(maybevirtual) \
93 public: \ 73 public: \
94 typedef int HasInlinedTraceMethodMarker; \
95 maybevirtual void trace(Visitor*); \ 74 maybevirtual void trace(Visitor*); \
96 maybevirtual void trace(InlinedGlobalMarkingVisitor); \ 75 maybevirtual void trace(InlinedGlobalMarkingVisitor); \
97 \ 76 \
98 private: \ 77 private: \
99 template <typename VisitorDispatcher> void traceImpl(VisitorDispatcher); \ 78 template <typename VisitorDispatcher> void traceImpl(VisitorDispatcher); \
100 \ 79 \
101 public: 80 public:
102 #define DEFINE_TRACE(T) \ 81 #define DEFINE_TRACE(T) \
103 void T::trace(Visitor* visitor) { traceImpl(visitor); } \ 82 void T::trace(Visitor* visitor) { traceImpl(visitor); } \
104 void T::trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } \ 83 void T::trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(visitor); } \
105 template <typename VisitorDispatcher> \ 84 template <typename VisitorDispatcher> \
106 ALWAYS_INLINE void T::traceImpl(VisitorDispatcher visitor) 85 ALWAYS_INLINE void T::traceImpl(VisitorDispatcher visitor)
107 86
108 #define DEFINE_INLINE_TRACE_IMPL(maybevirtual) \ 87 #define DEFINE_INLINE_TRACE_IMPL(maybevirtual) \
109 typedef int HasInlinedTraceMethodMarker; \
110 maybevirtual void trace(Visitor* visitor) { traceImpl(visitor); } \ 88 maybevirtual void trace(Visitor* visitor) { traceImpl(visitor); } \
111 maybevirtual void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(vis itor); } \ 89 maybevirtual void trace(InlinedGlobalMarkingVisitor visitor) { traceImpl(vis itor); } \
112 template <typename VisitorDispatcher> \ 90 template <typename VisitorDispatcher> \
113 inline void traceImpl(VisitorDispatcher visitor) 91 inline void traceImpl(VisitorDispatcher visitor)
114 92
115 #define DECLARE_TRACE_AFTER_DISPATCH() \ 93 #define DECLARE_TRACE_AFTER_DISPATCH() \
116 public: \ 94 public: \
117 typedef int HasInlinedTraceAfterDispatchMethodMarker; \
118 void traceAfterDispatch(Visitor*); \ 95 void traceAfterDispatch(Visitor*); \
119 void traceAfterDispatch(InlinedGlobalMarkingVisitor); \ 96 void traceAfterDispatch(InlinedGlobalMarkingVisitor); \
120 private: \ 97 private: \
121 template <typename VisitorDispatcher> void traceAfterDispatchImpl(VisitorDis patcher); \ 98 template <typename VisitorDispatcher> void traceAfterDispatchImpl(VisitorDis patcher); \
122 public: 99 public:
123 100
124 #define DEFINE_TRACE_AFTER_DISPATCH(T) \ 101 #define DEFINE_TRACE_AFTER_DISPATCH(T) \
125 void T::traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visito r); } \ 102 void T::traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visito r); } \
126 void T::traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { traceAfter DispatchImpl(visitor); } \ 103 void T::traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { traceAfter DispatchImpl(visitor); } \
127 template <typename VisitorDispatcher> \ 104 template <typename VisitorDispatcher> \
128 ALWAYS_INLINE void T::traceAfterDispatchImpl(VisitorDispatcher visitor) 105 ALWAYS_INLINE void T::traceAfterDispatchImpl(VisitorDispatcher visitor)
129 106
130 #define DEFINE_INLINE_TRACE_AFTER_DISPATCH() \ 107 #define DEFINE_INLINE_TRACE_AFTER_DISPATCH() \
131 typedef int HasInlinedTraceAfterDispatchMethodMarker; \
132 void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } \ 108 void traceAfterDispatch(Visitor* visitor) { traceAfterDispatchImpl(visitor); } \
133 void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { traceAfterDis patchImpl(visitor); } \ 109 void traceAfterDispatch(InlinedGlobalMarkingVisitor visitor) { traceAfterDis patchImpl(visitor); } \
134 template <typename VisitorDispatcher> \ 110 template <typename VisitorDispatcher> \
135 inline void traceAfterDispatchImpl(VisitorDispatcher visitor) 111 inline void traceAfterDispatchImpl(VisitorDispatcher visitor)
136 112
137 #define EMPTY_MACRO_ARGUMENT 113 #define EMPTY_MACRO_ARGUMENT
138 114
139 #define DECLARE_TRACE() DECLARE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT) 115 #define DECLARE_TRACE() DECLARE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT)
140 #define DECLARE_VIRTUAL_TRACE() DECLARE_TRACE_IMPL(virtual) 116 #define DECLARE_VIRTUAL_TRACE() DECLARE_TRACE_IMPL(virtual)
141 #define DEFINE_INLINE_TRACE() DEFINE_INLINE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT) 117 #define DEFINE_INLINE_TRACE() DEFINE_INLINE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT)
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 { 393 {
418 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>()))); 394 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>())));
419 return typenameString; 395 return typenameString;
420 } 396 }
421 }; 397 };
422 #endif 398 #endif
423 399
424 } // namespace blink 400 } // namespace blink
425 401
426 #endif // Visitor_h 402 #endif // Visitor_h
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/Deque.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698