Bug 793577 - Implement Return<T> for direct returns of unrooted GC pointers; r=billm r=njn

Return<T> wraps GC things that are returned from accessor methods.  The wrapper
helps to ensure correct rooting of the returned pointer and safe access while
unrooted.
This commit is contained in:
Terrence Cole
2012-09-26 11:13:20 -07:00
parent db798f4f71
commit 44b3dfe6c3
56 changed files with 705 additions and 269 deletions

View File

@@ -1503,6 +1503,8 @@ static JSBool
SendToGenerator(JSContext *cx, JSGeneratorOp op, HandleObject obj,
JSGenerator *gen, const Value &arg)
{
AssertCanGC();
if (gen->state == JSGEN_RUNNING || gen->state == JSGEN_CLOSING) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NESTING_GENERATOR);
return JS_FALSE;
@@ -1562,7 +1564,8 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, HandleObject obj,
PropertyIteratorObject *enumerators = cx->enumerators;
cx->enumerators = gen->enumerators;
ok = RunScript(cx, fp->script(), fp);
RootedScript script(cx, fp->script());
ok = RunScript(cx, script, fp);
gen->enumerators = cx->enumerators;
cx->enumerators = enumerators;