Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 6e05e62

Browse files
committed
Bug 1547824 - Change JS::Value from union to class. r=jwalden
Now that all the bad type-punning is gone, JS::Value has a single asBits_ field and we should use a class aggregate type instead. Differential Revision: https://phabricator.services.mozilla.com/D46325 --HG-- extra : moz-landing-system : lando
1 parent 86d5bde commit 6e05e62

7 files changed

Lines changed: 9 additions & 22 deletions

File tree

js/public/JSON.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
#include "jstypes.h" // JS_PUBLIC_API
1616

1717
#include "js/RootingAPI.h" // JS::Handle, JS::MutableHandle
18+
#include "js/Value.h" // JS::Value
1819

1920
struct JSContext;
2021
class JSObject;
2122
class JSString;
2223

23-
namespace JS {
24-
union Value;
25-
}
26-
2724
using JSONWriteCallback = bool (*)(const char16_t* buf, uint32_t len,
2825
void* data);
2926

js/public/LocaleSensitive.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515

1616
#include "js/RootingAPI.h" // JS::Handle, JS::MutableHandle
1717
#include "js/Utility.h" // JS::UniqueChars
18+
#include "js/Value.h" // JS::Value
1819

1920
struct JSContext;
2021
struct JSRuntime;
2122
class JSString;
2223

23-
namespace JS {
24-
union Value;
25-
}
26-
2724
/**
2825
* Set the default locale for the ECMAScript Internationalization API
2926
* (Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat, and others that will

js/public/TypeDecls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ typedef unsigned char Latin1Char;
4646

4747
class Symbol;
4848
class BigInt;
49-
union Value;
49+
class Value;
5050

5151
class Compartment;
5252
class Realm;

js/public/Value.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "js/Utility.h"
2828

2929
namespace JS {
30-
union Value;
30+
class Value;
3131
}
3232

3333
/* JS::Value can store a full int32_t. */
@@ -340,7 +340,7 @@ static inline double CanonicalizeNaN(double d) {
340340
* conditional move (not speculated) to zero the payload register if the type
341341
* doesn't match.
342342
*/
343-
union alignas(8) Value {
343+
class alignas(8) Value {
344344
private:
345345
uint64_t asBits_;
346346

js/src/builtin/Object.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99

1010
#include "jsapi.h"
1111

12+
#include "js/Value.h"
1213
#include "vm/NativeObject.h"
1314

14-
namespace JS {
15-
union Value;
16-
} // namespace JS
17-
1815
namespace js {
1916

2017
// Object constructor native. Exposed only so the JIT can know its address.

js/src/builtin/streams/QueueingStrategies.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@
1010
#define builtin_stream_QueueingStrategies_h
1111

1212
#include "js/Class.h" // JSClass, js::ClassSpec
13+
#include "js/Value.h" // JS::Value
14+
#include "vm/JSContext.h" // JSContext
1315
#include "vm/NativeObject.h" // js::NativeObject
1416

15-
struct JSContext;
16-
17-
namespace JS {
18-
union Value;
19-
}
20-
2117
namespace js {
2218

2319
class ByteLengthQueuingStrategy : public NativeObject {

js/src/wasm/AsmJS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class JSFunction;
3131

3232
namespace JS {
3333

34-
union Value;
34+
class Value;
3535

3636
template <typename T>
3737
class Handle;

0 commit comments

Comments
 (0)