Created
December 8, 2012 00:36
-
-
Save syg/4237844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp | |
index f20a2f2..0009b47 100644 | |
--- a/js/src/jsfriendapi.cpp | |
+++ b/js/src/jsfriendapi.cpp | |
@@ -23,7 +23,7 @@ using namespace js; | |
using namespace JS; | |
// Required by PerThreadDataFriendFields::getMainThread() | |
-JS_STATIC_ASSERT(offsetof(JSRuntime, mainThread) == JS_PERTHREADDATAOFFSET); | |
+JS_STATIC_ASSERT(offsetof(JSRuntime, mainThread) == PerThreadDataFriendFields::PerThreadDataOffset); | |
PerThreadDataFriendFields::PerThreadDataFriendFields() | |
{ | |
diff --git a/js/src/jspubtd.h b/js/src/jspubtd.h | |
index f914697d2..8496dd7 100644 | |
--- a/js/src/jspubtd.h | |
+++ b/js/src/jspubtd.h | |
@@ -318,6 +318,17 @@ class PerThreadData; | |
struct PerThreadDataFriendFields | |
{ | |
+ private: | |
+ // Note: this type only exists to permit us to derive the offset of | |
+ // the perThread data within the real JSRuntime* type in a portable | |
+ // way. | |
+ struct RuntimeDummy : RuntimeFriendFields | |
+ { | |
+ void *perThread; | |
+ }; | |
+ | |
+ public: | |
+ | |
PerThreadDataFriendFields(); | |
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) | |
@@ -331,42 +342,28 @@ struct PerThreadDataFriendFields | |
/* Limit pointer for checking native stack consumption. */ | |
uintptr_t nativeStackLimit; | |
- static inline PerThreadDataFriendFields *get(js::PerThreadData *pt); | |
- static inline PerThreadDataFriendFields *getMainThread(JSRuntime *rt); | |
- static inline const PerThreadDataFriendFields *getMainThread(const JSRuntime *rt);}; | |
+ static const size_t PerThreadDataOffset = offsetof(RuntimeDummy, perThread); | |
-// Note: this type only exists to permit us to derive the offset of | |
-// the perThread data within the real JSRuntime* type in a portable | |
-// way. | |
-struct __RuntimeDummy : RuntimeFriendFields | |
-{ | |
- PerThreadDataFriendFields perThread; | |
-}; | |
+ static inline PerThreadDataFriendFields *get(js::PerThreadData *pt) { | |
+ return reinterpret_cast<PerThreadDataFriendFields *>(pt); | |
+ } | |
-#define JS_PERTHREADDATAOFFSET offsetof(__RuntimeDummy, perThread) | |
+ static inline PerThreadDataFriendFields *getMainThread(JSRuntime *rt) { | |
+ // mainThread must always appear directly after |RuntimeFriendFields|. | |
+ // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| | |
+ return reinterpret_cast<PerThreadDataFriendFields *>( | |
+ reinterpret_cast<char*>(rt) + PerThreadDataOffset); | |
+ } | |
-} /* namespace js */ | |
+ static inline const PerThreadDataFriendFields *getMainThread(const JSRuntime *rt) { | |
+ // mainThread must always appear directly after |RuntimeFriendFields|. | |
+ // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| | |
+ return reinterpret_cast<const PerThreadDataFriendFields *>( | |
+ reinterpret_cast<const char*>(rt) + PerThreadDataOffset); | |
+ } | |
+}; | |
-js::PerThreadDataFriendFields * | |
-js::PerThreadDataFriendFields::get(js::PerThreadData *pt) { | |
- return reinterpret_cast<PerThreadDataFriendFields *>(pt); | |
-} | |
- | |
-js::PerThreadDataFriendFields * | |
-js::PerThreadDataFriendFields::getMainThread(JSRuntime *rt) { | |
- // mainThread must always appear directly after |RuntimeFriendFields|. | |
- // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| | |
- return reinterpret_cast<PerThreadDataFriendFields *>( | |
- reinterpret_cast<char*>(rt) + JS_PERTHREADDATAOFFSET); | |
-} | |
- | |
-const js::PerThreadDataFriendFields * | |
-js::PerThreadDataFriendFields::getMainThread(const JSRuntime *rt) { | |
- // mainThread must always appear directly after |RuntimeFriendFields|. | |
- // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| | |
- return reinterpret_cast<const PerThreadDataFriendFields *>( | |
- reinterpret_cast<const char*>(rt) + JS_PERTHREADDATAOFFSET); | |
-} | |
+} /* namespace js */ | |
#endif /* __cplusplus */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment