Skip to content
Snippets Groups Projects
Commit 0bb532d2 authored by Xi Ruoyao's avatar Xi Ruoyao
Browse files

Bug 1841040 - Remove over-alignment from GCMarker and Nursery,...

Bug 1841040 - Remove over-alignment from GCMarker and Nursery, r=spidermonkey-reviewers,jonco a=RyanVM

js_new<T> cannot guarantee the alignment if T is over-aligned, and this
issue is not trivial to fix (blocked by Bug 1842582).

Add a static assert to detect the attempt using js_new<T> for
over-aligned T, and remove the problematic alignas() attributes as a
short-term fix.

Differential Revision: https://phabricator.services.mozilla.com/D182546
parent 5805d10d
No related branches found
No related tags found
No related merge requests found
......@@ -478,6 +478,9 @@ static inline void js_free(void* p) {
#define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \
template <class T, typename... Args> \
QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(Args&&... args) { \
static_assert( \
alignof(T) <= alignof(max_align_t), \
"over-aligned type is not supported by JS_DECLARE_NEW_METHODS"); \
void* memory = ALLOCATOR(sizeof(T)); \
return MOZ_LIKELY(memory) ? new (memory) T(std::forward<Args>(args)...) \
: nullptr; \
......@@ -494,6 +497,9 @@ static inline void js_free(void* p) {
#define JS_DECLARE_NEW_ARENA_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \
template <class T, typename... Args> \
QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(arena_id_t arena, Args&&... args) { \
static_assert( \
alignof(T) <= alignof(max_align_t), \
"over-aligned type is not supported by JS_DECLARE_NEW_ARENA_METHODS"); \
void* memory = ALLOCATOR(arena, sizeof(T)); \
return MOZ_LIKELY(memory) ? new (memory) T(std::forward<Args>(args)...) \
: nullptr; \
......
......@@ -274,7 +274,7 @@ enum ShouldReportMarkTime : bool {
} /* namespace gc */
class alignas(TypicalCacheLineSize) GCMarker {
class GCMarker {
enum MarkingState : uint8_t {
// Have not yet started marking.
NotActive,
......
......@@ -67,7 +67,7 @@ class GCSchedulingTunables;
class TenuringTracer;
} // namespace gc
class alignas(TypicalCacheLineSize) Nursery {
class Nursery {
public:
explicit Nursery(gc::GCRuntime* gc);
~Nursery();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment