@ohos-ports/lmdb 2.5.3 → 2.8.5-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +72 -28
- package/SECURITY.md +12 -12
- package/bin/download-prebuilds.js +15 -0
- package/binding.gyp +115 -111
- package/build/Release/lmdb.node +0 -0
- package/caching.js +212 -156
- package/dependencies/lmdb/libraries/liblmdb/COPYRIGHT +20 -20
- package/dependencies/lmdb/libraries/liblmdb/Doxyfile +1631 -1631
- package/dependencies/lmdb/libraries/liblmdb/LICENSE +47 -47
- package/dependencies/lmdb/libraries/liblmdb/Makefile +136 -136
- package/dependencies/lmdb/libraries/liblmdb/chacha8.c +183 -183
- package/dependencies/lmdb/libraries/liblmdb/chacha8.h +14 -14
- package/dependencies/lmdb/libraries/liblmdb/crypto.c +121 -121
- package/dependencies/lmdb/libraries/liblmdb/intro.doc +192 -192
- package/dependencies/lmdb/libraries/liblmdb/lmdb.h +28 -3
- package/dependencies/lmdb/libraries/liblmdb/mdb.c +157 -31
- package/dependencies/lmdb/libraries/liblmdb/mdb_copy.1 +74 -74
- package/dependencies/lmdb/libraries/liblmdb/mdb_copy.c +106 -106
- package/dependencies/lmdb/libraries/liblmdb/mdb_drop.1 +53 -53
- package/dependencies/lmdb/libraries/liblmdb/mdb_drop.c +154 -154
- package/dependencies/lmdb/libraries/liblmdb/mdb_dump.1 +94 -94
- package/dependencies/lmdb/libraries/liblmdb/mdb_dump.c +333 -333
- package/dependencies/lmdb/libraries/liblmdb/mdb_load.1 +97 -97
- package/dependencies/lmdb/libraries/liblmdb/mdb_load.c +530 -530
- package/dependencies/lmdb/libraries/liblmdb/mdb_stat.1 +83 -83
- package/dependencies/lmdb/libraries/liblmdb/mdb_stat.c +276 -276
- package/dependencies/lmdb/libraries/liblmdb/midl-sparse.c +452 -0
- package/dependencies/lmdb/libraries/liblmdb/midl.c +452 -452
- package/dependencies/lmdb/libraries/liblmdb/midl.h +208 -208
- package/dependencies/lmdb/libraries/liblmdb/module.c +101 -101
- package/dependencies/lmdb/libraries/liblmdb/module.h +16 -16
- package/dependencies/lmdb/libraries/liblmdb/mtest.c +178 -178
- package/dependencies/lmdb/libraries/liblmdb/mtest2.c +124 -124
- package/dependencies/lmdb/libraries/liblmdb/mtest3.c +133 -133
- package/dependencies/lmdb/libraries/liblmdb/mtest4.c +168 -168
- package/dependencies/lmdb/libraries/liblmdb/mtest5.c +135 -135
- package/dependencies/lmdb/libraries/liblmdb/mtest6.c +141 -141
- package/dependencies/lmdb/libraries/liblmdb/mtest_enc.c +190 -190
- package/dependencies/lmdb/libraries/liblmdb/mtest_enc2.c +189 -189
- package/dependencies/lmdb/libraries/liblmdb/mtest_remap.c +177 -177
- package/dependencies/lmdb/libraries/liblmdb/sample-bdb.txt +73 -73
- package/dependencies/lmdb/libraries/liblmdb/sample-mdb.txt +62 -62
- package/dependencies/lmdb/libraries/liblmdb/tooltag +27 -27
- package/dependencies/lmdb-data-v1/libraries/liblmdb/CHANGES +266 -0
- package/dependencies/lmdb-data-v1/libraries/liblmdb/COPYRIGHT +20 -20
- package/dependencies/lmdb-data-v1/libraries/liblmdb/Doxyfile +1631 -1631
- package/dependencies/lmdb-data-v1/libraries/liblmdb/LICENSE +47 -47
- package/dependencies/lmdb-data-v1/libraries/liblmdb/intro.doc +192 -192
- package/dependencies/lmdb-data-v1/libraries/liblmdb/lmdb.h +1608 -1653
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb.c +10320 -11359
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_copy.1 +55 -61
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_copy.c +82 -84
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_dump.1 +75 -81
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_dump.c +319 -319
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_load.1 +84 -84
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_load.c +496 -492
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_stat.1 +64 -70
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_stat.c +263 -264
- package/dependencies/lmdb-data-v1/libraries/liblmdb/midl.c +359 -421
- package/dependencies/lmdb-data-v1/libraries/liblmdb/midl.h +186 -200
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest.c +177 -177
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest2.c +124 -124
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest3.c +133 -133
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest4.c +168 -168
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest5.c +135 -135
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mtest6.c +141 -141
- package/dependencies/lmdb-data-v1/libraries/liblmdb/sample-bdb.txt +73 -73
- package/dependencies/lmdb-data-v1/libraries/liblmdb/sample-mdb.txt +62 -62
- package/dependencies/lmdb-data-v1/libraries/liblmdb/tooltag +22 -27
- package/dependencies/lz4/LICENSE +11 -11
- package/dependencies/lz4/lib/LICENSE +24 -24
- package/dependencies/lz4/lib/Makefile +225 -0
- package/dependencies/lz4/lib/README.md +169 -137
- package/dependencies/lz4/lib/dll/example/Makefile +63 -0
- package/dependencies/lz4/lib/dll/example/README.md +69 -69
- package/dependencies/lz4/lib/dll/liblz4.def +62 -62
- package/dependencies/lz4/lib/liblz4-dll.rc.in +35 -35
- package/dependencies/lz4/lib/liblz4.pc.in +14 -14
- package/dependencies/lz4/lib/lz4.c +2722 -2495
- package/dependencies/lz4/lib/lz4.h +842 -774
- package/dependencies/lz4/lib/lz4file.c +311 -0
- package/dependencies/lz4/lib/lz4file.h +93 -0
- package/dependencies/lz4/lib/lz4frame.c +2078 -1899
- package/dependencies/lz4/lib/lz4frame.h +692 -623
- package/dependencies/lz4/lib/lz4frame_static.h +47 -47
- package/dependencies/lz4/lib/lz4hc.c +1631 -1615
- package/dependencies/lz4/lib/lz4hc.h +413 -413
- package/dependencies/lz4/lib/xxhash.c +1030 -1030
- package/dependencies/lz4/lib/xxhash.h +328 -328
- package/dependencies/v8/v8-fast-api-calls-v16.h +790 -790
- package/dependencies/v8/v8-fast-api-calls.h +784 -888
- package/dist/index.cjs +1050 -584
- package/dist/index.cjs.map +1 -1
- package/index.d.cts +420 -0
- package/index.d.ts +450 -385
- package/index.js +38 -37
- package/keys.js +116 -102
- package/level.js +26 -26
- package/native.js +8 -5
- package/node-index.js +21 -17
- package/open.js +51 -17
- package/package.json +63 -21
- package/read.js +338 -95
- package/src/compression.cpp +12 -9
- package/src/cursor.cpp +82 -31
- package/src/dbi.cpp +78 -40
- package/src/env.cpp +336 -68
- package/src/lmdb-js.cpp +64 -64
- package/src/lmdb-js.h +83 -49
- package/src/misc.cpp +297 -28
- package/src/ordered-binary.cpp +46 -46
- package/src/txn.cpp +210 -257
- package/src/v8-functions.cpp +170 -166
- package/src/windows.c +34 -34
- package/src/writer.cpp +169 -84
- package/util/RangeIterable.js +112 -17
- package/util/set-optional-deps.cjs +14 -10
- package/util/when.js +8 -8
- package/write.js +145 -121
- package/dependencies/lmdb-data-v1/libraries/liblmdb/Makefile +0 -118
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_drop.1 +0 -40
- package/dependencies/lmdb-data-v1/libraries/liblmdb/mdb_drop.c +0 -135
- package/rollup.config.js +0 -12
package/src/v8-functions.cpp
CHANGED
|
@@ -1,166 +1,170 @@
|
|
|
1
|
-
#include "lmdb-js.h"
|
|
2
|
-
#if ENABLE_V8_API
|
|
3
|
-
#include <string.h>
|
|
4
|
-
#include <stdio.h>
|
|
5
|
-
#include <v8.h>
|
|
6
|
-
#include <node.h>
|
|
7
|
-
|
|
8
|
-
#if NODE_VERSION_AT_LEAST(16,6,0)
|
|
9
|
-
#if NODE_VERSION_AT_LEAST(17,0,0)
|
|
10
|
-
#include "../dependencies/v8/v8-fast-api-calls.h"
|
|
11
|
-
#else
|
|
12
|
-
#include "../dependencies/v8/v8-fast-api-calls-v16.h"
|
|
13
|
-
#endif
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
using namespace v8;
|
|
17
|
-
int32_t getByBinaryFast(Local<v8::Object> instance, double dwPointer, uint32_t keySize) {
|
|
18
|
-
DbiWrap* dw = (DbiWrap*) (size_t) dwPointer;
|
|
19
|
-
return dw->doGetByBinary(keySize);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//class NanWrap : public Nan::ObjectWrap {};
|
|
23
|
-
void getByBinaryV8(const FunctionCallbackInfo<v8::Value>& info) {
|
|
24
|
-
Isolate* isolate = Isolate::GetCurrent();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
info
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
void
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
EXPORT_FAST("
|
|
151
|
-
EXPORT_FAST("
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
EXPORT_FUNCTION("
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
EXPORT_FUNCTION("
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
1
|
+
#include "lmdb-js.h"
|
|
2
|
+
#if ENABLE_V8_API
|
|
3
|
+
#include <string.h>
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <v8.h>
|
|
6
|
+
#include <node.h>
|
|
7
|
+
|
|
8
|
+
#if NODE_VERSION_AT_LEAST(16,6,0)
|
|
9
|
+
#if NODE_VERSION_AT_LEAST(17,0,0)
|
|
10
|
+
#include "../dependencies/v8/v8-fast-api-calls.h"
|
|
11
|
+
#else
|
|
12
|
+
#include "../dependencies/v8/v8-fast-api-calls-v16.h"
|
|
13
|
+
#endif
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
using namespace v8;
|
|
17
|
+
int32_t getByBinaryFast(Local<v8::Object> instance, double dwPointer, uint32_t keySize, uint32_t ifNotTxnId, int64_t txnAddress) {
|
|
18
|
+
DbiWrap* dw = (DbiWrap*) (size_t) dwPointer;
|
|
19
|
+
return dw->doGetByBinary(keySize, ifNotTxnId, txnAddress);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//class NanWrap : public Nan::ObjectWrap {};
|
|
23
|
+
void getByBinaryV8(const FunctionCallbackInfo<v8::Value>& info) {
|
|
24
|
+
Isolate* isolate = Isolate::GetCurrent();
|
|
25
|
+
auto context = isolate->GetCurrentContext();
|
|
26
|
+
DbiWrap* dw = (DbiWrap*) (size_t) info[0]->NumberValue(context).FromJust();
|
|
27
|
+
info.GetReturnValue().Set(v8::Number::New(isolate, dw->doGetByBinary(
|
|
28
|
+
info[1]->Uint32Value(context).FromJust(),
|
|
29
|
+
info[2]->Uint32Value(context).FromJust(),
|
|
30
|
+
info[3]->NumberValue(context).FromJust())));
|
|
31
|
+
}
|
|
32
|
+
int32_t positionFast(Local<v8::Object> instance, double cwPointer, uint32_t flags, uint32_t offset, uint32_t keySize, uint64_t endKeyAddress) {
|
|
33
|
+
CursorWrap* cw = (CursorWrap*) (size_t) cwPointer;
|
|
34
|
+
DbiWrap* dw = cw->dw;
|
|
35
|
+
dw->getFast = true;
|
|
36
|
+
cw->flags = flags;
|
|
37
|
+
return cw->doPosition(offset, keySize, endKeyAddress);
|
|
38
|
+
}
|
|
39
|
+
void positionV8(const FunctionCallbackInfo<v8::Value>& info) {
|
|
40
|
+
Isolate* isolate = Isolate::GetCurrent();
|
|
41
|
+
CursorWrap* cw = (CursorWrap*) (size_t) info[0]->NumberValue(isolate->GetCurrentContext()).FromJust();
|
|
42
|
+
cw->flags = info[1]->Uint32Value(isolate->GetCurrentContext()).FromJust();
|
|
43
|
+
uint32_t offset = info[2]->Uint32Value(isolate->GetCurrentContext()).FromJust();
|
|
44
|
+
uint32_t keySize = info[3]->Uint32Value(isolate->GetCurrentContext()).FromJust();
|
|
45
|
+
uint64_t endKeyAddress = info[4]->IntegerValue(isolate->GetCurrentContext()).FromJust();
|
|
46
|
+
info.GetReturnValue().Set(v8::Number::New(isolate, cw->doPosition(offset, keySize, endKeyAddress)));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
int32_t iterateFast(Local<v8::Object> instance, double cwPointer) {
|
|
50
|
+
CursorWrap* cw = (CursorWrap*) (size_t) cwPointer;
|
|
51
|
+
DbiWrap* dw = cw->dw;
|
|
52
|
+
dw->getFast = true;
|
|
53
|
+
MDB_val key, data;
|
|
54
|
+
int rc = mdb_cursor_get(cw->cursor, &key, &data, cw->iteratingOp);
|
|
55
|
+
return cw->returnEntry(rc, key, data);
|
|
56
|
+
}
|
|
57
|
+
void iterateV8(const FunctionCallbackInfo<v8::Value>& info) {
|
|
58
|
+
Isolate* isolate = Isolate::GetCurrent();
|
|
59
|
+
CursorWrap* cw = (CursorWrap*) (size_t) info[0]->NumberValue(isolate->GetCurrentContext()).FromJust();
|
|
60
|
+
DbiWrap* dw = cw->dw;
|
|
61
|
+
dw->getFast = true;
|
|
62
|
+
MDB_val key, data;
|
|
63
|
+
int rc = mdb_cursor_get(cw->cursor, &key, &data, cw->iteratingOp);
|
|
64
|
+
info.GetReturnValue().Set(v8::Number::New(isolate, cw->returnEntry(rc, key, data)));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
int32_t writeFast(Local<v8::Object> instance, double ewPointer, uint64_t instructionAddress) {
|
|
68
|
+
EnvWrap* ew = (EnvWrap*) (size_t) ewPointer;
|
|
69
|
+
int rc;
|
|
70
|
+
if (instructionAddress)
|
|
71
|
+
rc = WriteWorker::DoWrites(ew->writeTxn->txn, ew, (uint32_t*)instructionAddress, nullptr);
|
|
72
|
+
else {
|
|
73
|
+
pthread_cond_signal(ew->writingCond);
|
|
74
|
+
rc = 0;
|
|
75
|
+
}
|
|
76
|
+
return rc;
|
|
77
|
+
// if (rc && !(rc == MDB_KEYEXIST || rc == MDB_NOTFOUND))
|
|
78
|
+
// options.fallback = true;
|
|
79
|
+
}
|
|
80
|
+
void writeV8(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
|
81
|
+
Isolate* isolate = Isolate::GetCurrent();
|
|
82
|
+
EnvWrap* ew = (EnvWrap*) (size_t) info[0]->NumberValue(isolate->GetCurrentContext()).FromJust();
|
|
83
|
+
uint64_t instructionAddress = info[1]->IntegerValue(isolate->GetCurrentContext()).FromJust();
|
|
84
|
+
int rc;
|
|
85
|
+
if (instructionAddress)
|
|
86
|
+
rc = WriteWorker::DoWrites(ew->writeTxn->txn, ew, (uint32_t*)instructionAddress, nullptr);
|
|
87
|
+
else {
|
|
88
|
+
pthread_cond_signal(ew->writingCond);
|
|
89
|
+
rc = 0;
|
|
90
|
+
}
|
|
91
|
+
info.GetReturnValue().Set(v8::Number::New(isolate, rc));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
void resetTxnFast(Local<v8::Object> instance, double twPointer) {
|
|
95
|
+
TxnWrap* tw = (TxnWrap*) (size_t) twPointer;
|
|
96
|
+
tw->reset();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
void resetTxnV8(const FunctionCallbackInfo<v8::Value>& info) {
|
|
100
|
+
Isolate* isolate = Isolate::GetCurrent();
|
|
101
|
+
TxnWrap* tw = (TxnWrap*) (size_t) info[0]->NumberValue(isolate->GetCurrentContext()).FromJust();
|
|
102
|
+
tw->reset();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void noopFast(Local<v8::Object> instance) {
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void noopV8(const FunctionCallbackInfo<v8::Value>& info) {
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
void clearKeptObjects(const FunctionCallbackInfo<v8::Value>& info) {
|
|
113
|
+
#if NODE_VERSION_AT_LEAST(14,0,0)
|
|
114
|
+
v8::Isolate::GetCurrent()->ClearKeptObjects();
|
|
115
|
+
#endif
|
|
116
|
+
}
|
|
117
|
+
void detachBuffer(const FunctionCallbackInfo<v8::Value>& info) {
|
|
118
|
+
#if NODE_VERSION_AT_LEAST(12,0,0)
|
|
119
|
+
v8::Local<v8::ArrayBuffer> v8Buffer = Local<v8::ArrayBuffer>::Cast(info[0]);
|
|
120
|
+
v8Buffer->Detach();
|
|
121
|
+
#endif
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#endif
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
#define EXPORT_FAST(exportName, slowName, fastName) {\
|
|
128
|
+
auto fast = CFunction::Make(fastName);\
|
|
129
|
+
exports->Set(isolate->GetCurrentContext(), v8::String::NewFromUtf8(isolate, exportName, NewStringType::kInternalized).ToLocalChecked(), FunctionTemplate::New(\
|
|
130
|
+
isolate, slowName, Local<v8::Value>(),\
|
|
131
|
+
Local<Signature>(), 0, ConstructorBehavior::kThrow,\
|
|
132
|
+
SideEffectType::kHasNoSideEffect, &fast)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());\
|
|
133
|
+
}
|
|
134
|
+
#define EXPORT_FUNCTION(exportName, funcName) \
|
|
135
|
+
exports->Set(isolate->GetCurrentContext(), v8::String::NewFromUtf8(isolate, exportName, NewStringType::kInternalized).ToLocalChecked(), FunctionTemplate::New(\
|
|
136
|
+
isolate, funcName, Local<v8::Value>(),\
|
|
137
|
+
Local<Signature>(), 0, ConstructorBehavior::kThrow,\
|
|
138
|
+
SideEffectType::kHasNoSideEffect)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());
|
|
139
|
+
NAPI_FUNCTION(enableDirectV8) {
|
|
140
|
+
ARGS(2)
|
|
141
|
+
#if ENABLE_V8_API
|
|
142
|
+
Isolate* isolate = Isolate::GetCurrent();
|
|
143
|
+
napi_value exportsValue = args[0];
|
|
144
|
+
Local<v8::Object> exports;
|
|
145
|
+
memcpy((void*) &exports, (void*) &exportsValue, sizeof(exportsValue));
|
|
146
|
+
#if NODE_VERSION_AT_LEAST(16,6,1)
|
|
147
|
+
bool useFastApi;
|
|
148
|
+
napi_get_value_bool(env, args[1], &useFastApi);
|
|
149
|
+
if (useFastApi) {
|
|
150
|
+
EXPORT_FAST("getByBinary", getByBinaryV8, getByBinaryFast);
|
|
151
|
+
EXPORT_FAST("position", positionV8, positionFast);
|
|
152
|
+
EXPORT_FAST("iterate", iterateV8, iterateFast);
|
|
153
|
+
EXPORT_FAST("write", writeV8, writeFast);
|
|
154
|
+
EXPORT_FAST("resetTxn", resetTxnV8, resetTxnFast);
|
|
155
|
+
EXPORT_FAST("noop", noopV8, noopFast);
|
|
156
|
+
} else {
|
|
157
|
+
#endif
|
|
158
|
+
EXPORT_FUNCTION("getByBinary", getByBinaryV8);
|
|
159
|
+
EXPORT_FUNCTION("position", positionV8);
|
|
160
|
+
EXPORT_FUNCTION("iterate", iterateV8);
|
|
161
|
+
EXPORT_FUNCTION("write", writeV8);
|
|
162
|
+
EXPORT_FUNCTION("noop", noopV8);
|
|
163
|
+
#if NODE_VERSION_AT_LEAST(16,6,1)
|
|
164
|
+
}
|
|
165
|
+
#endif
|
|
166
|
+
EXPORT_FUNCTION("clearKeptObjects", clearKeptObjects);
|
|
167
|
+
EXPORT_FUNCTION("detachBuffer", detachBuffer);
|
|
168
|
+
#endif
|
|
169
|
+
RETURN_UNDEFINED
|
|
170
|
+
}
|
package/src/windows.c
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
#ifdef _WIN32
|
|
2
|
-
#include <windows.h>
|
|
3
|
-
#include <synchapi.h>
|
|
4
|
-
static int initializeMemoryPriority = 1;
|
|
5
|
-
static MEMORY_PRIORITY_INFORMATION lowMemPriority;
|
|
6
|
-
static MEMORY_PRIORITY_INFORMATION normalMemPriority;
|
|
7
|
-
int lowerMemoryPriority(int priority) {
|
|
8
|
-
if (initializeMemoryPriority) {
|
|
9
|
-
GetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
|
|
10
|
-
// fprintf(stderr, "initialized memory %u setting to %u\n", normalMemPriority.MemoryPriority, priority);
|
|
11
|
-
ZeroMemory(&lowMemPriority, sizeof(lowMemPriority));
|
|
12
|
-
lowMemPriority.MemoryPriority = priority;
|
|
13
|
-
initializeMemoryPriority = 0;
|
|
14
|
-
}
|
|
15
|
-
void* instruction;
|
|
16
|
-
void* pointer;
|
|
17
|
-
WaitOnAddress(instruction, pointer, 8, INFINITE);
|
|
18
|
-
|
|
19
|
-
return SetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &lowMemPriority, sizeof(lowMemPriority));
|
|
20
|
-
}
|
|
21
|
-
int setProcessMemoryPriority(int priority) {
|
|
22
|
-
if (initializeMemoryPriority) {
|
|
23
|
-
GetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
|
|
24
|
-
// fprintf(stderr, "initialized memory %u setting to %u\n", normalMemPriority.MemoryPriority, priority);
|
|
25
|
-
ZeroMemory(&lowMemPriority, sizeof(lowMemPriority));
|
|
26
|
-
lowMemPriority.MemoryPriority = priority;
|
|
27
|
-
initializeMemoryPriority = 0;
|
|
28
|
-
}
|
|
29
|
-
return SetProcessInformation(GetCurrentProcess(), ProcessMemoryPriority, &lowMemPriority, sizeof(lowMemPriority));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
int restoreMemoryPriority() {
|
|
33
|
-
return SetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
|
|
34
|
-
}
|
|
1
|
+
#ifdef _WIN32
|
|
2
|
+
#include <windows.h>
|
|
3
|
+
#include <synchapi.h>
|
|
4
|
+
static int initializeMemoryPriority = 1;
|
|
5
|
+
static MEMORY_PRIORITY_INFORMATION lowMemPriority;
|
|
6
|
+
static MEMORY_PRIORITY_INFORMATION normalMemPriority;
|
|
7
|
+
int lowerMemoryPriority(int priority) {
|
|
8
|
+
if (initializeMemoryPriority) {
|
|
9
|
+
GetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
|
|
10
|
+
// fprintf(stderr, "initialized memory %u setting to %u\n", normalMemPriority.MemoryPriority, priority);
|
|
11
|
+
ZeroMemory(&lowMemPriority, sizeof(lowMemPriority));
|
|
12
|
+
lowMemPriority.MemoryPriority = priority;
|
|
13
|
+
initializeMemoryPriority = 0;
|
|
14
|
+
}
|
|
15
|
+
void* instruction;
|
|
16
|
+
void* pointer;
|
|
17
|
+
WaitOnAddress(instruction, pointer, 8, INFINITE);
|
|
18
|
+
|
|
19
|
+
return SetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &lowMemPriority, sizeof(lowMemPriority));
|
|
20
|
+
}
|
|
21
|
+
int setProcessMemoryPriority(int priority) {
|
|
22
|
+
if (initializeMemoryPriority) {
|
|
23
|
+
GetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
|
|
24
|
+
// fprintf(stderr, "initialized memory %u setting to %u\n", normalMemPriority.MemoryPriority, priority);
|
|
25
|
+
ZeroMemory(&lowMemPriority, sizeof(lowMemPriority));
|
|
26
|
+
lowMemPriority.MemoryPriority = priority;
|
|
27
|
+
initializeMemoryPriority = 0;
|
|
28
|
+
}
|
|
29
|
+
return SetProcessInformation(GetCurrentProcess(), ProcessMemoryPriority, &lowMemPriority, sizeof(lowMemPriority));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
int restoreMemoryPriority() {
|
|
33
|
+
return SetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
|
|
34
|
+
}
|
|
35
35
|
#endif
|