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

Unified Diff: src/runtime/runtime-object.cc

Issue 1626423003: Support computed properties for ES2015 Function.name (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merge to trunk, disable bytecode generator class test Created 4 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 | « src/runtime/runtime-classes.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index 1f7b44770a7c74103bedc70a6466e7361d81c8e7..1377f67c86fc8f41a7c010d39457f9c2a2c6bbbc 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -915,6 +915,30 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) {
return *result;
}
+RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 5);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
+ CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
+ CONVERT_SMI_ARG_CHECKED(set_function_name, 4);
+
+ if (FLAG_harmony_function_name && set_function_name) {
+ DCHECK(value->IsJSFunction());
+ JSFunction::SetName(Handle<JSFunction>::cast(value), name,
+ isolate->factory()->empty_string());
+ }
+
+ LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name,
+ LookupIterator::OWN);
+ // Cannot fail since this should only be called when
+ // creating an object literal.
+ CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs,
+ Object::DONT_THROW)
+ .IsJust());
+ return *object;
+}
// Return property without being observable by accessors or interceptors.
RUNTIME_FUNCTION(Runtime_GetDataProperty) {
@@ -1006,6 +1030,11 @@ RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) {
CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2);
CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
+ if (FLAG_harmony_function_name &&
+ String::cast(getter->shared()->name())->length() == 0) {
+ JSFunction::SetName(getter, name, isolate->factory()->get_string());
+ }
+
RETURN_FAILURE_ON_EXCEPTION(
isolate,
JSObject::DefineAccessor(object, name, getter,
@@ -1022,6 +1051,11 @@ RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
+ if (FLAG_harmony_function_name &&
+ String::cast(setter->shared()->name())->length() == 0) {
+ JSFunction::SetName(setter, name, isolate->factory()->set_string());
+ }
+
RETURN_FAILURE_ON_EXCEPTION(
isolate,
JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698