Skip to content

Commit

Permalink
Bug 712289. Make sure that alignment requirements agree for js::Value…
Browse files Browse the repository at this point in the history
… and jsval_layout. r=luke, a=akeybl
  • Loading branch information
bzbarsky committed Jan 15, 2012
1 parent 0d42c82 commit 386903d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion js/src/jsapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ class Value

friend jsval_layout (::JSVAL_TO_IMPL)(Value);
friend Value (::IMPL_TO_JSVAL)(jsval_layout l);
} JSVAL_ALIGNMENT;
};

/************************************************************************/

Expand Down Expand Up @@ -839,6 +839,11 @@ IMPL_TO_JSVAL(jsval_layout l)
return v;
}

#ifdef DEBUG
struct JSValueAlignmentTester { char c; JS::Value v; };
JS_STATIC_ASSERT(sizeof(JSValueAlignmentTester) == 16);
#endif /* DEBUG */

#else /* defined(__cplusplus) */

/*
Expand All @@ -863,6 +868,11 @@ IMPL_TO_JSVAL(jsval_layout l)

#endif /* defined(__cplusplus) */

#ifdef DEBUG
typedef struct { char c; jsval_layout l; } JSLayoutAlignmentTester;
JS_STATIC_ASSERT(sizeof(JSLayoutAlignmentTester) == 16);
#endif /* DEBUG */

JS_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(jsval));

/************************************************************************/
Expand Down
8 changes: 4 additions & 4 deletions js/src/jsval.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ typedef union jsval_layout
} s;
double asDouble;
void *asPtr;
} jsval_layout;
} JSVAL_ALIGNMENT jsval_layout;
# elif JS_BITS_PER_WORD == 64
typedef union jsval_layout
{
Expand All @@ -348,7 +348,7 @@ typedef union jsval_layout
double asDouble;
void *asPtr;
size_t asWord;
} jsval_layout;
} JSVAL_ALIGNMENT jsval_layout;
# endif /* JS_BITS_PER_WORD */
#else /* defined(IS_LITTLE_ENDIAN) */
# if JS_BITS_PER_WORD == 32
Expand All @@ -370,7 +370,7 @@ typedef union jsval_layout
} s;
double asDouble;
void *asPtr;
} jsval_layout;
} JSVAL_ALIGNMENT jsval_layout;
# elif JS_BITS_PER_WORD == 64
typedef union jsval_layout
{
Expand All @@ -390,7 +390,7 @@ typedef union jsval_layout
double asDouble;
void *asPtr;
size_t asWord;
} jsval_layout;
} JSVAL_ALIGNMENT jsval_layout;
# endif /* JS_BITS_PER_WORD */
#endif /* defined(IS_LITTLE_ENDIAN) */

Expand Down

0 comments on commit 386903d

Please sign in to comment.