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

Unified Diff: src/factory.cc

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: rebased Created 4 years 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/factory.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 72d71ee654965831d1daf68d65c0a9f503cac3f1..b36ebc159330cacd314010126e126ac130e706bf 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -2727,6 +2727,42 @@ void Factory::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
}
}
+Handle<Map> Factory::CreateClassFunctionMap(Handle<JSFunction> empty_function) {
+ Handle<Map> map = NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
+ SetClassFunctionInstanceDescriptor(map);
+ map->set_is_constructor(true);
+ map->set_is_callable();
+ Map::SetPrototype(map, empty_function);
+ return map;
+}
+
+void Factory::SetClassFunctionInstanceDescriptor(Handle<Map> map) {
+ Map::EnsureDescriptorSlack(map, 2);
+
+ PropertyAttributes rw_attribs =
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
+ PropertyAttributes roc_attribs =
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
+
+ STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
+ { // Add length.
+ Handle<AccessorInfo> length =
+ Accessors::FunctionLengthInfo(isolate(), roc_attribs);
+ AccessorConstantDescriptor d(handle(Name::cast(length->name())), length,
+ roc_attribs);
+ map->AppendDescriptor(&d);
+ }
+
+ {
+ // Add prototype.
+ Handle<AccessorInfo> prototype =
+ Accessors::FunctionPrototypeInfo(isolate(), rw_attribs);
+ AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
+ prototype, rw_attribs);
+ map->AppendDescriptor(&d);
+ }
+}
+
Handle<JSFixedArrayIterator> Factory::NewJSFixedArrayIterator(
Handle<FixedArray> array) {
// Create the "next" function (must be unique per iterator object).
« no previous file with comments | « src/factory.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698