Skip to content
Browse files

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 : 8d31ffd349bcbaca3f2bbbcd0c4b5a099d57ec21
  • Loading branch information...
1 parent d06732c commit c5f0062dc70db49485a2f8d7c2c197a3bcf3b2cf @terrence2 terrence2 committed Dec 20, 2011
Showing with 9 additions and 10 deletions.
  1. +9 −10 js/src/jsexn.cpp
View
19 js/src/jsexn.cpp
@@ -256,7 +256,7 @@ CopyErrorReport(JSContext *cx, JSErrorReport *report)
return copy;
}
-static jsval *
+static HeapValue *
GetStackTraceValueBuffer(JSExnPrivate *priv)
{
/*
@@ -267,7 +267,7 @@ GetStackTraceValueBuffer(JSExnPrivate *priv)
*/
JS_STATIC_ASSERT(sizeof(JSStackTraceElem) % sizeof(jsval) == 0);
- return (jsval *)(priv->stackElems + priv->stackDepth);
+ return reinterpret_cast<HeapValue *>(priv->stackElems + priv->stackDepth);
}
struct SuppressErrorsGuard
@@ -359,7 +359,7 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
size_t nbytes = offsetof(JSExnPrivate, stackElems) +
frames.length() * sizeof(JSStackTraceElem) +
- values.length() * sizeof(Value);
+ values.length() * sizeof(HeapValue);
JSExnPrivate *priv = (JSExnPrivate *)cx->malloc_(nbytes);
if (!priv)
@@ -391,11 +391,12 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
priv->exnType = exnType;
JSStackTraceElem *framesDest = priv->stackElems;
- Value *valuesDest = reinterpret_cast<Value *>(framesDest + frames.length());
+ HeapValue *valuesDest = reinterpret_cast<HeapValue *>(framesDest + frames.length());
JS_ASSERT(valuesDest == GetStackTraceValueBuffer(priv));
PodCopy(framesDest, frames.begin(), frames.length());
- PodCopy(valuesDest, values.begin(), values.length());
+ for (size_t i = 0; i < values.length(); ++i)
+ valuesDest[i].init(cx->compartment, values[i]);
SetExnPrivate(cx, exnObject, priv);
return true;
@@ -414,7 +415,7 @@ exn_trace(JSTracer *trc, JSObject *obj)
JSExnPrivate *priv;
JSStackTraceElem *elem;
size_t vcount, i;
- jsval *vp, v;
+ HeapValue *vp;
priv = GetExnPrivate(obj);
if (priv) {
@@ -433,9 +434,7 @@ exn_trace(JSTracer *trc, JSObject *obj)
}
vp = GetStackTraceValueBuffer(priv);
for (i = 0; i != vcount; ++i, ++vp) {
- /* This value is read-only, so it's okay for it to be Unbarriered. */
- v = *vp;
- MarkValueUnbarriered(trc, v, "stack trace argument");
+ MarkValue(trc, *vp, "stack trace argument");
}
}
}
@@ -605,7 +604,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
jschar *stackbuf;
size_t stacklen, stackmax;
JSStackTraceElem *elem, *endElem;
- jsval *values;
+ HeapValue *values;
size_t i;
JSString *str;
const char *cp;

0 comments on commit c5f0062

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