Index: src/factory.cc |
diff --git a/src/factory.cc b/src/factory.cc |
index 3c0c7578760f4a0adb226d0ed5221c8e7231f9cd..9126334fdcdf620be4d437c826211125855fe745 100644 |
--- a/src/factory.cc |
+++ b/src/factory.cc |
@@ -2604,5 +2604,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) { |
+ int size = 3; // with prototype |
+ Map::EnsureDescriptorSlack(map, size); |
+ |
+ 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); |
+ } |
+} |
+ |
} // namespace internal |
} // namespace v8 |