| Index: src/accessors.cc
|
| diff --git a/src/accessors.cc b/src/accessors.cc
|
| index 73665fa036a081fcea2fa192100ba2be6688a7ed..74238eb168e832952a608d24f2da66fffcea172d 100644
|
| --- a/src/accessors.cc
|
| +++ b/src/accessors.cc
|
| @@ -664,10 +664,29 @@
|
| // Accessors::FunctionPrototype
|
| //
|
|
|
| +static Handle<Object> GetFunctionPrototype(Isolate* isolate,
|
| + Handle<JSFunction> function) {
|
| + if (!function->has_prototype()) {
|
| + Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function);
|
| + JSFunction::SetPrototype(function, proto);
|
| + }
|
| + return Handle<Object>(function->prototype(), isolate);
|
| +}
|
| +
|
| +
|
| +MUST_USE_RESULT static MaybeHandle<Object> SetFunctionPrototype(
|
| + Isolate* isolate, Handle<JSFunction> function, Handle<Object> value) {
|
| + JSFunction::SetPrototype(function, value);
|
| + DCHECK(function->prototype() == *value);
|
| + return function;
|
| +}
|
| +
|
| +
|
| MaybeHandle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function,
|
| Handle<Object> prototype) {
|
| - JSFunction::SetPrototype(function, prototype);
|
| - return function;
|
| + DCHECK(function->IsConstructor());
|
| + Isolate* isolate = function->GetIsolate();
|
| + return SetFunctionPrototype(isolate, function, prototype);
|
| }
|
|
|
|
|
| @@ -678,7 +697,7 @@
|
| HandleScope scope(isolate);
|
| Handle<JSFunction> function =
|
| Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
|
| - Handle<Object> result = JSFunction::GetPrototype(isolate, function);
|
| + Handle<Object> result = GetFunctionPrototype(isolate, function);
|
| info.GetReturnValue().Set(Utils::ToLocal(result));
|
| }
|
|
|
| @@ -692,7 +711,9 @@
|
| Handle<Object> value = Utils::OpenHandle(*val);
|
| Handle<JSFunction> object =
|
| Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
|
| - JSFunction::SetPrototype(object, value);
|
| + if (SetFunctionPrototype(isolate, object, value).is_null()) {
|
| + isolate->OptionalRescheduleException(false);
|
| + }
|
| }
|
|
|
|
|
|
|