Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: src/api.cc

Issue 2768923002: WIP: Allow ValueSerializer clients to transfer long strings out of band.
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/value-serializer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 3112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 isolate->error_function(), i::MessageTemplate::kDataCloneError, 3123 isolate->error_function(), i::MessageTemplate::kDataCloneError,
3124 Utils::OpenHandle(*shared_array_buffer))); 3124 Utils::OpenHandle(*shared_array_buffer)));
3125 return Nothing<uint32_t>(); 3125 return Nothing<uint32_t>();
3126 } 3126 }
3127 3127
3128 Maybe<uint32_t> ValueSerializer::Delegate::GetWasmModuleTransferId( 3128 Maybe<uint32_t> ValueSerializer::Delegate::GetWasmModuleTransferId(
3129 Isolate* v8_isolate, Local<WasmCompiledModule> module) { 3129 Isolate* v8_isolate, Local<WasmCompiledModule> module) {
3130 return Nothing<uint32_t>(); 3130 return Nothing<uint32_t>();
3131 } 3131 }
3132 3132
3133 Maybe<uint32_t> ValueSerializer::Delegate::GetLongStringId(
3134 Isolate* v8_isolate, Local<String> string) {
3135 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
3136 isolate->ScheduleThrow(*isolate->factory()->NewError(
3137 isolate->error_function(), i::MessageTemplate::kDataCloneError,
3138 Utils::OpenHandle(*string)));
3139 return Nothing<uint32_t>();
3140 }
3141
3133 void* ValueSerializer::Delegate::ReallocateBufferMemory(void* old_buffer, 3142 void* ValueSerializer::Delegate::ReallocateBufferMemory(void* old_buffer,
3134 size_t size, 3143 size_t size,
3135 size_t* actual_size) { 3144 size_t* actual_size) {
3136 *actual_size = size; 3145 *actual_size = size;
3137 return realloc(old_buffer, size); 3146 return realloc(old_buffer, size);
3138 } 3147 }
3139 3148
3140 void ValueSerializer::Delegate::FreeBufferMemory(void* buffer) { 3149 void ValueSerializer::Delegate::FreeBufferMemory(void* buffer) {
3141 return free(buffer); 3150 return free(buffer);
3142 } 3151 }
(...skipping 13 matching lines...) Expand all
3156 new PrivateData(reinterpret_cast<i::Isolate*>(isolate), delegate)) {} 3165 new PrivateData(reinterpret_cast<i::Isolate*>(isolate), delegate)) {}
3157 3166
3158 ValueSerializer::~ValueSerializer() { delete private_; } 3167 ValueSerializer::~ValueSerializer() { delete private_; }
3159 3168
3160 void ValueSerializer::WriteHeader() { private_->serializer.WriteHeader(); } 3169 void ValueSerializer::WriteHeader() { private_->serializer.WriteHeader(); }
3161 3170
3162 void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) { 3171 void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) {
3163 private_->serializer.SetTreatArrayBufferViewsAsHostObjects(mode); 3172 private_->serializer.SetTreatArrayBufferViewsAsHostObjects(mode);
3164 } 3173 }
3165 3174
3175 void ValueSerializer::SetMinimumLongStringLength(int length) {
3176 private_->serializer.SetMinimumLongStringLength(length);
3177 }
3178
3166 Maybe<bool> ValueSerializer::WriteValue(Local<Context> context, 3179 Maybe<bool> ValueSerializer::WriteValue(Local<Context> context,
3167 Local<Value> value) { 3180 Local<Value> value) {
3168 PREPARE_FOR_EXECUTION_PRIMITIVE(context, ValueSerializer, WriteValue, bool); 3181 PREPARE_FOR_EXECUTION_PRIMITIVE(context, ValueSerializer, WriteValue, bool);
3169 i::Handle<i::Object> object = Utils::OpenHandle(*value); 3182 i::Handle<i::Object> object = Utils::OpenHandle(*value);
3170 Maybe<bool> result = private_->serializer.WriteObject(object); 3183 Maybe<bool> result = private_->serializer.WriteObject(object);
3171 has_pending_exception = result.IsNothing(); 3184 has_pending_exception = result.IsNothing();
3172 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3185 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3173 return result; 3186 return result;
3174 } 3187 }
3175 3188
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 Utils::OpenHandle(*array_buffer)); 3334 Utils::OpenHandle(*array_buffer));
3322 } 3335 }
3323 3336
3324 void ValueDeserializer::TransferSharedArrayBuffer( 3337 void ValueDeserializer::TransferSharedArrayBuffer(
3325 uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) { 3338 uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) {
3326 CHECK(!private_->has_aborted); 3339 CHECK(!private_->has_aborted);
3327 private_->deserializer.TransferArrayBuffer( 3340 private_->deserializer.TransferArrayBuffer(
3328 transfer_id, Utils::OpenHandle(*shared_array_buffer)); 3341 transfer_id, Utils::OpenHandle(*shared_array_buffer));
3329 } 3342 }
3330 3343
3344 void ValueDeserializer::TransferLongString(uint32_t transfer_id,
3345 Local<String> string) {
3346 CHECK(!private_->has_aborted);
3347 private_->deserializer.TransferLongString(transfer_id,
3348 Utils::OpenHandle(*string));
3349 }
3350
3331 bool ValueDeserializer::ReadUint32(uint32_t* value) { 3351 bool ValueDeserializer::ReadUint32(uint32_t* value) {
3332 return private_->deserializer.ReadUint32(value); 3352 return private_->deserializer.ReadUint32(value);
3333 } 3353 }
3334 3354
3335 bool ValueDeserializer::ReadUint64(uint64_t* value) { 3355 bool ValueDeserializer::ReadUint64(uint64_t* value) {
3336 return private_->deserializer.ReadUint64(value); 3356 return private_->deserializer.ReadUint64(value);
3337 } 3357 }
3338 3358
3339 bool ValueDeserializer::ReadDouble(double* value) { 3359 bool ValueDeserializer::ReadDouble(double* value) {
3340 return private_->deserializer.ReadDouble(value); 3360 return private_->deserializer.ReadDouble(value);
(...skipping 6949 matching lines...) Expand 10 before | Expand all | Expand 10 after
10290 Address callback_address = 10310 Address callback_address =
10291 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10311 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10292 VMState<EXTERNAL> state(isolate); 10312 VMState<EXTERNAL> state(isolate);
10293 ExternalCallbackScope call_scope(isolate, callback_address); 10313 ExternalCallbackScope call_scope(isolate, callback_address);
10294 callback(info); 10314 callback(info);
10295 } 10315 }
10296 10316
10297 10317
10298 } // namespace internal 10318 } // namespace internal
10299 } // namespace v8 10319 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/value-serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698