@@ -31,6 +31,7 @@ using v8::MaybeLocal; |
31 | 31 | using v8::Nothing; |
32 | 32 | using v8::Object; |
33 | 33 | using v8::SharedArrayBuffer; |
| 34 | +using v8::SharedValueConveyor; |
34 | 35 | using v8::String; |
35 | 36 | using v8::Symbol; |
36 | 37 | using v8::Value; |
@@ -92,10 +93,12 @@ class DeserializerDelegate : public ValueDeserializer::Delegate { |
92 | 93 | Environment* env, |
93 | 94 | const std::vector<BaseObjectPtr<BaseObject>>& host_objects, |
94 | 95 | const std::vector<Local<SharedArrayBuffer>>& shared_array_buffers, |
95 | | - const std::vector<CompiledWasmModule>& wasm_modules) |
| 96 | + const std::vector<CompiledWasmModule>& wasm_modules, |
| 97 | + const std::optional<SharedValueConveyor>& shared_value_conveyor) |
96 | 98 | : host_objects_(host_objects), |
97 | 99 | shared_array_buffers_(shared_array_buffers), |
98 | | - wasm_modules_(wasm_modules) {} |
| 100 | + wasm_modules_(wasm_modules), |
| 101 | + shared_value_conveyor_(shared_value_conveyor) {} |
99 | 102 |
|
100 | 103 | MaybeLocal<Object> ReadHostObject(Isolate* isolate) override { |
101 | 104 | // Identifying the index in the message's BaseObject array is sufficient. |
@@ -128,12 +131,18 @@ class DeserializerDelegate : public ValueDeserializer::Delegate { |
128 | 131 | isolate, wasm_modules_[transfer_id]); |
129 | 132 | } |
130 | 133 |
|
| 134 | + const SharedValueConveyor* GetSharedValueConveyor(Isolate* isolate) override { |
| 135 | + CHECK(shared_value_conveyor_.has_value()); |
| 136 | + return &shared_value_conveyor_.value(); |
| 137 | + } |
| 138 | + |
131 | 139 | ValueDeserializer* deserializer = nullptr; |
132 | 140 |
|
133 | 141 | private: |
134 | 142 | const std::vector<BaseObjectPtr<BaseObject>>& host_objects_; |
135 | 143 | const std::vector<Local<SharedArrayBuffer>>& shared_array_buffers_; |
136 | 144 | const std::vector<CompiledWasmModule>& wasm_modules_; |
| 145 | + const std::optional<SharedValueConveyor>& shared_value_conveyor_; |
137 | 146 | }; |
138 | 147 |
|
139 | 148 | } // anonymous namespace |
@@ -198,8 +207,12 @@ MaybeLocal<Value> Message::Deserialize(Environment* env, |
198 | 207 | shared_array_buffers.push_back(sab); |
199 | 208 | } |
200 | 209 |
|
201 | | - DeserializerDelegate delegate( |
202 | | - this, env, host_objects, shared_array_buffers, wasm_modules_); |
| 210 | + DeserializerDelegate delegate(this, |
| 211 | + env, |
| 212 | + host_objects, |
| 213 | + shared_array_buffers, |
| 214 | + wasm_modules_, |
| 215 | + shared_value_conveyor_); |
203 | 216 | ValueDeserializer deserializer( |
204 | 217 | env->isolate(), |
205 | 218 | reinterpret_cast<const uint8_t*>(main_message_buf_.data), |
@@ -243,6 +256,10 @@ uint32_t Message::AddWASMModule(CompiledWasmModule&& mod) { |
243 | 256 | return wasm_modules_.size() - 1; |
244 | 257 | } |
245 | 258 |
|
| 259 | +void Message::AdoptSharedValueConveyor(SharedValueConveyor&& conveyor) { |
| 260 | + shared_value_conveyor_.emplace(std::move(conveyor)); |
| 261 | +} |
| 262 | + |
246 | 263 | namespace { |
247 | 264 |
|
248 | 265 | MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context) { |
@@ -347,6 +364,12 @@ class SerializerDelegate : public ValueSerializer::Delegate { |
347 | 364 | return Just(msg_->AddWASMModule(module->GetCompiledModule())); |
348 | 365 | } |
349 | 366 |
|
| 367 | + bool AdoptSharedValueConveyor(Isolate* isolate, |
| 368 | + SharedValueConveyor&& conveyor) override { |
| 369 | + msg_->AdoptSharedValueConveyor(std::move(conveyor)); |
| 370 | + return true; |
| 371 | + } |
| 372 | + |
350 | 373 | Maybe<bool> Finish(Local<Context> context) { |
351 | 374 | for (uint32_t i = 0; i < host_objects_.size(); i++) { |
352 | 375 | BaseObjectPtr<BaseObject> host_object = std::move(host_objects_[i]); |
|