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 { ...@@ -21,15 +21,15 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
explicit MicrotaskQueueBuiltinsAssembler(compiler::CodeAssemblerState* state) explicit MicrotaskQueueBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {} : CodeStubAssembler(state) {}
TNode<IntPtrT> GetDefaultMicrotaskQueue(); TNode<RawPtrT> GetDefaultMicrotaskQueue();
TNode<IntPtrT> GetMicrotaskQueue(TNode<Context> context); TNode<RawPtrT> GetMicrotaskQueue(TNode<Context> context);
TNode<IntPtrT> GetMicrotaskRingBuffer(TNode<IntPtrT> microtask_queue); TNode<RawPtrT> GetMicrotaskRingBuffer(TNode<RawPtrT> microtask_queue);
TNode<IntPtrT> GetMicrotaskQueueCapacity(TNode<IntPtrT> microtask_queue); TNode<IntPtrT> GetMicrotaskQueueCapacity(TNode<RawPtrT> microtask_queue);
TNode<IntPtrT> GetMicrotaskQueueSize(TNode<IntPtrT> microtask_queue); TNode<IntPtrT> GetMicrotaskQueueSize(TNode<RawPtrT> microtask_queue);
void SetMicrotaskQueueSize(TNode<IntPtrT> microtask_queue, void SetMicrotaskQueueSize(TNode<RawPtrT> microtask_queue,
TNode<IntPtrT> new_size); TNode<IntPtrT> new_size);
TNode<IntPtrT> GetMicrotaskQueueStart(TNode<IntPtrT> microtask_queue); TNode<IntPtrT> GetMicrotaskQueueStart(TNode<RawPtrT> microtask_queue);
void SetMicrotaskQueueStart(TNode<IntPtrT> microtask_queue, void SetMicrotaskQueueStart(TNode<RawPtrT> microtask_queue,
TNode<IntPtrT> new_start); TNode<IntPtrT> new_start);
TNode<IntPtrT> CalculateRingBufferOffset(TNode<IntPtrT> capacity, TNode<IntPtrT> CalculateRingBufferOffset(TNode<IntPtrT> capacity,
TNode<IntPtrT> start, TNode<IntPtrT> start,
...@@ -48,55 +48,55 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler { ...@@ -48,55 +48,55 @@ class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
SloppyTNode<HeapObject> promise_or_capability); SloppyTNode<HeapObject> promise_or_capability);
}; };
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetDefaultMicrotaskQueue() { TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetDefaultMicrotaskQueue() {
auto ref = ExternalReference::default_microtask_queue_address(isolate()); auto ref = ExternalReference::default_microtask_queue_address(isolate());
return UncheckedCast<IntPtrT>( return UncheckedCast<RawPtrT>(
Load(MachineType::Pointer(), ExternalConstant(ref))); Load(MachineType::Pointer(), ExternalConstant(ref)));
} }
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueue( TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueue(
TNode<Context> native_context) { TNode<Context> native_context) {
CSA_ASSERT(this, IsNativeContext(native_context)); CSA_ASSERT(this, IsNativeContext(native_context));
return LoadObjectField<IntPtrT>(native_context, return LoadObjectField<RawPtrT>(native_context,
NativeContext::kMicrotaskQueueOffset); NativeContext::kMicrotaskQueueOffset);
} }
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskRingBuffer( TNode<RawPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskRingBuffer(
TNode<IntPtrT> microtask_queue) { TNode<RawPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>( return UncheckedCast<RawPtrT>(
Load(MachineType::IntPtr(), microtask_queue, Load(MachineType::Pointer(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kRingBufferOffset))); IntPtrConstant(MicrotaskQueue::kRingBufferOffset)));
} }
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueCapacity( TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueCapacity(
TNode<IntPtrT> microtask_queue) { TNode<RawPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>( return UncheckedCast<IntPtrT>(
Load(MachineType::IntPtr(), microtask_queue, Load(MachineType::IntPtr(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kCapacityOffset))); IntPtrConstant(MicrotaskQueue::kCapacityOffset)));
} }
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueSize( TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueSize(
TNode<IntPtrT> microtask_queue) { TNode<RawPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>( return UncheckedCast<IntPtrT>(
Load(MachineType::IntPtr(), microtask_queue, Load(MachineType::IntPtr(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kSizeOffset))); IntPtrConstant(MicrotaskQueue::kSizeOffset)));
} }
void MicrotaskQueueBuiltinsAssembler::SetMicrotaskQueueSize( void MicrotaskQueueBuiltinsAssembler::SetMicrotaskQueueSize(
TNode<IntPtrT> microtask_queue, TNode<IntPtrT> new_size) { TNode<RawPtrT> microtask_queue, TNode<IntPtrT> new_size) {
StoreNoWriteBarrier(MachineType::PointerRepresentation(), microtask_queue, StoreNoWriteBarrier(MachineType::PointerRepresentation(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kSizeOffset), new_size); IntPtrConstant(MicrotaskQueue::kSizeOffset), new_size);
} }
TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueStart( TNode<IntPtrT> MicrotaskQueueBuiltinsAssembler::GetMicrotaskQueueStart(
TNode<IntPtrT> microtask_queue) { TNode<RawPtrT> microtask_queue) {
return UncheckedCast<IntPtrT>( return UncheckedCast<IntPtrT>(
Load(MachineType::IntPtr(), microtask_queue, Load(MachineType::IntPtr(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kStartOffset))); IntPtrConstant(MicrotaskQueue::kStartOffset)));
} }
void MicrotaskQueueBuiltinsAssembler::SetMicrotaskQueueStart( void MicrotaskQueueBuiltinsAssembler::SetMicrotaskQueueStart(
TNode<IntPtrT> microtask_queue, TNode<IntPtrT> new_start) { TNode<RawPtrT> microtask_queue, TNode<IntPtrT> new_start) {
StoreNoWriteBarrier(MachineType::PointerRepresentation(), microtask_queue, StoreNoWriteBarrier(MachineType::PointerRepresentation(), microtask_queue,
IntPtrConstant(MicrotaskQueue::kStartOffset), new_start); IntPtrConstant(MicrotaskQueue::kStartOffset), new_start);
} }
...@@ -464,12 +464,11 @@ void MicrotaskQueueBuiltinsAssembler::RunPromiseHook( ...@@ -464,12 +464,11 @@ void MicrotaskQueueBuiltinsAssembler::RunPromiseHook(
TF_BUILTIN(EnqueueMicrotask, MicrotaskQueueBuiltinsAssembler) { TF_BUILTIN(EnqueueMicrotask, MicrotaskQueueBuiltinsAssembler) {
TNode<Microtask> microtask = TNode<Microtask> microtask =
UncheckedCast<Microtask>(Parameter(Descriptor::kMicrotask)); UncheckedCast<Microtask>(Parameter(Descriptor::kMicrotask));
TNode<Context> context = TNode<Context> context = CAST(Parameter(Descriptor::kContext));
UncheckedCast<Context>(Parameter(Descriptor::kContext));
TNode<Context> native_context = LoadNativeContext(context); 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> capacity = GetMicrotaskQueueCapacity(microtask_queue);
TNode<IntPtrT> size = GetMicrotaskQueueSize(microtask_queue); TNode<IntPtrT> size = GetMicrotaskQueueSize(microtask_queue);
TNode<IntPtrT> start = GetMicrotaskQueueStart(microtask_queue); TNode<IntPtrT> start = GetMicrotaskQueueStart(microtask_queue);
...@@ -508,7 +507,7 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) { ...@@ -508,7 +507,7 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) {
TNode<Context> current_context = GetCurrentContext(); TNode<Context> current_context = GetCurrentContext();
// TODO(tzik): Take a MicrotaskQueue parameter to support non-default queue. // 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); Label loop(this), done(this);
Goto(&loop); Goto(&loop);
...@@ -519,16 +518,15 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) { ...@@ -519,16 +518,15 @@ TF_BUILTIN(RunMicrotasks, MicrotaskQueueBuiltinsAssembler) {
// Exit if the queue is empty. // Exit if the queue is empty.
GotoIf(WordEqual(size, IntPtrConstant(0)), &done); 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> capacity = GetMicrotaskQueueCapacity(microtask_queue);
TNode<IntPtrT> start = GetMicrotaskQueueStart(microtask_queue); TNode<IntPtrT> start = GetMicrotaskQueueStart(microtask_queue);
TNode<IntPtrT> offset = TNode<IntPtrT> offset =
CalculateRingBufferOffset(capacity, start, IntPtrConstant(0)); CalculateRingBufferOffset(capacity, start, IntPtrConstant(0));
TNode<IntPtrT> microtask_pointer = TNode<RawPtrT> microtask_pointer =
UncheckedCast<IntPtrT>(Load(MachineType::Pointer(), ring_buffer, offset)); UncheckedCast<RawPtrT>(Load(MachineType::Pointer(), ring_buffer, offset));
TNode<Microtask> microtask = TNode<Microtask> microtask = CAST(BitcastWordToTagged(microtask_pointer));
UncheckedCast<Microtask>(BitcastWordToTagged(microtask_pointer));
TNode<IntPtrT> new_size = IntPtrSub(size, IntPtrConstant(1)); TNode<IntPtrT> new_size = IntPtrSub(size, IntPtrConstant(1));
TNode<IntPtrT> new_start = WordAnd(IntPtrAdd(start, 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