Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Espresso, NodeJS 12.11.1 #58

Open
prepare opened this issue Oct 6, 2019 · 3 comments
Open

Espresso, NodeJS 12.11.1 #58

prepare opened this issue Oct 6, 2019 · 3 comments
Labels

Comments

@prepare
Copy link
Owner

prepare commented Oct 6, 2019

Bridge your C# soul to the power of Javascript (V8 Javascript Engine / NodeJs)

node_v12
EspressoND, Http/2, NodeJS12.11.1

@prepare prepare added the INFO label Oct 6, 2019
@prepare
Copy link
Owner Author

prepare commented Oct 6, 2019

Patches for NodeJS 12.11.1

There are 5 patches,
patches are located here => Espresso\node_patches\node12.11.1_modified

...about line 8

#if defined(LEAK_SANITIZER)
#include <sanitizer/lsan_interface.h>
#endif
//////////////////////////////////
//#espresso ,#1
#include "../src/libespresso/bridge2.h"
void DoEngineSetupCallback(JsEngine* engine, JsContext* jsContext);
void DoEngineClosingCallback(JsEngine* engine,
                             JsContext* jsContext,
                             int exitCode);
//////////////////////////////////
namespace node {

using v8::Context;
using v8::HandleScope;

patch 1: src/node_main_instance.cc


...about line 113

 int NodeMainInstance::Run() {
  Locker locker(isolate_);
  Isolate::Scope isolate_scope(isolate_);
  HandleScope handle_scope(isolate_);

  int exit_code = 0;
  std::unique_ptr<Environment> env = CreateMainEnvironment(&exit_code);

  CHECK_NOT_NULL(env);
  Context::Scope context_scope(env->context());

  if (exit_code == 0) {
    ////////////////////////////////
    //#espresso ,#2
    JsEngine* jsEngine = JsEngine::NewFromExistingIsolate(isolate_);
    v8::Persistent<Context>* pcontext =
        new v8::Persistent<Context>(isolate_, env->context());
    JsContext* jscontext =
        JsContext::NewFromExistingContext(0, jsEngine, pcontext);
    DoEngineSetupCallback(jsEngine, jscontext);
    ////////////////////////////////
    {
      AsyncCallbackScope callback_scope(env.get());
      env->async_hooks()->push_async_ids(1, 0);
      LoadEnvironment(env.get());
      env->async_hooks()->pop_async_id(1);
    }

patch 2: src/node_main_instance.cc


...about line 162

   env->set_trace_sync_io(false);
    exit_code = EmitExit(env.get());
    ////////////////////////////////
    //#espresso ,#3
    DoEngineClosingCallback(jsEngine, jscontext, exit_code);
    ////////////////////////////////
    WaitForInspectorDisconnect(env.get());
  }

patch 3: src/node_main_instance.cc


@prepare
Copy link
Owner Author

prepare commented Oct 6, 2019

... about line about line 725

Module._resolveFilename = function(request, parent, isMain, options) {
  if (NativeModule.canBeRequiredByUsers(request)) {
    return request;
  }
  ////////////////////////////////////////////
  //#espresso, #4
  if (request.endsWith(".espr")) {
      return request;
  }
  ////////////////////////////////////////////
  var paths;

patch4: lib/internal/modules/cjs/loader.js


... about line about line 989

 // Native extension for .node
Module._extensions['.node'] = function(module, filename) {
  if (manifest) {
    const content = fs.readFileSync(filename);
    const moduleURL = pathToFileURL(filename);
    manifest.assertIntegrity(moduleURL, content);
  }
  // Be aware this doesn't use `content`
  return process.dlopen(module, path.toNamespacedPath(filename));
};
//////////////////////////////////
//#espresso, #5 
Module._extensions['.espr'] = function (module, filename) {
    //this make node to callback to our module
    var content = LibEspresso.LoadMainSrcFile();
    module._compile(stripBOM(content), filename);
};
//////////////////////////////////

patch5: lib/internal/modules/cjs/loader.js


@prepare
Copy link
Owner Author

prepare commented Oct 7, 2019

for x86 on Windows
"x86 release nobuild full-icu"

@prepare prepare changed the title Espression, NodeJS 12.11.1 Espresso, NodeJS 12.11.1 Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant