diff options
author | cjihrig <cjihrig@gmail.com> | 2019-09-04 17:56:51 -0400 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-30 18:06:39 +0100 |
commit | 09b1228c3a2723c6ecb768b40a507688015a478f (patch) | |
tree | 88acbfc979bc6f73572c86e8ee804bf0fa4ad326 /src/node_wasi.h | |
parent | 73c837b1ae91cb8852e75a921fa24c714471d690 (diff) | |
download | android-node-v8-09b1228c3a2723c6ecb768b40a507688015a478f.tar.gz android-node-v8-09b1228c3a2723c6ecb768b40a507688015a478f.tar.bz2 android-node-v8-09b1228c3a2723c6ecb768b40a507688015a478f.zip |
wasi: introduce initial WASI support
Co-authored-by: Gus Caplan <me@gus.host>
Co-authored-by: Daniel Bevenius <daniel.bevenius@gmail.com>
Co-authored-by: Jiawen Geng <technicalcute@gmail.com>
Co-authored-by: Tobias Nießen <tniessen@tnie.de>
Co-authored-by: Chengzhong Wu <legendecas@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/30258
Refs: https://github.com/nodejs/node/pull/27850
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'src/node_wasi.h')
-rw-r--r-- | src/node_wasi.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/node_wasi.h b/src/node_wasi.h new file mode 100644 index 0000000000..ca726e48a4 --- /dev/null +++ b/src/node_wasi.h @@ -0,0 +1,103 @@ +#ifndef SRC_NODE_WASI_H_ +#define SRC_NODE_WASI_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "base_object.h" +#include "memory_tracker-inl.h" +#include "uvwasi.h" + +namespace node { +namespace wasi { + + +class WASI : public BaseObject { + public: + WASI(Environment* env, + v8::Local<v8::Object> object, + uvwasi_options_t* options); + static void New(const v8::FunctionCallbackInfo<v8::Value>& args); + void MemoryInfo(MemoryTracker* tracker) const override { + /* TODO(cjihrig): Get memory consumption from uvwasi. */ + tracker->TrackField("memory", memory_); + } + + SET_MEMORY_INFO_NAME(WASI) + SET_SELF_SIZE(WASI) + + static void ArgsGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void ArgsSizesGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void ClockResGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void ClockTimeGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void EnvironGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void EnvironSizesGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdAdvise(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdAllocate(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdClose(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdDatasync(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdFdstatGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdFdstatSetFlags(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdFdstatSetRights( + const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdFilestatGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdFilestatSetSize( + const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdFilestatSetTimes( + const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdPread(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdPrestatGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdPrestatDirName(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdPwrite(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdRead(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdReaddir(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdRenumber(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdSeek(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdSync(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdTell(const v8::FunctionCallbackInfo<v8::Value>& args); + static void FdWrite(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathCreateDirectory( + const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathFilestatGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathFilestatSetTimes( + const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathLink(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathOpen(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathReadlink(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathRemoveDirectory( + const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathRename(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathSymlink(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PathUnlinkFile(const v8::FunctionCallbackInfo<v8::Value>& args); + static void PollOneoff(const v8::FunctionCallbackInfo<v8::Value>& args); + static void ProcExit(const v8::FunctionCallbackInfo<v8::Value>& args); + static void ProcRaise(const v8::FunctionCallbackInfo<v8::Value>& args); + static void RandomGet(const v8::FunctionCallbackInfo<v8::Value>& args); + static void SchedYield(const v8::FunctionCallbackInfo<v8::Value>& args); + static void SockRecv(const v8::FunctionCallbackInfo<v8::Value>& args); + static void SockSend(const v8::FunctionCallbackInfo<v8::Value>& args); + static void SockShutdown(const v8::FunctionCallbackInfo<v8::Value>& args); + + static void _SetMemory(const v8::FunctionCallbackInfo<v8::Value>& args); + + private: + ~WASI() override; + inline void readUInt8(char* memory, uint8_t* value, uint32_t offset); + inline void readUInt16(char* memory, uint16_t* value, uint32_t offset); + inline void readUInt32(char* memory, uint32_t* value, uint32_t offset); + inline void readUInt64(char* memory, uint64_t* value, uint32_t offset); + inline void writeUInt8(char* memory, uint8_t value, uint32_t offset); + inline void writeUInt16(char* memory, uint16_t value, uint32_t offset); + inline void writeUInt32(char* memory, uint32_t value, uint32_t offset); + inline void writeUInt64(char* memory, uint64_t value, uint32_t offset); + uvwasi_errno_t backingStore(char** store, size_t* byte_length); + uvwasi_t uvw_; + v8::Global<v8::Object> memory_; +}; + + +} // namespace wasi +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_NODE_WASI_H_ |