Gentoo Archives: gentoo-commits

From: Ian Stakenvicius <axs@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/spidermonkey/files/, dev-lang/spidermonkey/
Date: Mon, 27 Feb 2017 23:39:43
Message-Id: 1488238741.c6b9e11e5e556f1eb6a1446b9f789b97af743e19.axs@gentoo
1 commit: c6b9e11e5e556f1eb6a1446b9f789b97af743e19
2 Author: Ian Stakenvicius <axs <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 27 22:35:15 2017 +0000
4 Commit: Ian Stakenvicius <axs <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 27 23:39:01 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c6b9e11e
7
8 dev-lang/spidermonkey: add mozjs38 release for gnome-3.23
9
10 Package-Manager: portage-2.3.3
11
12 dev-lang/spidermonkey/Manifest | 1 +
13 dev-lang/spidermonkey/files/mozjs38-1269317.patch | 124 +++++
14 .../files/mozjs38-fix-tracelogger.patch | 605 +++++++++++++++++++++
15 .../files/spidermonkey-38-jsapi-tests.patch | 16 +
16 dev-lang/spidermonkey/metadata.xml | 4 +-
17 .../spidermonkey/spidermonkey-38.2.1_rc0.ebuild | 145 +++++
18 6 files changed, 894 insertions(+), 1 deletion(-)
19
20 diff --git a/dev-lang/spidermonkey/Manifest b/dev-lang/spidermonkey/Manifest
21 index 45577ad653..d6a76976d6 100644
22 --- a/dev-lang/spidermonkey/Manifest
23 +++ b/dev-lang/spidermonkey/Manifest
24 @@ -1,4 +1,5 @@
25 DIST js-1.7.0.tar.gz 1165607 SHA256 44363f0f3895800ee6010763eae90c0d15ed28e07d783bc7b3c607ce98d8668b SHA512 9d9fbd9c1dae969ca19ddb0f977ac56f3e0479ec393b859de252fcdd8b7fc325e80399073540884ed365ce56a3219be34c0db9300d5e50f32969660c90527e51 WHIRLPOOL 8044b306b3a1f0abed5ac8a6bf4f9ed70e1ebc6f83f44934a6306d9ed68cd73124f82e40430d764f158377031f5ee986595e58fdb52259ab6a3a8674eaf4eed1
26 DIST js185-1.0.0.tar.gz 6164605 SHA256 5d12f7e1f5b4a99436685d97b9b7b75f094d33580227aa998c406bbae6f2a687 SHA512 2af7122a7c7007fd7b6668776fe1222515a810b3e43bbf0f76b8f94e1ef406ffd3fb5ccec393021b00274c05b38a77235bc8d6886994c56762fcaf0aa7cf6718 WHIRLPOOL 58b372713275874d3ae3c6b58c12c56bf8d17d024d591e321538bcdd8e615332e41655954368ce86b90e970209e3fd650c39d931000880f5ec22cb044b5d7a4e
27 DIST mozjs-24.2.0.tar.bz2 15624530 SHA256 e62f3f331ddd90df1e238c09d61a505c516fe9fd8c5c95336611d191d18437d8 SHA512 49805e256f6fa797505c01b7596d5bb941ed7a2454862c52ed42ad48b5ae4540b777e77ed8da1b98c89f8622ed2c76052187983687008a4ff53594addb328df4 WHIRLPOOL ea74d19c79b1a0fe407e2803900c49c23e8b76444fb4e20995072c3c59427e8df1895df04f2f4de779a1c58cd1166dd97aeaf7564350832011efe89dbcf9583e
28 +DIST mozjs-38.2.1.rc0.tar.bz2 25012381 SHA256 01994c758174bc173bcf4960f05ecb4da21014f09641a63b2952bbf9eeaa8b5c SHA512 60262c7619cc418569aec81775a671105acbc5bf372273828868f2fbbbc4ea33f78380f7455710816bfcdae828fb4115a08234d599cb30d0db859fcba17f019d WHIRLPOOL b1661859dc41a61317a48a8ee34cab53a369f37067c6565db2c890c596411e51981e0e64f81c5f5bd2bc2ff943493d972b00a5984b99de6e07ce16c07f784cb7
29 DIST mozjs17.0.0.tar.gz 6778934 SHA256 321e964fe9386785d3bf80870640f2fa1c683e32fe988eeb201b04471c172fba SHA512 39b68aeb9f712f146778d8b68ee795709a1372c8ab893a222af4eb34882427d6f5cf877e743d6cb2f1b4348c194d8f3774f00cb775b03515b34b49560b748be4 WHIRLPOOL 4df7b51577787194065162b09d2c3dda849c13fa901305f9925d4ca5d38bb7f8e2daa943099e003fb9d11f9264ae2d77ccf04e5eea11e3ddcb624b504b99d52f
30
31 diff --git a/dev-lang/spidermonkey/files/mozjs38-1269317.patch b/dev-lang/spidermonkey/files/mozjs38-1269317.patch
32 new file mode 100644
33 index 0000000000..39cc6809af
34 --- /dev/null
35 +++ b/dev-lang/spidermonkey/files/mozjs38-1269317.patch
36 @@ -0,0 +1,124 @@
37 +from https://github.com/GNOME/jhbuild/blob/master/patches/mozjs38-1269317.patch
38 +
39 +--- a/js/src/jit/RegisterSets.h 2017-02-10 17:33:06.210702431 -0800
40 ++++ b/js/src/jit/RegisterSets.h 2017-02-10 17:43:52.877514146 -0800
41 +@@ -7,7 +7,6 @@
42 + #ifndef jit_RegisterSets_h
43 + #define jit_RegisterSets_h
44 +
45 +-#include "mozilla/Alignment.h"
46 + #include "mozilla/MathAlgorithms.h"
47 +
48 + #include "jit/JitAllocPolicy.h"
49 +@@ -26,8 +25,8 @@
50 + Code code_;
51 +
52 + public:
53 +- AnyRegister()
54 +- { }
55 ++ AnyRegister() = default;
56 ++
57 + explicit AnyRegister(Register gpr) {
58 + code_ = gpr.code();
59 + }
60 +@@ -156,7 +155,7 @@
61 + }
62 + #endif
63 +
64 +- ValueOperand() {}
65 ++ ValueOperand() = default;
66 + };
67 +
68 + // Registers to hold either either a typed or untyped value.
69 +@@ -165,46 +164,25 @@
70 + // Type of value being stored.
71 + MIRType type_;
72 +
73 +- // Space to hold either an AnyRegister or a ValueOperand.
74 + union U {
75 +- mozilla::AlignedStorage2<AnyRegister> typed;
76 +- mozilla::AlignedStorage2<ValueOperand> value;
77 ++ AnyRegister typed;
78 ++ ValueOperand value;
79 + } data;
80 +
81 +- AnyRegister& dataTyped() {
82 +- MOZ_ASSERT(hasTyped());
83 +- return *data.typed.addr();
84 +- }
85 +- ValueOperand& dataValue() {
86 +- MOZ_ASSERT(hasValue());
87 +- return *data.value.addr();
88 +- }
89 +-
90 +- AnyRegister dataTyped() const {
91 +- MOZ_ASSERT(hasTyped());
92 +- return *data.typed.addr();
93 +- }
94 +- const ValueOperand& dataValue() const {
95 +- MOZ_ASSERT(hasValue());
96 +- return *data.value.addr();
97 +- }
98 +-
99 + public:
100 +
101 +- TypedOrValueRegister()
102 +- : type_(MIRType_None)
103 +- {}
104 ++ TypedOrValueRegister() = default;
105 +
106 + TypedOrValueRegister(MIRType type, AnyRegister reg)
107 + : type_(type)
108 + {
109 +- dataTyped() = reg;
110 ++ data.typed = reg;
111 + }
112 +
113 + MOZ_IMPLICIT TypedOrValueRegister(ValueOperand value)
114 + : type_(MIRType_Value)
115 + {
116 +- dataValue() = value;
117 ++ data.value = value;
118 + }
119 +
120 + MIRType type() const {
121 +@@ -220,11 +198,13 @@
122 + }
123 +
124 + AnyRegister typedReg() const {
125 +- return dataTyped();
126 ++ MOZ_ASSERT(hasTyped());
127 ++ return data.typed;
128 + }
129 +
130 + ValueOperand valueReg() const {
131 +- return dataValue();
132 ++ MOZ_ASSERT(hasValue());
133 ++ return data.value;
134 + }
135 +
136 + AnyRegister scratchReg() {
137 +@@ -240,19 +220,18 @@
138 + // Whether a constant value is being stored.
139 + bool constant_;
140 +
141 +- // Space to hold either a Value or a TypedOrValueRegister.
142 + union U {
143 +- mozilla::AlignedStorage2<Value> constant;
144 +- mozilla::AlignedStorage2<TypedOrValueRegister> reg;
145 ++ Value constant;
146 ++ TypedOrValueRegister reg;
147 + } data;
148 +
149 + Value& dataValue() {
150 + MOZ_ASSERT(constant());
151 +- return *data.constant.addr();
152 ++ return data.constant;
153 + }
154 + TypedOrValueRegister& dataReg() {
155 + MOZ_ASSERT(!constant());
156 +- return *data.reg.addr();
157 ++ return data.reg;
158 + }
159 +
160 + public:
161
162 diff --git a/dev-lang/spidermonkey/files/mozjs38-fix-tracelogger.patch b/dev-lang/spidermonkey/files/mozjs38-fix-tracelogger.patch
163 new file mode 100644
164 index 0000000000..2197f617a0
165 --- /dev/null
166 +++ b/dev-lang/spidermonkey/files/mozjs38-fix-tracelogger.patch
167 @@ -0,0 +1,605 @@
168 +from https://github.com/GNOME/jhbuild/blob/master/patches/mozjs38-fix-tracelogger.patch
169 +
170 +# === Fix the SM38 tracelogger ===
171 +# This patch is a squashed version of several patches that were adapted
172 +# to fix failing hunks.
173 +#
174 +# Applied in the following order, they are:
175 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1223767
176 +# Assertion failure: i < size_, at js/src/vm/TraceLoggingTypes.h:210
177 +# Also fix stop-information to make reduce.py work correctly.
178 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1227914
179 +# Limit the memory tracelogger can take.
180 +# This causes tracelogger to flush data to the disk regularly and prevents out of
181 +# memory issues if a lot of data gets logged.
182 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1155618
183 +# Fix tracelogger destructor that touches possibly uninitialised hash table.
184 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1223636
185 +# Don't treat extraTextId as containing only extra ids.
186 +# This fixes an assertion failure: id == nextTextId at js/src/vm/TraceLoggingGraph.cpp
187 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1227028
188 +# Fix when to keep the payload of a TraceLogger event.
189 +# This fixes an assertion failure: textId < uint32_t(1 << 31) at js/src/vm/TraceLoggingGraph.h
190 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1266649
191 +# Handle failing to add to pointermap gracefully.
192 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1280648
193 +# Don't cache based on pointers to movable GC things.
194 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1224123
195 +# Fix the use of LastEntryId in tracelogger.h.
196 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1231170
197 +# Use size in debugger instead of the current id to track last logged item.
198 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1221844
199 +# Move TraceLogger_Invalidation to LOG_ITEM.
200 +# Add some debug checks to logTimestamp.
201 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1255766
202 +# Also mark resizing of memory.
203 +# * https://bugzilla.mozilla.org/show_bug.cgi?id=1259403
204 +# Only increase capacity by multiples of 2.
205 +# Always make sure there are 3 free slots for events.
206 +# ===
207 +
208 +diff --git a/js/src/jit-test/tests/tracelogger/bug1231170.js b/js/src/jit-test/tests/tracelogger/bug1231170.js
209 +new file mode 100644
210 +index 0000000..023e93e
211 +--- /dev/null
212 ++++ b/js/src/jit-test/tests/tracelogger/bug1231170.js
213 +@@ -0,0 +1,3 @@
214 ++var du = new Debugger();
215 ++if (typeof du.drainTraceLogger === "function")
216 ++ du.drainTraceLogger();
217 +diff --git a/js/src/jit-test/tests/tracelogger/bug1266649.js b/js/src/jit-test/tests/tracelogger/bug1266649.js
218 +new file mode 100644
219 +index 0000000..81ae7ad
220 +--- /dev/null
221 ++++ b/js/src/jit-test/tests/tracelogger/bug1266649.js
222 +@@ -0,0 +1,10 @@
223 ++
224 ++var du = new Debugger();
225 ++if (typeof du.setupTraceLogger === "function" &&
226 ++ typeof oomTest === 'function')
227 ++{
228 ++ du.setupTraceLogger({
229 ++ Scripts: true
230 ++ })
231 ++ oomTest(() => function(){});
232 ++}
233 +diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp
234 +index 93e2fda..09049d6 100644
235 +--- a/js/src/jit/Ion.cpp
236 ++++ b/js/src/jit/Ion.cpp
237 +@@ -1055,6 +1055,8 @@ IonScript::Destroy(FreeOp* fop, IonScript* script)
238 +
239 + script->destroyCaches();
240 + script->unlinkFromRuntime(fop);
241 ++ // Frees the potential event we have set.
242 ++ script->traceLoggerScriptEvent_ = TraceLoggerEvent();
243 + fop->free_(script);
244 + }
245 +
246 +diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp
247 +index 26262fd..af7f313 100644
248 +--- a/js/src/vm/Debugger.cpp
249 ++++ b/js/src/vm/Debugger.cpp
250 +@@ -369,10 +369,10 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg)
251 + objects(cx),
252 + environments(cx),
253 + #ifdef NIGHTLY_BUILD
254 +- traceLoggerLastDrainedId(0),
255 ++ traceLoggerLastDrainedSize(0),
256 + traceLoggerLastDrainedIteration(0),
257 + #endif
258 +- traceLoggerScriptedCallsLastDrainedId(0),
259 ++ traceLoggerScriptedCallsLastDrainedSize(0),
260 + traceLoggerScriptedCallsLastDrainedIteration(0)
261 + {
262 + assertSameCompartment(cx, dbg);
263 +@@ -3907,9 +3907,9 @@ Debugger::drainTraceLogger(JSContext* cx, unsigned argc, Value* vp)
264 + size_t num;
265 + TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
266 + bool lostEvents = logger->lostEvents(dbg->traceLoggerLastDrainedIteration,
267 +- dbg->traceLoggerLastDrainedId);
268 ++ dbg->traceLoggerLastDrainedSize);
269 + EventEntry* events = logger->getEventsStartingAt(&dbg->traceLoggerLastDrainedIteration,
270 +- &dbg->traceLoggerLastDrainedId,
271 ++ &dbg->traceLoggerLastDrainedSize,
272 + &num);
273 +
274 + RootedObject array(cx, NewDenseEmptyArray(cx));
275 +@@ -4002,10 +4002,10 @@ Debugger::drainTraceLoggerScriptCalls(JSContext* cx, unsigned argc, Value* vp)
276 + size_t num;
277 + TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
278 + bool lostEvents = logger->lostEvents(dbg->traceLoggerScriptedCallsLastDrainedIteration,
279 +- dbg->traceLoggerScriptedCallsLastDrainedId);
280 ++ dbg->traceLoggerScriptedCallsLastDrainedSize);
281 + EventEntry* events = logger->getEventsStartingAt(
282 + &dbg->traceLoggerScriptedCallsLastDrainedIteration,
283 +- &dbg->traceLoggerScriptedCallsLastDrainedId,
284 ++ &dbg->traceLoggerScriptedCallsLastDrainedSize,
285 + &num);
286 +
287 + RootedObject array(cx, NewDenseEmptyArray(cx));
288 +diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h
289 +index 8cac36a..c92d685 100644
290 +--- a/js/src/vm/Debugger.h
291 ++++ b/js/src/vm/Debugger.h
292 +@@ -314,10 +314,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
293 + * lost events.
294 + */
295 + #ifdef NIGHTLY_BUILD
296 +- uint32_t traceLoggerLastDrainedId;
297 ++ uint32_t traceLoggerLastDrainedSize;
298 + uint32_t traceLoggerLastDrainedIteration;
299 + #endif
300 +- uint32_t traceLoggerScriptedCallsLastDrainedId;
301 ++ uint32_t traceLoggerScriptedCallsLastDrainedSize;
302 + uint32_t traceLoggerScriptedCallsLastDrainedIteration;
303 +
304 + class FrameRange;
305 +diff --git a/js/src/vm/TraceLogging.cpp b/js/src/vm/TraceLogging.cpp
306 +index 6715b36..9766a6f 100644
307 +--- a/js/src/vm/TraceLogging.cpp
308 ++++ b/js/src/vm/TraceLogging.cpp
309 +@@ -131,7 +131,7 @@ TraceLoggerThread::init()
310 + {
311 + if (!pointerMap.init())
312 + return false;
313 +- if (!extraTextId.init())
314 ++ if (!textIdPayloads.init())
315 + return false;
316 + if (!events.init())
317 + return false;
318 +@@ -185,10 +185,10 @@ TraceLoggerThread::~TraceLoggerThread()
319 + graph = nullptr;
320 + }
321 +
322 +- for (TextIdHashMap::Range r = extraTextId.all(); !r.empty(); r.popFront())
323 +- js_delete(r.front().value());
324 +- extraTextId.finish();
325 +- pointerMap.finish();
326 ++ if (textIdPayloads.initialized()) {
327 ++ for (TextIdHashMap::Range r = textIdPayloads.all(); !r.empty(); r.popFront())
328 ++ js_delete(r.front().value());
329 ++ }
330 + }
331 +
332 + bool
333 +@@ -287,7 +287,7 @@ TraceLoggerThread::eventText(uint32_t id)
334 + if (id < TraceLogger_Last)
335 + return TLTextIdString(static_cast<TraceLoggerTextId>(id));
336 +
337 +- TextIdHashMap::Ptr p = extraTextId.lookup(id);
338 ++ TextIdHashMap::Ptr p = textIdPayloads.lookup(id);
339 + MOZ_ASSERT(p);
340 +
341 + return p->value()->string();
342 +@@ -341,13 +341,15 @@ TraceLoggerThread::extractScriptDetails(uint32_t textId, const char** filename,
343 + TraceLoggerEventPayload*
344 + TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId textId)
345 + {
346 +- TextIdHashMap::AddPtr p = extraTextId.lookupForAdd(textId);
347 +- if (p)
348 ++ TextIdHashMap::AddPtr p = textIdPayloads.lookupForAdd(textId);
349 ++ if (p) {
350 ++ MOZ_ASSERT(p->value()->textId() == textId); // Sanity check.
351 + return p->value();
352 ++ }
353 +
354 + TraceLoggerEventPayload* payload = js_new<TraceLoggerEventPayload>(textId, (char*)nullptr);
355 +
356 +- if (!extraTextId.add(p, textId, payload))
357 ++ if (!textIdPayloads.add(p, textId, payload))
358 + return nullptr;
359 +
360 + return payload;
361 +@@ -357,8 +359,10 @@ TraceLoggerEventPayload*
362 + TraceLoggerThread::getOrCreateEventPayload(const char* text)
363 + {
364 + PointerHashMap::AddPtr p = pointerMap.lookupForAdd((const void*)text);
365 +- if (p)
366 ++ if (p) {
367 ++ MOZ_ASSERT(p->value()->textId() < nextTextId); // Sanity check.
368 + return p->value();
369 ++ }
370 +
371 + size_t len = strlen(text);
372 + char* str = js_pod_malloc<char>(len + 1);
373 +@@ -369,7 +373,7 @@ TraceLoggerThread::getOrCreateEventPayload(const char* text)
374 + MOZ_ASSERT(ret == len);
375 + MOZ_ASSERT(strlen(str) == len);
376 +
377 +- uint32_t textId = extraTextId.count() + TraceLogger_Last;
378 ++ uint32_t textId = nextTextId;
379 +
380 + TraceLoggerEventPayload* payload = js_new<TraceLoggerEventPayload>(textId, str);
381 + if (!payload) {
382 +@@ -377,17 +381,19 @@ TraceLoggerThread::getOrCreateEventPayload(const char* text)
383 + return nullptr;
384 + }
385 +
386 +- if (!extraTextId.putNew(textId, payload)) {
387 ++ if (!textIdPayloads.putNew(textId, payload)) {
388 + js_delete(payload);
389 + return nullptr;
390 + }
391 +
392 +- if (!pointerMap.add(p, text, payload))
393 +- return nullptr;
394 +-
395 + if (graph.get())
396 + graph->addTextId(textId, str);
397 +
398 ++ nextTextId++;
399 ++
400 ++ if (!pointerMap.add(p, text, payload))
401 ++ return nullptr;
402 ++
403 + return payload;
404 + }
405 +
406 +@@ -407,9 +413,14 @@ TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const char* f
407 + if (!traceLoggerState->isTextIdEnabled(type))
408 + return getOrCreateEventPayload(type);
409 +
410 +- PointerHashMap::AddPtr p = pointerMap.lookupForAdd(ptr);
411 +- if (p)
412 +- return p->value();
413 ++ PointerHashMap::AddPtr p;
414 ++ if (ptr) {
415 ++ p = pointerMap.lookupForAdd(ptr);
416 ++ if (p) {
417 ++ MOZ_ASSERT(p->value()->textId() < nextTextId); // Sanity check.
418 ++ return p->value();
419 ++ }
420 ++ }
421 +
422 + // Compute the length of the string to create.
423 + size_t lenFilename = strlen(filename);
424 +@@ -428,24 +439,28 @@ TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const char* f
425 + MOZ_ASSERT(ret == len);
426 + MOZ_ASSERT(strlen(str) == len);
427 +
428 +- uint32_t textId = extraTextId.count() + TraceLogger_Last;
429 ++ uint32_t textId = nextTextId;
430 + TraceLoggerEventPayload* payload = js_new<TraceLoggerEventPayload>(textId, str);
431 + if (!payload) {
432 + js_free(str);
433 + return nullptr;
434 + }
435 +
436 +- if (!extraTextId.putNew(textId, payload)) {
437 ++ if (!textIdPayloads.putNew(textId, payload)) {
438 + js_delete(payload);
439 + return nullptr;
440 + }
441 +
442 +- if (!pointerMap.add(p, ptr, payload))
443 +- return nullptr;
444 +-
445 + if (graph.get())
446 + graph->addTextId(textId, str);
447 +
448 ++ nextTextId++;
449 ++
450 ++ if (ptr) {
451 ++ if (!pointerMap.add(p, ptr, payload))
452 ++ return nullptr;
453 ++ }
454 ++
455 + return payload;
456 + }
457 +
458 +@@ -453,14 +468,14 @@ TraceLoggerEventPayload*
459 + TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, JSScript* script)
460 + {
461 + return getOrCreateEventPayload(type, script->filename(), script->lineno(), script->column(),
462 +- script);
463 ++ nullptr);
464 + }
465 +
466 + TraceLoggerEventPayload*
467 + TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type,
468 + const JS::ReadOnlyCompileOptions& script)
469 + {
470 +- return getOrCreateEventPayload(type, script.filename(), script.lineno, script.column, &script);
471 ++ return getOrCreateEventPayload(type, script.filename(), script.lineno, script.column, nullptr);
472 + }
473 +
474 + void
475 +@@ -485,7 +500,7 @@ TraceLoggerThread::startEvent(uint32_t id)
476 + if (!traceLoggerState->isTextIdEnabled(id))
477 + return;
478 +
479 +- logTimestamp(id);
480 ++ log(id);
481 + }
482 +
483 + void
484 +@@ -510,7 +525,7 @@ TraceLoggerThread::stopEvent(uint32_t id)
485 + if (!traceLoggerState->isTextIdEnabled(id))
486 + return;
487 +
488 +- logTimestamp(TraceLogger_Stop);
489 ++ log(TraceLogger_Stop);
490 + }
491 +
492 + void
493 +@@ -522,23 +537,57 @@ TraceLoggerThread::logTimestamp(TraceLoggerTextId id)
494 + void
495 + TraceLoggerThread::logTimestamp(uint32_t id)
496 + {
497 ++ MOZ_ASSERT(id > TraceLogger_LastTreeItem && id < TraceLogger_Last);
498 ++ log(id);
499 ++}
500 ++
501 ++void
502 ++TraceLoggerThread::log(uint32_t id)
503 ++{
504 + if (enabled == 0)
505 + return;
506 +
507 + MOZ_ASSERT(traceLoggerState);
508 +- if (!events.ensureSpaceBeforeAdd()) {
509 ++
510 ++ // We request for 3 items to add, since if we don't have enough room
511 ++ // we record the time it took to make more place. To log this information
512 ++ // we need 2 extra free entries.
513 ++ if (!events.hasSpaceForAdd(3)) {
514 + uint64_t start = rdtsc() - traceLoggerState->startupTime;
515 +
516 +- if (graph.get())
517 +- graph->log(events);
518 ++ if (!events.ensureSpaceBeforeAdd(3)) {
519 ++ if (graph.get())
520 ++ graph->log(events);
521 ++
522 ++ iteration_++;
523 ++ events.clear();
524 ++
525 ++ // Remove the item in the pointerMap for which the payloads
526 ++ // have no uses anymore
527 ++ for (PointerHashMap::Enum e(pointerMap); !e.empty(); e.popFront()) {
528 ++ if (e.front().value()->uses() != 0)
529 ++ continue;
530 ++
531 ++ TextIdHashMap::Ptr p = textIdPayloads.lookup(e.front().value()->textId());
532 ++ MOZ_ASSERT(p);
533 ++ textIdPayloads.remove(p);
534 ++
535 ++ e.removeFront();
536 ++ }
537 +
538 +- iteration_++;
539 +- events.clear();
540 ++ // Free all payloads that have no uses anymore.
541 ++ for (TextIdHashMap::Enum e(textIdPayloads); !e.empty(); e.popFront()) {
542 ++ if (e.front().value()->uses() == 0) {
543 ++ js_delete(e.front().value());
544 ++ e.removeFront();
545 ++ }
546 ++ }
547 ++ }
548 +
549 + // Log the time it took to flush the events as being from the
550 + // Tracelogger.
551 + if (graph.get()) {
552 +- MOZ_ASSERT(events.capacity() > 2);
553 ++ MOZ_ASSERT(events.hasSpaceForAdd(2));
554 + EventEntry& entryStart = events.pushUninitialized();
555 + entryStart.time = start;
556 + entryStart.textId = TraceLogger_Internal;
557 +@@ -548,13 +597,6 @@ TraceLoggerThread::logTimestamp(uint32_t id)
558 + entryStop.textId = TraceLogger_Stop;
559 + }
560 +
561 +- // Free all TextEvents that have no uses anymore.
562 +- for (TextIdHashMap::Enum e(extraTextId); !e.empty(); e.popFront()) {
563 +- if (e.front().value()->uses() == 0) {
564 +- js_delete(e.front().value());
565 +- e.removeFront();
566 +- }
567 +- }
568 + }
569 +
570 + uint64_t time = rdtsc() - traceLoggerState->startupTime;
571 +@@ -956,3 +998,16 @@ TraceLoggerEvent::~TraceLoggerEvent()
572 + if (payload_)
573 + payload_->release();
574 + }
575 ++
576 ++TraceLoggerEvent&
577 ++TraceLoggerEvent::operator=(const TraceLoggerEvent& other)
578 ++{
579 ++ if (hasPayload())
580 ++ payload()->release();
581 ++ if (other.hasPayload())
582 ++ other.payload()->use();
583 ++
584 ++ payload_ = other.payload_;
585 ++
586 ++ return *this;
587 ++}
588 +diff --git a/js/src/vm/TraceLogging.h b/js/src/vm/TraceLogging.h
589 +index a124dcb..91a1eb0 100644
590 +--- a/js/src/vm/TraceLogging.h
591 ++++ b/js/src/vm/TraceLogging.h
592 +@@ -110,6 +110,9 @@ class TraceLoggerEvent {
593 + bool hasPayload() const {
594 + return !!payload_;
595 + }
596 ++
597 ++ TraceLoggerEvent& operator=(const TraceLoggerEvent& other);
598 ++ TraceLoggerEvent(const TraceLoggerEvent& event) = delete;
599 + };
600 +
601 + /**
602 +@@ -130,6 +133,10 @@ class TraceLoggerEventPayload {
603 + uses_(0)
604 + { }
605 +
606 ++ ~TraceLoggerEventPayload() {
607 ++ MOZ_ASSERT(uses_ == 0);
608 ++ }
609 ++
610 + uint32_t textId() {
611 + return textId_;
612 + }
613 +@@ -166,7 +173,8 @@ class TraceLoggerThread
614 + mozilla::UniquePtr<TraceLoggerGraph> graph;
615 +
616 + PointerHashMap pointerMap;
617 +- TextIdHashMap extraTextId;
618 ++ TextIdHashMap textIdPayloads;
619 ++ uint32_t nextTextId;
620 +
621 + ContinuousSpace<EventEntry> events;
622 +
623 +@@ -181,6 +189,7 @@ class TraceLoggerThread
624 + : enabled(0),
625 + failed(false),
626 + graph(),
627 ++ nextTextId(TraceLogger_Last),
628 + iteration_(0),
629 + top(nullptr)
630 + { }
631 +@@ -195,22 +204,22 @@ class TraceLoggerThread
632 + bool enable(JSContext* cx);
633 + bool disable();
634 +
635 +- // Given the previous iteration and lastEntryId, return an array of events
636 ++ // Given the previous iteration and size, return an array of events
637 + // (there could be lost events). At the same time update the iteration and
638 +- // lastEntry and gives back how many events there are.
639 +- EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastEntryId, size_t* num) {
640 ++ // size and gives back how many events there are.
641 ++ EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastSize, size_t* num) {
642 + EventEntry* start;
643 + if (iteration_ == *lastIteration) {
644 +- MOZ_ASSERT(events.lastEntryId() >= *lastEntryId);
645 +- *num = events.lastEntryId() - *lastEntryId;
646 +- start = events.data() + *lastEntryId + 1;
647 ++ MOZ_ASSERT(*lastSize <= events.size());
648 ++ *num = events.size() - *lastSize;
649 ++ start = events.data() + *lastSize;
650 + } else {
651 +- *num = events.lastEntryId() + 1;
652 ++ *num = events.size();
653 + start = events.data();
654 + }
655 +
656 + *lastIteration = iteration_;
657 +- *lastEntryId = events.lastEntryId();
658 ++ *lastSize = events.size();
659 + return start;
660 + }
661 +
662 +@@ -220,16 +229,16 @@ class TraceLoggerThread
663 + const char** lineno, size_t* lineno_len, const char** colno,
664 + size_t* colno_len);
665 +
666 +- bool lostEvents(uint32_t lastIteration, uint32_t lastEntryId) {
667 ++ bool lostEvents(uint32_t lastIteration, uint32_t lastSize) {
668 + // If still logging in the same iteration, there are no lost events.
669 + if (lastIteration == iteration_) {
670 +- MOZ_ASSERT(lastEntryId <= events.lastEntryId());
671 ++ MOZ_ASSERT(lastSize <= events.size());
672 + return false;
673 + }
674 +
675 +- // When proceeded to the next iteration and lastEntryId points to
676 +- // the maximum capacity there are no logs that are lost.
677 +- if (lastIteration + 1 == iteration_ && lastEntryId == events.capacity())
678 ++ // If we are in a consecutive iteration we are only sure we didn't lose any events,
679 ++ // when the lastSize equals the maximum size 'events' can get.
680 ++ if (lastIteration == iteration_ - 1 && lastSize == events.maxSize())
681 + return false;
682 +
683 + return true;
684 +@@ -268,6 +277,7 @@ class TraceLoggerThread
685 + void stopEvent(uint32_t id);
686 + private:
687 + void stopEvent();
688 ++ void log(uint32_t id);
689 +
690 + public:
691 + static unsigned offsetOfEnabled() {
692 +diff --git a/js/src/vm/TraceLoggingGraph.cpp b/js/src/vm/TraceLoggingGraph.cpp
693 +index d1b7f2e..a4eb273 100644
694 +--- a/js/src/vm/TraceLoggingGraph.cpp
695 ++++ b/js/src/vm/TraceLoggingGraph.cpp
696 +@@ -276,7 +276,7 @@ TraceLoggerGraph::flush()
697 + if (bytesWritten < tree.size())
698 + return false;
699 +
700 +- treeOffset += tree.lastEntryId();
701 ++ treeOffset += tree.size();
702 + tree.clear();
703 + }
704 +
705 +@@ -359,7 +359,7 @@ TraceLoggerGraph::startEventInternal(uint32_t id, uint64_t timestamp)
706 +
707 + if (parent.lastChildId() == 0) {
708 + MOZ_ASSERT(!entry.hasChildren());
709 +- MOZ_ASSERT(parent.treeId() == tree.lastEntryId() + treeOffset);
710 ++ MOZ_ASSERT(parent.treeId() == treeOffset + tree.size() - 1);
711 +
712 + if (!updateHasChildren(parent.treeId()))
713 + return false;
714 +diff --git a/js/src/vm/TraceLoggingTypes.h b/js/src/vm/TraceLoggingTypes.h
715 +index f1c9d0c..10b76d6 100644
716 +--- a/js/src/vm/TraceLoggingTypes.h
717 ++++ b/js/src/vm/TraceLoggingTypes.h
718 +@@ -21,7 +21,6 @@
719 + _(Internal) \
720 + _(Interpreter) \
721 + _(InlinedScripts) \
722 +- _(Invalidation) \
723 + _(IonCompilation) \
724 + _(IonCompilationPaused) \
725 + _(IonLinking) \
726 +@@ -60,6 +59,7 @@
727 +
728 + #define TRACELOGGER_LOG_ITEMS(_) \
729 + _(Bailout) \
730 ++ _(Invalidation) \
731 + _(Disable) \
732 + _(Enable) \
733 + _(Stop)
734 +@@ -130,6 +130,9 @@ class ContinuousSpace {
735 + uint32_t size_;
736 + uint32_t capacity_;
737 +
738 ++ // The maximum amount of ram memory a continuous space structure can take (in bytes).
739 ++ static const uint32_t LIMIT = 200 * 1024 * 1024;
740 ++
741 + public:
742 + ContinuousSpace ()
743 + : data_(nullptr)
744 +@@ -151,6 +154,10 @@ class ContinuousSpace {
745 + data_ = nullptr;
746 + }
747 +
748 ++ static uint32_t maxSize() {
749 ++ return LIMIT / sizeof(T);
750 ++ }
751 ++
752 + T* data() {
753 + return data_;
754 + }
755 +@@ -187,11 +194,14 @@ class ContinuousSpace {
756 + if (hasSpaceForAdd(count))
757 + return true;
758 +
759 ++ // Limit the size of a continuous buffer.
760 ++ if (size_ + count > maxSize())
761 ++ return false;
762 ++
763 + uint32_t nCapacity = capacity_ * 2;
764 +- if (size_ + count > nCapacity)
765 +- nCapacity = size_ + count;
766 +- T* entries = (T*) js_realloc(data_, nCapacity * sizeof(T));
767 ++ nCapacity = (nCapacity < maxSize()) ? nCapacity : maxSize();
768 +
769 ++ T* entries = (T*) js_realloc(data_, nCapacity * sizeof(T));
770 + if (!entries)
771 + return false;
772 +
773
774 diff --git a/dev-lang/spidermonkey/files/spidermonkey-38-jsapi-tests.patch b/dev-lang/spidermonkey/files/spidermonkey-38-jsapi-tests.patch
775 new file mode 100644
776 index 0000000000..8b023fd318
777 --- /dev/null
778 +++ b/dev-lang/spidermonkey/files/spidermonkey-38-jsapi-tests.patch
779 @@ -0,0 +1,16 @@
780 +--- a/js/src/jsapi-tests/testPreserveJitCode.cpp 2015-09-17 16:12:22.000000000 -0400
781 ++++ b/js/src/jsapi-tests/testPreserveJitCode.cpp 2017-02-27 16:30:28.899191525 -0500
782 +@@ -16,8 +16,12 @@
783 +
784 + BEGIN_TEST(test_PreserveJitCode)
785 + {
786 ++#ifndef JS_CODEGEN_NONE
787 + CHECK(testPreserveJitCode(false, 0));
788 + CHECK(testPreserveJitCode(true, 1));
789 ++#else
790 ++ printf("*JIT is disabled, therefore CANNOT preserve jit code - skipping.\n");
791 ++#endif
792 + return true;
793 + }
794 +
795 +
796
797 diff --git a/dev-lang/spidermonkey/metadata.xml b/dev-lang/spidermonkey/metadata.xml
798 index 564a0ee481..83c60ddc3f 100644
799 --- a/dev-lang/spidermonkey/metadata.xml
800 +++ b/dev-lang/spidermonkey/metadata.xml
801 @@ -6,9 +6,11 @@
802 <name>Gentoo Mozilla Team</name>
803 </maintainer>
804 <longdescription lang="en">
805 - Stand-alone JavaScript C library
806 + Stand-alone JavaScript C++ library
807 </longdescription>
808 <use>
809 + <flag name="custom-optimization">Build with user-specified compiler optimizations
810 + (-Os, -O0, -O1, -O2, -O3) from CFLAGS (unsupported)</flag>
811 <flag name="debug">Enable assertions to allow for easier debugging of programs that link to spidermonkey -- note this will often crash software on regular end-user systems</flag>
812 <flag name="threadsafe">Build a threadsafe version of spidermonkey</flag>
813 <flag name="system-icu">Use the system-wide <pkg>dev-libs/icu</pkg> instead of bundled -- note, only takes effect when icu flag is enabled</flag>
814
815 diff --git a/dev-lang/spidermonkey/spidermonkey-38.2.1_rc0.ebuild b/dev-lang/spidermonkey/spidermonkey-38.2.1_rc0.ebuild
816 new file mode 100644
817 index 0000000000..6673931956
818 --- /dev/null
819 +++ b/dev-lang/spidermonkey/spidermonkey-38.2.1_rc0.ebuild
820 @@ -0,0 +1,145 @@
821 +# Copyright 1999-2017 Gentoo Foundation
822 +# Distributed under the terms of the GNU General Public License v2
823 +# $Id$
824 +
825 +EAPI=6
826 +WANT_AUTOCONF="2.1"
827 +PYTHON_COMPAT=( python2_7 )
828 +PYTHON_REQ_USE="threads"
829 +inherit autotools toolchain-funcs multilib python-any-r1 versionator pax-utils mozcoreconf-v4
830 +
831 +MY_PN="mozjs"
832 +MY_P="${MY_PN}-${PV/_/.}"
833 +DESCRIPTION="Stand-alone JavaScript C library"
834 +HOMEPAGE="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey"
835 +SRC_URI="https://people.mozilla.org/~sstangl/${MY_P}.tar.bz2"
836 +
837 +LICENSE="NPL-1.1"
838 +SLOT="38"
839 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
840 +IUSE="debug +jit minimal static-libs +system-icu test"
841 +
842 +RESTRICT="ia64? ( test )"
843 +
844 +#S="${WORKDIR}/${MY_P%.rc*}"
845 +S="${WORKDIR}/mozjs-38.0.0"
846 +BUILDDIR="${S}/js/src"
847 +
848 +RDEPEND=">=dev-libs/nspr-4.10.10
849 + virtual/libffi
850 + sys-libs/readline:0=
851 + >=sys-libs/zlib-1.2.3
852 + system-icu? ( >=dev-libs/icu-51.1:= )"
853 +DEPEND="${RDEPEND}
854 + ${PYTHON_DEPS}
855 + app-arch/zip
856 + virtual/pkgconfig"
857 +
858 +pkg_setup(){
859 + if [[ ${MERGE_TYPE} != "binary" ]]; then
860 + moz_pkgsetup
861 + fi
862 +}
863 +
864 +src_prepare() {
865 + eapply "${FILESDIR}"/${PN}-38-jsapi-tests-makefile.patch \
866 + "${FILESDIR}"/mozjs38-1269317.patch \
867 + "${FILESDIR}"/mozjs38-fix-tracelogger.patch
868 +
869 + eapply_user
870 +
871 + if [[ ${CHOST} == *-freebsd* ]]; then
872 + # Don't try to be smart, this does not work in cross-compile anyway
873 + ln -sfn "${BUILDDIR}/config/Linux_All.mk" "${S}/config/$(uname -s)$(uname -r).mk" || die
874 + fi
875 +
876 + cd "${BUILDDIR}" || die
877 + eautoconf
878 +}
879 +
880 +src_configure() {
881 + export SHELL=/bin/sh
882 + cd "${BUILDDIR}" || die
883 +
884 + econf \
885 + --enable-jemalloc \
886 + --enable-readline \
887 + --enable-threadsafe \
888 + --with-system-nspr \
889 + --enable-system-ffi \
890 + --disable-optimize \
891 + --with-intl-api \
892 + $(use_with system-icu) \
893 + $(use_enable debug) \
894 + $(use_enable jit yarr-jit) \
895 + $(use_enable jit ion) \
896 + $(use_enable static-libs static) \
897 + $(use_enable test tests)
898 +}
899 +
900 +cross_make() {
901 + emake \
902 + CFLAGS="${BUILD_CFLAGS}" \
903 + CXXFLAGS="${BUILD_CXXFLAGS}" \
904 + AR="${BUILD_AR}" \
905 + CC="${BUILD_CC}" \
906 + CXX="${BUILD_CXX}" \
907 + RANLIB="${BUILD_RANLIB}" \
908 + "$@"
909 +}
910 +src_compile() {
911 + cd "${BUILDDIR}" || die
912 + if tc-is-cross-compiler; then
913 + tc-export_build_env BUILD_{AR,CC,CXX,RANLIB}
914 + cross_make \
915 + MOZ_OPTIMIZE_FLAGS="" MOZ_DEBUG_FLAGS="" \
916 + HOST_OPTIMIZE_FLAGS="" MODULE_OPTIMIZE_FLAGS="" \
917 + MOZ_PGO_OPTIMIZE_FLAGS="" \
918 + host_jsoplengen host_jskwgen
919 + cross_make \
920 + MOZ_OPTIMIZE_FLAGS="" MOZ_DEBUG_FLAGS="" HOST_OPTIMIZE_FLAGS="" \
921 + -C config nsinstall
922 + mv {,native-}host_jskwgen || die
923 + mv {,native-}host_jsoplengen || die
924 + mv config/{,native-}nsinstall || die
925 + sed -i \
926 + -e 's@./host_jskwgen@./native-host_jskwgen@' \
927 + -e 's@./host_jsoplengen@./native-host_jsoplengen@' \
928 + Makefile || die
929 + sed -i -e 's@/nsinstall@/native-nsinstall@' config/config.mk || die
930 + rm -f config/host_nsinstall.o \
931 + config/host_pathsub.o \
932 + host_jskwgen.o \
933 + host_jsoplengen.o || die
934 + fi
935 +
936 + MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX%/}/bin/bash}" \
937 + emake \
938 + MOZ_OPTIMIZE_FLAGS="" MOZ_DEBUG_FLAGS="" \
939 + HOST_OPTIMIZE_FLAGS="" MODULE_OPTIMIZE_FLAGS="" \
940 + MOZ_PGO_OPTIMIZE_FLAGS=""
941 +}
942 +
943 +src_test() {
944 + cd "${BUILDDIR}/js/src/jsapi-tests" || die
945 + ./jsapi-tests || die
946 +}
947 +
948 +src_install() {
949 + cd "${BUILDDIR}" || die
950 + emake DESTDIR="${D}" install
951 +
952 + if ! use minimal; then
953 + if use jit; then
954 + pax-mark m "${ED}/usr/bin/js${SLOT}"
955 + fi
956 + else
957 + rm -f "${ED}/usr/bin/js${SLOT}"
958 + fi
959 +
960 + if ! use static-libs; then
961 + # We can't actually disable building of static libraries
962 + # They're used by the tests and in a few other places
963 + find "${D}" -iname '*.a' -delete || die
964 + fi
965 +}