From bd765d61d7425d82e80bdf2f4f27c0424221837b Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 3 Nov 2018 14:26:32 +0800 Subject: src: compile native modules and their code cache in C++ This patch refactors out a part of NativeModule.prototype.compile (in JS land) into a C++ NativeModule class, this enables a couple of possibilities: 1. By moving the code to the C++ land, we have more opportunity to specialize the compilation process of the native modules (e.g. compilation options, code cache) that is orthogonal to how user land modules are compiled 2. We can reuse the code to compile bootstrappers and context fixers and enable them to be compiled with the code cache later, since they are not loaded by NativeModule in the JS land their caching must be done in C++. 3. Since there is no need to pass the static data to JS for compilation anymore, this enables us to use (std::map) in the generated node_code_cache.cc and node_javascript.cc later, and scope every actual access to the source of native modules to a std::map lookup instead of a lookup on a v8::Object in dictionary mode. This patch also refactor the code cache generator and tests a bit and trace the `withCodeCache` and `withoutCodeCache` in a Set instead of an Array, and makes sure that all the cachable builtins are tested. PR-URL: https://github.com/nodejs/node/pull/24221 Reviewed-By: Refael Ackermann Reviewed-By: Anna Henningsen --- src/node_internals.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/node_internals.h') diff --git a/src/node_internals.h b/src/node_internals.h index b026a96843..b6cd628086 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -118,6 +118,7 @@ struct sockaddr; V(js_stream) \ V(messaging) \ V(module_wrap) \ + V(native_module) \ V(options) \ V(os) \ V(performance) \ -- cgit v1.2.3