[torque] Torque Context definition should better match C++ definition
This change also makes it possible to create Torque references to elements in the context. Change-Id: I064b73dedf8463c8d92b94b0e59f3cb4e366611a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2280084 Commit-Queue: Daniel Clifford <danno@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#68677}
This commit is contained in:
parent
8cf4ca8f75
commit
2e895c1376
@ -416,7 +416,7 @@ macro LoadJoinStack(implicit context: Context)(): FixedArray
|
||||
labels IfUninitialized {
|
||||
const nativeContext: NativeContext = LoadNativeContext(context);
|
||||
const stack: HeapObject = UnsafeCast<HeapObject>(
|
||||
nativeContext[NativeContextSlot::ARRAY_JOIN_STACK_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::ARRAY_JOIN_STACK_INDEX]);
|
||||
if (stack == Undefined) goto IfUninitialized;
|
||||
assert(Is<FixedArray>(stack));
|
||||
return UnsafeCast<FixedArray>(stack);
|
||||
@ -424,7 +424,7 @@ macro LoadJoinStack(implicit context: Context)(): FixedArray
|
||||
|
||||
macro SetJoinStack(implicit context: Context)(stack: FixedArray): void {
|
||||
const nativeContext: NativeContext = LoadNativeContext(context);
|
||||
nativeContext[NativeContextSlot::ARRAY_JOIN_STACK_INDEX] = stack;
|
||||
nativeContext.elements[NativeContextSlot::ARRAY_JOIN_STACK_INDEX] = stack;
|
||||
}
|
||||
|
||||
// Adds a receiver to the stack. The FixedArray will automatically grow to
|
||||
|
@ -62,7 +62,7 @@ macro HandleFastAliasedSloppyArgumentsSlice(
|
||||
for (let current: Smi = start; current < to; ++current) {
|
||||
const e: Object = sloppyElements.mapped_entries[current];
|
||||
const newElement = UnsafeCast<(JSAny | TheHole)>(
|
||||
e != TheHole ? argumentsContext[UnsafeCast<Smi>(e)] :
|
||||
e != TheHole ? argumentsContext.elements[UnsafeCast<Smi>(e)] :
|
||||
unmappedElements.objects[current]);
|
||||
// It is safe to skip the write barrier here because resultElements was
|
||||
// allocated together with result in a folded allocation.
|
||||
|
@ -1094,59 +1094,73 @@ macro AllowNonNumberElements(kind: ElementsKind): ElementsKind {
|
||||
|
||||
macro GetObjectFunction(implicit context: Context)(): JSFunction {
|
||||
return UnsafeCast<JSFunction>(
|
||||
LoadNativeContext(context)[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
}
|
||||
macro GetArrayFunction(implicit context: Context)(): JSFunction {
|
||||
return UnsafeCast<JSFunction>(
|
||||
LoadNativeContext(context)[NativeContextSlot::ARRAY_FUNCTION_INDEX]);
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::ARRAY_FUNCTION_INDEX]);
|
||||
}
|
||||
macro GetArrayBufferFunction(implicit context: Context)(): Constructor {
|
||||
return UnsafeCast<Constructor>(
|
||||
LoadNativeContext(context)[NativeContextSlot::ARRAY_BUFFER_FUN_INDEX]);
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::ARRAY_BUFFER_FUN_INDEX]);
|
||||
}
|
||||
macro GetArrayBufferNoInitFunction(implicit context: Context)(): JSFunction {
|
||||
return UnsafeCast<JSFunction>(LoadNativeContext(
|
||||
context)[NativeContextSlot::ARRAY_BUFFER_NOINIT_FUN_INDEX]);
|
||||
return UnsafeCast<JSFunction>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::ARRAY_BUFFER_NOINIT_FUN_INDEX]);
|
||||
}
|
||||
macro GetFastPackedElementsJSArrayMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(LoadNativeContext(
|
||||
context)[NativeContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX]);
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX]);
|
||||
}
|
||||
macro GetFastPackedSmiElementsJSArrayMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(LoadNativeContext(
|
||||
context)[NativeContextSlot::JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX]);
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX]);
|
||||
}
|
||||
macro GetProxyRevocableResultMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(LoadNativeContext(
|
||||
context)[NativeContextSlot::PROXY_REVOCABLE_RESULT_MAP_INDEX]);
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::PROXY_REVOCABLE_RESULT_MAP_INDEX]);
|
||||
}
|
||||
macro GetIteratorResultMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
}
|
||||
macro GetInitialStringIteratorMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(LoadNativeContext(
|
||||
context)[NativeContextSlot::INITIAL_STRING_ITERATOR_MAP_INDEX]);
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::INITIAL_STRING_ITERATOR_MAP_INDEX]);
|
||||
}
|
||||
macro GetReflectApply(implicit context: Context)(): Callable {
|
||||
return UnsafeCast<Callable>(
|
||||
LoadNativeContext(context)[NativeContextSlot::REFLECT_APPLY_INDEX]);
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::REFLECT_APPLY_INDEX]);
|
||||
}
|
||||
macro GetRegExpLastMatchInfo(implicit context: Context)(): RegExpMatchInfo {
|
||||
return %RawDownCast<RegExpMatchInfo>(LoadNativeContext(
|
||||
context)[NativeContextSlot::REGEXP_LAST_MATCH_INFO_INDEX]);
|
||||
return %RawDownCast<RegExpMatchInfo>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::REGEXP_LAST_MATCH_INFO_INDEX]);
|
||||
}
|
||||
macro GetStrictArgumentsMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(LoadNativeContext(
|
||||
context)[NativeContextSlot::STRICT_ARGUMENTS_MAP_INDEX]);
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::STRICT_ARGUMENTS_MAP_INDEX]);
|
||||
}
|
||||
macro GetSloppyArgumentsMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(LoadNativeContext(
|
||||
context)[NativeContextSlot::SLOPPY_ARGUMENTS_MAP_INDEX]);
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::SLOPPY_ARGUMENTS_MAP_INDEX]);
|
||||
}
|
||||
macro GetFastAliasedArgumentsMap(implicit context: Context)(): Map {
|
||||
return UnsafeCast<Map>(LoadNativeContext(
|
||||
context)[NativeContextSlot::FAST_ALIASED_ARGUMENTS_MAP_INDEX]);
|
||||
return UnsafeCast<Map>(
|
||||
LoadNativeContext(context)
|
||||
.elements[NativeContextSlot::FAST_ALIASED_ARGUMENTS_MAP_INDEX]);
|
||||
}
|
||||
|
||||
// Call(Context, Target, Receiver, ...Args)
|
||||
|
@ -126,7 +126,8 @@ transitioning builtin ToObject(implicit context: Context)(input: JSAny):
|
||||
}
|
||||
} label WrapPrimitive(constructorIndex: intptr) {
|
||||
const nativeContext = LoadNativeContext(context);
|
||||
const constructor = UnsafeCast<JSFunction>(nativeContext[constructorIndex]);
|
||||
const constructor =
|
||||
UnsafeCast<JSFunction>(nativeContext.elements[constructorIndex]);
|
||||
const map: Map = UnsafeCast<Map>(constructor.prototype_or_initial_map);
|
||||
const wrapper =
|
||||
UnsafeCast<JSPrimitiveWrapper>(AllocateFastOrSlowJSObjectFromMap(map));
|
||||
|
@ -68,10 +68,12 @@ FastFunctionPrototypeBind(
|
||||
|
||||
const boundFunctionMap: Map = UnsafeCast<Map>(
|
||||
IsConstructor(fn) ?
|
||||
context[NativeContextSlot::
|
||||
BOUND_FUNCTION_WITH_CONSTRUCTOR_MAP_INDEX] :
|
||||
context[NativeContextSlot::
|
||||
BOUND_FUNCTION_WITHOUT_CONSTRUCTOR_MAP_INDEX]);
|
||||
context
|
||||
.elements[NativeContextSlot::
|
||||
BOUND_FUNCTION_WITH_CONSTRUCTOR_MAP_INDEX] :
|
||||
context.elements
|
||||
[NativeContextSlot::
|
||||
BOUND_FUNCTION_WITHOUT_CONSTRUCTOR_MAP_INDEX]);
|
||||
|
||||
// Verify that prototype matches that of the target bound function.
|
||||
|
||||
|
@ -438,17 +438,17 @@ extern macro RefillMathRandom(NativeContext): Smi;
|
||||
transitioning javascript builtin
|
||||
MathRandom(js-implicit context: NativeContext, receiver: JSAny)(): Number {
|
||||
let smiIndex: Smi =
|
||||
Cast<Smi>(context[NativeContextSlot::MATH_RANDOM_INDEX_INDEX])
|
||||
Cast<Smi>(context.elements[NativeContextSlot::MATH_RANDOM_INDEX_INDEX])
|
||||
otherwise unreachable;
|
||||
if (smiIndex == 0) {
|
||||
// refill math random.
|
||||
smiIndex = RefillMathRandom(context);
|
||||
}
|
||||
const newSmiIndex: Smi = smiIndex - 1;
|
||||
context[NativeContextSlot::MATH_RANDOM_INDEX_INDEX] = newSmiIndex;
|
||||
context.elements[NativeContextSlot::MATH_RANDOM_INDEX_INDEX] = newSmiIndex;
|
||||
|
||||
const array: FixedDoubleArray = Cast<FixedDoubleArray>(
|
||||
context[NativeContextSlot::MATH_RANDOM_CACHE_INDEX])
|
||||
context.elements[NativeContextSlot::MATH_RANDOM_CACHE_INDEX])
|
||||
otherwise unreachable;
|
||||
const random: float64 =
|
||||
array.floats[Convert<intptr>(newSmiIndex)].ValueUnsafeAssumeNotHole();
|
||||
|
@ -100,14 +100,14 @@ transitioning builtin CreateObjectWithoutProperties(implicit context: Context)(
|
||||
typeswitch (prototype) {
|
||||
case (Null): {
|
||||
map = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP]);
|
||||
properties = AllocateNameDictionary(kNameDictionaryInitialCapacity);
|
||||
}
|
||||
case (prototype: JSReceiver): {
|
||||
properties = kEmptyFixedArray;
|
||||
const objectFunction = UnsafeCast<JSFunction>(
|
||||
nativeContext[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
map = UnsafeCast<Map>(objectFunction.prototype_or_initial_map);
|
||||
if (prototype != map.prototype) {
|
||||
const prototypeInfo = prototype.map.PrototypeInfo() otherwise Runtime;
|
||||
|
@ -269,7 +269,7 @@ macro CreatePromiseCapabilitiesExecutorContext(
|
||||
const executorContext = AllocateSyntheticFunctionContext(
|
||||
nativeContext, kPromiseBuiltinsCapabilitiesContextLength);
|
||||
|
||||
executorContext[kPromiseBuiltinsCapabilitySlot] = capability;
|
||||
executorContext.elements[kPromiseBuiltinsCapabilitySlot] = capability;
|
||||
return executorContext;
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ macro CreatePromiseResolvingFunctions(implicit context: Context)(
|
||||
const promiseContext = CreatePromiseResolvingFunctionsContext(
|
||||
promise, debugEvent, nativeContext);
|
||||
const map = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
|
||||
const resolveInfo = PromiseCapabilityDefaultResolveSharedFunConstant();
|
||||
|
||||
@ -316,7 +316,7 @@ InnerNewPromiseCapability(implicit context: Context)(
|
||||
const nativeContext = LoadNativeContext(context);
|
||||
if (TaggedEqual(
|
||||
constructor,
|
||||
nativeContext[NativeContextSlot::PROMISE_FUNCTION_INDEX])) {
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX])) {
|
||||
const promise = NewJSPromise();
|
||||
|
||||
const pair =
|
||||
@ -332,7 +332,7 @@ InnerNewPromiseCapability(implicit context: Context)(
|
||||
|
||||
const executorInfo = PromiseGetCapabilitiesExecutorSharedFunConstant();
|
||||
const functionMap = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
|
||||
const executor = AllocateFunctionWithMapAndContext(
|
||||
functionMap, executorInfo, executorContext);
|
||||
@ -370,11 +370,12 @@ transitioning javascript builtin
|
||||
PromiseCapabilityDefaultReject(
|
||||
js-implicit context: NativeContext, receiver: JSAny)(reason: JSAny): JSAny {
|
||||
// 2. Let promise be F.[[Promise]].
|
||||
const promise = UnsafeCast<JSPromise>(context[kPromiseBuiltinsPromiseSlot]);
|
||||
const promise =
|
||||
UnsafeCast<JSPromise>(context.elements[kPromiseBuiltinsPromiseSlot]);
|
||||
|
||||
// 3. Let alreadyResolved be F.[[AlreadyResolved]].
|
||||
const alreadyResolved =
|
||||
UnsafeCast<Boolean>(context[kPromiseBuiltinsAlreadyResolvedSlot]);
|
||||
const alreadyResolved = UnsafeCast<Boolean>(
|
||||
context.elements[kPromiseBuiltinsAlreadyResolvedSlot]);
|
||||
|
||||
// 4. If alreadyResolved.[[Value]] is true, return undefined.
|
||||
if (alreadyResolved == True) {
|
||||
@ -382,11 +383,11 @@ PromiseCapabilityDefaultReject(
|
||||
}
|
||||
|
||||
// 5. Set alreadyResolved.[[Value]] to true.
|
||||
context[kPromiseBuiltinsAlreadyResolvedSlot] = True;
|
||||
context.elements[kPromiseBuiltinsAlreadyResolvedSlot] = True;
|
||||
|
||||
// 6. Return RejectPromise(promise, reason).
|
||||
const debugEvent =
|
||||
UnsafeCast<Boolean>(context[kPromiseBuiltinsDebugEventSlot]);
|
||||
UnsafeCast<Boolean>(context.elements[kPromiseBuiltinsDebugEventSlot]);
|
||||
return RejectPromise(promise, reason, debugEvent);
|
||||
}
|
||||
|
||||
@ -396,11 +397,12 @@ PromiseCapabilityDefaultResolve(
|
||||
js-implicit context: NativeContext,
|
||||
receiver: JSAny)(resolution: JSAny): JSAny {
|
||||
// 2. Let promise be F.[[Promise]].
|
||||
const promise = UnsafeCast<JSPromise>(context[kPromiseBuiltinsPromiseSlot]);
|
||||
const promise =
|
||||
UnsafeCast<JSPromise>(context.elements[kPromiseBuiltinsPromiseSlot]);
|
||||
|
||||
// 3. Let alreadyResolved be F.[[AlreadyResolved]].
|
||||
const alreadyResolved =
|
||||
UnsafeCast<Boolean>(context[kPromiseBuiltinsAlreadyResolvedSlot]);
|
||||
const alreadyResolved = UnsafeCast<Boolean>(
|
||||
context.elements[kPromiseBuiltinsAlreadyResolvedSlot]);
|
||||
|
||||
// 4. If alreadyResolved.[[Value]] is true, return undefined.
|
||||
if (alreadyResolved == True) {
|
||||
@ -408,7 +410,7 @@ PromiseCapabilityDefaultResolve(
|
||||
}
|
||||
|
||||
// 5. Set alreadyResolved.[[Value]] to true.
|
||||
context[kPromiseBuiltinsAlreadyResolvedSlot] = True;
|
||||
context.elements[kPromiseBuiltinsAlreadyResolvedSlot] = True;
|
||||
|
||||
// The rest of the logic (and the catch prediction) is
|
||||
// encapsulated in the dedicated ResolvePromise builtin.
|
||||
@ -475,7 +477,8 @@ PromiseReject(
|
||||
const receiver = Cast<JSReceiver>(receiver) otherwise
|
||||
ThrowTypeError(MessageTemplate::kCalledOnNonObject, 'PromiseReject');
|
||||
|
||||
const promiseFun = context[NativeContextSlot::PROMISE_FUNCTION_INDEX];
|
||||
const promiseFun =
|
||||
context.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX];
|
||||
if (promiseFun == receiver) {
|
||||
const promise = NewJSPromise(PromiseState::kRejected, reason);
|
||||
runtime::PromiseRejectEventFromStack(promise, reason);
|
||||
@ -501,8 +504,8 @@ transitioning javascript builtin
|
||||
PromiseGetCapabilitiesExecutor(
|
||||
js-implicit context: NativeContext, receiver: JSAny)(
|
||||
resolve: JSAny, reject: JSAny): JSAny {
|
||||
const capability =
|
||||
UnsafeCast<PromiseCapability>(context[kPromiseBuiltinsCapabilitySlot]);
|
||||
const capability = UnsafeCast<PromiseCapability>(
|
||||
context.elements[kPromiseBuiltinsCapabilitySlot]);
|
||||
if (capability.resolve != Undefined || capability.reject != Undefined)
|
||||
deferred {
|
||||
ThrowTypeError(kPromiseExecutorAlreadyInvoked);
|
||||
@ -517,7 +520,7 @@ macro IsPromiseResolveLookupChainIntact(implicit context: Context)(
|
||||
nativeContext: NativeContext, constructor: JSReceiver): bool {
|
||||
if (IsForceSlowPath()) return false;
|
||||
const promiseFun = UnsafeCast<JSFunction>(
|
||||
nativeContext[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
return promiseFun == constructor && !IsPromiseResolveProtectorCellInvalid();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ struct PromiseAllSettledWrapResultAsFulfilledFunctor {
|
||||
// prevent transitions here.
|
||||
// 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
|
||||
const objectFunction = UnsafeCast<JSFunction>(
|
||||
nativeContext[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
const objectFunctionMap =
|
||||
UnsafeCast<Map>(objectFunction.prototype_or_initial_map);
|
||||
const obj = AllocateJSObjectFromMap(objectFunctionMap);
|
||||
@ -45,7 +45,7 @@ struct PromiseAllSettledWrapResultAsRejectedFunctor {
|
||||
// prevent transitions here.
|
||||
// 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
|
||||
const objectFunction = UnsafeCast<JSFunction>(
|
||||
nativeContext[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::OBJECT_FUNCTION_INDEX]);
|
||||
const objectFunctionMap =
|
||||
UnsafeCast<Map>(objectFunction.prototype_or_initial_map);
|
||||
const obj = AllocateJSObjectFromMap(objectFunctionMap);
|
||||
@ -109,32 +109,34 @@ transitioning macro PromiseAllResolveElementClosure<F: type>(
|
||||
assert(identityHash > 0);
|
||||
const index = identityHash - 1;
|
||||
|
||||
let remainingElementsCount =
|
||||
UnsafeCast<Smi>(context[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot]);
|
||||
let remainingElementsCount = UnsafeCast<Smi>(
|
||||
context.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot]);
|
||||
|
||||
let values =
|
||||
UnsafeCast<FixedArray>(context[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot]);
|
||||
let values = UnsafeCast<FixedArray>(
|
||||
context.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot]);
|
||||
const newCapacity = index + 1;
|
||||
if (newCapacity > values.length_intptr) deferred {
|
||||
// This happens only when the promises are resolved during iteration.
|
||||
values = ExtractFixedArray(values, 0, values.length_intptr, newCapacity);
|
||||
context[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot] = values;
|
||||
context.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot] = values;
|
||||
}
|
||||
values.objects[index] = updatedValue;
|
||||
|
||||
remainingElementsCount = remainingElementsCount - 1;
|
||||
context[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] = remainingElementsCount;
|
||||
context.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] =
|
||||
remainingElementsCount;
|
||||
if (remainingElementsCount == 0) {
|
||||
const capability = UnsafeCast<PromiseCapability>(
|
||||
context[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementCapabilitySlot]);
|
||||
context.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementCapabilitySlot]);
|
||||
const resolve = UnsafeCast<JSAny>(capability.resolve);
|
||||
const arrayMap = UnsafeCast<Map>(
|
||||
nativeContext[NativeContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX]);
|
||||
nativeContext
|
||||
.elements[NativeContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX]);
|
||||
const valuesArray = NewJSArray(arrayMap, values);
|
||||
Call(context, resolve, Undefined, valuesArray);
|
||||
}
|
||||
|
@ -21,12 +21,15 @@ macro CreatePromiseAllResolveElementContext(implicit context: Context)(
|
||||
const resolveContext = AllocateSyntheticFunctionContext(
|
||||
nativeContext,
|
||||
PromiseAllResolveElementContextSlots::kPromiseAllResolveElementLength);
|
||||
resolveContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] = SmiConstant(1);
|
||||
resolveContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementCapabilitySlot] = capability;
|
||||
resolveContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot] = kEmptyFixedArray;
|
||||
resolveContext.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] =
|
||||
SmiConstant(1);
|
||||
resolveContext.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementCapabilitySlot] =
|
||||
capability;
|
||||
resolveContext.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot] =
|
||||
kEmptyFixedArray;
|
||||
return resolveContext;
|
||||
}
|
||||
|
||||
@ -37,7 +40,7 @@ macro CreatePromiseAllResolveElementFunction(implicit context: Context)(
|
||||
assert(index < kPropertyArrayHashFieldMax);
|
||||
|
||||
const map = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
|
||||
const resolve = AllocateFunctionWithMapAndContext(
|
||||
map, resolveFunction, resolveElementContext);
|
||||
@ -53,9 +56,9 @@ macro CreatePromiseResolvingFunctionsContext(implicit context: Context)(
|
||||
Context {
|
||||
const resolveContext = AllocateSyntheticFunctionContext(
|
||||
nativeContext, kPromiseBuiltinsPromiseContextLength);
|
||||
resolveContext[kPromiseBuiltinsPromiseSlot] = promise;
|
||||
resolveContext[kPromiseBuiltinsAlreadyResolvedSlot] = False;
|
||||
resolveContext[kPromiseBuiltinsDebugEventSlot] = debugEvent;
|
||||
resolveContext.elements[kPromiseBuiltinsPromiseSlot] = promise;
|
||||
resolveContext.elements[kPromiseBuiltinsAlreadyResolvedSlot] = False;
|
||||
resolveContext.elements[kPromiseBuiltinsDebugEventSlot] = debugEvent;
|
||||
return resolveContext;
|
||||
}
|
||||
|
||||
@ -64,7 +67,7 @@ macro IsPromiseThenLookupChainIntact(implicit context: Context)(
|
||||
if (IsForceSlowPath()) return false;
|
||||
if (!IsJSPromiseMap(receiverMap)) return false;
|
||||
if (receiverMap.prototype !=
|
||||
nativeContext[NativeContextSlot::PROMISE_PROTOTYPE_INDEX])
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_PROTOTYPE_INDEX])
|
||||
return false;
|
||||
return !IsPromiseThenProtectorCellInvalid();
|
||||
}
|
||||
@ -131,7 +134,7 @@ Reject(Object) {
|
||||
|
||||
try {
|
||||
const fastIteratorResultMap = UnsafeCast<Map>(
|
||||
nativeContext[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
while (true) {
|
||||
let nextValue: JSAny;
|
||||
try {
|
||||
@ -167,10 +170,12 @@ Reject(Object) {
|
||||
// Set remainingElementsCount.[[Value]] to
|
||||
// remainingElementsCount.[[Value]] + 1.
|
||||
const remainingElementsCount = UnsafeCast<Smi>(
|
||||
resolveElementContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot]);
|
||||
resolveElementContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] =
|
||||
resolveElementContext
|
||||
.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot]);
|
||||
resolveElementContext
|
||||
.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] =
|
||||
remainingElementsCount + 1;
|
||||
|
||||
// Let resolveElement be CreateBuiltinFunction(steps,
|
||||
@ -248,19 +253,21 @@ Reject(Object) {
|
||||
// Set remainingElementsCount.[[Value]] to
|
||||
// remainingElementsCount.[[Value]] - 1.
|
||||
let remainingElementsCount = UnsafeCast<Smi>(
|
||||
resolveElementContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot]);
|
||||
resolveElementContext
|
||||
.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot]);
|
||||
remainingElementsCount -= 1;
|
||||
resolveElementContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] =
|
||||
resolveElementContext.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementRemainingSlot] =
|
||||
remainingElementsCount;
|
||||
if (remainingElementsCount > 0) {
|
||||
// Pre-allocate the backing store for the {values} to the desired
|
||||
// capacity. We may already have elements in "values" - this happens
|
||||
// when the Thenable calls the resolve callback immediately.
|
||||
let values = UnsafeCast<FixedArray>(
|
||||
resolveElementContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot]);
|
||||
resolveElementContext
|
||||
.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot]);
|
||||
// 'index' is a 1-based index and incremented after every Promise. Later we
|
||||
// use 'values' as a 0-based array, so capacity 'index - 1' is enough.
|
||||
const newCapacity = SmiUntag(index) - 1;
|
||||
@ -268,8 +275,9 @@ Reject(Object) {
|
||||
const oldCapacity = values.length_intptr;
|
||||
if (oldCapacity < newCapacity) {
|
||||
values = ExtractFixedArray(values, 0, oldCapacity, newCapacity);
|
||||
resolveElementContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot] = values;
|
||||
resolveElementContext.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot] =
|
||||
values;
|
||||
}
|
||||
} else
|
||||
deferred {
|
||||
@ -280,10 +288,12 @@ Reject(Object) {
|
||||
// « valuesArray »).
|
||||
|
||||
const values = UnsafeCast<FixedArray>(
|
||||
resolveElementContext[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot]);
|
||||
resolveElementContext
|
||||
.elements[PromiseAllResolveElementContextSlots::
|
||||
kPromiseAllResolveElementValuesSlot]);
|
||||
const arrayMap = UnsafeCast<Map>(
|
||||
nativeContext[NativeContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX]);
|
||||
nativeContext
|
||||
.elements[NativeContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX]);
|
||||
const valuesArray = NewJSArray(arrayMap, values);
|
||||
Call(nativeContext, UnsafeCast<JSAny>(resolve), Undefined, valuesArray);
|
||||
}
|
||||
|
@ -31,12 +31,15 @@ transitioning macro CreatePromiseAnyRejectElementContext(
|
||||
const rejectContext = AllocateSyntheticFunctionContext(
|
||||
nativeContext,
|
||||
PromiseAnyRejectElementContextSlots::kPromiseAnyRejectElementLength);
|
||||
rejectContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] = SmiConstant(1);
|
||||
rejectContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementCapabilitySlot] = capability;
|
||||
rejectContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot] = kEmptyFixedArray;
|
||||
rejectContext.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] =
|
||||
SmiConstant(1);
|
||||
rejectContext.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementCapabilitySlot] =
|
||||
capability;
|
||||
rejectContext.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot] =
|
||||
kEmptyFixedArray;
|
||||
return rejectContext;
|
||||
}
|
||||
|
||||
@ -46,7 +49,7 @@ macro CreatePromiseAnyRejectElementFunction(implicit context: Context)(
|
||||
assert(index > 0);
|
||||
assert(index < kPropertyArrayHashFieldMax);
|
||||
const map = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
|
||||
const rejectInfo = PromiseAnyRejectElementSharedFunConstant();
|
||||
const reject =
|
||||
@ -91,31 +94,32 @@ PromiseAnyRejectElementClosure(
|
||||
const index = identityHash - 1;
|
||||
|
||||
// 6. Let errors be F.[[Errors]].
|
||||
let errors =
|
||||
UnsafeCast<FixedArray>(context[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot]);
|
||||
let errors = UnsafeCast<FixedArray>(
|
||||
context.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot]);
|
||||
|
||||
// 7. Let promiseCapability be F.[[Capability]].
|
||||
|
||||
// 8. Let remainingElementsCount be F.[[RemainingElements]].
|
||||
let remainingElementsCount =
|
||||
UnsafeCast<Smi>(context[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot]);
|
||||
let remainingElementsCount = UnsafeCast<Smi>(
|
||||
context.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot]);
|
||||
|
||||
// 9. Set errors[index] to x.
|
||||
const newCapacity = IntPtrMax(SmiUntag(remainingElementsCount), index + 1);
|
||||
if (newCapacity > errors.length_intptr) deferred {
|
||||
errors = ExtractFixedArray(errors, 0, errors.length_intptr, newCapacity);
|
||||
context[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot] = errors;
|
||||
context.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot] = errors;
|
||||
}
|
||||
errors.objects[index] = value;
|
||||
|
||||
// 10. Set remainingElementsCount.[[Value]] to
|
||||
// remainingElementsCount.[[Value]] - 1.
|
||||
remainingElementsCount = remainingElementsCount - 1;
|
||||
context[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] = remainingElementsCount;
|
||||
context.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] =
|
||||
remainingElementsCount;
|
||||
|
||||
// 11. If remainingElementsCount.[[Value]] is 0, then
|
||||
if (remainingElementsCount == 0) {
|
||||
@ -125,8 +129,8 @@ PromiseAnyRejectElementClosure(
|
||||
const error = ConstructAggregateError(errors);
|
||||
// c. Return ? Call(promiseCapability.[[Reject]], undefined, « error »).
|
||||
const capability = UnsafeCast<PromiseCapability>(
|
||||
context[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementCapabilitySlot]);
|
||||
context.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementCapabilitySlot]);
|
||||
Call(context, UnsafeCast<Callable>(capability.reject), Undefined, error);
|
||||
}
|
||||
|
||||
@ -155,7 +159,7 @@ Reject(Object) {
|
||||
|
||||
try {
|
||||
const fastIteratorResultMap = UnsafeCast<Map>(
|
||||
nativeContext[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
// 8. Repeat,
|
||||
while (true) {
|
||||
let nextValue: JSAny;
|
||||
@ -228,10 +232,11 @@ Reject(Object) {
|
||||
// q. Set remainingElementsCount.[[Value]] to
|
||||
// remainingElementsCount.[[Value]] + 1.
|
||||
const remainingElementsCount = UnsafeCast<Smi>(
|
||||
rejectElementContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot]);
|
||||
rejectElementContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] =
|
||||
rejectElementContext
|
||||
.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot]);
|
||||
rejectElementContext.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] =
|
||||
remainingElementsCount + 1;
|
||||
|
||||
// r. Perform ? Invoke(nextPromise, "then", «
|
||||
@ -266,11 +271,11 @@ Reject(Object) {
|
||||
// ii. Set remainingElementsCount.[[Value]] to
|
||||
// remainingElementsCount.[[Value]] - 1.
|
||||
let remainingElementsCount = UnsafeCast<Smi>(
|
||||
rejectElementContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot]);
|
||||
rejectElementContext.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot]);
|
||||
remainingElementsCount -= 1;
|
||||
rejectElementContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] =
|
||||
rejectElementContext.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementRemainingSlot] =
|
||||
remainingElementsCount;
|
||||
|
||||
// iii. If remainingElementsCount.[[Value]] is 0, then
|
||||
@ -281,8 +286,9 @@ Reject(Object) {
|
||||
// We may already have elements in "errors" - this happens when the
|
||||
// Thenable calls the reject callback immediately.
|
||||
const errors = UnsafeCast<FixedArray>(
|
||||
rejectElementContext[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot]);
|
||||
rejectElementContext
|
||||
.elements[PromiseAnyRejectElementContextSlots::
|
||||
kPromiseAnyRejectElementErrorsSlot]);
|
||||
|
||||
const error = ConstructAggregateError(errors);
|
||||
// 3. Return ThrowCompletion(error).
|
||||
|
@ -58,7 +58,7 @@ PromiseConstructor(
|
||||
}
|
||||
|
||||
const promiseFun = UnsafeCast<JSFunction>(
|
||||
context[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
context.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
|
||||
// Silently fail if the stack looks fishy.
|
||||
if (HasAccessCheckFailed(context, promiseFun, executor)) {
|
||||
|
@ -25,12 +25,12 @@ const kPromiseBuiltinsPromiseFinallyContextLength: constexpr int31
|
||||
transitioning javascript builtin
|
||||
PromiseValueThunkFinally(
|
||||
js-implicit context: Context, receiver: JSAny)(): JSAny {
|
||||
return UnsafeCast<JSAny>(context[kPromiseBuiltinsValueSlot]);
|
||||
return UnsafeCast<JSAny>(context.elements[kPromiseBuiltinsValueSlot]);
|
||||
}
|
||||
|
||||
transitioning javascript builtin
|
||||
PromiseThrowerFinally(js-implicit context: Context, receiver: JSAny)(): never {
|
||||
const reason = UnsafeCast<JSAny>(context[kPromiseBuiltinsValueSlot]);
|
||||
const reason = UnsafeCast<JSAny>(context.elements[kPromiseBuiltinsValueSlot]);
|
||||
Throw(reason);
|
||||
}
|
||||
|
||||
@ -38,9 +38,9 @@ macro CreateThrowerFunction(implicit context: Context)(
|
||||
nativeContext: NativeContext, reason: JSAny): JSFunction {
|
||||
const throwerContext = AllocateSyntheticFunctionContext(
|
||||
nativeContext, kPromiseBuiltinsPromiseValueThunkOrReasonContextLength);
|
||||
throwerContext[kPromiseBuiltinsValueSlot] = reason;
|
||||
throwerContext.elements[kPromiseBuiltinsValueSlot] = reason;
|
||||
const map = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
|
||||
const throwerInfo = PromiseThrowerFinallySharedFunConstant();
|
||||
return AllocateFunctionWithMapAndContext(map, throwerInfo, throwerContext);
|
||||
@ -52,14 +52,14 @@ PromiseCatchFinally(
|
||||
// 1. Let onFinally be F.[[OnFinally]].
|
||||
// 2. Assert: IsCallable(onFinally) is true.
|
||||
const onFinally =
|
||||
UnsafeCast<Callable>(context[kPromiseBuiltinsOnFinallySlot]);
|
||||
UnsafeCast<Callable>(context.elements[kPromiseBuiltinsOnFinallySlot]);
|
||||
|
||||
// 3. Let result be ? Call(onFinally).
|
||||
const result = Call(context, onFinally, Undefined);
|
||||
|
||||
// 4. Let C be F.[[Constructor]].
|
||||
const constructor =
|
||||
UnsafeCast<JSFunction>(context[kPromiseBuiltinsConstructorSlot]);
|
||||
UnsafeCast<JSFunction>(context.elements[kPromiseBuiltinsConstructorSlot]);
|
||||
|
||||
// 5. Assert: IsConstructor(C) is true.
|
||||
assert(IsConstructor(constructor));
|
||||
@ -79,9 +79,9 @@ macro CreateValueThunkFunction(implicit context: Context)(
|
||||
nativeContext: NativeContext, value: JSAny): JSFunction {
|
||||
const valueThunkContext = AllocateSyntheticFunctionContext(
|
||||
nativeContext, kPromiseBuiltinsPromiseValueThunkOrReasonContextLength);
|
||||
valueThunkContext[kPromiseBuiltinsValueSlot] = value;
|
||||
valueThunkContext.elements[kPromiseBuiltinsValueSlot] = value;
|
||||
const map = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
|
||||
const valueThunkInfo = PromiseValueThunkFinallySharedFunConstant();
|
||||
return AllocateFunctionWithMapAndContext(
|
||||
@ -94,14 +94,14 @@ PromiseThenFinally(
|
||||
// 1. Let onFinally be F.[[OnFinally]].
|
||||
// 2. Assert: IsCallable(onFinally) is true.
|
||||
const onFinally =
|
||||
UnsafeCast<Callable>(context[kPromiseBuiltinsOnFinallySlot]);
|
||||
UnsafeCast<Callable>(context.elements[kPromiseBuiltinsOnFinallySlot]);
|
||||
|
||||
// 3. Let result be ? Call(onFinally).
|
||||
const result = Call(context, onFinally, Undefined);
|
||||
|
||||
// 4. Let C be F.[[Constructor]].
|
||||
const constructor =
|
||||
UnsafeCast<JSFunction>(context[kPromiseBuiltinsConstructorSlot]);
|
||||
UnsafeCast<JSFunction>(context.elements[kPromiseBuiltinsConstructorSlot]);
|
||||
|
||||
// 5. Assert: IsConstructor(C) is true.
|
||||
assert(IsConstructor(constructor));
|
||||
@ -127,10 +127,10 @@ macro CreatePromiseFinallyFunctions(implicit context: Context)(
|
||||
constructor: JSReceiver): PromiseFinallyFunctions {
|
||||
const promiseContext = AllocateSyntheticFunctionContext(
|
||||
nativeContext, kPromiseBuiltinsPromiseFinallyContextLength);
|
||||
promiseContext[kPromiseBuiltinsOnFinallySlot] = onFinally;
|
||||
promiseContext[kPromiseBuiltinsConstructorSlot] = constructor;
|
||||
promiseContext.elements[kPromiseBuiltinsOnFinallySlot] = onFinally;
|
||||
promiseContext.elements[kPromiseBuiltinsConstructorSlot] = constructor;
|
||||
const map = UnsafeCast<Map>(
|
||||
nativeContext
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX]);
|
||||
const thenFinallyInfo = PromiseThenFinallySharedFunConstant();
|
||||
const thenFinally =
|
||||
@ -155,7 +155,7 @@ PromisePrototypeFinally(
|
||||
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
|
||||
const nativeContext = LoadNativeContext(context);
|
||||
const promiseFun = UnsafeCast<Callable>(
|
||||
nativeContext[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
|
||||
let constructor: JSReceiver = promiseFun;
|
||||
const receiverMap = jsReceiver.map;
|
||||
|
@ -22,7 +22,8 @@ PromiseResolveThenableJob(implicit context: Context)(
|
||||
// We take the generic (slow-)path if a PromiseHook is enabled or the
|
||||
// debugger is active, to make sure we expose spec compliant behavior.
|
||||
const nativeContext = LoadNativeContext(context);
|
||||
const promiseThen = nativeContext[NativeContextSlot::PROMISE_THEN_INDEX];
|
||||
const promiseThen =
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_THEN_INDEX];
|
||||
const thenableMap = thenable.map;
|
||||
if (TaggedEqual(then, promiseThen) && IsJSPromiseMap(thenableMap) &&
|
||||
!IsPromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate() &&
|
||||
|
@ -40,7 +40,7 @@ macro PromiseInit(promise: JSPromise): void {
|
||||
macro InnerNewJSPromise(implicit context: Context)(): JSPromise {
|
||||
const nativeContext = LoadNativeContext(context);
|
||||
const promiseFun = UnsafeCast<JSFunction>(
|
||||
nativeContext[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
assert(IsFunctionWithPrototypeSlotMap(promiseFun.map));
|
||||
const promiseMap = UnsafeCast<Map>(promiseFun.prototype_or_initial_map);
|
||||
const promiseHeapObject = promise_internal::AllocateJSPromise(context);
|
||||
@ -69,8 +69,9 @@ macro NewPromiseFulfillReactionJobTask(implicit context: Context)(
|
||||
context: handlerContext,
|
||||
handler,
|
||||
promise_or_capability: promiseOrCapability,
|
||||
continuation_preserved_embedder_data: nativeContext
|
||||
[NativeContextSlot::CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX]
|
||||
continuation_preserved_embedder_data:
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX]
|
||||
};
|
||||
}
|
||||
|
||||
@ -85,8 +86,9 @@ macro NewPromiseRejectReactionJobTask(implicit context: Context)(
|
||||
context: handlerContext,
|
||||
handler,
|
||||
promise_or_capability: promiseOrCapability,
|
||||
continuation_preserved_embedder_data: nativeContext
|
||||
[NativeContextSlot::CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX]
|
||||
continuation_preserved_embedder_data:
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX]
|
||||
};
|
||||
}
|
||||
|
||||
@ -143,8 +145,9 @@ macro NewPromiseReaction(implicit context: Context)(
|
||||
reject_handler: rejectHandler,
|
||||
fulfill_handler: fulfillHandler,
|
||||
promise_or_capability: promiseOrCapability,
|
||||
continuation_preserved_embedder_data: nativeContext
|
||||
[NativeContextSlot::CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX]
|
||||
continuation_preserved_embedder_data:
|
||||
nativeContext.elements
|
||||
[NativeContextSlot::CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX]
|
||||
};
|
||||
}
|
||||
|
||||
@ -207,8 +210,8 @@ macro InvokeThen<F: type>(implicit context: Context)(
|
||||
if (!Is<Smi>(receiver) &&
|
||||
IsPromiseThenLookupChainIntact(
|
||||
nativeContext, UnsafeCast<HeapObject>(receiver).map)) {
|
||||
const then =
|
||||
UnsafeCast<JSAny>(nativeContext[NativeContextSlot::PROMISE_THEN_INDEX]);
|
||||
const then = UnsafeCast<JSAny>(
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_THEN_INDEX]);
|
||||
return callFunctor.Call(nativeContext, then, receiver, arg1, arg2);
|
||||
} else
|
||||
deferred {
|
||||
|
@ -51,7 +51,7 @@ PromiseRace(
|
||||
// Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
||||
try {
|
||||
const fastIteratorResultMap = UnsafeCast<Map>(
|
||||
nativeContext[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]);
|
||||
while (true) {
|
||||
let nextValue: JSAny;
|
||||
try {
|
||||
|
@ -30,7 +30,8 @@ transitioning builtin
|
||||
PromiseResolve(implicit context: Context)(
|
||||
constructor: JSReceiver, value: JSAny): JSAny {
|
||||
const nativeContext = LoadNativeContext(context);
|
||||
const promiseFun = nativeContext[NativeContextSlot::PROMISE_FUNCTION_INDEX];
|
||||
const promiseFun =
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX];
|
||||
try {
|
||||
// Check if {value} is a JSPromise.
|
||||
const value = Cast<JSPromise>(value) otherwise NeedToAllocate;
|
||||
@ -40,7 +41,7 @@ PromiseResolve(implicit context: Context)(
|
||||
// intact, as that guards the lookup path for "constructor" on
|
||||
// JSPromise instances which have the (initial) Promise.prototype.
|
||||
const promisePrototype =
|
||||
nativeContext[NativeContextSlot::PROMISE_PROTOTYPE_INDEX];
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_PROTOTYPE_INDEX];
|
||||
if (value.map.prototype != promisePrototype) {
|
||||
goto SlowConstructor;
|
||||
}
|
||||
@ -137,7 +138,8 @@ ResolvePromise(implicit context: Context)(
|
||||
assert(IsJSReceiverMap(resolutionMap));
|
||||
assert(!IsPromiseThenProtectorCellInvalid());
|
||||
if (resolutionMap ==
|
||||
nativeContext[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]) {
|
||||
nativeContext
|
||||
.elements[NativeContextSlot::ITERATOR_RESULT_MAP_INDEX]) {
|
||||
return FulfillPromise(promise, resolution);
|
||||
} else {
|
||||
goto Slow;
|
||||
@ -145,10 +147,10 @@ ResolvePromise(implicit context: Context)(
|
||||
}
|
||||
|
||||
const promisePrototype =
|
||||
nativeContext[NativeContextSlot::PROMISE_PROTOTYPE_INDEX];
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_PROTOTYPE_INDEX];
|
||||
if (resolutionMap.prototype == promisePrototype) {
|
||||
// The {resolution} is a native Promise in this case.
|
||||
then = nativeContext[NativeContextSlot::PROMISE_THEN_INDEX];
|
||||
then = nativeContext.elements[NativeContextSlot::PROMISE_THEN_INDEX];
|
||||
goto Enqueue;
|
||||
}
|
||||
goto Slow;
|
||||
|
@ -10,7 +10,7 @@ macro
|
||||
IsPromiseSpeciesLookupChainIntact(
|
||||
nativeContext: NativeContext, promiseMap: Map): bool {
|
||||
const promisePrototype =
|
||||
nativeContext[NativeContextSlot::PROMISE_PROTOTYPE_INDEX];
|
||||
nativeContext.elements[NativeContextSlot::PROMISE_PROTOTYPE_INDEX];
|
||||
if (IsForceSlowPath()) return false;
|
||||
if (promiseMap.prototype != promisePrototype) return false;
|
||||
return !IsPromiseSpeciesProtectorCellInvalid();
|
||||
@ -28,7 +28,7 @@ PromisePrototypeThen(js-implicit context: NativeContext, receiver: JSAny)(
|
||||
|
||||
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
|
||||
const promiseFun = UnsafeCast<JSFunction>(
|
||||
context[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
context.elements[NativeContextSlot::PROMISE_FUNCTION_INDEX]);
|
||||
|
||||
// 4. Let resultCapability be ? NewPromiseCapability(C).
|
||||
let resultPromiseOrCapability: JSPromise|PromiseCapability;
|
||||
|
@ -11,7 +11,7 @@ namespace proxy {
|
||||
transitioning javascript builtin
|
||||
ProxyRevoke(js-implicit context: NativeContext)(): Undefined {
|
||||
// 1. Let p be F.[[RevocableProxy]].
|
||||
const proxyObject: Object = context[PROXY_SLOT];
|
||||
const proxyObject: Object = context.elements[PROXY_SLOT];
|
||||
|
||||
// 2. If p is null, return undefined
|
||||
if (proxyObject == Null) {
|
||||
@ -19,7 +19,7 @@ ProxyRevoke(js-implicit context: NativeContext)(): Undefined {
|
||||
}
|
||||
|
||||
// 3. Set F.[[RevocableProxy]] to null.
|
||||
context[PROXY_SLOT] = Null;
|
||||
context.elements[PROXY_SLOT] = Null;
|
||||
|
||||
// 4. Assert: p is a Proxy object.
|
||||
const proxy: JSProxy = UnsafeCast<JSProxy>(proxyObject);
|
||||
|
@ -158,7 +158,7 @@ transitioning macro RegExpPrototypeExecBody(implicit context: Context)(
|
||||
macro LoadRegExpFunction(implicit context: Context)(
|
||||
nativeContext: NativeContext): JSFunction {
|
||||
return UnsafeCast<JSFunction>(
|
||||
nativeContext[NativeContextSlot::REGEXP_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::REGEXP_FUNCTION_INDEX]);
|
||||
}
|
||||
|
||||
// Note this doesn't guarantee const-ness of object properties, just
|
||||
|
@ -2513,41 +2513,6 @@ TNode<BoolT> CodeStubAssembler::LoadScopeInfoHasExtensionField(
|
||||
return IsSetWord<ScopeInfo::HasContextExtensionSlotBit>(value);
|
||||
}
|
||||
|
||||
TNode<Object> CodeStubAssembler::LoadContextElement(
|
||||
SloppyTNode<Context> context, int slot_index) {
|
||||
int offset = Context::SlotOffset(slot_index);
|
||||
return Load<Object>(context, IntPtrConstant(offset));
|
||||
}
|
||||
|
||||
TNode<Object> CodeStubAssembler::LoadContextElement(
|
||||
SloppyTNode<Context> context, SloppyTNode<IntPtrT> slot_index) {
|
||||
TNode<IntPtrT> offset = ElementOffsetFromIndex(slot_index, PACKED_ELEMENTS,
|
||||
Context::SlotOffset(0));
|
||||
return Load<Object>(context, offset);
|
||||
}
|
||||
|
||||
TNode<Object> CodeStubAssembler::LoadContextElement(TNode<Context> context,
|
||||
TNode<Smi> slot_index) {
|
||||
TNode<IntPtrT> offset = ElementOffsetFromIndex(slot_index, PACKED_ELEMENTS,
|
||||
Context::SlotOffset(0));
|
||||
return Load<Object>(context, offset);
|
||||
}
|
||||
|
||||
void CodeStubAssembler::StoreContextElement(SloppyTNode<Context> context,
|
||||
int slot_index,
|
||||
SloppyTNode<Object> value) {
|
||||
int offset = Context::SlotOffset(slot_index);
|
||||
Store(context, IntPtrConstant(offset), value);
|
||||
}
|
||||
|
||||
void CodeStubAssembler::StoreContextElement(SloppyTNode<Context> context,
|
||||
SloppyTNode<IntPtrT> slot_index,
|
||||
SloppyTNode<Object> value) {
|
||||
TNode<IntPtrT> offset = IntPtrAdd(TimesTaggedSize(slot_index),
|
||||
IntPtrConstant(Context::SlotOffset(0)));
|
||||
Store(context, offset, value);
|
||||
}
|
||||
|
||||
void CodeStubAssembler::StoreContextElementNoWriteBarrier(
|
||||
SloppyTNode<Context> context, int slot_index, SloppyTNode<Object> value) {
|
||||
int offset = Context::SlotOffset(slot_index);
|
||||
|
@ -1517,17 +1517,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
|
||||
TNode<BoolT> LoadScopeInfoHasExtensionField(TNode<ScopeInfo> scope_info);
|
||||
|
||||
// Context manipulation:
|
||||
TNode<Object> LoadContextElement(SloppyTNode<Context> context,
|
||||
int slot_index);
|
||||
TNode<Object> LoadContextElement(SloppyTNode<Context> context,
|
||||
SloppyTNode<IntPtrT> slot_index);
|
||||
TNode<Object> LoadContextElement(TNode<Context> context,
|
||||
TNode<Smi> slot_index);
|
||||
void StoreContextElement(SloppyTNode<Context> context, int slot_index,
|
||||
SloppyTNode<Object> value);
|
||||
void StoreContextElement(SloppyTNode<Context> context,
|
||||
SloppyTNode<IntPtrT> slot_index,
|
||||
SloppyTNode<Object> value);
|
||||
void StoreContextElementNoWriteBarrier(SloppyTNode<Context> context,
|
||||
int slot_index,
|
||||
SloppyTNode<Object> value);
|
||||
|
@ -53,7 +53,7 @@ extern shape JSStrictArgumentsObject extends JSArgumentsObject {
|
||||
// entry has been deleted fron the arguments object, and value is looked up in
|
||||
// the unmapped arguments array, as described above. Otherwise, t is a Smi
|
||||
// index into the context array specified at elements.context, and the return
|
||||
// value is elements.context[t].
|
||||
// value is elements.context.
|
||||
//
|
||||
// A graphic representation of a SloppyArgumentsElements object and a
|
||||
// corresponding unmapped arguments FixedArray:
|
||||
@ -149,7 +149,7 @@ struct ParameterMapIterator {
|
||||
macro NewParameterMapIterator(
|
||||
context: Context, formalParameterCount: intptr,
|
||||
mappedCount: intptr): ParameterMapIterator {
|
||||
const flags = context.scope_info.flags;
|
||||
const flags = context.GetScopeInfo().flags;
|
||||
let contextHeaderSize: intptr = MIN_CONTEXT_SLOTS;
|
||||
if (flags.has_context_extension_slot) ++contextHeaderSize;
|
||||
// Copy the parameter slots and the holes in the arguments.
|
||||
|
@ -440,6 +440,8 @@ class Context : public HeapObject {
|
||||
|
||||
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
|
||||
TORQUE_GENERATED_CONTEXT_FIELDS)
|
||||
static const int kScopeInfoOffset = kHeaderSize;
|
||||
static const int kPreviousOffset = kScopeInfoOffset + kTaggedSize;
|
||||
|
||||
// TODO(v8:8989): [torque] Support marker constants
|
||||
/* TODO(ishell): remove this fixedArray-like header size. */
|
||||
@ -448,10 +450,10 @@ class Context : public HeapObject {
|
||||
/* Header size. */ \
|
||||
/* TODO(ishell): use this as header size once MIN_CONTEXT_SLOTS */ \
|
||||
/* is removed in favour of offset-based access to common fields. */ \
|
||||
static const int kTodoHeaderSize = kHeaderSize;
|
||||
static const int kTodoHeaderSize = kPreviousOffset + kTaggedSize;
|
||||
|
||||
// If the extension slot exists, it is the first slot after the header.
|
||||
static const int kExtensionOffset = kHeaderSize;
|
||||
static const int kExtensionOffset = kTodoHeaderSize;
|
||||
|
||||
// Garbage collection support.
|
||||
V8_INLINE static constexpr int SizeFor(int length) {
|
||||
@ -514,7 +516,7 @@ class Context : public HeapObject {
|
||||
|
||||
static const int kExtensionSize =
|
||||
(MIN_CONTEXT_EXTENDED_SLOTS - MIN_CONTEXT_SLOTS) * kTaggedSize;
|
||||
static const int kExtendedHeaderSize = kHeaderSize + kExtensionSize;
|
||||
static const int kExtendedHeaderSize = kTodoHeaderSize + kExtensionSize;
|
||||
|
||||
// A region of native context entries containing maps for functions created
|
||||
// by Builtins::kFastNewClosure.
|
||||
|
@ -4,10 +4,13 @@
|
||||
|
||||
@abstract
|
||||
extern class Context extends HeapObject {
|
||||
length: Smi;
|
||||
scope_info: ScopeInfo;
|
||||
previous: Context|Zero|Undefined;
|
||||
macro GetScopeInfo(): ScopeInfo {
|
||||
return UnsafeCast<ScopeInfo>(this.elements[0]);
|
||||
}
|
||||
const length: Smi;
|
||||
elements[length]: Object;
|
||||
}
|
||||
|
||||
extern class AwaitContext extends Context generates 'TNode<Context>';
|
||||
extern class BlockContext extends Context generates 'TNode<Context>';
|
||||
extern class CatchContext extends Context generates 'TNode<Context>';
|
||||
@ -60,20 +63,40 @@ extern enum NativeContextSlot extends intptr constexpr 'Context::Field' {
|
||||
...
|
||||
}
|
||||
|
||||
extern operator '[]' macro LoadContextElement(
|
||||
NativeContext, NativeContextSlot): Object;
|
||||
extern operator '[]=' macro StoreContextElement(
|
||||
NativeContext, NativeContextSlot, Object): void;
|
||||
|
||||
type ContextSlot generates 'TNode<IntPtrT>' constexpr 'int32_t';
|
||||
type ContextSlot extends intptr
|
||||
generates 'TNode<IntPtrT>' constexpr 'int32_t';
|
||||
const PROXY_SLOT: constexpr ContextSlot
|
||||
generates 'Context::MIN_CONTEXT_SLOTS';
|
||||
extern operator '[]' macro LoadContextElement(Context, ContextSlot): Object;
|
||||
extern operator '[]=' macro StoreContextElement(
|
||||
Context, ContextSlot, Object): void;
|
||||
|
||||
extern operator '[]' macro LoadContextElement(Context, intptr): Object;
|
||||
extern operator '[]' macro LoadContextElement(Context, Smi): Object;
|
||||
@export
|
||||
macro LoadContextElement(c: Context, i: intptr): Object {
|
||||
return c.elements[i];
|
||||
}
|
||||
|
||||
@export
|
||||
macro LoadContextElement(c: Context, i: Smi): Object {
|
||||
return c.elements[i];
|
||||
}
|
||||
|
||||
@export
|
||||
macro LoadContextElement(c: Context, i: constexpr int32): Object {
|
||||
return c.elements[i];
|
||||
}
|
||||
|
||||
@export
|
||||
macro StoreContextElement(c: Context, i: intptr, o: Object) {
|
||||
c.elements[i] = o;
|
||||
}
|
||||
|
||||
@export
|
||||
macro StoreContextElement(c: Context, i: Smi, o: Object) {
|
||||
c.elements[i] = o;
|
||||
}
|
||||
|
||||
@export
|
||||
macro StoreContextElement(c: Context, i: constexpr int32, o: Object) {
|
||||
c.elements[i] = o;
|
||||
}
|
||||
|
||||
// A dummy used instead of a context constant for runtime calls that don't need
|
||||
// a context.
|
||||
|
@ -17,7 +17,7 @@ macro CreateArrayIterator(implicit context: NativeContext)(
|
||||
array: JSReceiver, kind: constexpr IterationKind): JSArrayIterator {
|
||||
return new JSArrayIterator{
|
||||
map: UnsafeCast<Map>(
|
||||
context[NativeContextSlot::INITIAL_ARRAY_ITERATOR_MAP_INDEX]),
|
||||
context.elements[NativeContextSlot::INITIAL_ARRAY_ITERATOR_MAP_INDEX]),
|
||||
properties_or_hash: kEmptyFixedArray,
|
||||
elements: kEmptyFixedArray,
|
||||
iterated_object: array,
|
||||
|
@ -1294,7 +1294,7 @@ macro TestGeneratedCastOperators(implicit context: Context)() {
|
||||
|
||||
const nativeContext = LoadNativeContext(context);
|
||||
const jsf: JSFunction = UnsafeCast<JSFunction>(
|
||||
nativeContext[NativeContextSlot::REGEXP_FUNCTION_INDEX]);
|
||||
nativeContext.elements[NativeContextSlot::REGEXP_FUNCTION_INDEX]);
|
||||
assert(!Is<JSSloppyArgumentsObject>(jsf));
|
||||
|
||||
const parameterValues = NewFixedArray(0, ConstantIterator(TheHole));
|
||||
|
Loading…
Reference in New Issue
Block a user