OLD | NEW |
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 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 | 2965 |
2966 Maybe<bool> ValueSerializer::Delegate::WriteHostObject(Isolate* v8_isolate, | 2966 Maybe<bool> ValueSerializer::Delegate::WriteHostObject(Isolate* v8_isolate, |
2967 Local<Object> object) { | 2967 Local<Object> object) { |
2968 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 2968 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
2969 isolate->ScheduleThrow(*isolate->factory()->NewError( | 2969 isolate->ScheduleThrow(*isolate->factory()->NewError( |
2970 isolate->error_function(), i::MessageTemplate::kDataCloneError, | 2970 isolate->error_function(), i::MessageTemplate::kDataCloneError, |
2971 Utils::OpenHandle(*object))); | 2971 Utils::OpenHandle(*object))); |
2972 return Nothing<bool>(); | 2972 return Nothing<bool>(); |
2973 } | 2973 } |
2974 | 2974 |
| 2975 void* ValueSerializer::Delegate::ReallocateBufferMemory(void* old_buffer, |
| 2976 size_t size, |
| 2977 size_t* actual_size) { |
| 2978 *actual_size = size; |
| 2979 return realloc(old_buffer, size); |
| 2980 } |
| 2981 |
| 2982 void ValueSerializer::Delegate::FreeBufferMemory(void* buffer) { |
| 2983 return free(buffer); |
| 2984 } |
| 2985 |
2975 struct ValueSerializer::PrivateData { | 2986 struct ValueSerializer::PrivateData { |
2976 explicit PrivateData(i::Isolate* i, ValueSerializer::Delegate* delegate) | 2987 explicit PrivateData(i::Isolate* i, ValueSerializer::Delegate* delegate) |
2977 : isolate(i), serializer(i, delegate) {} | 2988 : isolate(i), serializer(i, delegate) {} |
2978 i::Isolate* isolate; | 2989 i::Isolate* isolate; |
2979 i::ValueSerializer serializer; | 2990 i::ValueSerializer serializer; |
2980 }; | 2991 }; |
2981 | 2992 |
2982 ValueSerializer::ValueSerializer(Isolate* isolate) | 2993 ValueSerializer::ValueSerializer(Isolate* isolate) |
2983 : ValueSerializer(isolate, nullptr) {} | 2994 : ValueSerializer(isolate, nullptr) {} |
2984 | 2995 |
(...skipping 12 matching lines...) Expand all Loading... |
2997 Maybe<bool> result = private_->serializer.WriteObject(object); | 3008 Maybe<bool> result = private_->serializer.WriteObject(object); |
2998 has_pending_exception = result.IsNothing(); | 3009 has_pending_exception = result.IsNothing(); |
2999 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3010 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3000 return result; | 3011 return result; |
3001 } | 3012 } |
3002 | 3013 |
3003 std::vector<uint8_t> ValueSerializer::ReleaseBuffer() { | 3014 std::vector<uint8_t> ValueSerializer::ReleaseBuffer() { |
3004 return private_->serializer.ReleaseBuffer(); | 3015 return private_->serializer.ReleaseBuffer(); |
3005 } | 3016 } |
3006 | 3017 |
| 3018 std::pair<uint8_t*, size_t> ValueSerializer::Release() { |
| 3019 return private_->serializer.Release(); |
| 3020 } |
| 3021 |
3007 void ValueSerializer::TransferArrayBuffer(uint32_t transfer_id, | 3022 void ValueSerializer::TransferArrayBuffer(uint32_t transfer_id, |
3008 Local<ArrayBuffer> array_buffer) { | 3023 Local<ArrayBuffer> array_buffer) { |
3009 private_->serializer.TransferArrayBuffer(transfer_id, | 3024 private_->serializer.TransferArrayBuffer(transfer_id, |
3010 Utils::OpenHandle(*array_buffer)); | 3025 Utils::OpenHandle(*array_buffer)); |
3011 } | 3026 } |
3012 | 3027 |
3013 void ValueSerializer::TransferSharedArrayBuffer( | 3028 void ValueSerializer::TransferSharedArrayBuffer( |
3014 uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) { | 3029 uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) { |
3015 private_->serializer.TransferArrayBuffer( | 3030 private_->serializer.TransferArrayBuffer( |
3016 transfer_id, Utils::OpenHandle(*shared_array_buffer)); | 3031 transfer_id, Utils::OpenHandle(*shared_array_buffer)); |
(...skipping 6747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9764 Address callback_address = | 9779 Address callback_address = |
9765 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9780 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9766 VMState<EXTERNAL> state(isolate); | 9781 VMState<EXTERNAL> state(isolate); |
9767 ExternalCallbackScope call_scope(isolate, callback_address); | 9782 ExternalCallbackScope call_scope(isolate, callback_address); |
9768 callback(info); | 9783 callback(info); |
9769 } | 9784 } |
9770 | 9785 |
9771 | 9786 |
9772 } // namespace internal | 9787 } // namespace internal |
9773 } // namespace v8 | 9788 } // namespace v8 |
OLD | NEW |