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

Unified Diff: src/accessors.cc

Issue 960343002: ES6: Make function name configurable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use reconfigure instead Created 5 years, 10 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 | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index 052108a9b065feba47aa9ae907d55a9f33d092ab..51fdee67f28e5b0cd0ca0070842e5124de7fb2a1 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -1131,12 +1131,44 @@ 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.ReconfigureDataProperty(value, it.property_details().attributes());
+ value = it.WriteDataValue(value);
+
+ if (is_observed && !old_value->SameValue(*value)) {
+ return JSObject::EnqueueChangeRecord(function, "update", name, old_value);
+ }
+
+ 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);
+ }
}
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698