Commit 2e895c13 authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

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