Skip to content

Commit

Permalink
Bug 1620853 - RelazifyFunctions testing function should preserve DoNo…
Browse files Browse the repository at this point in the history
…tRelazify. r=jandem

When using the `relazifyFunctions` testing method, we mark live scripts on
stack as DoNotRelazify. Previously we would clear this flag after the
operation was done, but this may conflict with other uses of the flag, such
as the debugger. Only rare test-only code is affected.

Differential Revision: https://phabricator.services.mozilla.com/D65904
  • Loading branch information
moztcampbell committed Mar 9, 2020
1 parent 5cf1e73 commit c4ae7bd
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions js/src/builtin/TestingFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,28 +672,26 @@ static bool GCParameter(JSContext* cx, unsigned argc, Value* vp) {
return true;
}

static void SetAllowRelazification(JSContext* cx, bool allow) {
JSRuntime* rt = cx->runtime();
MOZ_ASSERT(rt->allowRelazificationForTesting != allow);
rt->allowRelazificationForTesting = allow;

for (AllScriptFramesIter i(cx); !i.done(); ++i) {
i.script()->setDoNotRelazify(allow);
}
}

static bool RelazifyFunctions(JSContext* cx, unsigned argc, Value* vp) {
// Relazifying functions on GC is usually only done for compartments that are
// not active. To aid fuzzing, this testing function allows us to relazify
// even if the compartment is active.

CallArgs args = CallArgsFromVp(argc, vp);
SetAllowRelazification(cx, true);

// Disable relazification of all scripts on stack. It is a pervasive
// assumption in the engine that running scripts still have bytecode.
for (AllScriptFramesIter i(cx); !i.done(); ++i) {
i.script()->setDoNotRelazify();
}

cx->runtime()->allowRelazificationForTesting = true;

JS::PrepareForFullGC(cx);
JS::NonIncrementalGC(cx, GC_SHRINK, JS::GCReason::API);

SetAllowRelazification(cx, false);
cx->runtime()->allowRelazificationForTesting = false;

args.rval().setUndefined();
return true;
}
Expand Down

0 comments on commit c4ae7bd

Please sign in to comment.