Pieter De Baets e541d9b108 Define wrapper versions of all JSC methods
Reviewed By: bnham

Differential Revision: D4197369

fbshipit-source-id: 53869fe1b56010c8a5330025d06ef557369e4957
2016-11-22 06:13:33 -08:00

50 lines
1.2 KiB
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#include "JSCMemory.h"
#ifdef WITH_FB_MEMORY_PROFILING
#include <stdio.h>
#include <string.h>
#include <JavaScriptCore/API/JSProfilerPrivate.h>
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
using namespace facebook::react;
static JSValueRef nativeCaptureHeap(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception) {
if (argumentCount < 1) {
if (exception) {
*exception = Value::makeError(
ctx,
"nativeCaptureHeap requires the path to save the capture");
}
return Value::makeUndefined(ctx);
}
auto outputFilename = String::adopt(
ctx, JSValueToStringCopy(ctx, arguments[0], exception));
JSCaptureHeap(ctx, outputFilename.str().c_str(), exception);
return Value::makeUndefined(ctx);
}
#endif // WITH_FB_MEMORY_PROFILING
namespace facebook {
namespace react {
void addNativeMemoryHooks(JSGlobalContextRef ctx) {
#ifdef WITH_FB_MEMORY_PROFILING
installGlobalFunction(ctx, "nativeCaptureHeap", nativeCaptureHeap);
#endif // WITH_FB_MEMORY_PROFILING
}
} }