[vm] Avoid a second map lookup when dispatching isolate messages.

- Use the currently-unused ReceivePort.handler field instead of a second map.
 - Recognize ReceivePort's fields instead of using natives.

This also has the effect that if one discovers that a port handler is holding onto a large amount of memory via its context, the receive port along with its debug name will appear in the retaining path.

TEST=ci
Change-Id: I4b8d0764a41729a3b397b85bc4603e4d6b0ca9a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285403
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2023-02-27 18:08:25 +00:00 committed by Commit Queue
parent 7e5297e5f8
commit 7c0a694668
14 changed files with 137 additions and 29 deletions

View file

@ -66,11 +66,6 @@ DEFINE_NATIVE_ENTRY(RawReceivePort_get_id, 0, 1) {
return Integer::New(port.Id());
}
DEFINE_NATIVE_ENTRY(RawReceivePort_get_sendport, 0, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0));
return port.send_port();
}
DEFINE_NATIVE_ENTRY(RawReceivePort_closeInternal, 0, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0));
Dart_Port id = port.Id();

View file

@ -58,7 +58,6 @@ namespace dart {
V(Capability_get_hashcode, 1) \
V(RawReceivePort_factory, 2) \
V(RawReceivePort_get_id, 1) \
V(RawReceivePort_get_sendport, 1) \
V(RawReceivePort_closeInternal, 1) \
V(RawReceivePort_setActive, 2) \
V(SendPort_get_id, 1) \

View file

@ -2792,6 +2792,8 @@ void LoadFieldInstr::InferRange(RangeAnalysis* analysis, Range* range) {
Definition::InferRange(analysis, range);
break;
case Slot::Kind::kReceivePort_send_port:
case Slot::Kind::kReceivePort_handler:
case Slot::Kind::kLinkedHashBase_index:
case Slot::Kind::kImmutableLinkedHashBase_index:
case Slot::Kind::kLinkedHashBase_data:

View file

@ -145,6 +145,8 @@ bool Slot::IsImmutableLengthSlot() const {
case Slot::Kind::k##Class##_##Field:
UNBOXED_NATIVE_SLOTS_LIST(UNBOXED_NATIVE_SLOT_CASE)
#undef UNBOXED_NATIVE_SLOT_CASE
case Slot::Kind::kReceivePort_send_port:
case Slot::Kind::kReceivePort_handler:
case Slot::Kind::kLinkedHashBase_index:
case Slot::Kind::kImmutableLinkedHashBase_index:
case Slot::Kind::kLinkedHashBase_data:

View file

@ -70,6 +70,8 @@ class ParsedFunction;
V(Closure, UntaggedClosure, function_type_arguments, TypeArguments, FINAL) \
V(FunctionType, UntaggedFunctionType, type_parameters, TypeParameters, \
FINAL) \
V(ReceivePort, UntaggedReceivePort, send_port, SendPort, FINAL) \
V(ReceivePort, UntaggedReceivePort, handler, Closure, VAR) \
V(ImmutableLinkedHashBase, UntaggedLinkedHashBase, index, \
TypedDataUint32Array, VAR) \
V(Instance, UntaggedInstance, native_fields_array, Dynamic, VAR) \

View file

@ -876,6 +876,8 @@ Fragment FlowGraphBuilder::NativeFunctionBody(const Function& function,
V(FinalizerEntry_getValue, FinalizerEntry_value) \
V(NativeFinalizer_getCallback, NativeFinalizer_callback) \
V(GrowableArrayLength, GrowableObjectArray_length) \
V(ReceivePort_getSendPort, ReceivePort_send_port) \
V(ReceivePort_getHandler, ReceivePort_handler) \
V(ImmutableLinkedHashBase_getData, ImmutableLinkedHashBase_data) \
V(ImmutableLinkedHashBase_getIndex, ImmutableLinkedHashBase_index) \
V(LinkedHashBase_getData, LinkedHashBase_data) \
@ -901,6 +903,7 @@ Fragment FlowGraphBuilder::NativeFunctionBody(const Function& function,
V(FinalizerBase_setDetachments, FinalizerBase_detachments) \
V(FinalizerEntry_setToken, FinalizerEntry_token) \
V(NativeFinalizer_setCallback, NativeFinalizer_callback) \
V(ReceivePort_setHandler, ReceivePort_handler) \
V(LinkedHashBase_setData, LinkedHashBase_data) \
V(LinkedHashBase_setIndex, LinkedHashBase_index) \
V(SuspendState_setFunctionData, SuspendState_function_data) \

View file

@ -292,6 +292,7 @@ void MethodRecognizer::Libraries(GrowableArray<Library*>* libs) {
libs->Add(&Library::ZoneHandle(Library::TypedDataLibrary()));
libs->Add(&Library::ZoneHandle(Library::ConvertLibrary()));
libs->Add(&Library::ZoneHandle(Library::InternalLibrary()));
libs->Add(&Library::ZoneHandle(Library::IsolateLibrary()));
libs->Add(&Library::ZoneHandle(Library::DeveloperLibrary()));
libs->Add(&Library::ZoneHandle(Library::AsyncLibrary()));
libs->Add(&Library::ZoneHandle(Library::FfiLibrary()));

View file

@ -244,6 +244,9 @@ namespace dart {
V(_Int32x4, _withFlagY, Int32x4WithFlagY, 0xa8cf9ba6) \
V(_Int32x4, _withFlagZ, Int32x4WithFlagZ, 0xa8058854) \
V(_Int32x4, _withFlagW, Int32x4WithFlagW, 0xb333f958) \
V(_RawReceivePort, get:sendPort, ReceivePort_getSendPort, 0xe6bb706d) \
V(_RawReceivePort, get:_handler, ReceivePort_getHandler, 0xf1f36233) \
V(_RawReceivePort, set:_handler, ReceivePort_setHandler, 0x571c5330) \
V(_HashVMBase, get:_index, LinkedHashBase_getIndex, 0x882671dc) \
V(_HashVMBase, set:_index, LinkedHashBase_setIndex, 0xa2be9418) \
V(_HashVMBase, get:_data, LinkedHashBase_getData, 0x2c8b5e83) \

View file

@ -998,6 +998,8 @@ class Capability : public AllStatic {
class ReceivePort : public AllStatic {
public:
static word send_port_offset();
static word handler_offset();
static word InstanceSize();
FINAL_CLASS();
};

View file

@ -272,6 +272,8 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
static constexpr dart::compiler::target::word PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 4;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 8;
static constexpr dart::compiler::target::word Record_shape_offset = 4;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 8;
@ -952,6 +954,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 16;
static constexpr dart::compiler::target::word Record_shape_offset = 8;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -1635,6 +1639,8 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
static constexpr dart::compiler::target::word PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 4;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 8;
static constexpr dart::compiler::target::word Record_shape_offset = 4;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 8;
@ -2315,6 +2321,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 16;
static constexpr dart::compiler::target::word Record_shape_offset = 8;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -3000,6 +3008,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 12;
static constexpr dart::compiler::target::word Record_shape_offset = 12;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -3685,6 +3695,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 12;
static constexpr dart::compiler::target::word Record_shape_offset = 12;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -4370,6 +4382,8 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
static constexpr dart::compiler::target::word PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 4;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 8;
static constexpr dart::compiler::target::word Record_shape_offset = 4;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 8;
@ -5052,6 +5066,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 16;
static constexpr dart::compiler::target::word Record_shape_offset = 8;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -5730,6 +5746,8 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
static constexpr dart::compiler::target::word PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 4;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 8;
static constexpr dart::compiler::target::word Record_shape_offset = 4;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 8;
@ -6402,6 +6420,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 16;
static constexpr dart::compiler::target::word Record_shape_offset = 8;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -7077,6 +7097,8 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
static constexpr dart::compiler::target::word PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 4;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 8;
static constexpr dart::compiler::target::word Record_shape_offset = 4;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 8;
@ -7749,6 +7771,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 16;
static constexpr dart::compiler::target::word Record_shape_offset = 8;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -8426,6 +8450,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 12;
static constexpr dart::compiler::target::word Record_shape_offset = 12;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -9103,6 +9129,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 12;
static constexpr dart::compiler::target::word Record_shape_offset = 12;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -9780,6 +9808,8 @@ static constexpr dart::compiler::target::word
static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
static constexpr dart::compiler::target::word PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 4;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 8;
static constexpr dart::compiler::target::word Record_shape_offset = 4;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 8;
@ -10454,6 +10484,8 @@ static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
static constexpr dart::compiler::target::word PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
16;
static constexpr dart::compiler::target::word ReceivePort_send_port_offset = 8;
static constexpr dart::compiler::target::word ReceivePort_handler_offset = 16;
static constexpr dart::compiler::target::word Record_shape_offset = 8;
static constexpr dart::compiler::target::word
SingleTargetCache_entry_point_offset = 16;
@ -11165,6 +11197,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
4;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
8;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 4;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 8;
@ -11918,6 +11954,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
16;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -12678,6 +12718,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
16;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -13436,6 +13480,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
12;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -14194,6 +14242,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
12;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -14952,6 +15004,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
4;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
8;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 4;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 8;
@ -15707,6 +15763,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
16;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -16457,6 +16517,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
4;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
8;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 4;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 8;
@ -17201,6 +17265,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
16;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -17952,6 +18020,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
16;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -18701,6 +18773,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
12;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -19450,6 +19526,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
12;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 12;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;
@ -20199,6 +20279,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 4;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 8;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
4;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
8;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 4;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 8;
@ -20945,6 +21029,10 @@ static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
static constexpr dart::compiler::target::word AOT_PointerBase_data_offset = 8;
static constexpr dart::compiler::target::word
AOT_Pointer_type_arguments_offset = 16;
static constexpr dart::compiler::target::word AOT_ReceivePort_send_port_offset =
8;
static constexpr dart::compiler::target::word AOT_ReceivePort_handler_offset =
16;
static constexpr dart::compiler::target::word AOT_Record_shape_offset = 8;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_entry_point_offset = 16;

View file

@ -209,6 +209,8 @@
FIELD(OneByteString, data_offset) \
FIELD(PointerBase, data_offset) \
FIELD(Pointer, type_arguments_offset) \
FIELD(ReceivePort, send_port_offset) \
FIELD(ReceivePort, handler_offset) \
FIELD(Record, shape_offset) \
FIELD(SingleTargetCache, entry_point_offset) \
FIELD(SingleTargetCache, lower_limit_offset) \

View file

@ -15192,6 +15192,7 @@ void Library::CheckFunctionFingerprints() {
all_libs.Add(&Library::ZoneHandle(Library::CollectionLibrary()));
all_libs.Add(&Library::ZoneHandle(Library::ConvertLibrary()));
all_libs.Add(&Library::ZoneHandle(Library::InternalLibrary()));
all_libs.Add(&Library::ZoneHandle(Library::IsolateLibrary()));
all_libs.Add(&Library::ZoneHandle(Library::FfiLibrary()));
all_libs.Add(&Library::ZoneHandle(Library::NativeWrappersLibrary()));
all_libs.Add(&Library::ZoneHandle(Library::DeveloperLibrary()));

View file

@ -12143,10 +12143,18 @@ class Capability : public Instance {
class ReceivePort : public Instance {
public:
SendPortPtr send_port() const { return untag()->send_port(); }
static intptr_t send_port_offset() {
return OFFSET_OF(UntaggedReceivePort, send_port_);
}
Dart_Port Id() const { return send_port()->untag()->id_; }
InstancePtr handler() const { return untag()->handler(); }
void set_handler(const Instance& value) const;
void set_handler(const Instance& value) const {
untag()->set_handler(value.ptr());
}
static intptr_t handler_offset() {
return OFFSET_OF(UntaggedReceivePort, handler_);
}
#if !defined(PRODUCT)
StackTracePtr allocation_location() const {

View file

@ -135,9 +135,7 @@ Function _getIsolateScheduleImmediateClosure() {
class _RawReceivePort implements RawReceivePort {
factory _RawReceivePort(String debugName) {
final port = _RawReceivePort._(debugName);
_portMap[port._get_id()] = <String, dynamic>{
'port': port,
};
_portMap[port._get_id()] = port;
return port;
}
@ -149,9 +147,10 @@ class _RawReceivePort implements RawReceivePort {
_portMap.remove(this._closeInternal());
}
SendPort get sendPort {
return _get_sendport();
}
@pragma("vm:recognized", "other")
@pragma("vm:prefer-inline")
@pragma("vm:external-name", "RawReceivePort_getSendPort")
external SendPort get sendPort;
bool operator ==(var other) {
return (other is _RawReceivePort) && (this._get_id() == other._get_id());
@ -164,32 +163,30 @@ class _RawReceivePort implements RawReceivePort {
/**** Internal implementation details ****/
@pragma("vm:external-name", "RawReceivePort_get_id")
external int _get_id();
@pragma("vm:external-name", "RawReceivePort_get_sendport")
external SendPort _get_sendport();
// Called from the VM to retrieve the handler for a message.
@pragma("vm:entry-point", "call")
static _lookupHandler(int id) {
var result = _portMap[id]?['handler'];
return result;
return _portMap[id]?._handler;
}
// Called from the VM service to enumerate ports.
@pragma("vm:entry-point", "call")
static _lookupOpenPorts() {
return _portMap.values.map((e) => e['port']).toList();
return _portMap.values.toList();
}
// Called from the VM to retrieve the handler and handle a message.
// Called from the VM to dispatch a message.
@pragma("vm:entry-point", "call")
static _handleMessage(int id, var message) {
final handler = _portMap[id]?['handler'];
final Function? handler = _portMap[id]?._handler;
if (handler == null) {
return null;
}
// TODO(floitsch): this relies on the fact that any exception aborts the
// VM. Once we have non-fatal global exceptions we need to catch errors
// so that we can run the immediate callbacks.
(handler as Function)(message);
handler(message);
_runPendingImmediateCallback();
return handler;
}
@ -205,17 +202,20 @@ class _RawReceivePort implements RawReceivePort {
@pragma("vm:external-name", "RawReceivePort_setActive")
external _setActive(bool active);
@pragma("vm:recognized", "other")
@pragma("vm:prefer-inline")
@pragma("vm:external-name", "RawReceivePort_getHandler")
external Function? get _handler;
@pragma("vm:recognized", "other")
@pragma("vm:prefer-inline")
@pragma("vm:external-name", "RawReceivePort_setHandler")
external set _handler(Function? handler);
void set handler(Function? value) {
final int id = this._get_id();
if (!_portMap.containsKey(id)) {
_portMap[id] = <String, dynamic>{
'port': this,
};
}
_portMap[id]!['handler'] = value;
_handler = value;
}
static final _portMap = <int, Map<String, dynamic>>{};
static final _portMap = <int, _RawReceivePort>{};
}
@pragma("vm:entry-point")