Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug 712460 - Add missing barriers in jsexn; r=billm

When we create an exception object, we copy Values into a custom exception
privates struct that we pass around.  If any of the Values copied to this
struct are gcthings in the nursery, this external array needs to root them.

--HG--
extra : rebase_source : 8d31ffd
  • Loading branch information...
commit c5f0062dc70db49485a2f8d7c2c197a3bcf3b2cf 1 parent d06732c
Terrence Cole terrence2 authored

Showing 1 changed file with 9 additions and 10 deletions. Show diff stats Hide diff stats

  1. +9 10 js/src/jsexn.cpp
19 js/src/jsexn.cpp
@@ -256,7 +256,7 @@ CopyErrorReport(JSContext *cx, JSErrorReport *report)
256 256 return copy;
257 257 }
258 258
259   -static jsval *
  259 +static HeapValue *
260 260 GetStackTraceValueBuffer(JSExnPrivate *priv)
261 261 {
262 262 /*
@@ -267,7 +267,7 @@ GetStackTraceValueBuffer(JSExnPrivate *priv)
267 267 */
268 268 JS_STATIC_ASSERT(sizeof(JSStackTraceElem) % sizeof(jsval) == 0);
269 269
270   - return (jsval *)(priv->stackElems + priv->stackDepth);
  270 + return reinterpret_cast<HeapValue *>(priv->stackElems + priv->stackDepth);
271 271 }
272 272
273 273 struct SuppressErrorsGuard
@@ -359,7 +359,7 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
359 359
360 360 size_t nbytes = offsetof(JSExnPrivate, stackElems) +
361 361 frames.length() * sizeof(JSStackTraceElem) +
362   - values.length() * sizeof(Value);
  362 + values.length() * sizeof(HeapValue);
363 363
364 364 JSExnPrivate *priv = (JSExnPrivate *)cx->malloc_(nbytes);
365 365 if (!priv)
@@ -391,11 +391,12 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
391 391 priv->exnType = exnType;
392 392
393 393 JSStackTraceElem *framesDest = priv->stackElems;
394   - Value *valuesDest = reinterpret_cast<Value *>(framesDest + frames.length());
  394 + HeapValue *valuesDest = reinterpret_cast<HeapValue *>(framesDest + frames.length());
395 395 JS_ASSERT(valuesDest == GetStackTraceValueBuffer(priv));
396 396
397 397 PodCopy(framesDest, frames.begin(), frames.length());
398   - PodCopy(valuesDest, values.begin(), values.length());
  398 + for (size_t i = 0; i < values.length(); ++i)
  399 + valuesDest[i].init(cx->compartment, values[i]);
399 400
400 401 SetExnPrivate(cx, exnObject, priv);
401 402 return true;
@@ -414,7 +415,7 @@ exn_trace(JSTracer *trc, JSObject *obj)
414 415 JSExnPrivate *priv;
415 416 JSStackTraceElem *elem;
416 417 size_t vcount, i;
417   - jsval *vp, v;
  418 + HeapValue *vp;
418 419
419 420 priv = GetExnPrivate(obj);
420 421 if (priv) {
@@ -433,9 +434,7 @@ exn_trace(JSTracer *trc, JSObject *obj)
433 434 }
434 435 vp = GetStackTraceValueBuffer(priv);
435 436 for (i = 0; i != vcount; ++i, ++vp) {
436   - /* This value is read-only, so it's okay for it to be Unbarriered. */
437   - v = *vp;
438   - MarkValueUnbarriered(trc, v, "stack trace argument");
  437 + MarkValue(trc, *vp, "stack trace argument");
439 438 }
440 439 }
441 440 }
@@ -605,7 +604,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
605 604 jschar *stackbuf;
606 605 size_t stacklen, stackmax;
607 606 JSStackTraceElem *elem, *endElem;
608   - jsval *values;
  607 + HeapValue *values;
609 608 size_t i;
610 609 JSString *str;
611 610 const char *cp;

0 comments on commit c5f0062

Please sign in to comment.
Something went wrong with that request. Please try again.