Title: [98601] trunk/Source/_javascript_Core
- Revision
- 98601
- Author
- [email protected]
- Date
- 2011-10-27 10:38:19 -0700 (Thu, 27 Oct 2011)
Log Message
Add ability to check for presence of static members at compile time
https://bugs.webkit.org/show_bug.cgi?id=70986
Reviewed by Geoffrey Garen.
Added new CREATE_MEMBER_CHECKER macro to instantiate the template and the
HAS_MEMBER_NAMED macro to use that template to check if the specified class
does indeed have a method with that name. This mechanism is not currently
used anywhere, but will be in the future when adding virtual methods from
JSObject to the MethodTable.
* runtime/ClassInfo.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (98600 => 98601)
--- trunk/Source/_javascript_Core/ChangeLog 2011-10-27 17:33:07 UTC (rev 98600)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-10-27 17:38:19 UTC (rev 98601)
@@ -1,5 +1,20 @@
2011-10-27 Mark Hahnenberg <[email protected]>
+ Add ability to check for presence of static members at compile time
+ https://bugs.webkit.org/show_bug.cgi?id=70986
+
+ Reviewed by Geoffrey Garen.
+
+ Added new CREATE_MEMBER_CHECKER macro to instantiate the template and the
+ HAS_MEMBER_NAMED macro to use that template to check if the specified class
+ does indeed have a method with that name. This mechanism is not currently
+ used anywhere, but will be in the future when adding virtual methods from
+ JSObject to the MethodTable.
+
+ * runtime/ClassInfo.h:
+
+2011-10-27 Mark Hahnenberg <[email protected]>
+
De-virtualize JSCell::toThisObject
https://bugs.webkit.org/show_bug.cgi?id=70958
Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (98600 => 98601)
--- trunk/Source/_javascript_Core/runtime/ClassInfo.h 2011-10-27 17:33:07 UTC (rev 98600)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h 2011-10-27 17:38:19 UTC (rev 98601)
@@ -63,6 +63,25 @@
ToThisObjectFunctionPtr toThisObject;
};
+#define CREATE_MEMBER_CHECKER(member) \
+template <typename T> \
+struct MemberCheck##member { \
+ struct Fallback { \
+ void member(...); \
+ }; \
+ struct Derived : T, Fallback { }; \
+ template <typename U, U> struct Check; \
+ typedef char Yes[2]; \
+ typedef char No[1]; \
+ template <typename U> \
+ static No &func(Check<void (Fallback::*)(...), &U::member>*); \
+ template <typename U> \
+ static Yes &func(...); \
+ enum { has = sizeof(func<Derived>(0)) == sizeof(Yes) }; \
+}
+
+#define HAS_MEMBER_NAMED(klass, name) (MemberCheck##name<klass>::has)
+
#define CREATE_METHOD_TABLE(ClassName) { \
&ClassName::visitChildren, \
&ClassName::getCallData, \
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes