Chromium Code Reviews| Index: src/accessors.cc |
| diff --git a/src/accessors.cc b/src/accessors.cc |
| index 052108a9b065feba47aa9ae907d55a9f33d092ab..25bb5074cdc76af47f476f7fe06ee8a57602aea7 100644 |
| --- a/src/accessors.cc |
| +++ b/src/accessors.cc |
| @@ -1131,12 +1131,46 @@ void Accessors::FunctionNameGetter( |
| } |
| +MUST_USE_RESULT static MaybeHandle<Object> SetFunctionName( |
| + Isolate* isolate, Handle<JSFunction> function, Handle<Object> value) { |
| + Handle<Object> old_value; |
| + bool is_observed = function->map()->is_observed(); |
| + if (is_observed) { |
| + old_value = handle(function->shared()->name(), isolate); |
| + } |
| + |
| + Handle<Name> name = isolate->factory()->name_string(); |
| + LookupIterator it(function, name); |
| + CHECK_EQ(LookupIterator::ACCESSOR, it.state()); |
| + DCHECK(it.HolderIsReceiverOrHiddenPrototype()); |
| + it.PrepareForDataProperty(value); |
| + value = it.WriteDataValue(value); |
|
arv (Not doing code reviews)
2015/02/27 15:44:32
Turns out that I could not use SetDataProperty sin
|
| + |
| + if (is_observed && !old_value->SameValue(*value)) { |
| + MaybeHandle<Object> result = |
| + JSObject::EnqueueChangeRecord(function, "update", name, old_value); |
| + if (result.is_null()) return MaybeHandle<Object>(); |
| + } |
| + |
| + return value; |
| +} |
| + |
| + |
| void Accessors::FunctionNameSetter( |
| v8::Local<v8::Name> name, |
| v8::Local<v8::Value> val, |
| const v8::PropertyCallbackInfo<void>& info) { |
| - // Function name is non writable, non configurable. |
| - UNREACHABLE(); |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| + HandleScope scope(isolate); |
| + Handle<Object> value = Utils::OpenHandle(*val); |
| + |
| + if (SetPropertyOnInstanceIfInherited(isolate, info, name, value)) return; |
| + |
| + Handle<JSFunction> object = |
| + Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
| + if (SetFunctionName(isolate, object, value).is_null()) { |
| + isolate->OptionalRescheduleException(false); |
| + } |
| } |