Skip to content

Commit 2a451ae

Browse files
committed
refactor(runtime): drop the host-object claim gate's messaging half
The serializer claims custom host objects unconditionally now, so the "any ports or transfer brands exist" flag that extended the former gate has no reader.
1 parent 03eb98c commit 2a451ae

2 files changed

Lines changed: 2 additions & 18 deletions

File tree

‎NativeScript/runtime/Messaging.cpp‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct MessagingState {
4444
// plain object in every graph. An isolate that has neither created a port
4545
// nor stamped a brand cannot be holding either, so it keeps serializing on
4646
// the cheap path.
47-
bool claimHostObjects = false;
4847
};
4948

5049
// The isolate's Caches is invalidated long before ~Runtime reaches the point
@@ -181,12 +180,8 @@ void StampBrand(const FunctionCallbackInfo<Value>& info,
181180
if (brand.IsEmpty()) {
182181
return;
183182
}
184-
if (info[0]
185-
.As<Object>()
186-
->SetPrivate(isolate->GetCurrentContext(), brand, v8::True(isolate))
187-
.FromMaybe(false)) {
188-
State(isolate)->claimHostObjects = true;
189-
}
183+
(void)info[0].As<Object>()->SetPrivate(isolate->GetCurrentContext(), brand,
184+
v8::True(isolate));
190185
}
191186

192187
} // namespace
@@ -411,7 +406,6 @@ std::shared_ptr<NativeMessagePort> NativeMessagePort::New(
411406
wrapper->SetAlignedPointerInInternalField(0, port.get(),
412407
v8::kEmbedderDataTypeTagDefault);
413408
state->livePorts.insert(port);
414-
state->claimHostObjects = true;
415409

416410
if (data != nullptr) {
417411
port->data_ = std::move(data);
@@ -746,11 +740,6 @@ MaybeLocal<Object> AdoptPort(Local<Context> context,
746740
return port->Wrapper(v8::Isolate::GetCurrent());
747741
}
748742

749-
bool AnyPortsOrBrands(Isolate* isolate) {
750-
MessagingState* state = State(isolate);
751-
return state != nullptr && state->claimHostObjects;
752-
}
753-
754743
Maybe<bool> IsMarkedUntransferable(Isolate* isolate, Local<Object> object) {
755744
Local<Private> brand = UntransferableBrand(isolate, false);
756745
if (brand.IsEmpty()) {

‎NativeScript/runtime/Messaging.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,6 @@ bool IsPortWrapper(v8::Isolate* isolate, v8::Local<v8::Object> object);
181181
v8::MaybeLocal<v8::Object> AdoptPort(v8::Local<v8::Context> context,
182182
std::unique_ptr<PortData> data);
183183

184-
// Whether this isolate has ever created a port or stamped a transfer brand.
185-
// Gates the serializer's host-object claim: until one of those happens, no
186-
// value in this isolate can need the messaging hooks.
187-
bool AnyPortsOrBrands(v8::Isolate* isolate);
188-
189184
// The markAsUntransferable / markAsUncloneable brands. Both answer Just(false)
190185
// without creating anything when this isolate has never stamped one.
191186
v8::Maybe<bool> IsMarkedUntransferable(v8::Isolate* isolate,

0 commit comments

Comments
 (0)