5
5
#include " node_http_parser.h"
6
6
#include " node_javascript.h"
7
7
#include " node_version.h"
8
+ #include " node_internals.h"
8
9
9
10
#if defined HAVE_PERFCTR
10
11
#include " node_counters.h"
@@ -146,6 +147,8 @@ static uv_async_t dispatch_debug_messages_async;
146
147
static Isolate* node_isolate = nullptr ;
147
148
static v8::Platform* default_platform;
148
149
150
+ bool using_old_buffer = false ;
151
+
149
152
class ArrayBufferAllocator : public ArrayBuffer ::Allocator {
150
153
public:
151
154
// Impose an upper limit to avoid out of memory errors that bring down
@@ -165,23 +168,21 @@ ArrayBufferAllocator ArrayBufferAllocator::the_singleton;
165
168
166
169
167
170
void * ArrayBufferAllocator::Allocate (size_t length) {
168
- if (length > kMaxLength )
171
+ void * data = malloc (length);
172
+ if (data == nullptr )
169
173
return nullptr ;
170
- char * data = new char [length];
171
174
memset (data, 0 , length);
172
175
return data;
173
176
}
174
177
175
178
176
179
void * ArrayBufferAllocator::AllocateUninitialized (size_t length) {
177
- if (length > kMaxLength )
178
- return nullptr ;
179
- return new char [length];
180
+ return malloc (length);
180
181
}
181
182
182
183
183
184
void ArrayBufferAllocator::Free (void * data, size_t length) {
184
- delete[] static_cast < char *> (data);
185
+ free (data);
185
186
}
186
187
187
188
@@ -2844,6 +2845,11 @@ void SetupProcessObject(Environment* env,
2844
2845
// after LoadEnvironment() has run.
2845
2846
}
2846
2847
2848
+ // --use-old_buffer
2849
+ if (using_old_buffer) {
2850
+ READONLY_PROPERTY (process, " useOldBuffer" , True (env->isolate ()));
2851
+ }
2852
+
2847
2853
size_t exec_path_len = 2 * PATH_MAX;
2848
2854
char * exec_path = new char [exec_path_len];
2849
2855
Local<String> exec_path_value;
@@ -3072,6 +3078,7 @@ static void PrintHelp() {
3072
3078
" --trace-deprecation show stack traces on deprecations\n "
3073
3079
" --trace-sync-io show stack trace when use of sync IO\n "
3074
3080
" is detected after the first tick\n "
3081
+ " --use-old-buffer Revert to old Buffer implementation\n "
3075
3082
" --v8-options print v8 command line options\n "
3076
3083
#if defined(NODE_HAVE_I18N_SUPPORT)
3077
3084
" --icu-data-dir=dir set ICU data load path to dir\n "
@@ -3208,6 +3215,9 @@ static void ParseArgs(int* argc,
3208
3215
#endif
3209
3216
} else if (strcmp (arg, " --expose-internals" ) == 0 ||
3210
3217
strcmp (arg, " --expose_internals" ) == 0 ) {
3218
+ } else if (strcmp (arg, " --use-old-buffer" ) == 0 ) {
3219
+ using_old_buffer = true ;
3220
+
3211
3221
// consumed in js
3212
3222
} else {
3213
3223
// V8 option. Pass through as-is.
0 commit comments