Skip to content

Commit 1eb8c50

Browse files
authored
Merge pull request #73 from mozilla-spidermonkey/esr115
Update to ESR 115
2 parents 1a518f2 + 47c20df commit 1eb8c50

5 files changed

Lines changed: 67 additions & 65 deletions

File tree

docs/Building SpiderMonkey.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,28 @@ Use these instructions to build your own copy of SpiderMonkey.
44

55
## Prerequisites ##
66

7-
You will need a **C++ compiler** that can handle the C++17 standard, **Rust**
8-
version 1.59 or later, **GNU Make**, **zlib**, and **libffi**.
7+
You will need a **C++ compiler** that can handle the C++17 standard,
8+
**Rust** version [1.66][minimum-rust-version] or later, **GNU Make**,
9+
**zlib**, and **libffi**.
910
These can usually be installed with a package manager.
10-
You will also need **Autoconf 2.13** (not any later version) which is
11-
also usually available through a package manager.
12-
The package will usually be called something like `autoconf2.13` rather
13-
than just `autoconf`.
1411

15-
> **NOTE** SpiderMonkey also requires ICU of at least version 71.1, but
16-
> it will build a bundled copy by default.
12+
> **NOTE** SpiderMonkey also requires ICU of at least version
13+
> [73.1][minimum-icu-version], but it will build a bundled copy by
14+
> default.
1715
> If you have a new enough copy installed on your system, you can add
1816
> `--with-system-icu` in the build instructions below, for a shorter
1917
> build time.
2018
19+
[minimum-rust-version]: https://searchfox.org/mozilla-esr115/rev/61b47de1faebf23626e519b2464b461589fbea3e/python/mozboot/mozboot/util.py#14
20+
[minimum-icu-version]: https://searchfox.org/mozilla-esr115/rev/61b47de1faebf23626e519b2464b461589fbea3e/js/moz.configure#1107
21+
2122
## Getting the source code ##
2223

2324
Currently, the most reliable way to get the SpiderMonkey source code is
2425
to download the Firefox source.
25-
At the time of writing, the latest source for Firefox ESR 102, which
26-
contains the source for SpiderMonkey ESR 102, can be found here:
27-
https://ftp.mozilla.org/pub/firefox/releases/102.1.0esr/source/
28-
29-
This version is broken for embedder builds so you will need to either
30-
wait for version 102.2.0 or patch the 102.1.0 source with the fixes for
31-
the following bugs:
32-
33-
- [1776254 - Cannot build library for SM embedding examples, missing
34-
ProfilingCategoryList.h](https://bugzilla.mozilla.org/show_bug.cgi?id=1776254)
35-
- [1780857 - Embedder build broken in js/public/Debug.h if DEBUG not
36-
defined](https://bugzilla.mozilla.org/show_bug.cgi?id=1780857)
26+
At the time of writing, the latest source for Firefox ESR 115, which
27+
contains the source for SpiderMonkey ESR 115, can be found here:
28+
https://ftp.mozilla.org/pub/firefox/releases/115.1.0esr/source/
3729

3830
The ESR releases have a major release approximately once a year with
3931
security patches released throughout the year.

docs/Migration Guide.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,46 @@ of SpiderMonkey to the next ESR version.
55

66
## ESR 102 to ESR 115 ##
77

8+
### More Versatile `JS_InitClass` ###
9+
10+
In previous versions of SpiderMonkey, the name of the constructor
11+
function added by `JS_InitClass` was always the name of the prototype
12+
object's `JSClass`.
13+
This limitation caused the instances and the prototype to always share
14+
the same `JSClass` and `JSClassOps` specification.
15+
If the prototype should behave differently than the instances, custom
16+
checks were needed.
17+
Now `JS_InitClass` accepts a `const char *` parameter for naming the
18+
constructor function, so a different `JSClass *` can be used for the
19+
prototype object.
20+
If `nullptr` is passed, the prototype object will be a plain JS object.
21+
See [this patch from bug 1808171](https://hg.mozilla.org/releases/mozilla-esr115/rev/15e1e69037e370750f704d97d631e23ef32f3812).
22+
23+
### Bound Function Objects ###
24+
25+
Bound function objects (callable functions created with
26+
`Function.prototype.bind()`) are no longer `JSFunction` objects.
27+
`JS::GetBuiltinClass()` will not return `js::ESClass::Function` for such
28+
objects.
29+
30+
Unless you are using `JS::GetBuiltinClass()` to determine whether an
31+
object is callable, you will most likely not have to migrate anything.
32+
Consider using `JS::IsCallable()`.
33+
34+
If you need to check whether an object is specifically a bound function
35+
object, use `JS_ObjectIsBoundFunction()`.
36+
837
### Various API changes ###
938

1039
This is a non-exhaustive list of minor API changes and renames.
1140

1241
- `JS::ModuleInstantiate``JS::ModuleLink`
42+
- `mozilla::Tuple``std::tuple` (`<mozilla/Tuple.h>` is removed, use
43+
the standard C++ header `<tuple>` instead)
44+
- `mozilla::IsFinite()``std::isfinite()`
45+
- `mozilla::IsNaN()``std::isnan()`
46+
- Script filenames are now always encoded as UTF-8, see
47+
[this patch from bug 1492090](https://hg.mozilla.org/releases/mozilla-esr115/rev/416af93c3205460856a2cae7bee084a656ee2ee9)
1348

1449
## ESR 91 to ESR 102 ##
1550

examples/cookbook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ static bool MyClassConstructor(JSContext* cx, unsigned argc, JS::Value* vp) {
819819

820820
static bool DefineMyClass(JSContext* cx, JS::HandleObject global) {
821821
JS::RootedObject protoObj(
822-
cx, JS_InitClass(cx, global, nullptr, &myClass,
822+
cx, JS_InitClass(cx, global, nullptr, nullptr, myClass.name,
823823
// native constructor function and min arg count
824824
MyClassConstructor, 2,
825825

examples/resolve.cpp

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ class Crc {
7272
return JS::GetMaybePtrFromReservedSlot<Crc>(obj, CrcSlot);
7373
}
7474

75-
static bool isPrototype(JSObject* obj) { return getPriv(obj) == nullptr; }
76-
77-
static bool checkIsInstance(JSContext* cx, JSObject* obj, const char* what) {
78-
if (isPrototype(obj)) {
79-
JS_ReportErrorASCII(cx, "can't %s on Crc.prototype", what);
80-
return false;
81-
}
82-
return true;
83-
}
84-
8575
static bool constructor(JSContext* cx, unsigned argc, JS::Value* vp) {
8676
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
8777

@@ -106,26 +96,21 @@ class Crc {
10696
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
10797
JS::RootedObject thisObj(cx);
10898
if (!args.computeThis(cx, &thisObj)) return false;
109-
if (!checkIsInstance(cx, thisObj, "call update()")) return false;
99+
if (!JS_InstanceOf(cx, thisObj, &Crc::klass, &args)) return false;
110100
return getPriv(thisObj)->updateImpl(cx, args);
111101
}
112102

113103
static bool getChecksum(JSContext* cx, unsigned argc, JS::Value* vp) {
114104
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
115105
JS::RootedObject thisObj(cx);
116106
if (!args.computeThis(cx, &thisObj)) return false;
117-
if (!checkIsInstance(cx, thisObj, "read checksum")) return false;
107+
if (!JS_InstanceOf(cx, thisObj, &Crc::klass, &args)) return false;
118108
return getPriv(thisObj)->getChecksumImpl(cx, args);
119109
}
120110

121111
static bool newEnumerate(JSContext* cx, JS::HandleObject obj,
122112
JS::MutableHandleIdVector properties,
123113
bool enumerableOnly) {
124-
// We only want to enumerate if obj is the prototype. For instances, we
125-
// should return immediately, and this will be called again on the
126-
// prototype.
127-
if (!isPrototype(obj)) return true;
128-
129114
jsid idUpdate =
130115
JS::PropertyKey::fromPinnedString(JS_AtomizeAndPinString(cx, "update"));
131116
if (!properties.append(idUpdate)) return false;
@@ -139,13 +124,6 @@ class Crc {
139124

140125
static bool resolve(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
141126
bool* resolved) {
142-
// We only want to resolve if obj is the prototype. For instances, we should
143-
// return immediately, and this will be called again on the prototype.
144-
if (!isPrototype(obj)) {
145-
*resolved = false;
146-
return true;
147-
}
148-
149127
if (!id.isString()) {
150128
*resolved = false;
151129
return true;
@@ -214,24 +192,21 @@ class Crc {
214192
public:
215193
static bool DefinePrototype(JSContext* cx) {
216194
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
217-
JS::RootedObject proto(
218-
cx, JS_InitClass(cx,
219-
global, // the object in which to define the class
220-
nullptr, // the prototype of the parent class
221-
// (in our case, no parent class)
222-
&Crc::klass, // the JSClass defined above
223-
&Crc::constructor,
224-
0, // constructor and num. args
225-
// The four nullptrs below are for arrays where you
226-
// would list predefined (not lazy) methods and
227-
// properties, static and non-static
228-
nullptr, nullptr, nullptr, nullptr));
229-
if (!proto) return false;
230-
231-
// Here's how we tell the prototype apart from instances. The private
232-
// pointer will be null.
233-
JS::SetReservedSlot(proto, CrcSlot, JS::UndefinedValue());
234-
return true;
195+
return JS_InitClass(cx,
196+
global, // the object in which to define the class
197+
nullptr, // the prototype object, Crc.prototype
198+
// (in our case, a plain JS object because
199+
// calling "Crc.prototype.update" does not
200+
// make sense)
201+
nullptr, // the prototype of the parent class (in our
202+
// case, Object.prototype)
203+
Crc::klass.name, // "Crc", the constructor name
204+
&Crc::constructor,
205+
0, // constructor and num. args
206+
// The four nullptrs below are for arrays where you
207+
// would list predefined (not lazy) methods and
208+
// properties, static and non-static
209+
nullptr, nullptr, nullptr, nullptr);
235210
}
236211
};
237212
constexpr JSClassOps Crc::classOps;

meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project('spidermonkey-embedding-examples', 'cpp', version: 'esr102',
1+
project('spidermonkey-embedding-examples', 'cpp', version: 'esr115',
22
meson_version: '>= 0.43.0',
33
default_options: ['cpp_std=c++17', 'warning_level=3'])
44

@@ -7,7 +7,7 @@ cxx = meson.get_compiler('cpp')
77
args = []
88

99
zlib = dependency('zlib') # (is already a SpiderMonkey dependency)
10-
spidermonkey = dependency('mozjs-102')
10+
spidermonkey = dependency('mozjs-115')
1111
readline = cxx.find_library('readline')
1212

1313
# Check if SpiderMonkey was compiled with --enable-debug. If this is the case,

0 commit comments

Comments
 (0)