Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: src/api.cc

Issue 2133643002: Version 5.1.281.74 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.1
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8-version.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 853bd50f2195a411776c24fef760df3b3931b503..6206074944e882e2333ff517691a9d9730dd53fa 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1141,14 +1141,26 @@ Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate,
v8::Local<Value> data,
v8::Local<Signature> signature,
int length) {
+ return New(
+ isolate, callback, data, signature, length, ConstructorBehavior::kAllow);
+}
+
+Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate,
+ FunctionCallback callback,
+ v8::Local<Value> data,
+ v8::Local<Signature> signature,
+ int length,
+ ConstructorBehavior behavior) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
// Changes to the environment cannot be captured in the snapshot. Expect no
// function templates when the isolate is created for serialization.
DCHECK(!i_isolate->serializer_enabled());
LOG_API(i_isolate, "FunctionTemplate::New");
ENTER_V8(i_isolate);
- return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature,
- length, false);
+ auto tmpl = FunctionTemplateNew(i_isolate, callback, nullptr, data, signature,
+ length, false);
+ if (behavior == ConstructorBehavior::kThrow) tmpl->RemovePrototype();
+ return tmpl;
}
@@ -4437,15 +4449,21 @@ Local<v8::Value> Object::CallAsConstructor(int argc,
MaybeLocal<Function> Function::New(Local<Context> context,
FunctionCallback callback, Local<Value> data,
int length) {
+ return New(context, callback, data, length, ConstructorBehavior::kAllow);
+}
+
+MaybeLocal<Function> Function::New(Local<Context> context,
+ FunctionCallback callback, Local<Value> data,
+ int length, ConstructorBehavior behavior) {
i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate();
LOG_API(isolate, "Function::New");
ENTER_V8(isolate);
- return FunctionTemplateNew(isolate, callback, nullptr, data,
- Local<Signature>(), length, true)
- ->GetFunction(context);
+ auto tmpl = FunctionTemplateNew(isolate, callback, nullptr, data,
+ Local<Signature>(), length, true);
+ if (behavior == ConstructorBehavior::kThrow) tmpl->RemovePrototype();
+ return tmpl->GetFunction(context);
}
-
Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
Local<Value> data, int length) {
return Function::New(v8_isolate->GetCurrentContext(), callback, data, length)
« no previous file with comments | « include/v8-version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698