summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2016-04-19 15:31:29 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2016-04-22 23:48:31 +0200
commit7940ecfa0093d1cc5b793f59a5c48b5050211d6b (patch)
treebaf1e5dd64b18d0c29f1b5fef033c443030cd270 /deps
parente84c69310f742c1b2381fa19b155db6f178af7da (diff)
downloadandroid-node-v8-7940ecfa0093d1cc5b793f59a5c48b5050211d6b.tar.gz
android-node-v8-7940ecfa0093d1cc5b793f59a5c48b5050211d6b.tar.bz2
android-node-v8-7940ecfa0093d1cc5b793f59a5c48b5050211d6b.zip
v8: warn in Template::Set() on improper use
The next major release will make it a fatal error to use non-primitive values in function templates and object templates. Print a warning that includes the C and JS stack trace to tell people to upgrade their add-ons. The C stack trace is only printed on platforms that support it (the BSDs, OS X and Linux+glibc.) The warning can be disabled with the new `--nowarn_template_set` flag. Refs: https://github.com/nodejs/node/issues/6216 PR-URL: https://github.com/nodejs/node/pull/6277 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps')
-rw-r--r--deps/v8/src/api.cc11
-rw-r--r--deps/v8/src/flag-definitions.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index 0247d950a7..9b6ae72052 100644
--- a/deps/v8/src/api.cc
+++ b/deps/v8/src/api.cc
@@ -939,6 +939,17 @@ void Template::Set(v8::Local<Name> name, v8::Local<Data> value,
i::Isolate* isolate = templ->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
+ auto value_obj = Utils::OpenHandle(*value);
+ if (i::FLAG_warn_template_set &&
+ value_obj->IsJSReceiver() &&
+ !value_obj->IsTemplateInfo()) {
+ base::OS::PrintError(
+ "(node) v8::%sTemplate::Set() with non-primitive values is deprecated\n"
+ "(node) and will stop working in the next major release.\n",
+ templ->IsFunctionTemplateInfo() ? "Function" : "Object");
+ isolate->PrintStack(stderr, i::Isolate::kPrintStackConcise);
+ base::DumpBacktrace();
+ }
// TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo.
i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name),
Utils::OpenHandle(*value),
diff --git a/deps/v8/src/flag-definitions.h b/deps/v8/src/flag-definitions.h
index ac430ab503..1eb9dd5111 100644
--- a/deps/v8/src/flag-definitions.h
+++ b/deps/v8/src/flag-definitions.h
@@ -172,6 +172,9 @@ struct MaybeBoolFlag {
//
#define FLAG FLAG_FULL
+DEFINE_BOOL(warn_template_set, true,
+ "warn on deprecated v8::Template::Set() use")
+
DEFINE_BOOL(experimental_extras, false,
"enable code compiled in via v8_experimental_extra_library_files")