Commit 60657604 authored by tzik's avatar tzik Committed by Commit Bot

Refine typings of MicrotaskQueue builtins

This updates node typings in MicrotaskQueue builtins including:
 - Use RawPtrT instead of IntPtrT for pointers.
 - Prefer CAST instead of UncheckedCast where possible.
 - Fix MachineType / MachineRepresentation values there.

Bug: v8:8124
Change-Id: Idb02ac3ae51d2e9d45920115955afb68c81c7794
Reviewed-on: https://chromium-review.googlesource.com/c/1375510
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58300}
parent 75bacb4a
......@@ -21,15 +21,15 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
explicit MicrotaskQueueBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
TNode<IntPtrT> GetDefaultMicrotaskQueue();
TNode<IntPtrT> GetMicrotaskQueue(TNode<Context> context);
TNode<IntPtrT> GetMicrotaskRingBuffer(TNode<IntPtrT> microtask_queue);
TNode<IntPtrT> GetMicrotaskQueueCapacity(TNode<IntPtrT> microtask_queue);
TNode<IntPtrT> GetMicrotaskQueueSize(TNode<IntPtrT> microtask_queue);
void SetMicrotaskQueueSize(TNode<IntPtrT> microtask_queue,
TNode<RawPtrT> GetDefaultMicrotaskQueue();
TNode<RawPtrT> GetMicrotaskQueue(TNode<Context> context);
TNode<RawPtrT> GetMicrotaskRingBuffer(TNode<RawPtrT> microtask_queue);
TNode<IntPtrT> GetMicrotaskQueueCapacity(TNode<RawPtrT> microtask_queue);
TNode<IntPtrT> GetMicrotaskQueueSize(TNode<RawPtrT> microtask_queue);
void SetMicrotaskQueueSize(TNode<RawPtrT> microtask_queue,
TNode<IntPtrT> new_size);
TNode<IntPtrT> GetMicrotaskQueueStart(TNode<IntPtrT> microtask_queue);
void SetMicrotaskQueueStart(TNode<IntPtrT> microtask_queue,
TNode<IntPtrT> GetMicrotaskQueueStart(TNode<RawPtrT> microtask_queue);
void SetMicrotaskQueueStart(TNode<RawPtrT> microtask_queue,
TNode<IntPtrT> new_start);
TNode<IntPtrT> CalculateRingBufferOffset(TNode<IntPtrT> capacity,
TNode<IntPtrT> start,
......@@ -48,55 +48,55 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
SloppyTNode<HeapObject> promise_or_capability);
};
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetDefaultMicrotaskQueue() {
TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetDefaultMicrotaskQueue() {
auto ref = ExternalReference::default_microtask_queue_address(isolate());
return UncheckedCast<IntPtrT>(
return UncheckedCast<RawPtrT>(
Load(MachineType::Pointer(), ExternalConstant(ref)));
}
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueue(
TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueue(
TNode<Context> native_context) {
CSA_ASSERT(this, IsNativeContext(native_context));
return LoadObjectField<IntPtrT>(native_context,
return LoadObjectField<RawPtrT>(native_context,
NativeContext::kMicrotaskQueueOffset);
}
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskRingBuffer(
TNode<IntPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>(
Load(MachineType::IntPtr(), microtask_queue,
TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskRingBuffer(
TNode<RawPtrT> microtask_queue) {
return UncheckedCast<RawPtrT>(
Load(MachineType::Pointer(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kRingBufferOffset)));
}
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueCapacity(
TNode<IntPtrT> microtask_queue) {
TNode<RawPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>(
Load(MachineType::IntPtr(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kCapacityOffset)));
}
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueSize(
TNode<IntPtrT> microtask_queue) {
TNode<RawPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>(
Load(MachineType::IntPtr(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kSizeOffset)));
}
void MicrotaskQueueBuiltinsAssembler::SetMicrotaskQueueSize(
TNode<IntPtrT> microtask_queue, TNode<IntPtrT> new_size) {
TNode<RawPtrT> microtask_queue, TNode<IntPtrT> new_size) {
StoreNoWriteBarrier(MachineType::PointerRepresentation(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kSizeOffset), new_size);
}
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueStart(
TNode<IntPtrT> microtask_queue) {
TNode<RawPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>(
Load(MachineType::IntPtr(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kStartOffset)));
}
void MicrotaskQueueBuiltinsAssembler::SetMicrotaskQueueStart(
TNode<IntPtrT> microtask_queue, TNode<IntPtrT> new_start) {
TNode<RawPtrT> microtask_queue, TNode<IntPtrT> new_start) {
StoreNoWriteBarrier(MachineType::PointerRepresentation(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kStartOffset), new_start);
}
......@@ -464,12 +464,11 @@ void MicrotaskQueueBuiltinsAssembler::RunPromiseHook(
TF_BUILTIN(EnqueueMicrotask, MicrotaskQueueBuiltinsAssembler) {
TNode<Microtask> microtask =
UncheckedCast<Microtask>(Parameter(Descriptor::kMicrotask));
TNode<Context> context =
UncheckedCast<Context>(Parameter(Descriptor::kContext));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Context> native_context = LoadNativeContext(context);
TNode<IntPtrT> microtask_queue = GetMicrotaskQueue(native_context);
TNode<RawPtrT> microtask_queue = GetMicrotaskQueue(native_context);
TNode<IntPtrT> ring_buffer = GetMicrotaskRingBuffer(microtask_queue);
TNode<RawPtrT> ring_buffer = GetMicrotaskRingBuffer(microtask_queue);
TNode<IntPtrT> capacity = GetMicrotaskQueueCapacity(microtask_queue);
TNode<IntPtrT> size = GetMicrotaskQueueSize(microtask_queue);
TNode<IntPtrT> start = GetMicrotaskQueueStart(microtask_queue);
......@@ -508,7 +507,7 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) {
TNode<Context> current_context = GetCurrentContext();
// TODO(tzik): Take a MicrotaskQueue parameter to support non-default queue.
TNode<IntPtrT> microtask_queue = GetDefaultMicrotaskQueue();
TNode<RawPtrT> microtask_queue = GetDefaultMicrotaskQueue();
Label loop(this), done(this);
Goto(&loop);
......@@ -519,16 +518,15 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) {
// Exit if the queue is empty.
GotoIf(WordEqual(size, IntPtrConstant(0)), &done);
TNode<IntPtrT> ring_buffer = GetMicrotaskRingBuffer(microtask_queue);
TNode<RawPtrT> ring_buffer = GetMicrotaskRingBuffer(microtask_queue);
TNode<IntPtrT> capacity = GetMicrotaskQueueCapacity(microtask_queue);
TNode<IntPtrT> start = GetMicrotaskQueueStart(microtask_queue);
TNode<IntPtrT> offset =
CalculateRingBufferOffset(capacity, start, IntPtrConstant(0));
TNode<IntPtrT> microtask_pointer =
UncheckedCast<IntPtrT>(Load(MachineType::Pointer(), ring_buffer, offset));
TNode<Microtask> microtask =
UncheckedCast<Microtask>(BitcastWordToTagged(microtask_pointer));
TNode<RawPtrT> microtask_pointer =
UncheckedCast<RawPtrT>(Load(MachineType::Pointer(), ring_buffer, offset));
TNode<Microtask> microtask = CAST(BitcastWordToTagged(microtask_pointer));
TNode<IntPtrT> new_size = IntPtrSub(size, IntPtrConstant(1));
TNode<IntPtrT> new_start = WordAnd(IntPtrAdd(start, IntPtrConstant(1)),
......
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