summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-07-01 23:47:37 +0200
committerRod Vagg <rod@vagg.org>2015-09-06 21:38:05 +1000
commit9a03ae63566f761539bd3a18f0b08c34c4ba0e13 (patch)
tree94782ca8be6adaed03a1f545b113cab2e2fd180b /src
parentd571680638dc45715994ec54d6bf5aa28e311eb8 (diff)
downloadnode-new-9a03ae63566f761539bd3a18f0b08c34c4ba0e13.tar.gz
src: enable v8 deprecation warnings and fix them
Turn on V8 API deprecation warnings. Fix up the no-arg Isolate::New() calls in src/node.cc and src/debug-agent.cc. PR-URL: https://github.com/nodejs/io.js/pull/2091 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/debug-agent.cc5
-rw-r--r--src/node.cc39
-rw-r--r--src/node_internals.h14
3 files changed, 22 insertions, 36 deletions
diff --git a/src/debug-agent.cc b/src/debug-agent.cc
index 39d8bfe9e5..b99446f69c 100644
--- a/src/debug-agent.cc
+++ b/src/debug-agent.cc
@@ -160,7 +160,10 @@ void Agent::Stop() {
void Agent::WorkerRun() {
static const char* argv[] = { "node", "--debug-agent" };
- Isolate* isolate = Isolate::New();
+ Isolate::CreateParams params;
+ ArrayBufferAllocator array_buffer_allocator;
+ params.array_buffer_allocator = &array_buffer_allocator;
+ Isolate* isolate = Isolate::New(params);
{
Locker locker(isolate);
Isolate::Scope isolate_scope(isolate);
diff --git a/src/node.cc b/src/node.cc
index d62ed28355..f460c8d161 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -152,38 +152,6 @@ static uv_async_t dispatch_debug_messages_async;
static Isolate* node_isolate = nullptr;
static v8::Platform* default_platform;
-class ArrayBufferAllocator : public ArrayBuffer::Allocator {
- public:
- // Impose an upper limit to avoid out of memory errors that bring down
- // the process.
- static const size_t kMaxLength = 0x3fffffff;
- static ArrayBufferAllocator the_singleton;
- virtual ~ArrayBufferAllocator() = default;
- virtual void* Allocate(size_t length) override;
- virtual void* AllocateUninitialized(size_t length) override;
- virtual void Free(void* data, size_t length) override;
- private:
- ArrayBufferAllocator() = default;
- DISALLOW_COPY_AND_ASSIGN(ArrayBufferAllocator);
-};
-
-ArrayBufferAllocator ArrayBufferAllocator::the_singleton;
-
-
-void* ArrayBufferAllocator::Allocate(size_t length) {
- return calloc(length, 1);
-}
-
-
-void* ArrayBufferAllocator::AllocateUninitialized(size_t length) {
- return malloc(length);
-}
-
-
-void ArrayBufferAllocator::Free(void* data, size_t length) {
- free(data);
-}
-
static void CheckImmediate(uv_check_t* handle) {
Environment* env = Environment::from_immediate_check_handle(handle);
@@ -3711,8 +3679,6 @@ void Init(int* argc,
V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1);
}
- V8::SetArrayBufferAllocator(&ArrayBufferAllocator::the_singleton);
-
if (!use_debug_agent) {
RegisterDebugSignalHandler();
}
@@ -3914,7 +3880,10 @@ Environment* CreateEnvironment(Isolate* isolate,
// node instance.
static void StartNodeInstance(void* arg) {
NodeInstanceData* instance_data = static_cast<NodeInstanceData*>(arg);
- Isolate* isolate = Isolate::New();
+ Isolate::CreateParams params;
+ ArrayBufferAllocator array_buffer_allocator;
+ params.array_buffer_allocator = &array_buffer_allocator;
+ Isolate* isolate = Isolate::New(params);
if (track_heap_objects) {
isolate->GetHeapProfiler()->StartTrackingHeapObjects(true);
}
diff --git a/src/node_internals.h b/src/node_internals.h
index aa198666b6..5ea4e0b9bd 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -226,6 +226,20 @@ NODE_DEPRECATED("Use ThrowUVException(isolate)",
return ThrowUVException(isolate, errorno, syscall, message, path);
})
+struct ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+ virtual void* Allocate(size_t size) {
+ return calloc(size, 1);
+ }
+
+ virtual void* AllocateUninitialized(size_t size) {
+ return malloc(size);
+ }
+
+ virtual void Free(void* data, size_t) {
+ free(data);
+ }
+};
+
enum NodeInstanceType { MAIN, WORKER };
class NodeInstanceData {