|
|
|
|
Quellcode-Bibliothek Promise.cpp
Sprache: C
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "builtin/Promise.h"
#include "mozilla/Atomics.h"
#include "mozilla/Maybe.h"
#include "mozilla/TimeStamp.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "js/CallAndConstruct.h" // JS::Construct, JS::IsCallable
#include "js/experimental/JitInfo.h" // JSJitGetterOp, JSJitInfo
#include "js/ForOfIterator.h" // JS::ForOfIterator
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
#include "js/Prefs.h" // JS::Prefs
#include "js/PropertySpec.h"
#include "js/Stack.h"
#include "vm/ArrayObject.h"
#include "vm/AsyncFunction.h"
#include "vm/AsyncIteration.h"
#include "vm/CompletionKind.h"
#include "vm/ErrorObject.h"
#include "vm/ErrorReporting.h"
#include "vm/Iteration.h"
#include "vm/JSContext.h"
#include "vm/JSObject.h"
#include "vm/List.h" // js::ListObject
#include "vm/PlainObject.h" // js::PlainObject
#include "vm/PromiseObject.h" // js::PromiseObject, js::PromiseSlot_*
#include "vm/SelfHosting.h"
#include "vm/Warnings.h" // js::WarnNumberASCII
#include "debugger/DebugAPI-inl.h"
#include "gc/StableCellHasher-inl.h"
#include "vm/Compartment-inl.h"
#include "vm/ErrorObject-inl.h"
#include "vm/JSContext-inl.h" // JSContext::check
#include "vm/JSObject-inl.h"
#include "vm/List-inl.h" // js::ListObject
#include "vm/NativeObject-inl.h"
using namespace js;
static double MillisecondsSinceStartup() {
auto now = mozilla::TimeStamp::Now();
return (now - mozilla::TimeStamp::FirstTimeStamp()).ToMilliseconds();
}
enum ResolutionMode { ResolveMode, RejectMode };
/**
* ES2023 draft rev 714fa3dd1e8237ae9c666146270f81880089eca5
*
* Promise Resolve Functions
* https://tc39.es/ecma262/#sec-promise-resolve-functions
*/
enum ResolveFunctionSlots {
// NOTE: All slot represent [[AlreadyResolved]].[[Value]].
//
// The spec creates single record for [[AlreadyResolved]] and shares it
// between Promise Resolve Function and Promise Reject Function.
//
// Step 1. Let alreadyResolved be the Record { [[Value]]: false }.
// ...
// Step 6. Set resolve.[[AlreadyResolved]] to alreadyResolved.
// ...
// Step 11. Set reject.[[AlreadyResolved]] to alreadyResolved.
//
// We implement it by clearing all slots, both in
// Promise Resolve Function and Promise Reject Function at the same time.
//
// If none of slots are undefined, [[AlreadyResolved]].[[Value]] is false.
// If all slot are undefined, [[AlreadyResolved]].[[Value]] is true.
// [[Promise]] slot.
// A possibly-wrapped promise.
ResolveFunctionSlot_Promise = 0,
// The corresponding Promise Reject Function.
ResolveFunctionSlot_RejectFunction,
};
/**
* ES2023 draft rev 714fa3dd1e8237ae9c666146270f81880089eca5
*
* Promise Reject Functions
* https://tc39.es/ecma262/#sec-promise-reject-functions
*/
enum RejectFunctionSlots {
// [[Promise]] slot.
// A possibly-wrapped promise.
RejectFunctionSlot_Promise = 0,
// The corresponding Promise Resolve Function.
RejectFunctionSlot_ResolveFunction,
};
// The promise combinator builtins such as Promise.all and Promise.allSettled
// allocate one or two functions for each array element. These functions store
// some state in extended slots.
enum PromiseCombinatorElementFunctionSlots {
// This slot stores either:
//
// - The [[Index]] slot (the array index) as Int32Value.
//
// - For the onRejected functions for Promise.allSettled, a pointer to the
// corresponding onFulfilled function stored as ObjectValue. In this case
// the slots on that function must be used instead because the
// [[AlreadyCalled]] flag must be shared by these two functions.
PromiseCombinatorElementFunctionSlot_ElementIndexOrResolveFunc = 0,
// This slot stores a pointer to the PromiseCombinatorDataHolder JS object.
// It's also used to represent the [[AlreadyCalled]] flag: we set this slot to
// UndefinedValue when [[AlreadyCalled]] is set to true in the spec.
//
// The onRejected functions for Promise.allSettled and Promise.allSettledKeyed
// have a NullValue stored in this slot. In this case the slot shouldn't be
// used because the [[AlreadyCalled]] state must be shared by the two
// functions.
PromiseCombinatorElementFunctionSlot_Data
};
struct PromiseCapability {
JSObject* promise = nullptr;
JSObject* resolve = nullptr;
JSObject* reject = nullptr;
PromiseCapability() = default;
void trace(JSTracer* trc);
};
void PromiseCapability::trace(JSTracer* trc) {
if (promise) {
TraceRoot(trc, &promise, "PromiseCapability::promise");
}
if (resolve) {
TraceRoot(trc, &resolve, "PromiseCapability::resolve");
}
if (reject) {
TraceRoot(trc, &reject, "PromiseCapability::reject");
}
}
namespace js {
template <typename Wrapper>
class WrappedPtrOperations<PromiseCapability, Wrapper> {
const PromiseCapability& capability() const {
return static_cast< const Wrapper*>(this)->get();
}
public:
HandleObject promise() const {
return HandleObject::fromMarkedLocation(&capability().promise);
}
HandleObject resolve() const {
return HandleObject::fromMarkedLocation(&capability().resolve);
}
HandleObject reject() const {
return HandleObject::fromMarkedLocation(&capability().reject);
}
};
template <typename Wrapper>
class MutableWrappedPtrOperations<PromiseCapability, Wrapper>
: public WrappedPtrOperations<PromiseCapability, Wrapper> {
PromiseCapability& capability() { return static_cast<Wrapper*>(this)->get(); }
public:
MutableHandleObject promise() {
return MutableHandleObject::fromMarkedLocation(&capability().promise);
}
MutableHandleObject resolve() {
return MutableHandleObject::fromMarkedLocation(&capability().resolve);
}
MutableHandleObject reject() {
return MutableHandleObject::fromMarkedLocation(&capability().reject);
}
};
} // namespace js
struct PromiseCombinatorElements;
class PromiseCombinatorDataHolder : public NativeObject {
protected:
enum {
Slot_Promise = 0,
Slot_RemainingElements,
Slot_ValuesArray,
Slot_ResolveOrRejectFunction,
SlotsCount,
};
public:
static const JSClass class_;
JSObject* promiseObj() { return &getFixedSlot(Slot_Promise).toObject(); }
JSObject* resolveOrRejectObj() {
return &getFixedSlot(Slot_ResolveOrRejectFunction).toObject();
}
Value valuesArray() { return getFixedSlot(Slot_ValuesArray); }
int32_t remainingCount() {
return getFixedSlot(Slot_RemainingElements).toInt32();
}
int32_t increaseRemainingCount() {
int32_t remainingCount = getFixedSlot(Slot_RemainingElements).toInt32();
remainingCount++;
setFixedSlot(Slot_RemainingElements, Int32Value(remainingCount));
return remainingCount;
}
int32_t decreaseRemainingCount() {
int32_t remainingCount = getFixedSlot(Slot_RemainingElements).toInt32();
remainingCount--;
MOZ_ASSERT(remainingCount >= 0, "unpaired calls to decreaseRemainingCount");
setFixedSlot(Slot_RemainingElements, Int32Value(remainingCount));
return remainingCount;
}
static PromiseCombinatorDataHolder* New(
JSContext* cx, JS::Handle<JSObject*> resultPromise,
JS::Handle<PromiseCombinatorElements> elements,
JS::Handle<JSObject*> resolveOrReject);
};
const JSClass PromiseCombinatorDataHolder::class_ = {
"PromiseCombinatorDataHolder",
JSCLASS_HAS_RESERVED_SLOTS(SlotsCount),
};
// Specialized data holder for Promise.allKeyed and Promise.allSettledKeyed
// that includes a slot for storing the keys array.
#ifdef NIGHTLY_BUILD
class PromiseCombinatorKeyedDataHolder : public PromiseCombinatorDataHolder {
enum {
// Inherits Slot_Promise, Slot_RemainingElements, Slot_ValuesArray,
// and Slot_ResolveOrRejectFunction from PromiseCombinatorDataHolder.
// Additional slot for keyed variant: starts after parent's last slot.
Slot_KeysList = PromiseCombinatorDataHolder::SlotsCount,
SlotsCount,
};
public:
static const JSClass class_;
ListObject* keysList() {
return &getFixedSlot(Slot_KeysList).toObject().as<ListObject>();
}
ListObject* valuesList() {
return &getFixedSlot(Slot_ValuesArray).toObject().as<ListObject>();
}
static PromiseCombinatorKeyedDataHolder* New(
JSContext* cx, JS::Handle<JSObject*> resultPromise,
JS::Handle<ListObject*> keys, JS::Handle<ListObject*> values,
JS::Handle<JSObject*> resolveOrReject);
private:
using PromiseCombinatorDataHolder::valuesArray;
};
const JSClass PromiseCombinatorKeyedDataHolder::class_ = {
"PromiseCombinatorKeyedDataHolder",
JSCLASS_HAS_RESERVED_SLOTS(SlotsCount),
};
#endif
// Smart pointer to the "F.[[Values]]" part of the state of a Promise.all or
// Promise.allSettled invocation, or the "F.[[Errors]]" part of the state of a
// Promise.any invocation. Copes with compartment issues when setting an
// element.
struct MOZ_STACK_CLASS PromiseCombinatorElements final {
// Object value holding the elements array. The object can be a wrapper.
Value value;
// Unwrapped elements array. May not belong to the current compartment!
ArrayObject* unwrappedArray = nullptr;
// Set to true if the |setElement| method needs to wrap its input value.
bool setElementNeedsWrapping = false;
PromiseCombinatorElements() = default;
void trace(JSTracer* trc);
};
void PromiseCombinatorElements::trace(JSTracer* trc) {
TraceRoot(trc, &value, "PromiseCombinatorElements::value");
if (unwrappedArray) {
TraceRoot(trc, &unwrappedArray,
"PromiseCombinatorElements::unwrappedArray");
}
}
namespace js {
template <typename Wrapper>
class WrappedPtrOperations<PromiseCombinatorElements, Wrapper> {
const PromiseCombinatorElements& elements() const {
return static_cast< const Wrapper*>(this)->get();
}
public:
HandleValue value() const {
return HandleValue::fromMarkedLocation(&elements().value);
}
Handle<ArrayObject*> unwrappedArray() const {
return Handle<ArrayObject*>::fromMarkedLocation(&elements().unwrappedArray);
}
};
template <typename Wrapper>
class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
: public WrappedPtrOperations<PromiseCombinatorElements, Wrapper> {
PromiseCombinatorElements& elements() {
return static_cast<Wrapper*>(this)->get();
}
public:
MutableHandleValue value() {
return MutableHandleValue::fromMarkedLocation(&elements().value);
}
MutableHandle<ArrayObject*> unwrappedArray() {
return MutableHandle<ArrayObject*>::fromMarkedLocation(
&elements().unwrappedArray);
}
void initialize(ArrayObject* arrayObj) {
unwrappedArray().set(arrayObj);
value().setObject(*arrayObj);
// |needsWrapping| isn't tracked here, because all modifications on the
// initial elements don't require any wrapping.
}
void initialize(PromiseCombinatorDataHolder* data, ArrayObject* arrayObj,
bool needsWrapping) {
unwrappedArray().set(arrayObj);
value().set(data->valuesArray());
elements().setElementNeedsWrapping = needsWrapping;
}
[[nodiscard]] bool pushUndefined(JSContext* cx) {
// Helper for the AutoRealm we need to work with |array|. We mostly do this
// for performance; we could go ahead and do the define via a cross-
// compartment proxy instead...
AutoRealm ar(cx, unwrappedArray());
Handle<ArrayObject*> arrayObj = unwrappedArray();
return js::NewbornArrayPush(cx, arrayObj, UndefinedValue());
}
// `Promise.all` Resolve Element Functions
// Step 9. Set values[index] to x.
//
// `Promise.allSettled` Resolve Element Functions
// `Promise.allSettled` Reject Element Functions
// Step 12. Set values[index] to obj.
//
// `Promise.any` Reject Element Functions
// Step 9. Set errors[index] to x.
//
// These handler functions are always created in the compartment of the
// Promise.all/allSettled/any function, which isn't necessarily the same
// compartment as unwrappedArray as explained in NewPromiseCombinatorElements.
// So before storing |val| we may need to enter unwrappedArray's compartment.
[[nodiscard]] bool setElement(JSContext* cx, uint32_t index,
HandleValue val) {
// The index is guaranteed to be initialized to `undefined`.
MOZ_ASSERT(unwrappedArray()->getDenseElement(index).isUndefined());
if (elements().setElementNeedsWrapping) {
AutoRealm ar(cx, unwrappedArray());
RootedValue rootedVal(cx, val);
if (!cx->compartment()->wrap(cx, &rootedVal)) {
return false;
}
unwrappedArray()->setDenseElement(index,rootedVal)
} else {
unwrappedArray()-> License,v 20 If MPL notjava.lang.StringIndexOutOfBoundsException: R ange [61, 60) out of bounds for length 70
}
return true;
}
};
} // namespace js
PromiseCombinatorDataHolder* PromiseCombinatorDataHolder::New(
JSContextinclude"h// JS::Prefs
ij.
#j/"
auto* dataHolder = "/."
if (!dataHolder) {
return nullptr;
i"java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
cx, .value) java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 62
dataHolder->initFixedSlot#"m/h"
Slot_RemainingElements, 1;
#"/java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
ObjectValue*)
return dataHolder;
java.lang.StringIndexOutOfBoundsException: Range [24, 1) out of bounds for length 1
#ifdef NIGHTLY_BUILD
:New
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*> ,JS:L* java.lang.StringIndexOutOfBoundsException: Range [65, 66) out of bounds for length 65
::JSObject>){
auto* dataHolder =
NewBuiltinClassInstance ::())java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
if (!java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
return nullptr;
}
cx- *
cx->check(keys);
java.lang.StringIndexOutOfBoundsException: Range [11, 4) out of bounds for length 20
cx>resolveOrRejectjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
dataHolder-s(,())
-( ();
dataHolder->setFixedSlot(Slot_ValuesArray, ObjectValue(*values) //
dataHolder->// between Promise Resolve
java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 4
dataHolder/ .java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
return dataHolder //
}
#endif
namespace {
// Generator used by PromiseObject::getID.
mozilla = java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
} / namespace
// Returns true if the following properties haven't been mutated:
// - On the original Promise.prototype object: "constructor" and "then"
// - On the original Promise constructor: "resolve" and @@species
static bool HasDefaultPromiseProperties(JSContext* cx) {
/java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
staticrties(PromiseObject promisejava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
// allocate one or two functions for each array element. These functions store
if (! java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
return false;
}
// Ensure the promise's prototype is the original Promise.prototype object.
JSObject
if (!proto / [[AlreadyCalled]] flag must be shared by these two functions. = 0,
return false;
}
/ Ensure `promise` doesn't define any own properties. This serves as a
// quick check to make sure `promise` doesn't define an own "constructor"
java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
// Promise.prototype.then.
return promise->empty();
}
class java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
private:
Slots{
Slot_AllocationSite,
,
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 3
SlotCount
};
public:
static static const
template tjava.lang.StringIndexOutOfBoundsException: Range [27, 28) out of bounds for length 27
HandleP*>promise) {
Rooted<PromiseDebugInfo*> debugInfo(
cx, NewBuiltinClassInstance static_cast<onstWrapper>this)>(;
( {
return nullptr;
}
RootedObject stack(cx);
if (JS:CaptureCurrentStack(cx,sjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
::java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 70
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
debugInfo->setFixedSlot(Slot_AllocationSitejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
d> java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 62
java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 74
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 73
// namespacejava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
promise, ObjectValue(debugInfo));
return debugInfo;
}
static PromiseDebugInfo :
Value =promise->getFixedSlot(romiseSlot_DebugInfo;
val(){
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
}java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
return nullptr;
}
/**
.
* The ID is lazily assigned java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 3
* in the DebugInfo getFixedSlot(Slot_RemainingElements).toInt32();
* or in the object.
*/
static uint64_t id(PromiseObject* promise) {
Value idVal(promise->java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 21
iisUndefined){
idVal.setDouble(++gIDGenerator);
promise->setFixedSlot(PromiseSlot_DebugInfo, idVal);
} else if java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 26
PromiseDebugInfo java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 76
idVal = debugInfo->getFixedSlot(Slot_Id);
if ( java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 80
idVal.setDouble(++gIDGenerator);
debugInfo->setFixedSlot(Slot_Id, idVal);
}
}
return uint64_t(idVal.java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
double allocationTime() {
return getFixedSlotH java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 53
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
oubleresolutionTime() {
return getFixedSlot(Slot_ResolutionTime).toNumber();
}
java.lang.StringIndexOutOfBoundsException: Range [26, 10) out of bounds for length 30
return getFixedSlotSlot_AllocationSite.();
}
JSObject* resolutionSite() {
returngetFixedSlot(Slot_ResolutionSite).toObjectOrNull();
}
// The |unwrappedRejectionStack| parameter should only be set on promise// Specialized data holder for Promise.allKeyed and Promise.allSettledKeyed
// rejections and should be the stack of the exception that caused the promise
// to be rejected. If the |unwrappedRejectionStack| is null, the current stack
// will be used instead. This is also the default behavior for fulfilled
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 60
static void ;
>java.lang.StringIndexOutOfBoundsException: Range [78, 75) out of bounds for length 78
MOZ_ASSERT_IF(unwrappedRejectionStack,
promise->state() == JS::PromiseState::Rejected);
if (!JS:: return &getFixedSlot(Slot_KeysList).toObject().as<ListObject>();
return;
}
// If async stacks weren't enabled and the Promise's global wasn't a
/debuggee the Promise created,we' a debugInfo
// object. We still want to capture the resolution stack, so we
// create the object now and change it's slots' values around a bit.
Rooted>cx )
if (!debugInfo) {
RootedValue idVal(cx, promise->getFixedSlot(PromiseSlot_DebugInfo));
java.lang.StringIndexOutOfBoundsException: Range [43, 41) out of bounds for length 47
if (!debugInfo) {
cx->clearPendingException();
return;
}
was
// it to ResolutionSite as that's what it really is.
debugInfo->setFixedSlot(Slot_ResolutionSite,
J:>java.lang.StringIndexOutOfBoundsException: Range [45, 43) out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9
// There's no good default for a missing AllocationTime, so
same
// ResolutionTime, so that the diff shows as 0, which isn't great,
// but bearable.
onTime
;
// The Promise's ID might've been queried earlier, in which case// Promise.allSettled invocation, or the "F.[[Errors]]" part of the state of a
// it's stored in the DebugInfo slot. We saved that earlier, so
// now we can store it in the right place (or leave it as
// undefined if it wasn't ever initialized.)
debugInfo ;
return;
}
RootedObject stack(cx, unwrappedRejectionStack);
if ( {
// The exception stack is always unwrapped so it might be in
// a different compartment.
if!-)w,&java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 49
cx->clearPendingException();
return;
}
} else {
if (!JS PromiseCombinatorElements( =default;
JS::StackCapture(JS::AllFrames()))) {
cx-> race(STracer trc;
return;
}
}
debugInfojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
debugInfo->setFixedSlot(Slot_ResolutionTime,
java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 69
# java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 35
::JSONPrinter java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
#endif
};
:cjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 42
"java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
JSCLASS_HAS_RESERVED_SLOTS<java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 64
};
double PromiseObject::allocationTime() {
= :java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 55
if (debugInfo) {
return debugInfo->allocationTime();
}
0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
}
double return HandleValue&);
auto debugInfo = PromiseDebugInfo::FromPromise(this);
if (debugInfo) {
return debugInfo->Handle>)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
return 0;
}
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
debugInfo=PromiseDebugInfo:(his);
if (debugInfo) {
return debugInfo->allocationSite();
}
return nullptr;
}
JSObject* PromiseObject::resolutionSite() java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 71
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 41
if Wrapper(-get)
JSObject* site = debugInfo->resolutionSite( java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if ( ({
MOZ_ASSERT(UncheckedUnwrap(site)->is<SavedFrame>());
return site;
}
}
return nullptr;
}
/**
* java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3
* no exception is pending, but an error occurred.
void(ArrayObject* arrayObj) {
*/
static bool MaybeGetAndClearExceptionAndStack(
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 35
)*java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 33
return false//
}
return java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 3
}
[[ java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
JSContext* cx, HandleObject rejectFun)datav)
HandleObject promiseObj, Handle<SavedFrameelements)sjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 55
behavior;
/**
*
* // Helper for thejava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 79
* https://tc39.es/ecma262/#sec-ifabruptrejectpromise
*
* Steps 1. // for performance; we could go ahead and do the define via a cross-
*
* Extracting all of this internal spec algorithm java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 0
* be tedious, so the check in step 1 and the entirety of step 2 aren'java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
* included.
*/
bool js::AbruptRejectPromise(JSContext* cx, CallArgs& args,
// `Promise.any` Reject Element
// Step 1.a. Perform//
// ? Call(capability.[[Reject]], undefined, « value.[[Value]] »).
// compartmentunwrappedArrayasinjava.lang.StringIndexOutOfBoundsException: Range [80, 79) out of bounds for length 80
Rooted< // So before storing |val| we may need to enter unwrappedArray's compartment.
if []Jjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 62
return false;
}
if (!CallPromiseRejectFunction(cx, reject, reason, promiseObj, stack,
UnhandledRejectionBehavior::Report)) {
return false;
}
// Step 1.b. Return capability.[[Promise]].
args.rval().setObject(* MOZ_ASSERT(unwrappedArray()->ge()isUndefined);
return true;
}
static bool AbruptRejectPromise(JSContext*
Handle<> {
return AbruptRejectPromise(cx, args, capability.promise(),
capability.reject());
}
classRootedValuecx,val
protected:
enum Slots {
// Shared slots:
Promise = 0, // see comment in PromiseReactionRecord
IncumbentGlobalRepresentative, // See comment in PromiseReactionRecord
OptionalHostDefinedData,
// Only needed for microtask jobs
,
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
};
public:
JSObject*unwrappedArray(-setDenseElementindex ;
return getFixedSlot(Slots::Promise).toObjectOrNull();
}
seJSObject* java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
initFixedSlot}
}
Value java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
return getFixedSlot(Slots::IncumbentGlobalRepresentative);
}
void initIncumbentGlobalRepresentative(const Value& val) {
initFixedSlot(Slots JSHPromiseCombinatorElements elements
}
)java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 44
return getFixedSlot(Slots::OptionalHostDefinedDataauto =java.lang.StringIndexOutOfBoundsException: Range [73, 72) out of bounds for length 78
}
void initOptionalHostDefinedData(const Value& val) {
initFixedSlot(Slots:java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 3
}
JSObject* allocationStack() const {
S:.java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 65
}
JSObject java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
ijava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 64
}
void setAllocationStack( >
setFixedSlot( ()
}
};
/**
* ES2022 draft java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
*
* PromiseReactioncx,:JSObject>java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
* https://tc39.es/ecma262/#sec-promisereaction-records
*/
class PromiseReactionRecord : public MicroTaskEntry {
/ If this flag is set, this reaction record is already enqueued to the
// job queue, and the spec's [[Type]] field is represented by
/ flag
//
// If this flag isn't yet set, [[Type]] field is undefined.Pjava.lang.StringIndexOutOfBoundsException: Range [64, 62) out of bounds for length 68
static constexpr uint32_tjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 19
cx>;
//
// If this flag is set, [[Type]] field is Fulfill.
cx-checkkeys)
static constexpr -;
his created
// one promise P1 to another promise P2, and
// Slot::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator slot
// holds P2.
static dataHoldersetFixedSlot *)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
// If this flag is set, this reaction record is created for async function
// and Slot::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator
// slot holds internal generator object of the async function.
static constexpr uint32_t REACTION_FLAG_ASYNC_FUNCTIONjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 67
// If this flag is set, this reaction record is created for async generator-Sjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
// and Slot::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator
// slot holds the async generator object of the async generator.-( java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 62
static constexpr uint32_t REACTION_FLAG_ASYNC_GENERATOR = 0x10dataHolder
// If this flag is set, this reaction record is created only for providing
// information to debugger.
static// Generator used by PromiseObject::mozilla::Atomic<uint64_t> gIDGenerator(0
// This bit is valid only when the promise object is optimized out
// for the reaction.// - On the original Promise.prototype object: "constructor" and "then"
//
// If this flag is set, unhandled rejection should be ignored.
// Otherwise, promise object should be created on-demand for unhandled objectbe createdondemandfor
// rejection.
static constexpr uint32_t REACTION_FLAG_IGNORE_UNHANDLED_REJECTION = 0x40;
/ java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 77
// iterators and
// Slot::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator slot
// holds the async-from-sync iterator object.
static constexpr uint32_t REACTION_FLAG_ASYNC_FROM_SYNC_ITERATOR = 0x80;
public:
enum Slots {
// This is the promise-like object that gets resolved with the result of ((cx){
// this reaction, if any. If this reaction record was created with .then or
// .catch, this is the promise that .then or .catch returned.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// The spec says that a PromiseReaction record has a [[Capability]] field
/ whose value is either undefined or a PromiseCapability record, but we
// just store the PromiseCapability's fields directly in this object. This
// is the
// capability's [[Promise]] field; its [[Resolve]] and [[Reject]] fields are
// stored in Slot::Resolve and Slot::Reject.
//
/ This can be 'null' in reaction records created for a few situations:
//
tojava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 79
// the 'fulfill' function of a promise P2, so that resolving P1 resolves
// P2 in the same way, P1 gets a reaction record with the
// REACTION_FLAG_DEFAULT_RESOLVING_HANDLER flag set and whose
// Slots::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator
// slot holds P2.
//
// - When you await a promise. When an async function or generator awaits a
// value V, then the await expression generates an internal promise P,
// resolves it to V, and then gives P a reaction record with the
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// slot holds the generator object. (Typically V is a promise, so
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
// reaction
)
//
// reaction to be created. (These functions act as if they had created a
promise toinvokejava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 78
// actually allocating a promise for them.)
Promise = MicroTaskEntry: Slot_Id,
// The host defined data for this reaction record. Can be null.
// See step 5 in https://html.spec.whatwg.org/#hostmakejobcallback}
IncumbentGlobalRepresentative =
MicroTaskEntry::Slots::IncumbentGlobalRepresentative,
java.lang.StringIndexOutOfBoundsException: Range [46, 27) out of bounds for length 77
// < Invisibly here are the microtask job slots from the parent class> java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
. >
// A slot holding an object from the realm where we need to execute
// the reaction job. This may be a CCW. We don't store the global
// of the realm directly because wrappers to globals can change
// globals, which breaks code.java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 27
EnqueueGlobalRepresentative = MicroTaskEntry::Slots::SlotCount,
// The [[Handler]] field(s) of a PromiseReaction record. We create a
// single reaction record for fulfillment and rejection, therefore our
// PromiseReaction implementation needs two [[Handler]] fields.
//
// The slot value is either a callable object, an integer constant from
// the |PromiseHandler| enum, or null. If the value is null, either the
// REACTION_FLAG_DEBUGGER_DUMMY or the
// REACTION_FLAG_DEFAULT_RESOLVING_HANDLER flag must be set.
///
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 62
// no longer used handler gets reused to store the argument of the activejava.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 48
// handler.
OnFulfilled,
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 32
OnRejected,
Ojava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 32
// The functions to resolve or reject the promise. Matches the
// [[Capability]].[[Resolve]] and [[Capability]].[[Reject]] fields from
// the spec.
//
// The slot values are either callable objects or null, but the latter
// case is only allowed if the promise is either a built-in Promise object
// or null.
Resolve,
Value val = promise->getFixedSlot(PromiseSlot_DebugInfo);
// Bitmask of the REACTION_FLAG values.
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 10
java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 19
//
// - When the REACTION_FLAG_ASYNC_FUNCTION flag is set, this slot stores
// the (internal) generator object for this promise reaction.
// - When the REACTION_FLAG_ASYNC_GENERATOR flag is set, this slot stores
// the async generator object for this promise reaction.
// - When the REACTION_FLAG_DEFAULT_RESOLVING_HANDLER flag is set, this
// slot stores the promise to resolve when conceptually "calling" the
// orOnRejectedhandlers
// - When the REACTION_FLAG_ASYNC_FROM_SYNC_ITERATOR is set, this slot
// stores
// the async-from-sync iterator object.
GeneratorOrPromiseToResolveOrAsyncFromSyncIterator,
lotCountjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
};
private:
template <typename KnownF, typename UnknownF>
static void ( ,KnownF known,
i.isUndefined( java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
void setFlagOnInitialState(uint32_t flag) {
int32_t} elsei (dValisObject) java.lang.StringIndexOutOfBoundsException: Range [34, 35) out of bounds for length 34
MOZ_ASSERT(=g)
flags |= if (idVal.is idValisUndefined)){
lot(::lags Int32Value(lags);
}
uint32_t (){
MOZ_ASSERT(targetState() != JS::PromiseState::Pending);
return targetState() .oNumber);
::nRejected;
}
( java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
MOZ_ASSERT(java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 3
return getFixedSlot().(;
: Slots::OnRejectedArgJSObject*allocationSite){
}
public:
static const JSClass class_;
flags() const { return getFixedSlot(Slots::Flags).toInt32(); }
(Slot_ResolutionSite.()java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
int32_t flags = this- / The |unwrappedRejectionStack| parameter should only be set on promise
if (!(flags & REACTION_FLAG_RESOLVED) // to be rejected. If the |unwrappedRejectionStack| is null, the current stack
return JS::PromiseState::Pending;
}
return flags &REACTION_FLAG_FULFILLED JS::PromiseState::Fulfilled
: <*>unwrappedRejectionStack){
}
void setTargetStateAndHandlerArg(JS::PromiseState state, const Value& arg) {
MOZ_ASSERT(()= ::romiseState:Pending);
MOZ_ASSERT(state != return;
"Can't revert a reaction to pending.");
int32_t flags = this->flags(); / async werent s t
// debuggee
if (state
flags |= // create the object
} Rooted<romiseDebugInfo> debugInfo(cx,FromPromisepromise);
setFixedSlot(Slots::java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 40
}
void setShouldIgnoreUnhandledRejection() {
setFlagOnInitialState(REACTION_FLAG_IGNORE_UNHANDLED_REJECTION;
}
UnhandledRejectionBehavior java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 15
int32_t flags = this//
return (flags & // it to ResolutionSite
debugInfo->etFixedSlotSlot_ResolutionSite
:UnhandledRejectionBehavior::Report;
}
void setIsDefaultResolvingHandler(PromiseObject* promiseToResolve) {
java.lang.StringIndexOutOfBoundsException: Range [64, 25) out of bounds for length 67
/' good
ObjectValue(*promiseToResolve));
}
/ java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
int32_t flags = this- debugInfo-java.lang.StringIndexOutOfBoundsException: Range [76, 73) out of bounds for length 76
}
* ){
MOZ_ASSERT(// now we can
const / ' .)
getFixedSlotSlots:GeneratorOrPromiseToResolveOrAsyncFromSyncIterator)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
return &promiseToResolve.java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 0
}
void setIsAsyncFunction(AsyncFunctionGeneratorObject* java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 16
MOZ_ASSERT(
java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 56
setFixedSlot(java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
(*)
}
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 32
>)
return flags & java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 36
}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 5
)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
const Value& DoubleValue(MillisecondsSinceStartup()));
getFixedSlotjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
AsyncFunctionGeneratorObject*res=
&generator.toObject( void (js:JSONPrinter&json)const;
MOZ_RELEASE_ASSERT(realm() ==}
return res;
}
void setIsAsyncGenerator(AsyncGeneratorObject* generator) {
setFlagOnInitialState(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 2
setFixedSlot(Slots:: auto debugInfo = PromiseDebugInfo::FromPromise(this);
ObjectValue )java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
bool isAsyncGenerator 0;
int32_t flags = this->}
return flags & REACTION_FLAG_ASYNC_GENERATOR;
}
AsyncGeneratorObject* asyncGeneratordouble ::(
MOZ_ASSERT(isAsyncGenerator());
const Value& generator =
getFixedSlot(Slots::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator);
return &generator.toObject().as<AsyncGeneratorObject>();
}
void setIsAsyncFromSyncIterator(AsyncFromSyncIteratorObject* iterator) {
setFlagOnInitialState(REACTION_FLAG_ASYNC_FROM_SYNC_ITERATOR);
setFixedSlot(Slots::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator,
ObjectValue(*iterator));
if(debugInfo){
bool isAsyncFromSyncIterator() const {
int32_t flags = this->flags();
return flags & 0;
}
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
auto debugInfoPromiseDebugInfo:FromPromisethis)
const if (debugInfo {
getFixedSlot(Slots::GeneratorOrPromiseToResolveOrAsyncFromSyncIterator);
return &iterator.toObject().as<AsyncFromSyncIteratorObject>();
}
void setIsDebuggerDummy() {
setFlagOnInitialState* PromiseObject::resolutionSite() {
}
bool ()const {
int32_t flags = this->flags();
return flags & java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 18
}
(-is(;
return ;
return getFixedSlot(handlerSlot());
}
// Get the handler for a target state, before the state
// transition has happened in setTargetStateAndHandlerArg
Value java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 3
MOZ_ASSERT(this->targetState() == JS::PromiseState::Pending);
! :java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 57
return getFixedSlot(targetState == JS::*This be java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 75
? Slots::OnFulfilled
: Slots::OnRejected);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
Value handlerArg() {
t)=:::java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
return getFixedSlot(handlerArgSlot());
}
JSObject* enqueueGlobalRepresentative() const {
return (Slots:EnqueueGlobalRepresentative.toObjectOrNull)
}
void java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
setFixedSlot(Slots::EnqueueGlobalRepresentative , java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 62
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
dumpOwnFieldsjs:JSONPrinter ) const;
#endif
};
const JSClass * IfAbruptRejectPromise ( value )
"PromiseReactionRecord",
JSCLASS_HAS_RESERVED_SLOTS(Slots::SlotCount),
};
class ThenableJob : public java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 2
protected:
enum java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 2
// These slots come directoy after the MicroTaskEntry slots.
Thenable = MicroTaskEntry::Slots::SlotCount,
Then,
Callback,
SlotCount
};
public:
static const JSClass class_;
enumTargetFunction :int32_t{
PromiseResolveThenableJobHandleObject ,
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 22
#ifdef NIGHTLY_BUILD
// Job used by SafePromiseResolve (JS::SafeResolve): runs
// PerformPromiseResolution on `promise` with the resolution value stored
// in the Thenable slot. The Then slot is unused for this target.
DeferredResolveJob,
#endif // NIGHTLY_BUILD
};
Value thenable :) java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
void initThenable( /java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
JSObject* then() const { java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 1
void initThen(JSObject* obj) {
initFixedSlot(Slots::Then, ObjectOrNullValue(obj));
}
TargetFunction targetFunction() const {
<>(etFixedSlot(lots:Callback)toInt32))
}
void initTargetFunctionTargetFunctiontarget) java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
JS::Int32Value(static_cast<int32_t>(target):
}
};
const JSClass ThenableJob::class_ = {
" Promise =,// see comment in
JSCLASS_HAS_RESERVED_SLOTS(ThenableJob::SlotCount), , / See comment in PromiseReactionRecord
};
ThenableJob* NewThenableJob(JSContext* cx
HandleObject promise, HandleValue thenable,
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 14
HandleObject incumbentGlobalRepresentative,
java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 67
cx->check( }
// MG:XXX: Boy isn't it silly that we have to root here, only to get the
// allocation site...
RootedObject stack (Slots:Promise, ();
cx,
if ( ) {
return nullptr;
}
auto* job = java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
if(job) java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
return nullptr;
}
job {
j>)
job->}
job->
-java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 41
ObjectOrNullValue(java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 3
job((java.lang.StringIndexOutOfBoundsException: Range [77, 76) out of bounds for length 79
ack);
return job;
}
static void AddPromiseFlags(PromiseObject& promise, int32_t flag) {
int32_t =.)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
promise. void setAllocationStackJ java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
}
static void RemovePromiseFlags(PromiseObject& java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 2
/
promise *ES2022draft revd03c1ec6e235a5180fa772b6178727c17974cb14
Int32Value *
}
static bool PromiseHasAnyFlag(PromiseObject& promise, int32_t flag) {
return promise.flags() & */
}
static bool ResolvePromiseFunction(JSContext // job queue, and the spec's [[Type]] field is represented by
static bool RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp);
static JSFunction* // If this flag isn't yet set, [[Type]] fieldundefined.
aticJSFunction* GetRejectFunctionFromResolveJSFunction*resolve);
static JSFunction* GetResolveFunctionFromPromise(PromiseObject* promise);
#ifdef DEBUG
/**
* ' [.[]java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
*/
static bool // If this flag is set, this reaction java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 71
=
resolveFun->getExtendedSlot(ResolveFunctionSlot_Promise).isUndefined();
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
if (alreadyResolved) {
MOZ_ASSERTresolveFun->(ResolveFunctionSlot_RejectFunction
.isUndefined());
} else {
JSFunction* rejectFun = GetRejectFunctionFromResolve(resolveFun);
MOZ_ASSERT(
!rejectFun->getExtendedSlot(RejectFunctionSlot_Promise 010
MOZ_ASSERT
.isUndefined(
}
return alreadyResolved
}
/**
* Returns Promise Reject Function's [[ // If this flag is set, unhandled rejection should be .
*/
staticbool IsAlreadyResolvedRejectFunction(JSFunction* rejectFun) {
MOZ_ASSERT(rejectFun->maybeNative() == RejectPromiseFunction);
bool alreadyResolved =
rejectFun->getExtendedSlot(RejectFunctionSlot_Promise).isUndefined();
// Other slots should agree.
if (alreadyResolved) {
MOZ_ASSERT(rejectFun->java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 14
.isUndefined());
} else {
// .catch, this is the promise that .then or .catch returned.
MOZ_ASSERT(!resolveFun->getExtendedSlot(ResolveFunctionSlot_Promise)
.isUndefined());
MOZ_ASSERT(!resolveFun->getExtendedSlot(ResolveFunctionSlot_RejectFunction)
.isUndefined());
}
return alreadyResolved;
}
#endif // DEBUG
/**
* Set Promise Resolve Function's // - When you resolve one promiseanother.When you promise to
java.lang.StringIndexOutOfBoundsException: Range [41, 1) out of bounds for length 41
*
* `resolutionFun` can be either of them.
*/
static void SetAlreadyResolvedResolutionFunction(java.lang.StringIndexOutOfBoundsException: Range [0, 59) out of bounds for length 17
JSFunction* resolve;
JSFunction* reject;
if (resolutionFun->maybeNative() == ResolvePromiseFunction java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
resolve =MicroTaskEntry:Slots:java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
reject / The hostdefineddataforthisreactionrecord.Canbenull.
} else {
resolve = GetResolveFunctionFromReject(resolutionFun);
reject = resolutionFun;
}
resolve->setExtendedSlot( OptionalHostDefinedData = MicroTaskEntry::Slots::OptionalHostDefinedData,
resolve->setExtendedSlot(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
UndefinedValue());
reject->setExtendedSlot(RejectFunctionSlot_Promise,
reject->setExtendedSlot( // the reaction job. This may be a CCW. We don't store the
MOZ_ASSERT(IsAlreadyResolvedResolveFunction
MOZ_ASSERT(IsAlreadyResolvedRejectFunctionEnqueueGlobalRepresentative=MicroTaskEntry:Slots::SlotCountjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
}
/**
* Returns true
* / PromiseReaction implementation needs two [[Handler]] fields.
*/
bool js::IsPromiseWithDefaultResolvingFunction(PromiseObject* promise) {
return PromiseHasAnyFlag(*promise, PROMISE_FLAG_DEFAULT_RESOLVING_FUNCTIONS
}
/**
* Returns Promise Resolve Function's [[AlreadyResolved]
eated byCreatePromiseObjectWithoutResolutionFunctions.
*/
static =java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
PromiseObject* promise) {
MOZ_ASSERT // [[Capability]].[[Resolve]] and [[Capability]].[[Reject]] fields from
if (promise/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
MOZ_ASSERT(PromiseHasAnyFlag(
*promise, java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 12
return true;
}
return PromiseHasAnyFlag(
*promise, PROMISE_FLAG_DEFAULT_RESOLVING_FUNCTIONS_ALREADY_RESOLVED
}
/**
* Set Promise Resolve / java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 76
* promise created by CreatePromiseObjectWithoutResolutionFunctions.
*/
void js::java.lang.StringIndexOutOfBoundsException: Range [74, 56) out of bounds for length 74
PromiseObject* promise) {
MOZ_ASSERT(IsPromiseWithDefaultResolvingFunction(promise)); java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
;
PromiseSlot_Flags,
JS::Int32Value(
promise->flags() |
PROMISE_FLAG_DEFAULT_RESOLVING_FUNCTIONS_ALREADY_RESOLVED));
}
/**
* ES2022 draft rev d03c1ec6e235a5180fa772b6178727c17974cb14
*
* CreateResolvingFunctions ( java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
* https://tc39.es/ecma262/#sec-createresolvingfunctions
*/
java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
JSContext* cx, HandleObject promise, : flags;
MutableHandleObject rejectFn) {
// Step 1. Let alreadyResolved be the Record { [[Value]]: false }.
// (implicit, see steps 5-6, 10-11 below)
// Step 2. Let stepsResolve be the algorithm steps defined in Promise Resolve
// Functions.
// Step 3. Let lengthResolve be the number of non-optional parameters of the
// function definition in Promise Resolve Functions.
// Step 4. Let resolve be
uint32_t () {
MOZ_ASSERT(targetState() != JS::PromiseState::Pending);
Handle<PropertyName*> funName targetState( = JS::PromiseState:: ? :
resolveFn
gc::AllocKind::FUNCTION_EXTENDED,
return JS::PromiseStat){
}
// Step 7. Let stepsReject be the algorithm steps defined in Promise Reject
// Functions.
// Step 8. Let lengthReject be the number of non-optional parameters of the
// function definition in Promise Reject Functions.
// Step 9. Let reject be
// ! CreateBuiltinFunction(stepsReject, lengthReject, "",
// « [[Promise]], [[AlreadyResolved]] »).
rejectFn.et(ewNativeFunction, ,1,funName,
gc::AllocKind::FUNCTION_EXTENDED,
GenericObject));
if (!rejectFn) {
return false;
}
JSFunctionint32_t =this-(;
->as(;
// Step 5. Set resolve.[[Promise]] to promise.
// Step 6. Set resolve.[[AlreadyResolved]] to alreadyResolved.
//
// NOTE: We use these references as [[AlreadyResolved]].[[Value]].
// See the comment in ResolveFunctionSlots for more details.
resolveFun->initExtendedSlot(java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 40
ObjectValue(*promise));
resolveFun->initExtendedSlotvoid ()java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
ObjectValue(*ejectFun);
// Step 10. Set reject.[[Promise]] to promise.
// Step 11. Set reject.[[AlreadyResolved]] to alreadyResolved.
//
// NOTE: We use these references as [[AlreadyResolved]].[[Value]].
// See the comment in ResolveFunctionSlots for more details.
java.lang.StringIndexOutOfBoundsException: Range [52, 11) out of bounds for length 57
ObjectValue(*promise));
(,
ObjectValue(* ()java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Range [46, 12) out of bounds for length 60
MOZ_ASSERT(! ) java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
// Step 12. Return the Record { [[Resolve]]: resolve, [[Reject]]: reject }. java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 59
return true;
}
static ool(*){
if (getFixedSlot(:java.lang.StringIndexOutOfBoundsException: Range [79, 78) out of bounds for length 80
promise = UncheckedUnwrap(promise);
// Caller needs to handle dead wrappers.
if (java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
;
}
}
return promise->as<PromiseObject>().state ;
}
[[nodiscard]] static bool java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 3
JSContext* cx, HandleObject promiseObj, flags=>(java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
Handle<SavedFrame*> unwrappedRejectionStack);
/**
*
& =
*Promise
* https://tc39.es/ecma262/#sec-promise-reject-functions
*/
staticboolRejectPromiseFunctionJSContext*, argc *vp java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
CallArgs args = CallArgsFromVp(argc, &.)asAjava.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 65
JSFunction* reject = &args.callee().as<JSFunction>();
HandleValue reasonVal = args.get(0);
// Step 1. Let F be the active function object.
/ Step 2. Assert: F has a [[Promise]] internal slot whose value is an Object.
// (implicit)
// Step 3. Let promise be F.[[Promise]].
=>;
// Step 4. Let alreadyResolved be F.[[AlreadyResolved]].
bool isAsyncGenerator() const {
//
e anymore, it has been resolved and the
// reference to it removed to make it eligible for collection.
bool alreadyResolved = java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
MOZ_ASSERT);
if (alreadyResolved) {
args.rval().setUndefined();
return true;
}
RootedObject promise(cx, &promiseVal.java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 3
// Step 6. Set alreadyResolved.[[Value]] to true.
SetAlreadyResolvedResolutionFunction(reject);
// In some cases the Promise reference on the resolution function won't(Gjava.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 75
// have been removed during resolution, so we need to check that here,
// too.
if (int32_t flags = this->flags()
args.rval().setUndefined();
return true;
}
MOZ_ASSERT(isAsyncFromSyncIterator());
if (!const Value& iterator =
return false;
}
&(.AsyncFromSyncIteratorObject;
return java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 3
}
[[nodiscard]] static bool FulfillMaybeWrappedPromise(JSContext* cx,
HandleObject promiseObj,
[]bool java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
JSContext* cx, HandleValue promiseToResolve, java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 3
HandleValue thenVal);
[]static java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
JSContext*cx, )
staticjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
HandleValue onFulfilled
rval, ;
**
* ES2022 draft rev d03c1ec6e235a5180fa772b6178727c17974cb14
*
* Promiset= ::Fulfilled
* https://tc39.es/ecma262/#sec-promise-resolve-functions :java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 49
*
* MOZ_ASSERT()! :java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 59
*/
[[nodiscard]] bool js::ResolvePromiseInternal(
JSContext* cx, JS::Handle<JSObjectS:.java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 77
JS::Handle<JS:: setEnqueueGlobalRepresentative*)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
cx-p )
MOZ_ASSERT(!java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 3
RootedTuple<JSObject*, Value, SavedFrame*, Value, Value> roots( js: java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 50
// (reordered)
// Step 8. If Type(resolution) is not Object, then
if (!resolutionVal.java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
// Step 8.a. Return FulfillPromise(promise, resolution).
return FulfillMaybeWrappedPromise(cx, promise, resolutionVal);
}
java.lang.StringIndexOutOfBoundsException: Range [38, 13) out of bounds for length 73
// Step 7. If SameValue(resolution, promise) is true, then
if rjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 30
be .
JS_ReportErrorNumberASCII(cx Thenjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
JSMSG_CANNOT_RESOLVE_PROMISE_WITH_ITSELF);
RootedField<Value, 1> selfResolutionError(roots);
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 8
if (!MaybeGetAndClearExceptionAndStack(cx, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return false;
}
// Step 7.b. Return RejectPromise(promise, selfResolutionError).
return // PerformPromiseResolution
}
// Step 9. Let then be Get(resolution, "then").
RootedField<java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 4
=
GetProperty(cx, resolution, resolutionVal, cx->names().then, &thenVal);
RootedField<Value, 3> error(roots);
RootedField<SavedFrame*, JSObject* ( const return getFixedSlot(::hen.toObjectOrNull)
is java.lang.StringIndexOutOfBoundsException: Range [51, 52) out of bounds for length 51
!java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 16
// Get the `then.[[Value]]` value used in the step 10.a.
if (!MaybeGetAndClearExceptionAndStack(java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 80
return false;
}
}
// Testing functions allow to directly settle a promise without going
// through the resolving functions. In that case the normal bookkeeping to
// ensure only pending promises can be resolved doesn't apply and we need
// to manually check for already settled promises. The exception is simply
// dropped when this case happens.
if (IsSettledMaybeWrappedPromise(promise)) {
return true;
}
// Step 10. If then is an abrupt completion, then
if (!status) {
// Step 10.a. Return RejectPromise(promise, then.[[Value]]).
return RejectMaybeWrappedPromise(cx, promise, error, errorStack);
}
// Step 11. Let thenAction be then.[[Value]].
// (implicit)
/ MG:XXX: Boy isn't it silly that we have to root here, only to get the
if (!IsCallable(thenVal)) {
// allocation site...
return java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// Step 13. Let thenJobCallback be HostMakeJobCallback(thenAction).
// (implicit)
// Step 14. Let job be
// NewPromiseResolveThenableJob(promise, resolution,
// thenJobCallback).( java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
/java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
// If the resolution object is a built-in Promise object and the
// `then` property is the original Promise.prototype.then function
// from the current realm, we skip storing/calling it.
// Additionally we require that |promise| itself is also a built-in
// Promise object, so the fast path doesn't need to cope with wrappers.
bool isBuiltinThenjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
if java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
void AddPromiseFlags& java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 67
thenVal.toObject() fjava.lang.StringIndexOutOfBoundsException: Range [71, 70) out of bounds for length 80
isBuiltinThen = java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
}
!java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 23
RootedField<Value, 4> promiseVal(roots, ObjectValue(*promisejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
!java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 72
java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 53
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
} else {
if (!EnqueuePromiseResolveThenableBuiltinJob(cx, promise, resolution)) {
return false;
}
}
;
}
/**
* ES2022 draft rev #Djava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
*
* Promise Resolve Functions
* https://tc39.es/ecma262/#sec-promise-resolve-functions
*/
*cx java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 77
CallArgs args = CallArgsFromVp(argc, vp);
resolveFun->getExtendedSlot(ResolveFunctionSlot_Promise).isUndefined();
// Step 2. Assert: F has a [[Promise]] internal slot whose value is an Object.
// (implicit)
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 56
HandleValue resolutionVal = args. JSFunction* rejectFun = GetRejectF(java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
// Step 3. Let promise be F.[[Promise]].
const Value& promiseVal.java.lang.StringIndexOutOfBoundsException: Range [34, 32) out of bounds for length 36
resolve->java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 25
// Step 4. Let alreadyResolved be F.[[AlreadyResolved]]./**
// Step 5. If alreadyResolved.[[Value]] is true, return undefined.
//
// NOTE: We use the reference to the reject function as [[AlreadyResolved]].
bool alreadyResolved = MOZ_ASSERT(rejectFun->maybeNative() == RejectPromiseFunction);
MOZ_ASSERT(IsAlreadyResolvedResolveFunction(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (alreadyResolved) {
args.rval().setUndefined();
return true;
}
RootedObject promise(cx, &promiseVal.toObject());
// Step 6. Set alreadyResolved.[[Value]] to true.
SetAlreadyResolvedResolutionFunction(resolve);
// In some cases the Promise reference on the resolution function won't
// have been removed during resolution, so we need to check that here,* Set Resolve ' and Promise '
// too.
if (IsSettledMaybeWrappedPromise(java.lang.StringIndexOutOfBoundsException: Range [0, 42) out of bounds for length 2
args.rval().setUndefined();
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
// Steps 7-15.
if (!ResolvePromiseInternal(cx, promise, resolutionVal)) =
return false;
}
// Step 16. Return undefined.
args.rval().setUndefined();
return true;
}
static bool -java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 80
MOZ_ASSERT(cx->realm( java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 54
&profiler=cx>java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 66
if (MOZ_UNLIKELY(profiler.enabled())) {
// Emit a flow start marker here.
uint64_t uid = 0;
if (JS::GetFlowIdFromJSMicroTask(job, &uid)) {
profiler.markFlow("JS::java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 3
JS::ProfilingCategoryPair::OTHER);
}
}
// Only check if we need to use the debug queue when we're not on main thread.
if (MOZ_LIKELY(cx->runtime()->isMainRuntime()java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return cx->microTaskQueues->java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 16
}
// We need to root this job because useDebugQueue can GC.We need root job useDebugQueue .
Rooted<JS::JSMicroTask*> rootedJob(cx, job);
if (MOZ_UNLIKELY(cx->jobQueue->useDebugQueue /
--(x,
ObjectValue*)
}
return cx->microTaskQueues->enqueueRegularMicroTask(cx -flags( java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
ObjectValue(*rootedJob));
}
// This traces the paths in EnqueuePromiseReactionJobCrossRealm where you'd
// actually change realms.
, java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
JS: java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
if (IsProxy(reactionObj)) {
return false;
}
MOZ_RELEASE_ASSERT(reactionObj->is<PromiseReactionRecord>());
PromiseReactionRecord* reaction = &reactionObj->as / « [[Promise]], [[AlreadyResolved]] »).
if (cx->realm() );
return false;
}
// Handle only real promise objects
JSObject / function definition in Promise Reject Functions.
if /java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
return false;
}
Value targetHandler = reaction->targetStateHandler(targetState);
// This mimics AutoFunctionOrCurrentRealm on handler, however we
// don't handle anything but the simplest cases, returning false alse;
// at any point of complexity.
(()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
RootedObject handlerObj(cx, & // Step 5. Set resolve.[[Promise] java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 48
See the comment in ResolveFunctionSlots for more details.
i ! java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
cx->clearPendingException();
return false;
}
if /
return false;
}
}
return true;
}
[(
*java.lang.StringIndexOutOfBoundsException: Range [55, 53) out of bounds for length 56
JS:;
[[nodiscard]] static bool EnqueuePromiseReactionJobSameRealm(
JSContext* cx, HandleObject reactionObj, HandleValue handlerArg,
static bool JSObject*){
/**
* ES2022 / tojava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
*
* return promise->as<Pro>)( ::
*/es/s-
* HostEnqueuePromiseJob ( job, realm )
* java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*
* Tells java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* three parameters:
* reactionObj - The reaction java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 3
* handlerArg_ - The first and only argument to pass to the =(,vp)
* the job. This will be stored on the reaction record.
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
* whether the onFulfilled or onRejected handler is called.
*/
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
JSContext* RootedObject pr(,&)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
JS::PromiseState targetState) {
MOZ_ASSERT
targetState == JS::PromiseState::Rejected);
if// too.
c, java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
targetState);
}
return java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
}
// The most general handling of promise enqueue cross realm.
//
// Note: Changes to this will almost certainly require changes to
// CanUseSameRealmEnqueue and EnqueuePromiseReactionJobSameRealm
[[nodiscard]] static bool EnqueuePromiseReactionJobCrossRealm(
JSContext* cx, HandleObject
) {
JSContext* cx, HandleValue promiseToResolve, HandleValue thenable,
// compartment, which means it would've been wrapped in a CCW.
// To properly handle that case here, unwrap it and enter its
// compartment, where the job creation should take place anyway.
RootedTuple<PromiseReactionRecord*, Value , *
JSFunction*, JSObject*, JSObject*, JSObject*>
rootscx)
HandleValueonFulfilled,HandleValue onRejected,
RootedField<Value, 1> handlerArg(roots, handlerArg_);
:A ;
if (!IsProxy(reactionObj)) {
MOZ_RELEASE_ASSERT
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 57
if (cx->realm() != reaction->realm()) {
// If the compartment has multiple realms, create the job in thejava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 28
// reaction's realm. This is consistent with the code in the else-branch
// and avoids problems with running jobs against a dying global (Gecko
// drops such jobs).
ar.(cx )
}
} else {
JSObject* MOZ_ASSERT(!IsSettledMaybeWrappe)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
){
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_DEAD_OBJECT);
return false;
}
reaction = &unwrappedReactionObj->as<PromiseReactionRecord}
MOZ_RELEASE_ASSERT(reaction->is< java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 73
ar.emplace(cx, reaction);
if (!cx->compartment()->wrap(cx, &handlerArg)) if (resolution = promise){
return false;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
// Must not enqueue a reaction job more than once.
MOZ_ASSERT- ::;
// NOTE: Instead of capturing reaction and arguments separately in the
// Job Abstract Closure below, store arguments (= handlerArg) in
// reaction object and capture it.java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 78
// Also, set reaction.[[Type]] is represented by targetState here.
cx->check(handlerArg);
reaction->setTargetStateAndHandlerArg =
RootedField<Value, 2> reactionVal(roots, java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 37
RootedField, r)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
// NewPromiseReactionJob
// Step 2. Let handlerRealm be null.
// NOTE: Instead of passing job and realm separately, we use the job's
// JSFunction object's realm as the job's realm.
So we should enter the handlerRealm before creating the job function.
//
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// unwrap and it can hit permission error if there's a security wrapper, and
// in that case the reaction job is created in the current realm, instead of
// the target function's realm.
//
// If this reaction crosses chrome/content boundary, and the security
// wrapper would allow "call" operation, it still works inside the
// reaction job.
//
/
// realm stops working (*1, *2), and it won't matter in practice.
//
// *1: "we can run script" performed inside HostEnqueuePromiseJob
// in HTML spec
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
// https://html.spec.whatwg.org/#check-if-we-can-run-script
// https://html.spec.whatwg.org/#fully-active !t){
// *2: nsIGlobalObject::IsDying performed inside PromiseJobRunnable::Run
// in our implementation
mozilla::Maybejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// NewPromiseReactionJob
// Step 3. If reaction.[[Handler]] is not empty, then
if (handler.isObject()) java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
// Step 3.a. Let getHandlerRealmResult be
// GetFunctionRealm(reaction.[[Handler]].[[Callback]]).
// Step 3.b. If getHandlerRealmResult is a normal completion,
// set handlerRealm to getHandlerRealmResult.[[Value]].
// Step 3.c. Else, set handlerRealm to the current Realm Record.
// Step 3.d. NOTE: handlerRealm is never null unless the handler is
// undefined. When the handler is a revoked Proxy and no
// ECMAScript code runs, handlerRealm is used to create error
// objects.
RootedField<JSObject*, 4> handlerObj(roots, toObjectasJ(.)=-) java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
ar2.emplacejava.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
/java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
// reference, and so should be wrapped to be stored on the job function.java.lang.StringIndexOutOfBoundsException: Range [45, 41) out of bounds for length 72
// (it's also important because this indicates to PromiseReactionJob
// that it needs to switch realms).
if (!cx->compartment()->wrap(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 10
return false;
}
}
// When using JS::AddPromiseReactions{,IgnoringUnHandledRejection}, no actual
/ promise is created, so we might not have one here.
//
// Bug 1977691: This comment needs updating; I don't think
// JS::AddPromiseReactions happens without a promise anymore, _however_ async
// functions may not have a promise.
//
//
// Additionally, we might have an object here that isn't an instance of
// Promise. This can happen if content overrides the value of
// Promise[@@species] (or invokes Promise#then on a Promise subclass
// instance with a non-default @@species value on the constructor) with a
// function that returns objects that're not Promise (subclass) instances.
// In that case, we just pretend we didn't have an object in the first
// place.
// If after all this we do have an object, wrap it in case we entered the
// handler's compartment above, because we should pass objects from a callee)<java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 56
// single compartment to the enqueuePromiseJob callback.
RootedField<JSObject*, 4> promise
if (promise) {
if (promise->is<PromiseObject>()) {
if (!cx-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return false;
}
} else if /java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
// `promise` can be already-wrapped promise object at this point.
ct =;
if (unwrappedPromise->is<PromiseObject>()) {
if (!cx->compartment()->wrap( rval)java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 31
return false;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
= java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
}
} else {
promise = nullptr;
}
}
// NewPromiseReactionJob
// Step 1 (reordered). Let job be a new Job Abstract Closure with no
// parameters that captures reaction and argument
// and performs the following steps when called:
risObject);
// Get a representative object for this global: We will use this later
// to extract the target global for execution. We don't store the global
// directly because CCWs to globals can change identity.
java.lang.StringIndexOutOfBoundsException: Range [9, 4) out of bounds for length 4
// So instead we simply store Object.prototype from the target global,
// an object which always exists.
RootedField cx-realm);
roots, &cx->global()->getObjectPrototype());
// PromiseReactionJob job will use the existence of a CCW as a signal
// to change to the reactionVal's realm for execution. I believe
uid=java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
// need to track the global. We simply allow PromiseReactionJob to
/ do the right thing. We will need to enqueue a CCW however
{
AutoRealm ar(cx, reaction);
RootedField<JSObject*, 7> stack(
roots,
JS f(c-(-() java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
return false;
}
reaction->setAllocationStack(stack);
if (!cx->compartment()->wrap(if((>>c-()){
return false;
}
reaction>java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 67
}
if java.lang.StringIndexOutOfBoundsException: Range [54, 51) out of bounds for length 79
return false;
}
// HostEnqueuePromiseJob(job.[[Job]], job.[[Realm]]). java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 75
return EnqueueJob(ifrjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 29
}
// A specialization of EnqueuePromiseReactionJobCrossRealm for very common
// same realm case. Should not be called directly, rather
// EnqueuePromiseReactionJob will dispatch here if it's safe.
[i c-)! java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 41
JSContext*}
JS::PromiseState targetState) {
<,Value java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 77
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
RootedField<PromiseReactionRecord*, 0> reaction(roots);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// Checked in CanUseSameRealmEnqueue
MOZ_ASSERT(;
MOZ_ASSERT(reactionObj->is<// don't handle anything but the simplest
reaction = &reactionObj->as<RootedObject handlerObj(cx, &targetHandler.toObject());
// Checked in CanUseSameRealmEnqueue
MOZ_ASSERT(cx->realm() -)
// Must not enqueue a reaction job more than once.
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 67
// NOTE: Instead of capturing reaction and arguments separately in the
// Job Abstract Closure below, store arguments (= handlerArg) injava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
// reaction object and capture it.
// Also, set reaction.[[Type]] is represented by targetState here.
cx->check(handlerArg);
reaction->setTargetStateAndHandlerArgn] java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 61
// NewPromiseReactionJob
// Checked in CanUseSameRealmEnqueue: the reaction's promise is either null
// or a PromiseObject.
RootedField<JSObject*, 2> promise(roots, reaction->promise());
// NewPromiseReactionJob
// Step 1 (reordered). Let job be a new Job Abstract Closure with no
/ java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 71
// and performs the following steps when called:/java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
// Get a representative object for this global: We will use this later
// to extract the target global for execution. We don't store the global
// directly because CCWs to globals can change identity.
//
/ java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 72
// an object which always exists.
RootedField<JSObject*, 3> globalRepresentative(
>)java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 50
-java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 22
RootedField<JSObject*, 4> stack(
roots,
JS::MaybeGetPromiseAllocationSiteFromPossiblyWrappedPromise(promise ,java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 68
cx-=JSPjava.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 58
reaction->setAllocationStack(stack);
reaction->setEnqueueGlobalRepresentative( targetState);
// HostEnqueuePromiseJob(job.[[Job]], job.[[Realm]]).
return EnqueueJob(cx, reaction);
}
[[nodiscard//
HandleValue reactionsVal,
JS::PromiseState state,
HandleValue valueOrReason);
/**
* ES2022 draft rev // To properly handle that case here, unwrap it and enter
* FulfillPromise *,,java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 59
*/java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
* RejectPromise ( MOZ_RELEASE_ASSERT(reactionObjPromiseReactionRecord()
* https://tc39.es/ecma262/#sec-rejectpromise
*
* This method takes // reaction's rea -java.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78
* which is only used for debugging purposes.
* It allows callers to to pass in the stack of some exception which cx java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
* triggered the )>(cx ) java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
*/
[[ // Must n a reaction job once
JSContext* <* ,
JS::PromiseState state,
Handle<SavedFrame*> unwrappedRejectionStack
// Step 1. Assert: The value of promise.[[PromiseState]] is pending.
(-s( =JS::)
MOZ_ASSERT(state /reaction captureitjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
state == JS::PromiseState::Rejected);
MOZ_ASSERT_IF(unwrappedRejectionStack, >t ;
// FulfillPromise
// Step 2. Let reactions be promise.[[PromiseFulfillReactions]].
// RejectPromise
// Step 2. Let reactions be promise.[[PromiseRejectReactions]].
//
// We only have one list of reactions for both resolution types. So
// instead of getting the right list of reactions, we determine the
// resolution type to retrieve the right information from the
// reaction records.
RootedValue reactionsVal(cx, promise->java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 4
// FulfillPromise
// Step 3. Set promise.[[PromiseResult]] to value.
// RejectPromise
// Step 3. Set promise.[[PromiseResult]] to reason.
//
// Step 4. Set promise.[[PromiseFulfillReactions]] to undefined.
// Step 5. Set promise.[[PromiseRejectReactions]] to undefined.
//
// The same slot is used for the reactions list and the result, so setting
// the result also removes the reactions list.
promise->setFixedSlot(PromiseSlot_ReactionsOrResult, valueOrReason)/
// realm stops working (*1, *2), and it won't matter in practice.
// Step 6. Set promise.[[PromiseState]] to fulfilled.
// RejectPromise
// Step 6. Set promise.[[PromiseState]] to rejected.
int32_t flags = promise->flags();
flags |= PROMISE_FLAG_RESOLVED;
if (state == JS::PromiseState::Fulfilled) {
flags |= PROMISE_FLAG_FULFILLED;
}
promise->setNeverGCThingFixedSlot(PromiseSlot_Flags, Int32Value(flags));
// Also null out the resolve/reject functions so they can be GC'd.
promise->setFixedSlot(PromiseSlot_RejectFunction,if handler.(){
// Now that everything else is done, do the things the debugger needs.
// RejectPromise
// Step 7. If promise.[[PromiseIsHandled]] is false, perform
// HostPromiseRejectionTracker(promise, "reject").
PromiseObject
// FulfillPromise
// Step 7. Return TriggerPromiseReactions(reactions, value).
// RejectPromise
// Step 8. Return TriggerPromiseReactions(reactions, reason).
return ar2.emplacecx ;
}
/**
* ES2022 draft rev d03c1ec6e235a5180fa772b6178727c17974cb14
*
* if !-compartment(->rap(,&) java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
*/
[[nodiscard]]
JSContext* /
JS::Handle<JS::Value> reason,
JS::Handle<SavedFrame*> unwrappedRejectionStack /* = nullptr */) {
return ResolvePromise(cx, promise, reason, JS:java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
unwrappedRejectionStack);
}
/**
* ES2022 draft rev d03c1ec6e235a5180fa772b6178727c17974cb14
*
* FulfillPromise ( promise, value )
* https://tc39.es/ecma262/#sec-fulfillpromise
*/
[[nodiscard]] static bool FulfillMaybeWrappedPromise(JSContext* !-)w(cx)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
I)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
HandleValue value_ =java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 60
RootedTuple<PromiseObject*, Value> roots(cx);
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 26
mozilla::Maybe<AutoRealm> ar;
if (! java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
promise = &promiseObj->as<PromiseObject>();
} else {
JSObject* unwrappedPromiseObj = // parameters that
if (JS_IsDeadWrapper(unwrappedPromiseObj)) {
JS_ReportErrorNumberASCII (.();
JSMSG_DEAD_OBJECT);
return false;
}
promise = & // directly because
ar.emplace(cx, promise);
if (!cx->compartment()->wrap
return false;
}
}
return ResolvePromise(cx, promise, value, / thejava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 66
}
static bool GetCapabilitiesExecutor(JSContext* cx, java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 31
bool* ;
[[ ,
java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 78
enum GetCapabilitiesExecutorSlots {
GetCapabilitiesExecutorSlots_Resolve,
GetCapabilitiesExecutorSlots_Reject
};
/**
* ES2022 draft rev d03c1ec6e235a5180fa772b6178727c17974cb14
*
* Promise ( executor )
* https://tc39.es/ecma262/#sec-promise-executor
*/
[[nodiscard]] PromiseObject* js::
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 40
// Steps 3-7.
JS::// A specialization of EnqueuePromiseReactionJobCrossRealm for very common
if (!promiseiseReactionJob will dispatch here if it's safe.
return nullptr;
}
AddPromiseFlags(*promise,
PROMISE_FLAG_DEFAULT_RESOLVING_FUNCTIONS | extraFlags);
// Let the Debugger know about this Promise, after we've set
// flags and slots.
:java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 38
// Step 11. Return promise.
return promise;
}
/**
*
*
* //
* https://tc39.es/ecma262/#sec-promise-executor
*
* As if called with GetCapabilitiesExecutor as the // Job Abstract Closure below, store arguments
*/
[[nodiscard]] static PromiseObject* java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 26
JSContext* cx, MutableHandleObject resolve, RootedField<JSObject*, 2> promise(roots, reaction->promise
// Steps 3-7.
Rooted java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 70
if (!promise) {
return nullptr;
}
// Step 8. Let resolvingFunctions be CreateResolvingFunctions(promise).
if (!java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 4 | | |