diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..638571ad --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**", + "/usr/local/include/node" + ], + "defines": [], + "macFrameworkPath": [ + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "macos-clang-arm64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/libagentcore.dylib b/libagentcore.dylib new file mode 100755 index 00000000..4aaed889 Binary files /dev/null and b/libagentcore.dylib differ diff --git a/omr-agentcore b/omr-agentcore index ff3dcc99..69e4dd03 160000 --- a/omr-agentcore +++ b/omr-agentcore @@ -1 +1 @@ -Subproject commit ff3dcc99c75ca1eedc7233ca5be2db2aaca01964 +Subproject commit 69e4dd031bc6313afb2af24935f00ddcfcc9afe4 diff --git a/package.json b/package.json index d7c5c817..820bab58 100644 --- a/package.json +++ b/package.json @@ -2,16 +2,16 @@ "name": "appmetrics", "version": "5.1.1", "engines": { - "node": ">=6" + "node": ">=14" }, "description": "Node Application Metrics", "dependencies": { - "nan": "2.x", - "node-gyp": "5.x", - "tar": "4.x", - "semver": "^5.3.0", - "jszip": "2.5.x", - "ibmapm-embed": ">=19.9.0" + "ibmapm-embed": ">=19.9.0", + "jszip": "^3.10.1", + "nan": "^2.20.0", + "node-gyp": "^10.2.0", + "semver": "^7.6.3", + "tar": "^7.4.3" }, "devDependencies": { "codecov": "^3.1.0", diff --git a/src/appmetrics.cpp b/src/appmetrics.cpp index 74a65789..97162167 100644 --- a/src/appmetrics.cpp +++ b/src/appmetrics.cpp @@ -421,7 +421,7 @@ static void emitMessage(uv_async_t *handle, int status) { argv[0] = Nan::New(source).ToLocalChecked(); argv[1] = buffer; - listener->callback->Call(argc, argv); + Nan::Call(*listener->callback, argc, argv); if (try_catch.HasCaught()) { Nan::FatalException(try_catch); } diff --git a/src/objecttracker.cpp b/src/objecttracker.cpp index b42d651e..4ed517f5 100644 --- a/src/objecttracker.cpp +++ b/src/objecttracker.cpp @@ -23,15 +23,17 @@ #include "nan.h" using namespace v8; -//Only perform object tracking on node v0.11 + +// Only perform object tracking on node v0.11 + #if NODE_VERSION_AT_LEAST(0, 11, 0) /* Take a heap snapshot and convert it into a histogram giving the counts and sizes * of every type of object on the heap. */ -NAN_METHOD(getObjectHistogram) { +NAN_METHOD(getObjectHistogram) +{ - Isolate *isolate = info.GetIsolate(); - if (isolate == NULL) { + Isolate *isolate = info.GetIsolate(); + if (isolate == NULL) + { return; } @@ -39,7 +41,7 @@ NAN_METHOD(getObjectHistogram) { Local currentContext = isolate->GetCurrentContext(); #if NODE_VERSION_AT_LEAST(4, 0, 0) // > v4.00+ - // Title field removed in Node 4.x + // Title field removed in Node 4.x #else Local snapshotName = String::NewFromUtf8(isolate, "snapshot"); #endif @@ -48,12 +50,12 @@ NAN_METHOD(getObjectHistogram) { * It's arguments changed so the latest versions don't need a title param. */ #if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+ - const HeapSnapshot* snapshot = heapProfiler->TakeHeapSnapshot( + const HeapSnapshot *snapshot = heapProfiler->TakeHeapSnapshot( #else - const HeapSnapshot* snapshot = heapProfiler->TakeSnapshot(snapshotName); + const HeapSnapshot *snapshot = heapProfiler->TakeSnapshot(snapshotName); #endif #if NODE_VERSION_AT_LEAST(4, 0, 0) // > v4.0+ - // Title field removed in Node 4.x + // Title field removed in Node 4.x #else snapshotName #endif @@ -83,12 +85,14 @@ NAN_METHOD(getObjectHistogram) { #endif /* Walk every node by index (not id) */ - for(int i = 0; i < snapshot->GetNodesCount(); i++ ) { + for (int i = 0; i < snapshot->GetNodesCount(); i++) + { - const HeapGraphNode* node = snapshot->GetNode(i); + const HeapGraphNode *node = snapshot->GetNode(i); Local name; - switch( node->GetType() ) { + switch (node->GetType()) + { case HeapGraphNode::kObject: name = node->GetName(); break; @@ -107,7 +111,8 @@ NAN_METHOD(getObjectHistogram) { int64_t ncount = 0; int64_t nsize = 0; - if( !(tupleval->IsNull() || tupleval->IsUndefined()) ) { + if (!(tupleval->IsNull() || tupleval->IsUndefined())) + { tuple = Nan::To(tupleval).ToLocalChecked(); /* Nothing else can access the tuple or histogram objects, @@ -119,8 +124,9 @@ NAN_METHOD(getObjectHistogram) { ncount = count->IntegerValue(Nan::GetCurrentContext()).FromJust(); Local size = Nan::Get(tuple, sizeName).ToLocalChecked(); nsize = size->IntegerValue(Nan::GetCurrentContext()).FromJust(); - - } else { + } + else + { /* Create a new tuple and add it to the histogram. * Number objects are immutable so we have to replace * existing values. There's no need to create initial @@ -128,23 +134,31 @@ NAN_METHOD(getObjectHistogram) { */ tuple = Object::New(isolate); #if NODE_VERSION_AT_LEAST(13, 0, 0) // > v13.0+ - histogram->Set(currentContext, name, tuple); + v8::Maybe result = histogram->Set(currentContext, name, tuple); + if (result.IsNothing()) + { + // Handle the error + } } /* Update the values in the existing (or new) tuple */ Local newcount = Number::New(isolate, ++ncount); tuple->Set(currentContext, countName, newcount); - Local newsize = Number::New(isolate, nsize+node->GetShallowSize()); - tuple->Set(currentContext,sizeName, newsize); + Local newsize = Number::New(isolate, nsize + node->GetShallowSize()); + tuple->Set(currentContext, sizeName, newsize); #else - histogram->Set(currentContext, name, tuple); + v8::Maybe result = histogram->Set(currentContext, name, tuple); + if (result.IsNothing()) + { + // Handle the error + } } /* Update the values in the existing (or new) tuple */ Local newcount = Number::New(isolate, ++ncount); tuple->Set(currentContext, countName, newcount); - Local newsize = Number::New(isolate, nsize+node->GetShallowSize()); - tuple->Set(currentContext,sizeName, newsize); + Local newsize = Number::New(isolate, nsize + node->GetShallowSize()); + tuple->Set(currentContext, sizeName, newsize); #endif } @@ -152,6 +166,5 @@ NAN_METHOD(getObjectHistogram) { heapProfiler->DeleteAllHeapSnapshots(); info.GetReturnValue().Set(histogram); - } #endif \ No newline at end of file