| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f146f68 commit b1a2d95
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,6 +180,8 @@ | |||
| 180 | 180 | 'NODE_ARCH="<(target_arch)"', | |
| 181 | 181 | 'NODE_PLATFORM="<(OS)"', | |
| 182 | 182 | 'NODE_WANT_INTERNALS=1', | |
| 183 | + # Warn when using deprecated V8 APIs. | ||
| 184 | + 'V8_DEPRECATION_WARNINGS=1', | ||
| 183 | 185 | ], | |
| 184 | 186 | ||
| 185 | 187 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,7 +160,10 @@ void Agent::Stop() { | |||
| 160 | 160 | ||
| 161 | 161 | void Agent::WorkerRun() { | |
| 162 | 162 | static const char* argv[] = { "node", "--debug-agent" }; | |
| 163 | - Isolate* isolate = Isolate::New(); | ||
| 163 | + Isolate::CreateParams params; | ||
| 164 | + ArrayBufferAllocator array_buffer_allocator; | ||
| 165 | + params.array_buffer_allocator = &array_buffer_allocator; | ||
| 166 | + Isolate* isolate = Isolate::New(params); | ||
| 164 | 167 | { | |
| 165 | 168 | Locker locker(isolate); | |
| 166 | 169 | Isolate::Scope isolate_scope(isolate); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -152,38 +152,6 @@ static uv_async_t dispatch_debug_messages_async; | |||
| 152 | 152 | static Isolate* node_isolate = nullptr; | |
| 153 | 153 | static v8::Platform* default_platform; | |
| 154 | 154 | ||
| 155 | - class ArrayBufferAllocator : public ArrayBuffer::Allocator { | ||
| 156 | - public: | ||
| 157 | - // Impose an upper limit to avoid out of memory errors that bring down | ||
| 158 | - // the process. | ||
| 159 | - static const size_t kMaxLength = 0x3fffffff; | ||
| 160 | - static ArrayBufferAllocator the_singleton; | ||
| 161 | - virtual ~ArrayBufferAllocator() = default; | ||
| 162 | - virtual void* Allocate(size_t length) override; | ||
| 163 | - virtual void* AllocateUninitialized(size_t length) override; | ||
| 164 | - virtual void Free(void* data, size_t length) override; | ||
| 165 | - private: | ||
| 166 | - ArrayBufferAllocator() = default; | ||
| 167 | - DISALLOW_COPY_AND_ASSIGN(ArrayBufferAllocator); | ||
| 168 | - }; | ||
| 169 | - | ||
| 170 | - ArrayBufferAllocator ArrayBufferAllocator::the_singleton; | ||
| 171 | - | ||
| 172 | - | ||
| 173 | - void* ArrayBufferAllocator::Allocate(size_t length) { | ||
| 174 | - return calloc(length, 1); | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - | ||
| 178 | - void* ArrayBufferAllocator::AllocateUninitialized(size_t length) { | ||
| 179 | - return malloc(length); | ||
| 180 | - } | ||
| 181 | - | ||
| 182 | - | ||
| 183 | - void ArrayBufferAllocator::Free(void* data, size_t length) { | ||
| 184 | - free(data); | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | 155 | ||
| 188 | 156 | static void CheckImmediate(uv_check_t* handle) { | |
| 189 | 157 | Environment* env = Environment::from_immediate_check_handle(handle); | |
@@ -3711,8 +3679,6 @@ void Init(int* argc, | |||
| 3711 | 3679 | V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1); | |
| 3712 | 3680 | } | |
| 3713 | 3681 | ||
| 3714 | - V8::SetArrayBufferAllocator(&ArrayBufferAllocator::the_singleton); | ||
| 3715 | - | ||
| 3716 | 3682 | if (!use_debug_agent) { | |
| 3717 | 3683 | RegisterDebugSignalHandler(); | |
| 3718 | 3684 | } | |
@@ -3914,7 +3880,10 @@ Environment* CreateEnvironment(Isolate* isolate, | |||
| 3914 | 3880 | // node instance. | |
| 3915 | 3881 | static void StartNodeInstance(void* arg) { | |
| 3916 | 3882 | NodeInstanceData* instance_data = static_cast<NodeInstanceData*>(arg); | |
| 3917 | - Isolate* isolate = Isolate::New(); | ||
| 3883 | + Isolate::CreateParams params; | ||
| 3884 | + ArrayBufferAllocator array_buffer_allocator; | ||
| 3885 | + params.array_buffer_allocator = &array_buffer_allocator; | ||
| 3886 | + Isolate* isolate = Isolate::New(params); | ||
| 3918 | 3887 | if (track_heap_objects) { | |
| 3919 | 3888 | isolate->GetHeapProfiler()->StartTrackingHeapObjects(true); | |
| 3920 | 3889 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -226,6 +226,20 @@ NODE_DEPRECATED("Use ThrowUVException(isolate)", | |||
| 226 | 226 | return ThrowUVException(isolate, errorno, syscall, message, path); | |
| 227 | 227 | }) | |
| 228 | 228 | ||
| 229 | + struct ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | ||
| 230 | + virtual void* Allocate(size_t size) { | ||
| 231 | + return calloc(size, 1); | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + virtual void* AllocateUninitialized(size_t size) { | ||
| 235 | + return malloc(size); | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + virtual void Free(void* data, size_t) { | ||
| 239 | + free(data); | ||
| 240 | + } | ||
| 241 | + }; | ||
| 242 | + | ||
| 229 | 243 | enum NodeInstanceType { MAIN, WORKER }; | |
| 230 | 244 | ||
| 231 | 245 | class NodeInstanceData { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments