Skip to content

Commit

Permalink
testing serializer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Aug 2, 2022
1 parent 8cf3385 commit e8114b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 9 additions & 8 deletions deps/v8/src/objects/value-serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,14 +561,8 @@ Maybe<bool> ValueSerializer::WriteJSReceiver(Handle<JSReceiver> receiver) {
case JS_SET_PROTOTYPE_TYPE:
case JS_STRING_ITERATOR_PROTOTYPE_TYPE:
case JS_TYPED_ARRAY_PROTOTYPE_TYPE:
case JS_API_OBJECT_TYPE: {
Handle<JSObject> js_object = Handle<JSObject>::cast(receiver);
if (JSObject::GetEmbedderFieldCount(js_object->map(isolate_))) {
return WriteHostObject(js_object);
} else {
return WriteJSObject(js_object);
}
}
case JS_API_OBJECT_TYPE:
return WriteJSObject(js_object);
case JS_SPECIAL_API_OBJECT_TYPE:
return WriteHostObject(Handle<JSObject>::cast(receiver));
case JS_DATE_TYPE:
Expand Down Expand Up @@ -612,6 +606,13 @@ Maybe<bool> ValueSerializer::WriteJSReceiver(Handle<JSReceiver> receiver) {
}

Maybe<bool> ValueSerializer::WriteJSObject(Handle<JSObject> object) {
{
Maybe<bool> result = WriteHostObject(object);
if (result.IsNothing() || result.FromMaybe(false)) {
return result;
}
}

DCHECK(!object->map().IsCustomElementsReceiverMap());
const bool can_serialize_fast =
object->HasFastProperties(isolate_) && object->elements().length() == 0;
Expand Down
4 changes: 4 additions & 0 deletions src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ class SerializerDelegate : public ValueSerializer::Delegate {
}

Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object) override {
if (object->InternalFieldCount() == 0) {
return Just(false);
}

if (env_->base_object_ctor_template()->HasInstance(object)) {
return WriteHostObject(
BaseObjectPtr<BaseObject> { Unwrap<BaseObject>(object) });
Expand Down
4 changes: 4 additions & 0 deletions src/node_serdes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ Maybe<uint32_t> SerializerContext::GetSharedArrayBufferId(

Maybe<bool> SerializerContext::WriteHostObject(Isolate* isolate,
Local<Object> input) {
if (input->InternalFieldCount() == 0 && !input->IsArrayBufferView()) {
return Just(false);
}

MaybeLocal<Value> ret;
Local<Value> args[1] = { input };

Expand Down

0 comments on commit e8114b0

Please sign in to comment.