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 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3907 Local<Object> local_target, | 3907 Local<Object> local_target, |
3908 Local<Object> local_handler); | 3908 Local<Object> local_handler); |
3909 | 3909 |
3910 V8_INLINE static Proxy* Cast(Value* obj); | 3910 V8_INLINE static Proxy* Cast(Value* obj); |
3911 | 3911 |
3912 private: | 3912 private: |
3913 Proxy(); | 3913 Proxy(); |
3914 static void CheckCast(Value* obj); | 3914 static void CheckCast(Value* obj); |
3915 }; | 3915 }; |
3916 | 3916 |
3917 // TODO(mtrofin): rename WasmCompiledModule to WasmModuleObject, for | |
clemensh
2017/03/27 07:39:20
FYI: Ben once had the plan to rename this to WasmS
Mircea Trofin
2017/03/27 07:58:30
By "module" you mean "wire bytes"?
An instance of
| |
3918 // consistency with internal APIs. | |
3917 class V8_EXPORT WasmCompiledModule : public Object { | 3919 class V8_EXPORT WasmCompiledModule : public Object { |
3918 public: | 3920 public: |
3919 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; | 3921 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; |
3920 // A buffer that is owned by the caller. | 3922 // A buffer that is owned by the caller. |
3921 typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; | 3923 typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; |
3922 | 3924 |
3923 // An opaque, native heap object for transferring wasm modules. It | 3925 // An opaque, native heap object for transferring wasm modules. It |
3924 // supports move semantics, and does not support copy semantics. | 3926 // supports move semantics, and does not support copy semantics. |
3925 class TransferrableModule final { | 3927 class TransferrableModule final { |
3926 public: | 3928 public: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3958 SerializedModule Serialize(); | 3960 SerializedModule Serialize(); |
3959 | 3961 |
3960 // If possible, deserialize the module, otherwise compile it from the provided | 3962 // If possible, deserialize the module, otherwise compile it from the provided |
3961 // uncompiled bytes. | 3963 // uncompiled bytes. |
3962 static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( | 3964 static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( |
3963 Isolate* isolate, const CallerOwnedBuffer& serialized_module, | 3965 Isolate* isolate, const CallerOwnedBuffer& serialized_module, |
3964 const CallerOwnedBuffer& wire_bytes); | 3966 const CallerOwnedBuffer& wire_bytes); |
3965 V8_INLINE static WasmCompiledModule* Cast(Value* obj); | 3967 V8_INLINE static WasmCompiledModule* Cast(Value* obj); |
3966 | 3968 |
3967 private: | 3969 private: |
3970 // TODO(ahaas): please remove the friend once streamed compilation is | |
3971 // implemented | |
3972 friend class WasmModuleObjectBuilder; | |
3973 | |
3968 static MaybeLocal<WasmCompiledModule> Deserialize( | 3974 static MaybeLocal<WasmCompiledModule> Deserialize( |
3969 Isolate* isolate, const CallerOwnedBuffer& serialized_module, | 3975 Isolate* isolate, const CallerOwnedBuffer& serialized_module, |
3970 const CallerOwnedBuffer& wire_bytes); | 3976 const CallerOwnedBuffer& wire_bytes); |
3971 static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, | 3977 static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, |
3972 const uint8_t* start, | 3978 const uint8_t* start, |
3973 size_t length); | 3979 size_t length); |
3974 static CallerOwnedBuffer AsCallerOwned( | 3980 static CallerOwnedBuffer AsCallerOwned( |
3975 const TransferrableModule::OwnedBuffer& buff) { | 3981 const TransferrableModule::OwnedBuffer& buff) { |
3976 return {buff.first.get(), buff.second}; | 3982 return {buff.first.get(), buff.second}; |
3977 } | 3983 } |
3978 | 3984 |
3979 WasmCompiledModule(); | 3985 WasmCompiledModule(); |
3980 static void CheckCast(Value* obj); | 3986 static void CheckCast(Value* obj); |
3981 }; | 3987 }; |
3982 | 3988 |
3989 class V8_EXPORT WasmModuleObjectBuilder final { | |
3990 public: | |
3991 WasmModuleObjectBuilder(Isolate* isolate) : isolate_(isolate) {} | |
3992 void OnBytesReceived(std::unique_ptr<const uint8_t[]>&& bytes, size_t size); | |
3993 MaybeLocal<WasmCompiledModule> Finish(); | |
3994 | |
3995 private: | |
3996 Isolate* isolate_ = nullptr; | |
3997 // TODO(ahaas): We probably need none of this below here once streamed | |
3998 // compilation is implemented. | |
3999 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> Buffer; | |
4000 | |
4001 // Disable copy semantics *in this implementation*. We can choose to | |
4002 // relax this, albeit it's not clear why. | |
4003 WasmModuleObjectBuilder(const WasmModuleObjectBuilder&) = delete; | |
4004 WasmModuleObjectBuilder(WasmModuleObjectBuilder&&) = default; | |
4005 WasmModuleObjectBuilder& operator=(const WasmModuleObjectBuilder&) = delete; | |
4006 WasmModuleObjectBuilder& operator=(WasmModuleObjectBuilder&&) = default; | |
4007 | |
4008 std::vector<Buffer> received_buffers_; | |
4009 size_t total_size_ = 0; | |
4010 }; | |
4011 | |
3983 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | 4012 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT |
3984 // The number of required internal fields can be defined by embedder. | 4013 // The number of required internal fields can be defined by embedder. |
3985 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | 4014 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 |
3986 #endif | 4015 #endif |
3987 | 4016 |
3988 | 4017 |
3989 enum class ArrayBufferCreationMode { kInternalized, kExternalized }; | 4018 enum class ArrayBufferCreationMode { kInternalized, kExternalized }; |
3990 | 4019 |
3991 | 4020 |
3992 /** | 4021 /** |
(...skipping 5895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9888 */ | 9917 */ |
9889 | 9918 |
9890 | 9919 |
9891 } // namespace v8 | 9920 } // namespace v8 |
9892 | 9921 |
9893 | 9922 |
9894 #undef TYPE_CHECK | 9923 #undef TYPE_CHECK |
9895 | 9924 |
9896 | 9925 |
9897 #endif // INCLUDE_V8_H_ | 9926 #endif // INCLUDE_V8_H_ |
OLD | NEW |