summaryrefslogtreecommitdiff
path: root/src/node_util.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-25 19:40:24 +0100
committerAnna Henningsen <anna@addaleax.net>2019-03-01 21:58:08 +0100
commitadbe3b837e8a2285238ec0fcba89c20882eb4cdb (patch)
treee04c000251c6202d416effa85cdf505c0b0ed8c2 /src/node_util.cc
parent6a0f4636d9f8e94ebe905f0807edd0f5d9fbdd51 (diff)
downloadandroid-node-v8-adbe3b837e8a2285238ec0fcba89c20882eb4cdb.tar.gz
android-node-v8-adbe3b837e8a2285238ec0fcba89c20882eb4cdb.tar.bz2
android-node-v8-adbe3b837e8a2285238ec0fcba89c20882eb4cdb.zip
test: verify heap buffer allocations occur
Check that small typed arrays, including `Buffer`s (unless allocated by `Buffer.allocUnsafe()`), are indeed heap-allocated. PR-URL: https://github.com/nodejs/node/pull/26301 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_util.cc')
-rw-r--r--src/node_util.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index f2c008c797..6d20f636f0 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -8,6 +8,7 @@ namespace util {
using v8::ALL_PROPERTIES;
using v8::Array;
+using v8::ArrayBufferView;
using v8::Boolean;
using v8::Context;
using v8::Function;
@@ -174,6 +175,11 @@ void WatchdogHasPendingSigint(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(ret);
}
+void ArrayBufferViewHasBuffer(const FunctionCallbackInfo<Value>& args) {
+ CHECK(args[0]->IsArrayBufferView());
+ args.GetReturnValue().Set(args[0].As<ArrayBufferView>()->HasBuffer());
+}
+
void EnqueueMicrotask(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
@@ -254,6 +260,7 @@ void Initialize(Local<Object> target,
env->SetMethodNoSideEffect(target, "watchdogHasPendingSigint",
WatchdogHasPendingSigint);
+ env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer);
env->SetMethod(target, "enqueueMicrotask", EnqueueMicrotask);
env->SetMethod(target, "triggerFatalException", FatalException);
Local<Object> constants = Object::New(env->isolate());