Lines Matching refs:cx

170 JSScript* js::GetOrCreateFunctionScript(JSContext* cx, HandleFunction fun) {  in GetOrCreateFunctionScript()  argument
172 AutoRealm ar(cx, fun); in GetOrCreateFunctionScript()
173 return JSFunction::getOrCreateScript(cx, fun); in GetOrCreateFunctionScript()
176 ArrayObject* js::GetFunctionParameterNamesArray(JSContext* cx, in GetFunctionParameterNamesArray() argument
178 RootedValueVector names(cx); in GetFunctionParameterNamesArray()
186 RootedScript script(cx, GetOrCreateFunctionScript(cx, fun)); in GetFunctionParameterNamesArray()
199 cx->markAtom(atom); in GetFunctionParameterNamesArray()
206 return NewDenseCopiedArray(cx, names.length(), names.begin()); in GetFunctionParameterNamesArray()
209 bool js::ValueToIdentifier(JSContext* cx, HandleValue v, MutableHandleId id) { in ValueToIdentifier() argument
210 if (!ToPropertyKey(cx, v, id)) { in ValueToIdentifier()
214 RootedValue val(cx, v); in ValueToIdentifier()
215 ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, val, in ValueToIdentifier()
242 bool DebugAPI::slowPathCheckNoExecute(JSContext* cx, HandleScript script) { in slowPathCheckNoExecute() argument
243 MOZ_ASSERT(cx->realm()->isDebuggee()); in slowPathCheckNoExecute()
244 MOZ_ASSERT(cx->noExecuteDebuggerTop); in slowPathCheckNoExecute()
245 return EnterDebuggeeNoExecute::reportIfFoundInStack(cx, script); in slowPathCheckNoExecute()
254 static void PropagateForcedReturn(JSContext* cx, AbstractFramePtr frame, in PropagateForcedReturn() argument
264 MOZ_ASSERT(!cx->isExceptionPending()); in PropagateForcedReturn()
265 cx->setPropagatingForcedReturn(); in PropagateForcedReturn()
269 [[nodiscard]] static bool AdjustGeneratorResumptionValue(JSContext* cx,
274 [[nodiscard]] static bool ApplyFrameResumeMode(JSContext* cx, in ApplyFrameResumeMode() argument
279 RootedValue rval(cx, rv); in ApplyFrameResumeMode()
284 if (!cx->compartment()->wrap(cx, &rval)) { in ApplyFrameResumeMode()
288 if (!AdjustGeneratorResumptionValue(cx, frame, resumeMode, &rval)) { in ApplyFrameResumeMode()
300 cx->setPendingException(rval, exnStack); in ApplyFrameResumeMode()
302 cx->setPendingExceptionAndCaptureStack(rval); in ApplyFrameResumeMode()
307 cx->clearPendingException(); in ApplyFrameResumeMode()
311 PropagateForcedReturn(cx, frame, rval); in ApplyFrameResumeMode()
320 static bool ApplyFrameResumeMode(JSContext* cx, AbstractFramePtr frame, in ApplyFrameResumeMode() argument
322 RootedSavedFrame nullStack(cx); in ApplyFrameResumeMode()
323 return ApplyFrameResumeMode(cx, frame, resumeMode, rval, nullStack); in ApplyFrameResumeMode()
326 bool js::ValueToStableChars(JSContext* cx, const char* fnname, in ValueToStableChars() argument
330 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in ValueToStableChars()
335 RootedLinearString linear(cx, value.toString()->ensureLinear(cx)); in ValueToStableChars()
339 if (!stableChars.initTwoByte(cx, linear)) { in ValueToStableChars()
345 bool EvalOptions::setFilename(JSContext* cx, const char* filename) { in setFilename() argument
348 copy = DuplicateString(cx, filename); in setFilename()
358 bool js::ParseEvalOptions(JSContext* cx, HandleValue value, in ParseEvalOptions() argument
364 RootedObject opts(cx, &value.toObject()); in ParseEvalOptions()
366 RootedValue v(cx); in ParseEvalOptions()
367 if (!JS_GetProperty(cx, opts, "url", &v)) { in ParseEvalOptions()
371 RootedString url_str(cx, ToString<CanGC>(cx, v)); in ParseEvalOptions()
375 UniqueChars url_bytes = JS_EncodeStringToLatin1(cx, url_str); in ParseEvalOptions()
379 if (!options.setFilename(cx, url_bytes.get())) { in ParseEvalOptions()
384 if (!JS_GetProperty(cx, opts, "lineNumber", &v)) { in ParseEvalOptions()
389 if (!ToUint32(cx, v, &lineno)) { in ParseEvalOptions()
519 Debugger::Debugger(JSContext* cx, NativeObject* dbg) in Debugger() argument
521 debuggees(cx->zone()), in Debugger()
525 observedGCs(cx->zone()), in Debugger()
526 allocationsLog(cx), in Debugger()
531 frames(cx->zone()), in Debugger()
532 generatorFrames(cx), in Debugger()
533 scripts(cx), in Debugger()
534 sources(cx), in Debugger()
535 objects(cx), in Debugger()
536 environments(cx), in Debugger()
537 wasmInstanceScripts(cx), in Debugger()
538 wasmInstanceSources(cx), in Debugger()
545 cx->check(dbg); in Debugger()
548 TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx); in Debugger()
559 cx->runtime()->debuggerList().insertBack(this); in Debugger()
585 JSContext* cx = TlsContext.get(); in ~Debugger() local
586 RemoveDebuggerEntry(cx->runtime()->onNewGlobalObjectWatchers(), this); in ~Debugger()
587 RemoveDebuggerEntry(cx->runtime()->onGarbageCollectionWatchers(), this); in ~Debugger()
614 bool Debugger::getFrame(JSContext* cx, const FrameIter& iter, in getFrame() argument
616 RootedDebuggerFrame result(cx); in getFrame()
617 if (!Debugger::getFrame(cx, iter, &result)) { in getFrame()
624 bool Debugger::getFrame(JSContext* cx, MutableHandleDebuggerFrame result) { in getFrame() argument
626 cx, &object->getReservedSlot(JSSLOT_DEBUG_FRAME_PROTO).toObject()); in getFrame()
627 RootedNativeObject debugger(cx, object); in getFrame()
632 cx, DebuggerFrame::create(cx, proto, debugger, nullptr, nullptr)); in getFrame()
641 bool Debugger::getFrame(JSContext* cx, const FrameIter& iter, in getFrame() argument
648 Rooted<AbstractGeneratorObject*> genObj(cx); in getFrame()
651 AutoRealm ar(cx, referent.callee()); in getFrame()
652 genObj = GetGeneratorObjectForFrame(cx, referent); in getFrame()
655 AutoRealm ar(cx, referent.script()->module()); in getFrame()
656 genObj = GetGeneratorObjectForFrame(cx, referent); in getFrame()
680 cx, &object->getReservedSlot(JSSLOT_DEBUG_FRAME_PROTO).toObject()); in getFrame()
681 RootedNativeObject debugger(cx, object); in getFrame()
684 cx, DebuggerFrame::create(cx, proto, debugger, &iter, genObj)); in getFrame()
690 terminateDebuggerFrame(cx->defaultFreeOp(), this, frame, referent); in getFrame()
694 DependentAddPtr<GeneratorWeakMap> genPtr(cx, generatorFrames, genObj); in getFrame()
695 if (!genPtr.add(cx, generatorFrames, genObj, frame)) { in getFrame()
700 if (!ensureExecutionObservabilityOfFrame(cx, referent)) { in getFrame()
705 ReportOutOfMemory(cx); in getFrame()
716 bool Debugger::getFrame(JSContext* cx, Handle<AbstractGeneratorObject*> genObj, in getFrame() argument
726 DependentAddPtr<GeneratorWeakMap> p(cx, generatorFrames, genObj); in getFrame()
735 cx, &object->getReservedSlot(JSSLOT_DEBUG_FRAME_PROTO).toObject()); in getFrame()
736 RootedNativeObject debugger(cx, object); in getFrame()
738 result.set(DebuggerFrame::create(cx, proto, debugger, nullptr, genObj)); in getFrame()
743 if (!p.add(cx, generatorFrames, genObj, result)) { in getFrame()
744 terminateDebuggerFrame(cx->runtime()->defaultFreeOp(), this, result, in getFrame()
803 bool DebuggerList<HookIsEnabledFun>::init(JSContext* cx) { in init() argument
807 Handle<GlobalObject*> global = cx->global(); in init()
810 if (dbg->isHookCallAllowed(cx) && hookIsEnabled(dbg)) { in init()
821 bool DebuggerList<HookIsEnabledFun>::dispatchHook(JSContext* cx, in dispatchHook() argument
827 if (!adjqi.init(cx)) { in dispatchHook()
833 Handle<GlobalObject*> global = cx->global(); in dispatchHook()
836 EnterDebuggeeNoExecute nx(cx, *dbg, adjqi); in dispatchHook()
839 dbg->enterDebuggerHook(cx, [&]() -> bool { return fireHook(dbg); }); in dispatchHook()
851 void DebuggerList<HookIsEnabledFun>::dispatchQuietHook(JSContext* cx, in dispatchQuietHook() argument
854 dispatchHook(cx, [&](Debugger* dbg) -> bool { return fireHook(dbg); }); in dispatchQuietHook()
859 cx->clearPendingException(); in dispatchQuietHook()
866 JSContext* cx, AbstractFramePtr frame, FireHookFun fireHook) { in dispatchResumptionHook() argument
868 RootedValue rval(cx); in dispatchResumptionHook()
869 return dispatchHook(cx, in dispatchResumptionHook()
873 ApplyFrameResumeMode(cx, frame, resumeMode, rval); in dispatchResumptionHook()
895 bool DebugAPI::slowPathOnEnterFrame(JSContext* cx, AbstractFramePtr frame) { in slowPathOnEnterFrame() argument
897 cx, frame, in slowPathOnEnterFrame()
902 -> bool { return dbg->fireEnterFrame(cx, resumeMode, vp); }); in slowPathOnEnterFrame()
906 bool DebugAPI::slowPathOnResumeFrame(JSContext* cx, AbstractFramePtr frame) { in slowPathOnResumeFrame() argument
914 cx, GetGeneratorObjectForFrame(cx, frame)); in slowPathOnResumeFrame()
921 Debugger::terminateDebuggerFrames(cx, frame); in slowPathOnResumeFrame()
929 FrameIter iter(cx); in slowPathOnResumeFrame()
938 ReportOutOfMemory(cx); in slowPathOnResumeFrame()
949 return slowPathOnEnterFrame(cx, frame); in slowPathOnResumeFrame()
953 NativeResumeMode DebugAPI::slowPathOnNativeCall(JSContext* cx, in slowPathOnNativeCall() argument
962 if (!cx->insideDebuggerEvaluationWithOnNativeCallHook) { in slowPathOnNativeCall()
966 DebuggerList debuggerList(cx, [](Debugger* dbg) -> bool { in slowPathOnNativeCall()
970 if (!debuggerList.init(cx)) { in slowPathOnNativeCall()
986 JSScript* script = cx->currentScript(); in slowPathOnNativeCall()
991 RootedValue rval(cx); in slowPathOnNativeCall()
993 bool result = debuggerList.dispatchHook(cx, [&](Debugger* dbg) -> bool { in slowPathOnNativeCall()
994 return dbg->fireNativeCall(cx, args, reason, resumeMode, &rval); in slowPathOnNativeCall()
1002 if (!cx->compartment()->wrap(cx, &rval)) { in slowPathOnNativeCall()
1011 cx->setPendingExceptionAndCaptureStack(rval); in slowPathOnNativeCall()
1015 cx->clearPendingException(); in slowPathOnNativeCall()
1041 AutoSetGeneratorRunning(JSContext* cx, in AutoSetGeneratorRunning() argument
1045 genObj_(cx, genObj) { in AutoSetGeneratorRunning()
1085 bool DebugAPI::slowPathOnLeaveFrame(JSContext* cx, AbstractFramePtr frame, in slowPathOnLeaveFrame() argument
1089 mozilla::DebugOnly<Handle<GlobalObject*>> debuggeeGlobal = cx->global(); in slowPathOnLeaveFrame()
1093 Rooted<Completion> completion(cx); in slowPathOnLeaveFrame()
1102 Debugger::suspendGeneratorDebuggerFrames(cx, frame); in slowPathOnLeaveFrame()
1104 Debugger::terminateDebuggerFrames(cx, frame); in slowPathOnLeaveFrame()
1112 cx, Debugger::DebuggerFrameVector(cx)); in slowPathOnLeaveFrame()
1120 completion = Completion::fromJSFramePop(cx, frame, pc, frameOk); in slowPathOnLeaveFrame()
1123 RootedValue rval(cx); in slowPathOnLeaveFrame()
1130 if (!adjqi.init(cx)) { in slowPathOnLeaveFrame()
1138 if (!cx->isThrowingOverRecursed() && !cx->isThrowingOutOfMemory()) { in slowPathOnLeaveFrame()
1140 cx, frame.isGeneratorFrame() ? GetGeneratorObjectForFrame(cx, frame) in slowPathOnLeaveFrame()
1147 EnterDebuggeeNoExecute nx(cx, *dbg, adjqi); in slowPathOnLeaveFrame()
1156 bool result = dbg->enterDebuggerHook(cx, [&]() -> bool { in slowPathOnLeaveFrame()
1158 RootedValue nextValue(cx); in slowPathOnLeaveFrame()
1171 AutoSetGeneratorRunning asgr(cx, genObj); in slowPathOnLeaveFrame()
1172 success = handler->onPop(cx, frameobj, completion, nextResumeMode, in slowPathOnLeaveFrame()
1176 return dbg->processParsedHandlerResult(cx, frame, pc, success, in slowPathOnLeaveFrame()
1188 MOZ_ASSERT(!cx->isExceptionPending()); in slowPathOnLeaveFrame()
1198 RootedValue completionValue(cx); in slowPathOnLeaveFrame()
1199 RootedSavedFrame completionStack(cx); in slowPathOnLeaveFrame()
1212 if (!ApplyFrameResumeMode(cx, frame, completionResumeMode, completionValue, in slowPathOnLeaveFrame()
1214 if (!cx->isPropagatingForcedReturn()) { in slowPathOnLeaveFrame()
1221 cx->clearPropagatingForcedReturn(); in slowPathOnLeaveFrame()
1228 bool DebugAPI::slowPathOnNewGenerator(JSContext* cx, AbstractFramePtr frame, in slowPathOnNewGenerator() argument
1240 MakeScopeExit([&] { Debugger::terminateDebuggerFrames(cx, frame); }); in slowPathOnNewGenerator()
1249 RootedDebuggerFrame frameObj(cx, frameObjPtr); in slowPathOnNewGenerator()
1251 AutoRealm ar(cx, frameObj); in slowPathOnNewGenerator()
1253 if (!DebuggerFrame::setGeneratorInfo(cx, frameObj, genObj)) { in slowPathOnNewGenerator()
1262 cx, dbg->generatorFrames, genObj); in slowPathOnNewGenerator()
1263 if (!genPtr.add(cx, dbg->generatorFrames, genObj, frameObj)) { in slowPathOnNewGenerator()
1277 bool DebugAPI::slowPathOnDebuggerStatement(JSContext* cx, in slowPathOnDebuggerStatement() argument
1280 cx, frame, in slowPathOnDebuggerStatement()
1285 -> bool { return dbg->fireDebuggerStatement(cx, resumeMode, vp); }); in slowPathOnDebuggerStatement()
1289 bool DebugAPI::slowPathOnExceptionUnwind(JSContext* cx, in slowPathOnExceptionUnwind() argument
1293 if (cx->isThrowingOverRecursed() || cx->isThrowingOutOfMemory()) { in slowPathOnExceptionUnwind()
1302 DebuggerList debuggerList(cx, [](Debugger* dbg) -> bool { in slowPathOnExceptionUnwind()
1306 if (!debuggerList.init(cx)) { in slowPathOnExceptionUnwind()
1317 RootedValue exc(cx); in slowPathOnExceptionUnwind()
1318 RootedSavedFrame stack(cx, cx->getPendingExceptionStack()); in slowPathOnExceptionUnwind()
1319 if (!cx->getPendingException(&exc)) { in slowPathOnExceptionUnwind()
1322 cx->clearPendingException(); in slowPathOnExceptionUnwind()
1325 cx, frame, in slowPathOnExceptionUnwind()
1328 return dbg->fireExceptionUnwind(cx, exc, resumeMode, vp); in slowPathOnExceptionUnwind()
1334 cx->setPendingException(exc, stack); in slowPathOnExceptionUnwind()
1340 bool Debugger::wrapEnvironment(JSContext* cx, Handle<Env*> env, in wrapEnvironment() argument
1347 RootedDebuggerEnvironment envobj(cx); in wrapEnvironment()
1349 if (!wrapEnvironment(cx, env, &envobj)) { in wrapEnvironment()
1357 bool Debugger::wrapEnvironment(JSContext* cx, Handle<Env*> env, in wrapEnvironment() argument
1365 DependentAddPtr<EnvironmentWeakMap> p(cx, environments, env); in wrapEnvironment()
1371 cx, &object->getReservedSlot(JSSLOT_DEBUG_ENV_PROTO).toObject()); in wrapEnvironment()
1372 RootedNativeObject debugger(cx, object); in wrapEnvironment()
1375 cx, DebuggerEnvironment::create(cx, proto, env, debugger)); in wrapEnvironment()
1380 if (!p.add(cx, environments, env, envobj)) { in wrapEnvironment()
1391 bool Debugger::wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp) { in wrapDebuggeeValue() argument
1392 cx->check(object.get()); in wrapDebuggeeValue()
1395 RootedObject obj(cx, &vp.toObject()); in wrapDebuggeeValue()
1396 RootedDebuggerObject dobj(cx); in wrapDebuggeeValue()
1398 if (!wrapDebuggeeObject(cx, obj, &dobj)) { in wrapDebuggeeValue()
1404 RootedPlainObject optObj(cx, NewBuiltinClassInstance<PlainObject>(cx)); in wrapDebuggeeValue()
1417 name = cx->names().missingArguments; in wrapDebuggeeValue()
1420 name = cx->names().optimizedOut; in wrapDebuggeeValue()
1423 name = cx->names().uninitialized; in wrapDebuggeeValue()
1429 RootedValue trueVal(cx, BooleanValue(true)); in wrapDebuggeeValue()
1430 if (!DefineDataProperty(cx, optObj, name, trueVal)) { in wrapDebuggeeValue()
1435 } else if (!cx->compartment()->wrap(cx, vp)) { in wrapDebuggeeValue()
1443 bool Debugger::wrapNullableDebuggeeObject(JSContext* cx, HandleObject obj, in wrapNullableDebuggeeObject() argument
1450 return wrapDebuggeeObject(cx, obj, result); in wrapNullableDebuggeeObject()
1453 bool Debugger::wrapDebuggeeObject(JSContext* cx, HandleObject obj, in wrapDebuggeeObject() argument
1457 DependentAddPtr<ObjectWeakMap> p(cx, objects, obj); in wrapDebuggeeObject()
1462 RootedNativeObject debugger(cx, object); in wrapDebuggeeObject()
1464 cx, &object->getReservedSlot(JSSLOT_DEBUG_OBJECT_PROTO).toObject()); in wrapDebuggeeObject()
1465 RootedDebuggerObject dobj(cx, in wrapDebuggeeObject()
1466 DebuggerObject::create(cx, proto, obj, debugger)); in wrapDebuggeeObject()
1471 if (!p.add(cx, objects, obj, dobj)) { in wrapDebuggeeObject()
1482 static DebuggerObject* ToNativeDebuggerObject(JSContext* cx, in ToNativeDebuggerObject() argument
1485 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in ToNativeDebuggerObject()
1494 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_PROTO, in ToNativeDebuggerObject()
1502 bool Debugger::unwrapDebuggeeObject(JSContext* cx, MutableHandleObject obj) { in unwrapDebuggeeObject() argument
1503 DebuggerObject* ndobj = ToNativeDebuggerObject(cx, obj); in unwrapDebuggeeObject()
1509 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in unwrapDebuggeeObject()
1518 bool Debugger::unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp) { in unwrapDebuggeeValue() argument
1519 cx->check(object.get(), vp); in unwrapDebuggeeValue()
1521 RootedObject dobj(cx, &vp.toObject()); in unwrapDebuggeeValue()
1522 if (!unwrapDebuggeeObject(cx, &dobj)) { in unwrapDebuggeeValue()
1530 static bool CheckArgCompartment(JSContext* cx, JSObject* obj, JSObject* arg, in CheckArgCompartment() argument
1533 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in CheckArgCompartment()
1541 static bool CheckArgCompartment(JSContext* cx, JSObject* obj, HandleValue v, in CheckArgCompartment() argument
1544 return CheckArgCompartment(cx, obj, &v.toObject(), methodname, propname); in CheckArgCompartment()
1550 JSContext* cx, HandleObject obj, MutableHandle<PropertyDescriptor> desc) { in unwrapPropertyDescriptor() argument
1552 RootedValue value(cx, desc.value()); in unwrapPropertyDescriptor()
1553 if (!unwrapDebuggeeValue(cx, &value) || in unwrapPropertyDescriptor()
1554 !CheckArgCompartment(cx, obj, value, "defineProperty", "value")) { in unwrapPropertyDescriptor()
1561 RootedObject get(cx, desc.getter()); in unwrapPropertyDescriptor()
1563 if (!unwrapDebuggeeObject(cx, &get)) { in unwrapPropertyDescriptor()
1566 if (!CheckArgCompartment(cx, obj, get, "defineProperty", "get")) { in unwrapPropertyDescriptor()
1574 RootedObject set(cx, desc.setter()); in unwrapPropertyDescriptor()
1576 if (!unwrapDebuggeeObject(cx, &set)) { in unwrapPropertyDescriptor()
1579 if (!CheckArgCompartment(cx, obj, set, "defineProperty", "set")) { in unwrapPropertyDescriptor()
1591 static bool GetResumptionProperty(JSContext* cx, HandleObject obj, in GetResumptionProperty() argument
1596 if (!HasProperty(cx, obj, name, &found)) { in GetResumptionProperty()
1602 if (!GetProperty(cx, obj, obj, name, vp)) { in GetResumptionProperty()
1609 bool js::ParseResumptionValue(JSContext* cx, HandleValue rval, in ParseResumptionValue() argument
1624 RootedObject obj(cx, &rval.toObject()); in ParseResumptionValue()
1625 if (!GetResumptionProperty(cx, obj, cx->names().return_, ResumeMode::Return, in ParseResumptionValue()
1629 if (!GetResumptionProperty(cx, obj, cx->names().throw_, ResumeMode::Throw, in ParseResumptionValue()
1636 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in ParseResumptionValue()
1643 static bool CheckResumptionValue(JSContext* cx, AbstractFramePtr frame, in CheckResumptionValue() argument
1659 ReportValueError(cx, JSMSG_BAD_DERIVED_RETURN, JSDVG_IGNORE_STACK, vp, in CheckResumptionValue()
1664 RootedValue thisv(cx); in CheckResumptionValue()
1666 AutoRealm ar(cx, frame.environmentChain()); in CheckResumptionValue()
1667 if (!GetThisValueForDebuggerFrameMaybeOptimizedOut(cx, frame, pc, in CheckResumptionValue()
1674 return ThrowUninitializedThis(cx); in CheckResumptionValue()
1678 if (!cx->compartment()->wrap(cx, &thisv)) { in CheckResumptionValue()
1688 Rooted<AbstractGeneratorObject*> genObj(cx); in CheckResumptionValue()
1690 AutoRealm ar(cx, frame.callee()); in CheckResumptionValue()
1691 genObj = GetGeneratorObjectForFrame(cx, frame); in CheckResumptionValue()
1695 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in CheckResumptionValue()
1711 JSContext* cx, AbstractFramePtr frame, ResumeMode& resumeMode, in AdjustGeneratorResumptionValue() argument
1744 cx, GetGeneratorObjectForFrame(cx, frame)); in AdjustGeneratorResumptionValue()
1759 PlainObject* pair = CreateIterResultObject(cx, vp, true); in AdjustGeneratorResumptionValue()
1776 GetGeneratorObjectForFrame(cx, frame)) { in AdjustGeneratorResumptionValue()
1784 cx, &genObj->as<AsyncFunctionGeneratorObject>()); in AdjustGeneratorResumptionValue()
1787 Rooted<PromiseObject*> promise(cx, asyncGenObj->promise()); in AdjustGeneratorResumptionValue()
1789 if (!AsyncFunctionResolve(cx, asyncGenObj, vp, in AdjustGeneratorResumptionValue()
1804 ? PromiseObject::unforgeableReject(cx, vp) in AdjustGeneratorResumptionValue()
1805 : PromiseObject::unforgeableResolve(cx, vp); in AdjustGeneratorResumptionValue()
1819 bool Debugger::processParsedHandlerResult(JSContext* cx, AbstractFramePtr frame, in processParsedHandlerResult() argument
1825 RootedValue rootValue(cx, value); in processParsedHandlerResult()
1826 if (!success || !prepareResumption(cx, frame, pc, resumeMode, &rootValue)) { in processParsedHandlerResult()
1827 RootedValue exceptionRv(cx); in processParsedHandlerResult()
1828 if (!callUncaughtExceptionHandler(cx, &exceptionRv) || in processParsedHandlerResult()
1829 !ParseResumptionValue(cx, exceptionRv, resumeMode, &rootValue) || in processParsedHandlerResult()
1830 !prepareResumption(cx, frame, pc, resumeMode, &rootValue)) { in processParsedHandlerResult()
1839 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in processParsedHandlerResult()
1851 bool Debugger::processHandlerResult(JSContext* cx, bool success, HandleValue rv, in processHandlerResult() argument
1856 RootedValue value(cx); in processHandlerResult()
1858 success = ParseResumptionValue(cx, rv, resumeMode, &value); in processHandlerResult()
1860 return processParsedHandlerResult(cx, frame, pc, success, resumeMode, value, in processHandlerResult()
1864 bool Debugger::prepareResumption(JSContext* cx, AbstractFramePtr frame, in prepareResumption() argument
1867 return unwrapDebuggeeValue(cx, vp) && in prepareResumption()
1868 CheckResumptionValue(cx, frame, pc, resumeMode, vp); in prepareResumption()
1871 bool Debugger::callUncaughtExceptionHandler(JSContext* cx, in callUncaughtExceptionHandler() argument
1876 MOZ_ASSERT(EnterDebuggeeNoExecute::isLockedInStack(cx, *this)); in callUncaughtExceptionHandler()
1878 if (cx->isExceptionPending() && uncaughtExceptionHook) { in callUncaughtExceptionHandler()
1879 RootedValue exc(cx); in callUncaughtExceptionHandler()
1880 if (!cx->getPendingException(&exc)) { in callUncaughtExceptionHandler()
1883 cx->clearPendingException(); in callUncaughtExceptionHandler()
1885 RootedValue fval(cx, ObjectValue(*uncaughtExceptionHook)); in callUncaughtExceptionHandler()
1886 if (js::Call(cx, fval, object, exc, vp)) { in callUncaughtExceptionHandler()
1893 bool Debugger::handleUncaughtException(JSContext* cx) { in handleUncaughtException() argument
1894 RootedValue rv(cx); in handleUncaughtException()
1896 return callUncaughtExceptionHandler(cx, &rv); in handleUncaughtException()
1899 void Debugger::reportUncaughtException(JSContext* cx) { in reportUncaughtException() argument
1902 MOZ_ASSERT(EnterDebuggeeNoExecute::isLockedInStack(cx, *this)); in reportUncaughtException()
1904 if (cx->isExceptionPending()) { in reportUncaughtException()
1912 RootedValue exn(cx); in reportUncaughtException()
1913 if (cx->getPendingException(&exn)) { in reportUncaughtException()
1916 cx->clearPendingException(); in reportUncaughtException()
1917 ReportErrorToGlobal(cx, cx->global(), exn); in reportUncaughtException()
1922 cx->clearPendingException(); in reportUncaughtException()
1929 Completion Completion::fromJSResult(JSContext* cx, bool ok, const Value& rv) { in fromJSResult() argument
1930 MOZ_ASSERT_IF(ok, !cx->isExceptionPending()); in fromJSResult()
1936 if (!cx->isExceptionPending()) { in fromJSResult()
1940 RootedValue exception(cx); in fromJSResult()
1941 RootedSavedFrame stack(cx, cx->getPendingExceptionStack()); in fromJSResult()
1942 bool getSucceeded = cx->getPendingException(&exception); in fromJSResult()
1943 cx->clearPendingException(); in fromJSResult()
1952 Completion Completion::fromJSFramePop(JSContext* cx, AbstractFramePtr frame, in fromJSFramePop() argument
1959 return fromJSResult(cx, ok, frame.returnValue()); in fromJSFramePop()
1977 cx, GetGeneratorObjectForFrame(cx, frame)); in fromJSFramePop()
2001 JSContext* cx; member
2005 BuildValueMatcher(JSContext* cx, Debugger* dbg, MutableHandleValue result) in BuildValueMatcher()
2006 : cx(cx), dbg(dbg), result(result) { in BuildValueMatcher()
2007 cx->check(dbg->toJSObject()); in BuildValueMatcher()
2011 RootedNativeObject obj(cx, newObject()); in operator ()()
2012 RootedValue retval(cx, ret.value); in operator ()()
2013 if (!obj || !wrap(&retval) || !add(obj, cx->names().return_, retval)) { in operator ()()
2021 RootedNativeObject obj(cx, newObject()); in operator ()()
2022 RootedValue exc(cx, thr.exception); in operator ()()
2023 if (!obj || !wrap(&exc) || !add(obj, cx->names().throw_, exc)) { in operator ()()
2027 RootedValue stack(cx, ObjectValue(*thr.stack)); in operator ()()
2028 if (!wrapStack(&stack) || !add(obj, cx->names().stack, stack)) { in operator ()()
2042 RootedNativeObject obj(cx, newObject()); in operator ()()
2043 RootedValue gen(cx, ObjectValue(*initialYield.generatorObject)); in operator ()()
2044 if (!obj || !wrap(&gen) || !add(obj, cx->names().return_, gen) || in operator ()()
2045 !add(obj, cx->names().yield, TrueHandleValue) || in operator ()()
2046 !add(obj, cx->names().initial, TrueHandleValue)) { in operator ()()
2054 RootedNativeObject obj(cx, newObject()); in operator ()()
2055 RootedValue iteratorResult(cx, yield.iteratorResult); in operator ()()
2057 !add(obj, cx->names().return_, iteratorResult) || in operator ()()
2058 !add(obj, cx->names().yield, TrueHandleValue)) { in operator ()()
2066 RootedNativeObject obj(cx, newObject()); in operator ()()
2067 RootedValue awaitee(cx, await.awaitee); in operator ()()
2068 if (!obj || !wrap(&awaitee) || !add(obj, cx->names().return_, awaitee) || in operator ()()
2069 !add(obj, cx->names().await, TrueHandleValue)) { in operator ()()
2078 return NewBuiltinClassInstance<PlainObject>(cx); in newObject()
2083 return NativeDefineDataProperty(cx, obj, name, value, JSPROP_ENUMERATE); in add()
2087 return dbg->wrapDebuggeeValue(cx, v); in wrap()
2092 return cx->compartment()->wrap(cx, stack); in wrapStack()
2096 bool Completion::buildCompletionValue(JSContext* cx, Debugger* dbg, in buildCompletionValue() argument
2098 return variant.match(BuildValueMatcher(cx, dbg, result)); in buildCompletionValue()
2174 static bool CallMethodIfPresent(JSContext* cx, HandleObject obj, in CallMethodIfPresent() argument
2178 JSAtom* atom = Atomize(cx, name, strlen(name)); in CallMethodIfPresent()
2183 RootedId id(cx, AtomToId(atom)); in CallMethodIfPresent()
2184 RootedValue fval(cx); in CallMethodIfPresent()
2185 if (!GetProperty(cx, obj, obj, id, &fval)) { in CallMethodIfPresent()
2193 InvokeArgs args(cx); in CallMethodIfPresent()
2194 if (!args.init(cx, argc)) { in CallMethodIfPresent()
2203 return js::Call(cx, fval, rval, args, rval); in CallMethodIfPresent()
2206 bool Debugger::fireDebuggerStatement(JSContext* cx, ResumeMode& resumeMode, in fireDebuggerStatement() argument
2208 RootedObject hook(cx, getHook(OnDebuggerStatement)); in fireDebuggerStatement()
2212 ScriptFrameIter iter(cx); in fireDebuggerStatement()
2213 RootedValue scriptFrame(cx); in fireDebuggerStatement()
2214 if (!getFrame(cx, iter, &scriptFrame)) { in fireDebuggerStatement()
2218 RootedValue fval(cx, ObjectValue(*hook)); in fireDebuggerStatement()
2219 RootedValue rv(cx); in fireDebuggerStatement()
2220 bool ok = js::Call(cx, fval, object, scriptFrame, &rv); in fireDebuggerStatement()
2221 return processHandlerResult(cx, ok, rv, iter.abstractFramePtr(), iter.pc(), in fireDebuggerStatement()
2225 bool Debugger::fireExceptionUnwind(JSContext* cx, HandleValue exc, in fireExceptionUnwind() argument
2228 RootedObject hook(cx, getHook(OnExceptionUnwind)); in fireExceptionUnwind()
2232 RootedValue scriptFrame(cx); in fireExceptionUnwind()
2233 RootedValue wrappedExc(cx, exc); in fireExceptionUnwind()
2235 FrameIter iter(cx); in fireExceptionUnwind()
2236 if (!getFrame(cx, iter, &scriptFrame) || in fireExceptionUnwind()
2237 !wrapDebuggeeValue(cx, &wrappedExc)) { in fireExceptionUnwind()
2241 RootedValue fval(cx, ObjectValue(*hook)); in fireExceptionUnwind()
2242 RootedValue rv(cx); in fireExceptionUnwind()
2243 bool ok = js::Call(cx, fval, object, scriptFrame, wrappedExc, &rv); in fireExceptionUnwind()
2244 return processHandlerResult(cx, ok, rv, iter.abstractFramePtr(), iter.pc(), in fireExceptionUnwind()
2248 bool Debugger::fireEnterFrame(JSContext* cx, ResumeMode& resumeMode, in fireEnterFrame() argument
2250 RootedObject hook(cx, getHook(OnEnterFrame)); in fireEnterFrame()
2254 RootedValue scriptFrame(cx); in fireEnterFrame()
2256 FrameIter iter(cx); in fireEnterFrame()
2261 AutoRealm ar(cx, iter.script()); in fireEnterFrame()
2262 auto* genObj = GetGeneratorObjectForFrame(cx, iter.abstractFramePtr()); in fireEnterFrame()
2267 if (!getFrame(cx, iter, &scriptFrame)) { in fireEnterFrame()
2271 RootedValue fval(cx, ObjectValue(*hook)); in fireEnterFrame()
2272 RootedValue rv(cx); in fireEnterFrame()
2273 bool ok = js::Call(cx, fval, object, scriptFrame, &rv); in fireEnterFrame()
2275 return processHandlerResult(cx, ok, rv, iter.abstractFramePtr(), iter.pc(), in fireEnterFrame()
2279 bool Debugger::fireNativeCall(JSContext* cx, const CallArgs& args, in fireNativeCall() argument
2282 RootedObject hook(cx, getHook(OnNativeCall)); in fireNativeCall()
2286 RootedValue fval(cx, ObjectValue(*hook)); in fireNativeCall()
2287 RootedValue calleeval(cx, args.calleev()); in fireNativeCall()
2288 if (!wrapDebuggeeValue(cx, &calleeval)) { in fireNativeCall()
2295 reasonAtom = cx->names().call; in fireNativeCall()
2298 reasonAtom = cx->names().get; in fireNativeCall()
2301 reasonAtom = cx->names().set; in fireNativeCall()
2304 cx->markAtom(reasonAtom); in fireNativeCall()
2306 RootedValue reasonval(cx, StringValue(reasonAtom)); in fireNativeCall()
2308 RootedValue rv(cx); in fireNativeCall()
2309 bool ok = js::Call(cx, fval, object, calleeval, reasonval, &rv); in fireNativeCall()
2311 return processHandlerResult(cx, ok, rv, NullFramePtr(), nullptr, resumeMode, in fireNativeCall()
2315 bool Debugger::fireNewScript(JSContext* cx, in fireNewScript() argument
2317 RootedObject hook(cx, getHook(OnNewScript)); in fireNewScript()
2321 JSObject* dsobj = wrapVariantReferent(cx, scriptReferent); in fireNewScript()
2326 RootedValue fval(cx, ObjectValue(*hook)); in fireNewScript()
2327 RootedValue dsval(cx, ObjectValue(*dsobj)); in fireNewScript()
2328 RootedValue rv(cx); in fireNewScript()
2329 return js::Call(cx, fval, object, dsval, &rv) || handleUncaughtException(cx); in fireNewScript()
2333 JSContext* cx, const JS::dbg::GarbageCollectionEvent::Ptr& gcData) { in fireOnGarbageCollectionHook() argument
2337 RootedObject hook(cx, getHook(OnGarbageCollection)); in fireOnGarbageCollectionHook()
2341 JSObject* dataObj = gcData->toJSObject(cx); in fireOnGarbageCollectionHook()
2346 RootedValue fval(cx, ObjectValue(*hook)); in fireOnGarbageCollectionHook()
2347 RootedValue dataVal(cx, ObjectValue(*dataObj)); in fireOnGarbageCollectionHook()
2348 RootedValue rv(cx); in fireOnGarbageCollectionHook()
2349 return js::Call(cx, fval, object, dataVal, &rv) || in fireOnGarbageCollectionHook()
2350 handleUncaughtException(cx); in fireOnGarbageCollectionHook()
2356 void Debugger::dispatchQuietHook(JSContext* cx, HookIsEnabledFun hookIsEnabled, in dispatchQuietHook() argument
2358 DebuggerList<HookIsEnabledFun> debuggerList(cx, hookIsEnabled); in dispatchQuietHook()
2360 if (!debuggerList.init(cx)) { in dispatchQuietHook()
2363 cx->clearPendingException(); in dispatchQuietHook()
2367 debuggerList.dispatchQuietHook(cx, fireHook); in dispatchQuietHook()
2372 bool Debugger::dispatchResumptionHook(JSContext* cx, AbstractFramePtr frame, in dispatchResumptionHook() argument
2375 DebuggerList<HookIsEnabledFun> debuggerList(cx, hookIsEnabled); in dispatchResumptionHook()
2377 if (!debuggerList.init(cx)) { in dispatchResumptionHook()
2381 return debuggerList.dispatchResumptionHook(cx, frame, fireHook); in dispatchResumptionHook()
2390 static bool RememberSourceURL(JSContext* cx, HandleScript script) { in RememberSourceURL() argument
2391 cx->check(script); in RememberSourceURL()
2404 RootedObject holder(cx, script->global().getSourceURLsHolder()); in RememberSourceURL()
2406 holder = NewDenseEmptyArray(cx); in RememberSourceURL()
2417 RootedString filenameString(cx, JS_AtomizeString(cx, filename)); in RememberSourceURL()
2424 return NewbornArrayPush(cx, holder, StringValue(filenameString)); in RememberSourceURL()
2427 void DebugAPI::onNewScript(JSContext* cx, HandleScript script) { in onNewScript() argument
2432 if (!RememberSourceURL(cx, script)) { in onNewScript()
2433 cx->clearPendingException(); in onNewScript()
2440 cx, in onNewScript()
2446 Rooted<DebuggerScriptReferent> scriptReferent(cx, base); in onNewScript()
2447 return dbg->fireNewScript(cx, scriptReferent); in onNewScript()
2452 JSContext* cx, Handle<WasmInstanceObject*> wasmInstance) { in slowPathOnNewWasmInstance() argument
2454 cx, in slowPathOnNewWasmInstance()
2460 Rooted<DebuggerScriptReferent> scriptReferent(cx, wasmInstance.get()); in slowPathOnNewWasmInstance()
2461 return dbg->fireNewScript(cx, scriptReferent); in slowPathOnNewWasmInstance()
2466 bool DebugAPI::onTrap(JSContext* cx) { in onTrap() argument
2467 FrameIter iter(cx); in onTrap()
2468 JS::AutoSaveExceptionState savedExc(cx); in onTrap()
2469 Rooted<GlobalObject*> global(cx); in onTrap()
2475 RootedScript script(cx, iter.script()); in onTrap()
2496 Vector<Breakpoint*> triggered(cx); in onTrap()
2504 RootedValue rval(cx); in onTrap()
2511 if (!adjqi.init(cx)) { in onTrap()
2532 EnterDebuggeeNoExecute nx(cx, *dbg, adjqi); in onTrap()
2534 bool result = dbg->enterDebuggerHook(cx, [&]() -> bool { in onTrap()
2535 RootedValue scriptFrame(cx); in onTrap()
2536 if (!dbg->getFrame(cx, iter, &scriptFrame)) { in onTrap()
2544 Rooted<JSObject*> handler(cx, bp->handler); in onTrap()
2545 if (!cx->compartment()->wrap(cx, &handler)) { in onTrap()
2549 RootedValue rv(cx); in onTrap()
2550 bool ok = CallMethodIfPresent(cx, handler, "hit", 1, in onTrap()
2553 return dbg->processHandlerResult(cx, ok, rv, iter.abstractFramePtr(), in onTrap()
2572 if (!ApplyFrameResumeMode(cx, iter.abstractFramePtr(), resumeMode, rval)) { in onTrap()
2580 bool DebugAPI::onSingleStep(JSContext* cx) { in onSingleStep() argument
2581 FrameIter iter(cx); in onSingleStep()
2586 JS::AutoSaveExceptionState savedExc(cx); in onSingleStep()
2591 cx, Debugger::DebuggerFrameVector(cx)); in onSingleStep()
2608 for (Realm::DebuggerVectorEntry& entry : cx->global()->getDebuggers()) { in onSingleStep()
2660 RootedValue rval(cx); in onSingleStep()
2668 if (!adjqi.init(cx)) { in onSingleStep()
2681 EnterDebuggeeNoExecute nx(cx, *dbg, adjqi); in onSingleStep()
2683 bool result = dbg->enterDebuggerHook(cx, [&]() -> bool { in onSingleStep()
2685 RootedValue nextValue(cx); in onSingleStep()
2687 bool success = handler->onStep(cx, frame, nextResumeMode, &nextValue); in onSingleStep()
2689 cx, iter.abstractFramePtr(), iter.pc(), success, nextResumeMode, in onSingleStep()
2700 if (!ApplyFrameResumeMode(cx, iter.abstractFramePtr(), resumeMode, rval)) { in onSingleStep()
2707 bool Debugger::fireNewGlobalObject(JSContext* cx, in fireNewGlobalObject() argument
2709 RootedObject hook(cx, getHook(OnNewGlobalObject)); in fireNewGlobalObject()
2713 RootedValue wrappedGlobal(cx, ObjectValue(*global)); in fireNewGlobalObject()
2714 if (!wrapDebuggeeValue(cx, &wrappedGlobal)) { in fireNewGlobalObject()
2724 RootedValue rv(cx); in fireNewGlobalObject()
2725 RootedValue fval(cx, ObjectValue(*hook)); in fireNewGlobalObject()
2726 bool ok = js::Call(cx, fval, object, wrappedGlobal, &rv); in fireNewGlobalObject()
2728 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in fireNewGlobalObject()
2733 return ok || handleUncaughtException(cx); in fireNewGlobalObject()
2736 void DebugAPI::slowPathOnNewGlobalObject(JSContext* cx, in slowPathOnNewGlobalObject() argument
2738 MOZ_ASSERT(!cx->runtime()->onNewGlobalObjectWatchers().isEmpty()); in slowPathOnNewGlobalObject()
2746 RootedObjectVector watchers(cx); in slowPathOnNewGlobalObject()
2747 for (auto& dbg : cx->runtime()->onNewGlobalObjectWatchers()) { in slowPathOnNewGlobalObject()
2752 if (cx->isExceptionPending()) { in slowPathOnNewGlobalObject()
2753 cx->clearPendingException(); in slowPathOnNewGlobalObject()
2763 if (!adjqi.init(cx)) { in slowPathOnNewGlobalObject()
2764 cx->clearPendingException(); in slowPathOnNewGlobalObject()
2770 EnterDebuggeeNoExecute nx(cx, *dbg, adjqi); in slowPathOnNewGlobalObject()
2774 cx, [&]() -> bool { return dbg->fireNewGlobalObject(cx, global); }); in slowPathOnNewGlobalObject()
2781 cx->clearPendingException(); in slowPathOnNewGlobalObject()
2786 MOZ_ASSERT(!cx->isExceptionPending()); in slowPathOnNewGlobalObject()
2835 bool DebugAPI::slowPathOnLogAllocationSite(JSContext* cx, HandleObject obj, in slowPathOnLogAllocationSite() argument
2849 Rooted<GCVector<JSObject*>> activeDebuggers(cx, GCVector<JSObject*>(cx)); in slowPathOnLogAllocationSite()
2862 !p->dbg->appendAllocationSite(cx, obj, frame, when)) { in slowPathOnLogAllocationSite()
2876 bool Debugger::appendAllocationSite(JSContext* cx, HandleObject obj, in appendAllocationSite() argument
2881 AutoRealm ar(cx, object); in appendAllocationSite()
2882 RootedObject wrappedFrame(cx, frame); in appendAllocationSite()
2883 if (!cx->compartment()->wrap(cx, &wrappedFrame)) { in appendAllocationSite()
2889 JS::ubi::Node(obj.get()).size(cx->runtime()->debuggerMallocSizeOf); in appendAllocationSite()
2894 ReportOutOfMemory(cx); in appendAllocationSite()
2907 bool Debugger::firePromiseHook(JSContext* cx, Hook hook, HandleObject promise) { in firePromiseHook() argument
2910 RootedObject hookObj(cx, getHook(hook)); in firePromiseHook()
2914 RootedValue dbgObj(cx, ObjectValue(*promise)); in firePromiseHook()
2915 if (!wrapDebuggeeValue(cx, &dbgObj)) { in firePromiseHook()
2921 RootedValue fval(cx, ObjectValue(*hookObj)); in firePromiseHook()
2922 RootedValue rv(cx); in firePromiseHook()
2923 bool ok = js::Call(cx, fval, object, dbgObj, &rv); in firePromiseHook()
2925 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in firePromiseHook()
2930 return ok || handleUncaughtException(cx); in firePromiseHook()
2934 void Debugger::slowPathPromiseHook(JSContext* cx, Hook hook, in slowPathPromiseHook() argument
2941 cx->check(promise); in slowPathPromiseHook()
2944 AutoRealm ar(cx, promise); in slowPathPromiseHook()
2947 cx, [hook](Debugger* dbg) -> bool { return dbg->getHook(hook); }, in slowPathPromiseHook()
2949 return dbg->firePromiseHook(cx, hook, promise); in slowPathPromiseHook()
2954 void DebugAPI::slowPathOnNewPromise(JSContext* cx, in slowPathOnNewPromise() argument
2956 Debugger::slowPathPromiseHook(cx, Debugger::OnNewPromise, promise); in slowPathOnNewPromise()
2960 void DebugAPI::slowPathOnPromiseSettled(JSContext* cx, in slowPathOnPromiseSettled() argument
2962 Debugger::slowPathPromiseHook(cx, Debugger::OnPromiseSettled, promise); in slowPathOnPromiseSettled()
2973 explicit ExecutionObservableRealms(JSContext* cx) : realms_(cx), zones_(cx) {} in ExecutionObservableRealms() argument
3062 ExecutionObservableScript(JSContext* cx, JSScript* script) in ExecutionObservableScript() argument
3063 : script_(cx, script) {} in ExecutionObservableScript()
3090 JSContext* cx, const DebugAPI::ExecutionObservableSet& obs, in updateExecutionObservabilityOfFrames() argument
3092 AutoSuppressProfilerSampling suppressProfilerSampling(cx); in updateExecutionObservabilityOfFrames()
3095 jit::JitContext jctx(cx, nullptr); in updateExecutionObservabilityOfFrames()
3096 if (!jit::RecompileOnStackBaselineScriptsForDebugMode(cx, obs, observing)) { in updateExecutionObservabilityOfFrames()
3097 ReportOutOfMemory(cx); in updateExecutionObservabilityOfFrames()
3103 for (AllFramesIter iter(cx); !iter.done(); ++iter) { in updateExecutionObservabilityOfFrames()
3111 iter.abstractFramePtr().asWasmDebugFrame()->observe(cx); in updateExecutionObservabilityOfFrames()
3127 AutoRealm ar(cx, oldestEnabledFrame.environmentChain()); in updateExecutionObservabilityOfFrames()
3128 DebugEnvironments::unsetPrevUpToDateUntil(cx, oldestEnabledFrame); in updateExecutionObservabilityOfFrames()
3141 static bool AppendAndInvalidateScript(JSContext* cx, Zone* zone, in AppendAndInvalidateScript() argument
3149 AutoRealm ar(cx, script); in AppendAndInvalidateScript()
3155 JSContext* cx, Zone* zone, const DebugAPI::ExecutionObservableSet& obs, in UpdateExecutionObservabilityOfScriptsInZone() argument
3159 AutoSuppressProfilerSampling suppressProfilerSampling(cx); in UpdateExecutionObservabilityOfScriptsInZone()
3161 JSFreeOp* fop = cx->runtime()->defaultFreeOp(); in UpdateExecutionObservabilityOfScriptsInZone()
3163 Vector<JSScript*> scripts(cx); in UpdateExecutionObservabilityOfScriptsInZone()
3171 if (!AppendAndInvalidateScript(cx, zone, script, invalid, scripts)) { in UpdateExecutionObservabilityOfScriptsInZone()
3183 if (!AppendAndInvalidateScript(cx, zone, script, invalid, scripts)) { in UpdateExecutionObservabilityOfScriptsInZone()
3189 Invalidate(cx, invalid); in UpdateExecutionObservabilityOfScriptsInZone()
3197 for (JitActivationIterator actIter(cx); !actIter.done(); ++actIter) { in UpdateExecutionObservabilityOfScriptsInZone()
3210 for (InlineFrameIterator inlineIter(cx, &frame); inlineIter.more(); in UpdateExecutionObservabilityOfScriptsInZone()
3239 instance->debug().ensureEnterFrameTrapsState(cx, enableTrap); in UpdateExecutionObservabilityOfScriptsInZone()
3248 JSContext* cx, const DebugAPI::ExecutionObservableSet& obs, in updateExecutionObservabilityOfScripts() argument
3251 return UpdateExecutionObservabilityOfScriptsInZone(cx, zone, obs, in updateExecutionObservabilityOfScripts()
3257 if (!UpdateExecutionObservabilityOfScriptsInZone(cx, r.front(), obs, in updateExecutionObservabilityOfScripts()
3279 void Debugger::forEachOnStackOrSuspendedDebuggerFrame(JSContext* cx, in forEachOnStackOrSuspendedDebuggerFrame() argument
3283 cx, frame.isGeneratorFrame() ? GetGeneratorObjectForFrame(cx, frame) in forEachOnStackOrSuspendedDebuggerFrame()
3317 JSContext* cx, DebugAPI::ExecutionObservableSet& obs, in updateExecutionObservability() argument
3325 return updateExecutionObservabilityOfScripts(cx, obs, observing) && in updateExecutionObservability()
3326 updateExecutionObservabilityOfFrames(cx, obs, observing); in updateExecutionObservability()
3330 bool Debugger::ensureExecutionObservabilityOfScript(JSContext* cx, in ensureExecutionObservabilityOfScript() argument
3335 ExecutionObservableScript obs(cx, script); in ensureExecutionObservabilityOfScript()
3336 return updateExecutionObservability(cx, obs, Observing); in ensureExecutionObservabilityOfScript()
3341 JSContext* cx, AbstractFramePtr osrSourceFrame) { in ensureExecutionObservabilityOfOsrFrame() argument
3348 return Debugger::updateExecutionObservabilityOfFrames(cx, obs, Observing); in ensureExecutionObservabilityOfOsrFrame()
3352 bool Debugger::ensureExecutionObservabilityOfFrame(JSContext* cx, in ensureExecutionObservabilityOfFrame() argument
3361 return updateExecutionObservabilityOfFrames(cx, obs, Observing); in ensureExecutionObservabilityOfFrame()
3365 bool Debugger::ensureExecutionObservabilityOfRealm(JSContext* cx, in ensureExecutionObservabilityOfRealm() argument
3370 ExecutionObservableRealms obs(cx); in ensureExecutionObservabilityOfRealm()
3375 return updateExecutionObservability(cx, obs, Observing); in ensureExecutionObservabilityOfRealm()
3414 bool Debugger::updateObservesAllExecutionOnDebuggees(JSContext* cx, in updateObservesAllExecutionOnDebuggees() argument
3416 ExecutionObservableRealms obs(cx); in updateObservesAllExecutionOnDebuggees()
3434 if (!updateExecutionObservability(cx, obs, observing)) { in updateObservesAllExecutionOnDebuggees()
3446 bool Debugger::updateObservesCoverageOnDebuggees(JSContext* cx, in updateObservesCoverageOnDebuggees() argument
3448 ExecutionObservableRealms obs(cx); in updateObservesCoverageOnDebuggees()
3470 for (FrameIter iter(cx); !iter.done(); ++iter) { in updateObservesCoverageOnDebuggees()
3472 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in updateObservesCoverageOnDebuggees()
3478 if (!updateExecutionObservability(cx, obs, observing)) { in updateObservesCoverageOnDebuggees()
3530 bool Debugger::addAllocationsTracking(JSContext* cx, in addAllocationsTracking() argument
3537 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in addAllocationsTracking()
3566 bool Debugger::addAllocationsTrackingForAllDebuggees(JSContext* cx) { in addAllocationsTrackingForAllDebuggees() argument
3577 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in addAllocationsTrackingForAllDebuggees()
3583 Rooted<GlobalObject*> g(cx); in addAllocationsTrackingForAllDebuggees()
3589 MOZ_ALWAYS_TRUE(Debugger::addAllocationsTracking(cx, g)); in addAllocationsTrackingForAllDebuggees()
4021 static Debugger* Debugger_fromThisValue(JSContext* cx, const CallArgs& args, in Debugger_fromThisValue() argument
4023 JSObject* thisobj = RequireObject(cx, args.thisv()); in Debugger_fromThisValue()
4028 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in Debugger_fromThisValue()
4039 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in Debugger_fromThisValue()
4047 JSContext* cx; member
4052 CallData(JSContext* cx, const CallArgs& args, Debugger* dbg) in CallData()
4053 : cx(cx), args(args), dbg(dbg) {} in CallData()
4099 static bool ToNative(JSContext* cx, unsigned argc, Value* vp);
4104 bool Debugger::CallData::ToNative(JSContext* cx, unsigned argc, Value* vp) { in ToNative() argument
4107 Debugger* dbg = Debugger_fromThisValue(cx, args, "method"); in ToNative()
4112 CallData data(cx, args, dbg); in ToNative()
4117 bool Debugger::getHookImpl(JSContext* cx, const CallArgs& args, Debugger& dbg, in getHookImpl() argument
4125 bool Debugger::setHookImpl(JSContext* cx, const CallArgs& args, Debugger& dbg, in setHookImpl() argument
4128 if (!args.requireAtLeast(cx, "Debugger.setHook", 1)) { in setHookImpl()
4133 return ReportIsNotFunction(cx, args[0], args.length() - 1); in setHookImpl()
4136 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in setHookImpl()
4141 RootedValue oldHook(cx, dbg.object->getReservedSlot(slot)); in setHookImpl()
4145 cx, dbg.observesAllExecution())) { in setHookImpl()
4151 Rooted<DebuggerDebuggeeLink*> debuggeeLink(cx, dbg.getDebuggeeLink()); in setHookImpl()
4163 bool Debugger::getGarbageCollectionHook(JSContext* cx, const CallArgs& args, in getGarbageCollectionHook() argument
4165 return getHookImpl(cx, args, dbg, OnGarbageCollection); in getGarbageCollectionHook()
4169 bool Debugger::setGarbageCollectionHook(JSContext* cx, const CallArgs& args, in setGarbageCollectionHook() argument
4171 Rooted<JSObject*> oldHook(cx, dbg.getHook(OnGarbageCollection)); in setGarbageCollectionHook()
4173 if (!setHookImpl(cx, args, dbg, OnGarbageCollection)) { in setGarbageCollectionHook()
4186 cx->runtime()->onGarbageCollectionWatchers().pushBack(&dbg); in setGarbageCollectionHook()
4188 cx->runtime()->onGarbageCollectionWatchers().remove(&dbg); in setGarbageCollectionHook()
4195 return getHookImpl(cx, args, *dbg, OnDebuggerStatement); in getOnDebuggerStatement()
4199 return setHookImpl(cx, args, *dbg, OnDebuggerStatement); in setOnDebuggerStatement()
4203 return getHookImpl(cx, args, *dbg, OnExceptionUnwind); in getOnExceptionUnwind()
4207 return setHookImpl(cx, args, *dbg, OnExceptionUnwind); in setOnExceptionUnwind()
4211 return getHookImpl(cx, args, *dbg, OnNewScript); in getOnNewScript()
4215 return setHookImpl(cx, args, *dbg, OnNewScript); in setOnNewScript()
4219 return getHookImpl(cx, args, *dbg, OnNewPromise); in getOnNewPromise()
4223 return setHookImpl(cx, args, *dbg, OnNewPromise); in setOnNewPromise()
4227 return getHookImpl(cx, args, *dbg, OnPromiseSettled); in getOnPromiseSettled()
4231 return setHookImpl(cx, args, *dbg, OnPromiseSettled); in setOnPromiseSettled()
4235 return getHookImpl(cx, args, *dbg, OnEnterFrame); in getOnEnterFrame()
4239 return setHookImpl(cx, args, *dbg, OnEnterFrame); in setOnEnterFrame()
4243 return getHookImpl(cx, args, *dbg, OnNativeCall); in getOnNativeCall()
4247 return setHookImpl(cx, args, *dbg, OnNativeCall); in setOnNativeCall()
4251 return getHookImpl(cx, args, *dbg, OnNewGlobalObject); in getOnNewGlobalObject()
4255 RootedObject oldHook(cx, dbg->getHook(OnNewGlobalObject)); in setOnNewGlobalObject()
4257 if (!setHookImpl(cx, args, *dbg, OnNewGlobalObject)) { in setOnNewGlobalObject()
4265 cx->runtime()->onNewGlobalObjectWatchers().pushBack(dbg); in setOnNewGlobalObject()
4267 cx->runtime()->onNewGlobalObjectWatchers().remove(dbg); in setOnNewGlobalObject()
4279 if (!args.requireAtLeast(cx, "Debugger.set uncaughtExceptionHook", 1)) { in setUncaughtExceptionHook()
4284 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in setUncaughtExceptionHook()
4300 if (!args.requireAtLeast(cx, "Debugger.set allowUnobservedAsmJS", 1)) { in setAllowUnobservedAsmJS()
4322 if (!args.requireAtLeast(cx, "Debugger.set collectCoverageInfo", 1)) { in setCollectCoverageInfo()
4328 if (!dbg->updateObservesCoverageOnDebuggees(cx, observing)) { in setCollectCoverageInfo()
4341 RootedObject memory(cx, DebuggerMemory::create(cx, dbg)); in getMemory()
4360 GlobalObject* Debugger::unwrapDebuggeeArgument(JSContext* cx, const Value& v) { in unwrapDebuggeeArgument() argument
4362 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in unwrapDebuggeeArgument()
4368 RootedObject obj(cx, &v.toObject()); in unwrapDebuggeeArgument()
4372 RootedValue rv(cx, v); in unwrapDebuggeeArgument()
4373 if (!unwrapDebuggeeValue(cx, &rv)) { in unwrapDebuggeeArgument()
4384 obj = CheckedUnwrapDynamic(obj, cx, /* stopAtWindowProxy = */ false); in unwrapDebuggeeArgument()
4386 ReportAccessDenied(cx); in unwrapDebuggeeArgument()
4392 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in unwrapDebuggeeArgument()
4402 if (!args.requireAtLeast(cx, "Debugger.addDebuggee", 1)) { in addDebuggee()
4405 Rooted<GlobalObject*> global(cx, dbg->unwrapDebuggeeArgument(cx, args[0])); in addDebuggee()
4410 if (!dbg->addDebuggeeGlobal(cx, global)) { in addDebuggee()
4414 RootedValue v(cx, ObjectValue(*global)); in addDebuggee()
4415 if (!dbg->wrapDebuggeeValue(cx, &v)) { in addDebuggee()
4423 for (CompartmentsIter comp(cx->runtime()); !comp.done(); comp.next()) { in addAllGlobalsAsDebuggees()
4434 Rooted<GlobalObject*> rg(cx, global); in addAllGlobalsAsDebuggees()
4435 if (!dbg->addDebuggeeGlobal(cx, rg)) { in addAllGlobalsAsDebuggees()
4447 if (!args.requireAtLeast(cx, "Debugger.removeDebuggee", 1)) { in removeDebuggee()
4450 Rooted<GlobalObject*> global(cx, dbg->unwrapDebuggeeArgument(cx, args[0])); in removeDebuggee()
4455 ExecutionObservableRealms obs(cx); in removeDebuggee()
4458 dbg->removeDebuggeeGlobal(cx->runtime()->defaultFreeOp(), global, nullptr, in removeDebuggee()
4467 if (!updateExecutionObservability(cx, obs, NotObserving)) { in removeDebuggee()
4477 ExecutionObservableRealms obs(cx); in removeAllDebuggees()
4480 Rooted<GlobalObject*> global(cx, e.front()); in removeAllDebuggees()
4481 dbg->removeDebuggeeGlobal(cx->runtime()->defaultFreeOp(), global, &e, in removeAllDebuggees()
4490 if (!updateExecutionObservability(cx, obs, NotObserving)) { in removeAllDebuggees()
4499 if (!args.requireAtLeast(cx, "Debugger.hasDebuggee", 1)) { in hasDebuggee()
4502 GlobalObject* global = dbg->unwrapDebuggeeArgument(cx, args[0]); in hasDebuggee()
4514 RootedValueVector debuggees(cx); in getDebuggees()
4527 RootedArrayObject arrobj(cx, NewDenseFullyAllocatedArray(cx, count)); in getDebuggees()
4533 RootedValue v(cx, debuggees[i]); in getDebuggees()
4534 if (!dbg->wrapDebuggeeValue(cx, &v)) { in getDebuggees()
4546 for (AllFramesIter i(cx); !i.done(); ++i) { in getNewestFrame()
4550 if (i.isIon() && !i.ensureHasRematerializedFrame(cx)) { in getNewestFrame()
4554 FrameIter iter(i.activation()->cx()); in getNewestFrame()
4559 return dbg->getFrame(cx, iter, args.rval()); in getNewestFrame()
4567 JSFreeOp* fop = cx->defaultFreeOp(); in clearAllBreakpoints()
4580 bool Debugger::construct(JSContext* cx, unsigned argc, Value* vp) { in construct() argument
4585 JSObject* argobj = RequireObject(cx, args[i]); in construct()
4590 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in construct()
4597 RootedValue v(cx); in construct()
4598 RootedObject callee(cx, &args.callee()); in construct()
4599 if (!GetProperty(cx, callee, callee, cx->names().prototype, &v)) { in construct()
4602 RootedNativeObject proto(cx, &v.toObject().as<NativeObject>()); in construct()
4609 cx, NewTenuredObjectWithGivenProto<DebuggerInstanceObject>(cx, proto)); in construct()
4620 cx, NewObjectWithGivenProto<DebuggerDebuggeeLink>(cx, nullptr)); in construct()
4629 auto dbg = cx->make_unique<Debugger>(cx, obj.get()); in construct()
4643 Rooted<GlobalObject*> debuggee(cx, &wrappedObj.nonCCWGlobal()); in construct()
4644 if (!debugger->addDebuggeeGlobal(cx, debuggee)) { in construct()
4653 bool Debugger::addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> global) { in addDebuggeeGlobal() argument
4664 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in addDebuggeeGlobal()
4671 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in addDebuggeeGlobal()
4680 Vector<Realm*> visited(cx); in addDebuggeeGlobal()
4687 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_LOOP); in addDebuggeeGlobal()
4716 AutoRealm ar(cx, global); in addDebuggeeGlobal()
4719 RootedObject debuggeeLink(cx, getDebuggeeLink()); in addDebuggeeGlobal()
4720 if (!cx->compartment()->wrap(cx, &debuggeeLink)) { in addDebuggeeGlobal()
4727 ReportOutOfMemory(cx); in addDebuggeeGlobal()
4734 ReportOutOfMemory(cx); in addDebuggeeGlobal()
4743 ReportOutOfMemory(cx); in addDebuggeeGlobal()
4754 !Debugger::addAllocationsTracking(cx, global)) { in addDebuggeeGlobal()
4770 !ensureExecutionObservabilityOfRealm(cx, debuggeeRealm)) { in addDebuggeeGlobal()
4893 QueryBase(JSContext* cx, Debugger* dbg) in QueryBase() argument
4894 : cx(cx), in QueryBase()
4896 iterMarker(&cx->runtime()->gc), in QueryBase()
4897 realms(cx->zone()) {} in QueryBase()
4900 JSContext* cx; member in Debugger::QueryBase
4922 ReportOutOfMemory(cx); in matchSingleGlobal()
4936 ReportOutOfMemory(cx); in matchAllDebuggeeGlobals()
4951 ScriptQuery(JSContext* cx, Debugger* dbg) in ScriptQuery() argument
4952 : QueryBase(cx, dbg), in ScriptQuery()
4953 url(cx), in ScriptQuery()
4954 displayURLString(cx), in ScriptQuery()
4955 source(cx, AsVariant(static_cast<ScriptSourceObject*>(nullptr))), in ScriptQuery()
4956 scriptVector(cx, BaseScriptVector(cx)), in ScriptQuery()
4957 partialMatchVector(cx, BaseScriptVector(cx)), in ScriptQuery()
4958 wasmInstanceVector(cx, WasmInstanceObjectVector(cx)) {} in ScriptQuery()
4967 RootedValue global(cx); in parseQuery()
4968 if (!GetProperty(cx, query, query, cx->names().global, &global)) { in parseQuery()
4976 GlobalObject* globalObject = debugger->unwrapDebuggeeArgument(cx, global); in parseQuery()
4991 if (!GetProperty(cx, query, query, cx->names().url, &url)) { in parseQuery()
4996 cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, in parseQuery()
5002 RootedValue debuggerSource(cx); in parseQuery()
5003 if (!GetProperty(cx, query, query, cx->names().source, &debuggerSource)) { in parseQuery()
5009 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5023 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5033 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5043 RootedValue displayURL(cx); in parseQuery()
5044 if (!GetProperty(cx, query, query, cx->names().displayURL, &displayURL)) { in parseQuery()
5048 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5056 displayURLString = displayURL.toString()->ensureLinear(cx); in parseQuery()
5063 RootedValue lineProperty(cx); in parseQuery()
5064 if (!GetProperty(cx, query, query, cx->names().line, &lineProperty)) { in parseQuery()
5071 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5078 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5086 cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, in parseQuery()
5092 PropertyName* innermostName = cx->names().innermost; in parseQuery()
5093 RootedValue innermostProperty(cx); in parseQuery()
5094 if (!GetProperty(cx, query, query, innermostName, &innermostProperty)) { in parseQuery()
5102 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5138 IterateScripts(cx, singletonRealm, this, considerScript); in findScripts()
5140 ReportOutOfMemory(cx); in findScripts()
5149 Rooted<BaseScript*> script(cx); in findScripts()
5150 RootedFunction fun(cx); in findScripts()
5173 JSScript* compiledScript = GetOrCreateFunctionScript(cx, fun); in findScripts()
5232 Rooted<RealmToScriptMap> innermostForRealm(cx); in findScripts()
5273 ReportOutOfMemory(cx); in findScripts()
5358 urlCString = JS_EncodeStringToLatin1(cx, url.toString()); in prepareQuery()
5527 ScriptQuery query(cx, dbg); in findScripts()
5530 RootedObject queryObject(cx, RequireObject(cx, args[0])); in findScripts()
5548 RootedArrayObject result(cx, NewDenseFullyAllocatedArray(cx, resultLength)); in findScripts()
5556 JSObject* scriptObject = dbg->wrapScript(cx, scripts[i]); in findScripts()
5565 JSObject* scriptObject = dbg->wrapWasmScript(cx, wasmInstances[i]); in findScripts()
5584 SourceQuery(JSContext* cx, Debugger* dbg) in SourceQuery() argument
5585 : QueryBase(cx, dbg), sources(cx, SourceSet(cx->zone())) {} in SourceQuery()
5600 IterateScripts(cx, singletonRealm, this, considerScript); in findSources()
5602 ReportOutOfMemory(cx); in findSources()
5613 ReportOutOfMemory(cx); in findSources()
5668 SourceQuery query(cx, dbg); in findSources()
5676 RootedArrayObject result(cx, NewDenseFullyAllocatedArray(cx, resultLength)); in findSources()
5685 Rooted<DebuggerSourceReferent> sourceReferent(cx, in findSources()
5687 RootedObject sourceObject(cx, dbg->wrapVariantReferent(cx, sourceReferent)); in findSources()
5706 ObjectQuery(JSContext* cx, Debugger* dbg) in ObjectQuery() argument
5707 : objects(cx), cx(cx), dbg(dbg), className(cx) {} in ObjectQuery()
5721 RootedValue cls(cx); in parseQuery()
5722 if (!GetProperty(cx, query, query, cx->names().class_, &cls)) { in parseQuery()
5727 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in parseQuery()
5733 JSLinearString* str = cls.toString()->ensureLinear(cx); in parseQuery()
5739 cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, in parseQuery()
5764 ReportOutOfMemory(cx); in findObjects()
5773 RootedObject dbgObj(cx, dbg->object); in findObjects()
5774 JS::ubi::RootList rootList(cx, maybeNoGC); in findObjects()
5776 ReportOutOfMemory(cx); in findObjects()
5780 Traversal traversal(cx, *this, maybeNoGC.ref()); in findObjects()
5850 JSContext* cx; member in Debugger::ObjectQuery
5870 classNameCString = JS_EncodeStringToASCII(cx, className.toString()); in prepareQuery()
5881 ObjectQuery query(cx, dbg); in findObjects()
5884 RootedObject queryObject(cx, RequireObject(cx, args[0])); in findObjects()
5897 RootedArrayObject result(cx, NewDenseFullyAllocatedArray(cx, length)); in findObjects()
5905 RootedValue debuggeeVal(cx, ObjectValue(*query.objects[i])); in findObjects()
5906 if (!dbg->wrapDebuggeeValue(cx, &debuggeeVal)) { in findObjects()
5917 RootedObjectVector globals(cx); in findAllGlobals()
5924 for (RealmsIter r(cx->runtime()); !r.done(); r.next()) { in findAllGlobals()
5941 if (cx->runtime()->isSelfHostingGlobal(global)) { in findAllGlobals()
5955 RootedObject result(cx, NewDenseEmptyArray(cx)); in findAllGlobals()
5961 RootedValue globalValue(cx, ObjectValue(*globals[i])); in findAllGlobals()
5962 if (!dbg->wrapDebuggeeValue(cx, &globalValue)) { in findAllGlobals()
5965 if (!NewbornArrayPush(cx, result, globalValue)) { in findAllGlobals()
5975 RootedObject result(cx, NewDenseEmptyArray(cx)); in findSourceURLs()
5982 RootedObject holder(cx, r.front()->getSourceURLsHolder()); in findSourceURLs()
5991 cx->markAtomValue(v); in findSourceURLs()
5993 if (!NewbornArrayPush(cx, result, v)) { in findSourceURLs()
6005 if (!args.requireAtLeast(cx, "Debugger.makeGlobalObjectReference", 1)) { in makeGlobalObjectReference()
6009 Rooted<GlobalObject*> global(cx, dbg->unwrapDebuggeeArgument(cx, args[0])); in makeGlobalObjectReference()
6018 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, in makeGlobalObjectReference()
6024 return dbg->wrapDebuggeeValue(cx, args.rval()); in makeGlobalObjectReference()
6027 bool Debugger::isCompilableUnit(JSContext* cx, unsigned argc, Value* vp) { in isCompilableUnit() argument
6030 if (!args.requireAtLeast(cx, "Debugger.isCompilableUnit", 1)) { in isCompilableUnit()
6036 cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, in isCompilableUnit()
6044 AutoStableStringChars chars(cx); in isCompilableUnit()
6045 if (!chars.initTwoByte(cx, str)) { in isCompilableUnit()
6051 CompileOptions options(cx); in isCompilableUnit()
6052 Rooted<frontend::CompilationInput> input(cx, in isCompilableUnit()
6054 if (!input.get().initForGlobal(cx)) { in isCompilableUnit()
6058 LifoAllocScope allocScope(&cx->tempLifoAlloc()); in isCompilableUnit()
6059 frontend::CompilationState compilationState(cx, allocScope, input.get()); in isCompilableUnit()
6060 if (!compilationState.init(cx)) { in isCompilableUnit()
6064 JS::AutoSuppressWarningReporter suppressWarnings(cx); in isCompilableUnit()
6066 cx, options, chars.twoByteChars(), length, in isCompilableUnit()
6072 if (cx->isThrowingOutOfMemory()) { in isCompilableUnit()
6082 cx->clearPendingException(); in isCompilableUnit()
6090 if (!args.requireAtLeast(cx, "Debugger.adoptDebuggeeValue", 1)) { in adoptDebuggeeValue()
6094 RootedValue v(cx, args[0]); in adoptDebuggeeValue()
6096 RootedObject obj(cx, &v.toObject()); in adoptDebuggeeValue()
6097 DebuggerObject* ndobj = ToNativeDebuggerObject(cx, &obj); in adoptDebuggeeValue()
6105 if (!dbg->wrapDebuggeeValue(cx, &v)) { in adoptDebuggeeValue()
6119 explicit DebuggerAdoptSourceMatcher(JSContext* cx, Debugger* dbg) in DebuggerAdoptSourceMatcher() argument
6120 : cx_(cx), dbg_(dbg) {} in DebuggerAdoptSourceMatcher()
6143 if (!args.requireAtLeast(cx, "Debugger.adoptFrame", 1)) { in adoptFrame()
6147 RootedObject obj(cx, RequireObject(cx, args[0])); in adoptFrame()
6154 JS_ReportErrorASCII(cx, "Argument is not a Debugger.Frame"); in adoptFrame()
6158 RootedValue objVal(cx, ObjectValue(*obj)); in adoptFrame()
6159 RootedDebuggerFrame frameObj(cx, DebuggerFrame::check(cx, objVal)); in adoptFrame()
6164 RootedDebuggerFrame adoptedFrame(cx); in adoptFrame()
6166 FrameIter iter = frameObj->getFrameIter(cx); in adoptFrame()
6168 JS_ReportErrorASCII(cx, "Debugger.Frame's global is not a debuggee"); in adoptFrame()
6171 if (!dbg->getFrame(cx, iter, &adoptedFrame)) { in adoptFrame()
6175 Rooted<AbstractGeneratorObject*> gen(cx, &frameObj->unwrappedGenerator()); in adoptFrame()
6177 JS_ReportErrorASCII(cx, "Debugger.Frame's global is not a debuggee"); in adoptFrame()
6181 if (!dbg->getFrame(cx, gen, &adoptedFrame)) { in adoptFrame()
6185 if (!dbg->getFrame(cx, &adoptedFrame)) { in adoptFrame()
6195 if (!args.requireAtLeast(cx, "Debugger.adoptSource", 1)) { in adoptSource()
6199 RootedObject obj(cx, RequireObject(cx, args[0])); in adoptSource()
6206 JS_ReportErrorASCII(cx, "Argument is not a Debugger.Source"); in adoptSource()
6210 RootedDebuggerSource sourceObj(cx, &obj->as<DebuggerSource>()); in adoptSource()
6212 JS_ReportErrorASCII(cx, "Argument is Debugger.Source.prototype"); in adoptSource()
6216 Rooted<DebuggerSourceReferent> referent(cx, sourceObj->getReferent()); in adoptSource()
6218 DebuggerAdoptSourceMatcher matcher(cx, dbg); in adoptSource()
6274 JSContext* cx, Handle<DebuggerScriptReferent> referent) { in newDebuggerScript() argument
6275 cx->check(object.get()); in newDebuggerScript()
6278 cx, &object->getReservedSlot(JSSLOT_DEBUG_SCRIPT_PROTO).toObject()); in newDebuggerScript()
6280 RootedNativeObject debugger(cx, object); in newDebuggerScript()
6282 return DebuggerScript::create(cx, proto, referent, debugger); in newDebuggerScript()
6287 JSContext* cx, Map& map, in wrapVariantReferent() argument
6289 cx->check(object); in wrapVariantReferent()
6293 MOZ_ASSERT(cx->compartment() != untaggedReferent->compartment()); in wrapVariantReferent()
6295 DependentAddPtr<Map> p(cx, map, untaggedReferent); in wrapVariantReferent()
6297 typename Map::WrapperType* wrapper = newVariantWrapper(cx, referent); in wrapVariantReferent()
6302 if (!p.add(cx, map, untaggedReferent, wrapper)) { in wrapVariantReferent()
6312 JSContext* cx, Handle<DebuggerScriptReferent> referent) { in wrapVariantReferent() argument
6314 return wrapVariantReferent<BaseScript>(cx, scripts, referent); in wrapVariantReferent()
6317 return wrapVariantReferent<WasmInstanceObject>(cx, wasmInstanceScripts, in wrapVariantReferent()
6321 DebuggerScript* Debugger::wrapScript(JSContext* cx, in wrapScript() argument
6323 Rooted<DebuggerScriptReferent> referent(cx, in wrapScript()
6325 return wrapVariantReferent(cx, referent); in wrapScript()
6329 JSContext* cx, Handle<WasmInstanceObject*> wasmInstance) { in wrapWasmScript() argument
6330 Rooted<DebuggerScriptReferent> referent(cx, wasmInstance.get()); in wrapWasmScript()
6331 return wrapVariantReferent(cx, referent); in wrapWasmScript()
6335 JSContext* cx, Handle<DebuggerSourceReferent> referent) { in newDebuggerSource() argument
6336 cx->check(object.get()); in newDebuggerSource()
6339 cx, &object->getReservedSlot(JSSLOT_DEBUG_SOURCE_PROTO).toObject()); in newDebuggerSource()
6341 RootedNativeObject debugger(cx, object); in newDebuggerSource()
6342 return DebuggerSource::create(cx, proto, referent, debugger); in newDebuggerSource()
6346 JSContext* cx, Handle<DebuggerSourceReferent> referent) { in wrapVariantReferent() argument
6349 obj = wrapVariantReferent<ScriptSourceObject>(cx, sources, referent); in wrapVariantReferent()
6351 obj = wrapVariantReferent<WasmInstanceObject>(cx, wasmInstanceSources, in wrapVariantReferent()
6358 DebuggerSource* Debugger::wrapSource(JSContext* cx, in wrapSource() argument
6360 Rooted<DebuggerSourceReferent> referent(cx, source.get()); in wrapSource()
6361 return wrapVariantReferent(cx, referent); in wrapSource()
6365 JSContext* cx, Handle<WasmInstanceObject*> wasmInstance) { in wrapWasmSource() argument
6366 Rooted<DebuggerSourceReferent> referent(cx, wasmInstance.get()); in wrapWasmSource()
6367 return wrapVariantReferent(cx, referent); in wrapWasmSource()
6410 bool Debugger::replaceFrameGuts(JSContext* cx, AbstractFramePtr from, in replaceFrameGuts() argument
6416 DebugEnvironments::forwardLiveFrame(cx, from, to); in replaceFrameGuts()
6421 terminateDebuggerFrames(cx, from); in replaceFrameGuts()
6422 terminateDebuggerFrames(cx, to); in replaceFrameGuts()
6429 Rooted<DebuggerFrameVector> frames(cx, DebuggerFrameVector(cx)); in replaceFrameGuts()
6443 if (!frameobj->replaceFrameIterData(cx, iter)) { in replaceFrameGuts()
6449 ReportOutOfMemory(cx); in replaceFrameGuts()
6475 void Debugger::suspendGeneratorDebuggerFrames(JSContext* cx, in suspendGeneratorDebuggerFrames() argument
6477 JSFreeOp* fop = cx->runtime()->defaultFreeOp(); in suspendGeneratorDebuggerFrames()
6495 void Debugger::terminateDebuggerFrames(JSContext* cx, AbstractFramePtr frame) { in terminateDebuggerFrames() argument
6496 JSFreeOp* fop = cx->runtime()->defaultFreeOp(); in terminateDebuggerFrames()
6499 cx, frame, [&](Debugger* dbg, DebuggerFrame* dbgFrame) { in terminateDebuggerFrames()
6506 RootedScript script(cx, frame.script()); in terminateDebuggerFrames()
6507 DebugScript::clearBreakpointsIn(cx->runtime()->defaultFreeOp(), script, in terminateDebuggerFrames()
6562 bool DebugAPI::handleBaselineOsr(JSContext* cx, InterpreterFrame* from, in handleBaselineOsr() argument
6564 ScriptFrameIter iter(cx); in handleBaselineOsr()
6566 return Debugger::replaceFrameGuts(cx, from, to, iter); in handleBaselineOsr()
6570 bool DebugAPI::handleIonBailout(JSContext* cx, jit::RematerializedFrame* from, in handleIonBailout() argument
6580 ScriptFrameIter iter(cx); in handleIonBailout()
6584 return Debugger::replaceFrameGuts(cx, from, to, iter); in handleIonBailout()
6589 JSContext* cx, jit::RematerializedFrame* frame) { in handleUnrecoverableIonBailoutError() argument
6593 Debugger::terminateDebuggerFrames(cx, frame); in handleUnrecoverableIonBailoutError()
6598 Builder::Builder(JSContext* cx, js::Debugger* debugger) in Builder() argument
6599 : debuggerObject(cx, debugger->toJSObject().get()), debugger(debugger) {} in Builder()
6611 bool Builder::Object::definePropertyToTrusted(JSContext* cx, const char* name, in definePropertyToTrusted() argument
6616 JSAtom* atom = Atomize(cx, name, strlen(name)); in definePropertyToTrusted()
6620 RootedId id(cx, AtomToId(atom)); in definePropertyToTrusted()
6622 return DefineDataProperty(cx, value, id, trusted); in definePropertyToTrusted()
6625 bool Builder::Object::defineProperty(JSContext* cx, const char* name, in defineProperty() argument
6627 AutoRealm ar(cx, debuggerObject()); in defineProperty()
6629 RootedValue propval(cx, propval_); in defineProperty()
6630 if (!debugger()->wrapDebuggeeValue(cx, &propval)) { in defineProperty()
6634 return definePropertyToTrusted(cx, name, &propval); in defineProperty()
6637 bool Builder::Object::defineProperty(JSContext* cx, const char* name, in defineProperty() argument
6639 RootedValue propval(cx, ObjectOrNullValue(propval_)); in defineProperty()
6640 return defineProperty(cx, name, propval); in defineProperty()
6643 bool Builder::Object::defineProperty(JSContext* cx, const char* name, in defineProperty() argument
6645 AutoRealm ar(cx, debuggerObject()); in defineProperty()
6647 RootedValue propval(cx, ObjectOrNullValue(propval_.value)); in defineProperty()
6648 return definePropertyToTrusted(cx, name, &propval); in defineProperty()
6651 Builder::Object Builder::newObject(JSContext* cx) { in newObject() argument
6652 AutoRealm ar(cx, debuggerObject); in newObject()
6654 RootedPlainObject obj(cx, NewBuiltinClassInstance<PlainObject>(cx)); in newObject()
6658 return Object(cx, *this, obj); in newObject()
6663 AutoEntryMonitor::AutoEntryMonitor(JSContext* cx) in AutoEntryMonitor() argument
6664 : cx_(cx), savedMonitor_(cx->entryMonitor) { in AutoEntryMonitor()
6665 cx->entryMonitor = this; in AutoEntryMonitor()
6672 extern JS_PUBLIC_API bool JS_DefineDebuggerObject(JSContext* cx, in JS_DefineDebuggerObject() argument
6674 RootedNativeObject debugCtor(cx), debugProto(cx), frameProto(cx), in JS_DefineDebuggerObject()
6675 scriptProto(cx), sourceProto(cx), objectProto(cx), envProto(cx), in JS_DefineDebuggerObject()
6676 memoryProto(cx); in JS_DefineDebuggerObject()
6677 RootedObject debuggeeWouldRunProto(cx); in JS_DefineDebuggerObject()
6678 RootedValue debuggeeWouldRunCtor(cx); in JS_DefineDebuggerObject()
6682 InitClass(cx, global, nullptr, &DebuggerInstanceObject::class_, in JS_DefineDebuggerObject()
6689 frameProto = DebuggerFrame::initClass(cx, global, debugCtor); in JS_DefineDebuggerObject()
6694 scriptProto = DebuggerScript::initClass(cx, global, debugCtor); in JS_DefineDebuggerObject()
6699 sourceProto = DebuggerSource::initClass(cx, global, debugCtor); in JS_DefineDebuggerObject()
6704 objectProto = DebuggerObject::initClass(cx, global, debugCtor); in JS_DefineDebuggerObject()
6709 envProto = DebuggerEnvironment::initClass(cx, global, debugCtor); in JS_DefineDebuggerObject()
6715 InitClass(cx, debugCtor, nullptr, &DebuggerMemory::class_, in JS_DefineDebuggerObject()
6723 cx, global, JSEXN_DEBUGGEEWOULDRUN); in JS_DefineDebuggerObject()
6729 cx, NameToId(ClassName(JSProto_DebuggeeWouldRun, cx))); in JS_DefineDebuggerObject()
6730 if (!DefineDataProperty(cx, debugCtor, debuggeeWouldRunId, in JS_DefineDebuggerObject()
6758 JSContext* cx, JSObject& dbgObj, MutableHandleObjectVector vector) { in GetDebuggeeGlobals() argument
6764 JS_ReportOutOfMemory(cx); in GetDebuggeeGlobals()
6847 static bool DefineStringProperty(JSContext* cx, HandleObject obj, in DefineStringProperty() argument
6849 RootedValue val(cx, UndefinedValue()); in DefineStringProperty()
6851 JSAtom* atomized = Atomize(cx, strVal, strlen(strVal)); in DefineStringProperty()
6857 return DefineDataProperty(cx, obj, propName, val); in DefineStringProperty()
6860 JSObject* GarbageCollectionEvent::toJSObject(JSContext* cx) const { in toJSObject()
6861 RootedObject obj(cx, NewBuiltinClassInstance<PlainObject>(cx)); in toJSObject()
6862 RootedValue gcCycleNumberVal(cx, NumberValue(majorGCNumber_)); in toJSObject()
6864 !DefineStringProperty(cx, obj, cx->names().nonincrementalReason, in toJSObject()
6866 !DefineStringProperty(cx, obj, cx->names().reason, reason) || in toJSObject()
6867 !DefineDataProperty(cx, obj, cx->names().gcCycleNumber, in toJSObject()
6872 RootedArrayObject slicesArray(cx, NewDenseEmptyArray(cx)); in toJSObject()
6881 RootedPlainObject collectionObj(cx, in toJSObject()
6882 NewBuiltinClassInstance<PlainObject>(cx)); in toJSObject()
6887 RootedValue start(cx), end(cx); in toJSObject()
6892 if (!DefineDataProperty(cx, collectionObj, cx->names().startTimestamp, in toJSObject()
6894 !DefineDataProperty(cx, collectionObj, cx->names().endTimestamp, end)) { in toJSObject()
6898 RootedValue collectionVal(cx, ObjectValue(*collectionObj)); in toJSObject()
6899 if (!DefineDataElement(cx, slicesArray, idx++, collectionVal)) { in toJSObject()
6904 RootedValue slicesValue(cx, ObjectValue(*slicesArray)); in toJSObject()
6905 if (!DefineDataProperty(cx, obj, cx->names().collections, slicesValue)) { in toJSObject()
6912 JS_PUBLIC_API bool FireOnGarbageCollectionHookRequired(JSContext* cx) { in FireOnGarbageCollectionHookRequired() argument
6915 for (auto& dbg : cx->runtime()->onGarbageCollectionWatchers()) { in FireOnGarbageCollectionHookRequired()
6917 if (dbg.observedGC(cx->runtime()->gc.majorGCCount())) { in FireOnGarbageCollectionHookRequired()
6926 JSContext* cx, JS::dbg::GarbageCollectionEvent::Ptr&& data) { in FireOnGarbageCollectionHook() argument
6927 RootedObjectVector triggered(cx); in FireOnGarbageCollectionHook()
6935 for (auto& dbg : cx->runtime()->onGarbageCollectionWatchers()) { in FireOnGarbageCollectionHook()
6939 JS_ReportOutOfMemory(cx); in FireOnGarbageCollectionHook()
6950 (void)dbg->enterDebuggerHook(cx, [&]() -> bool { in FireOnGarbageCollectionHook()
6951 return dbg->fireOnGarbageCollectionHook(cx, data); in FireOnGarbageCollectionHook()
6953 MOZ_ASSERT(!cx->isExceptionPending()); in FireOnGarbageCollectionHook()