Content-Length: 553673 | pFad | http://github.com/NativeScript/napi-android/commit/3c6c8e28fb079a498ab6b3319dd5d036b1a8343d

18 hermes: add support for napi_adjust_external_memory · NativeScript/napi-android@3c6c8e2 · GitHub
Skip to content

Commit 3c6c8e2

Browse files
committed
hermes: add support for napi_adjust_external_memory
1 parent a3ad92c commit 3c6c8e2

File tree

6 files changed

+42
-31
lines changed

6 files changed

+42
-31
lines changed

Diff for: test-app/app/src/main/assets/app/Infrastructure/Jasmine/jasmine-2.0.1/boot.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ var TerminalReporter = require('../jasmine-reporters/terminal_reporter').Termina
4040
},
4141

4242
it: function(desc, func) {
43-
if (global.__engine === "QuickJS") {
44-
if (func.length > 0) {
45-
return env.it(desc, func);
46-
} else {
47-
return env.it(desc, function(done) {
48-
func();
49-
__ns__setTimeout(() => {
50-
done();
51-
}, 1)
52-
53-
})
54-
}
55-
} else {
43+
// if (global.__engine === "QuickJS") {
44+
// if (func.length > 0) {
45+
// return env.it(desc, func);
46+
// } else {
47+
// return env.it(desc, function(done) {
48+
// func();
49+
// __ns__setTimeout(() => {
50+
// done();
51+
// }, 1)
52+
//
53+
// })
54+
// }
55+
// } else {
5656
return env.it(desc, func);
57-
}
57+
// }
5858
},
5959

6060
xit: function(desc, func) {

Diff for: test-app/runtime/src/main/cpp/napi/hermes/jsr.cpp

+28-17
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,33 @@
22
#include "js_runtime.h"
33

44
using namespace facebook::jsi;
5-
std::unordered_map<napi_env, JSR*> JSR::env_to_jsr_cache;
5+
std::unordered_map<napi_env, JSR *> JSR::env_to_jsr_cache;
66

77
typedef struct napi_runtime__ {
8-
JSR* hermes;
8+
JSR *hermes;
99
} napi_runtime__;
1010

1111
JSR::JSR() {
1212
hermes::vm::RuntimeConfig config =
13-
hermes::vm::RuntimeConfig::Builder().withMicrotaskQueue(true).withES6Class(true).withES6Promise(true).withArrayBuffer(true).withEnableEval(true).build();
13+
hermes::vm::RuntimeConfig::Builder().withMicrotaskQueue(true).withES6Class(
14+
true).withES6Promise(true).withArrayBuffer(true).withEnableEval(true).build();
1415
threadSafeRuntime = facebook::hermes::makeThreadSafeHermesRuntime(config);
1516

16-
facebook::jsi::Function abc = facebook::jsi::Function::createFromHostFunction(threadSafeRuntime->getUnsafeRuntime(), facebook::jsi::PropNameID::forAscii(threadSafeRuntime->getUnsafeRuntime(), "directFunction"), 0, [](Runtime& rt, const Value& thisVal, const Value* args, size_t count) -> Value {
17-
return Value::undefined();
18-
});
17+
facebook::jsi::Function abc = facebook::jsi::Function::createFromHostFunction(
18+
threadSafeRuntime->getUnsafeRuntime(),
19+
facebook::jsi::PropNameID::forAscii(threadSafeRuntime->getUnsafeRuntime(),
20+
"directFunction"), 0,
21+
[](Runtime &rt, const Value &thisVal, const Value *args, size_t count) -> Value {
22+
return Value::undefined();
23+
});
1924

20-
threadSafeRuntime->getUnsafeRuntime().global().setProperty(threadSafeRuntime->getUnsafeRuntime(), "directFunction", abc);
25+
threadSafeRuntime->getUnsafeRuntime().global().setProperty(
26+
threadSafeRuntime->getUnsafeRuntime(), "directFunction", abc);
2127

22-
rt = (facebook::hermes::HermesRuntime *)&threadSafeRuntime->getUnsafeRuntime();
28+
rt = (facebook::hermes::HermesRuntime *) &threadSafeRuntime->getUnsafeRuntime();
2329
}
2430

25-
napi_status js_create_runtime(napi_runtime* runtime) {
31+
napi_status js_create_runtime(napi_runtime *runtime) {
2632
if (runtime == nullptr) return napi_invalid_arg;
2733
*runtime = new napi_runtime__();
2834
(*runtime)->hermes = new JSR();
@@ -49,19 +55,21 @@ napi_status js_unlock_env(napi_env env) {
4955

5056
return napi_ok;
5157
}
52-
napi_status js_create_napi_env(napi_env* env, napi_runtime runtime) {
58+
59+
napi_status js_create_napi_env(napi_env *env, napi_runtime runtime) {
5360
if (env == nullptr) return napi_invalid_arg;
54-
runtime->hermes->rt->createNapiEnv( env);
61+
runtime->hermes->rt->createNapiEnv(env);
5562
JSR::env_to_jsr_cache.insert(std::make_pair(*env, runtime->hermes));
5663
return napi_ok;
5764
}
5865

59-
napi_status js_set_runtime_flags(const char* flags) {
66+
napi_status js_set_runtime_flags(const char *flags) {
6067
return napi_ok;
6168
}
6269

6370
napi_status js_free_napi_env(napi_env env) {
64-
return napi_ok;
71+
JSR::env_to_jsr_cache.erase(env);
72+
return napi_ok;
6573
}
6674

6775
napi_status js_free_runtime(napi_runtime runtime) {
@@ -90,20 +98,23 @@ napi_status js_get_engine_ptr(napi_env env, int64_t *engine_ptr) {
9098
return napi_ok;
9199
}
92100

93-
napi_status js_adjust_external_memory(napi_env env, int64_t changeInBytes, int64_t* externalMemory) {
101+
napi_status
102+
js_adjust_external_memory(napi_env env, int64_t changeInBytes, int64_t *externalMemory) {
103+
napi_adjust_external_memory(env, changeInBytes, externalMemory);
94104
return napi_ok;
95105
}
96106

97107
napi_status js_cache_script(napi_env env, const char *source, const char *file) {
98108
return napi_ok;
99109
}
100-
napi_status js_run_cached_script(napi_env env, const char * file, napi_value script, void* cache, napi_value *result) {
110+
111+
napi_status js_run_cached_script(napi_env env, const char *file, napi_value script, void *cache,
112+
napi_value *result) {
101113
return napi_ok;
102114
}
103115

104-
napi_status js_get_runtime_version(napi_env env, napi_value* version) {
116+
napi_status js_get_runtime_version(napi_env env, napi_value *version) {
105117
napi_create_string_utf8(env, "Hermes", NAPI_AUTO_LENGTH, version);
106-
107118
return napi_ok;
108119
}
109120

-1.14 KB
Binary file not shown.
-520 Bytes
Binary file not shown.
-584 Bytes
Binary file not shown.
-1.22 KB
Binary file not shown.

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/napi-android/commit/3c6c8e28fb079a498ab6b3319dd5d036b1a8343d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy