Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v8: warn in Template::Set() on improper use #6277

Merged
merged 1 commit into from
Apr 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to leave a to-do here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a TODO but what should it say?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps TODO: Throw Error instead of warning in v7.0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's not going to throw; newer V8 versions replace it with a CHECK that aborts when it fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. This is the change which you initially had in #6228, right? This? Then, we may not need a TODO I think. Eventually v8 upgrades will take care of this.

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),
Expand Down
3 changes: 3 additions & 0 deletions deps/v8/src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down