Bug 1257045 - Give Debugger wrappers of wasm code their own CCW key kinds. (r=jimb)

This commit is contained in:
Shu-yu Guo 2016-03-17 18:53:04 -07:00
Родитель 0f91ae27d6
Коммит ecec854b11
6 изменённых файлов: 25 добавлений и 5 удалений

Просмотреть файл

@ -149,6 +149,8 @@ JS::TraceIncomingCCWs(JSTracer* trc, const JS::CompartmentSet& compartments)
case CrossCompartmentKey::DebuggerObject:
case CrossCompartmentKey::DebuggerSource:
case CrossCompartmentKey::DebuggerEnvironment:
case CrossCompartmentKey::DebuggerWasmScript:
case CrossCompartmentKey::DebuggerWasmSource:
obj = static_cast<JSObject*>(key.wrapped);
// Ignore CCWs whose wrapped value doesn't live in our given
// set of zones.

Просмотреть файл

@ -0,0 +1,8 @@
fullcompartmentchecks(true);
var g = newGlobal();
var dbg = new Debugger(g);
dbg.onNewScript = (function(script) {
s = script;
})
g.eval(`Wasm.instantiateModule(wasmTextToBinary('(module (func) (export "" 0))'));`);
s.source;

Просмотреть файл

@ -226,7 +226,9 @@ class WrapperMapRef : public BufferableRef
if (key.kind == CrossCompartmentKey::ObjectWrapper ||
key.kind == CrossCompartmentKey::DebuggerObject ||
key.kind == CrossCompartmentKey::DebuggerEnvironment ||
key.kind == CrossCompartmentKey::DebuggerSource)
key.kind == CrossCompartmentKey::DebuggerSource ||
key.kind == CrossCompartmentKey::DebuggerWasmScript ||
key.kind == CrossCompartmentKey::DebuggerWasmSource)
{
MOZ_ASSERT(IsInsideNursery(key.wrapped) ||
key.wrapped->asTenured().getTraceKind() == JS::TraceKind::Object);
@ -767,6 +769,8 @@ CrossCompartmentKey::needsSweep()
case CrossCompartmentKey::DebuggerObject:
case CrossCompartmentKey::DebuggerEnvironment:
case CrossCompartmentKey::DebuggerSource:
case CrossCompartmentKey::DebuggerWasmScript:
case CrossCompartmentKey::DebuggerWasmSource:
MOZ_ASSERT(IsInsideNursery(wrapped) ||
wrapped->asTenured().getTraceKind() == JS::TraceKind::Object);
keyDying = IsAboutToBeFinalizedUnbarriered(reinterpret_cast<JSObject**>(&wrapped));

Просмотреть файл

@ -73,7 +73,9 @@ struct CrossCompartmentKey
DebuggerScript,
DebuggerSource,
DebuggerObject,
DebuggerEnvironment
DebuggerEnvironment,
DebuggerWasmScript,
DebuggerWasmSource
};
Kind kind;

Просмотреть файл

@ -4146,6 +4146,8 @@ GCRuntime::markCompartments()
case CrossCompartmentKey::DebuggerObject:
case CrossCompartmentKey::DebuggerSource:
case CrossCompartmentKey::DebuggerEnvironment:
case CrossCompartmentKey::DebuggerWasmScript:
case CrossCompartmentKey::DebuggerWasmSource:
dest = static_cast<JSObject*>(key.wrapped)->compartment();
break;
case CrossCompartmentKey::DebuggerScript:
@ -4589,7 +4591,9 @@ JSCompartment::findOutgoingEdges(ComponentFinder<JS::Zone>& finder)
MOZ_ASSERT(kind == CrossCompartmentKey::DebuggerScript ||
kind == CrossCompartmentKey::DebuggerSource ||
kind == CrossCompartmentKey::DebuggerObject ||
kind == CrossCompartmentKey::DebuggerEnvironment);
kind == CrossCompartmentKey::DebuggerEnvironment ||
kind == CrossCompartmentKey::DebuggerWasmScript ||
kind == CrossCompartmentKey::DebuggerWasmSource);
/*
* Add edge for debugger object wrappers, to ensure (in conjuction
* with call to Debugger::findCompartmentEdges below) that debugger

Просмотреть файл

@ -5010,7 +5010,7 @@ Debugger::wrapVariantReferent(JSContext* cx, Handle<DebuggerScriptReferent> refe
cx, scripts, CrossCompartmentKey::DebuggerScript, referent);
} else {
obj = wrapVariantReferent<DebuggerScriptReferent, WasmModuleObject*, WasmModuleWeakMap>(
cx, wasmModuleScripts, CrossCompartmentKey::DebuggerObject, referent);
cx, wasmModuleScripts, CrossCompartmentKey::DebuggerWasmScript, referent);
}
MOZ_ASSERT_IF(obj, GetScriptReferent(obj) == referent);
return obj;
@ -6253,7 +6253,7 @@ Debugger::wrapVariantReferent(JSContext* cx, Handle<DebuggerSourceReferent> refe
cx, sources, CrossCompartmentKey::DebuggerSource, referent);
} else {
obj = wrapVariantReferent<DebuggerSourceReferent, WasmModuleObject*, WasmModuleWeakMap>(
cx, wasmModuleSources, CrossCompartmentKey::DebuggerObject, referent);
cx, wasmModuleSources, CrossCompartmentKey::DebuggerWasmSource, referent);
}
MOZ_ASSERT_IF(obj, GetSourceReferent(obj) == referent);
return obj;