Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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: #2091
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
bnoordhuis authored and ofrobots committed Aug 24, 2015
commit 6aad84c57ece8c9208ac2c59988d4a9434323bbe
2 changes: 2 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@
'NODE_PLATFORM="<(OS)"',
'NODE_V8_OPTIONS="<(node_v8_options)"',
'NODE_WANT_INTERNALS=1',
# Warn when using deprecated V8 APIs.
'V8_DEPRECATION_WARNINGS=1',
],


Expand Down
5 changes: 4 additions & 1 deletion src/debug-agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
39 changes: 4 additions & 35 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,38 +148,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);
Expand Down Expand Up @@ -3725,8 +3693,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();
}
Expand Down Expand Up @@ -3928,7 +3894,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);
}
Expand Down
14 changes: 14 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,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 {
Expand Down