Chromium Code Reviews| Index: src/factory.cc |
| diff --git a/src/factory.cc b/src/factory.cc |
| index 39badb69362c7c68c50287dfd61a1854acf28b84..43d9c684a2bb4f168f3004fa78a2550d7090de80 100644 |
| --- a/src/factory.cc |
| +++ b/src/factory.cc |
| @@ -1298,6 +1298,9 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, |
| ElementsKind elements_kind = |
| type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; |
| Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); |
| + // TODO(littledan): Why do we have this is_generator test when |
| + // NewFunctionPrototype already handles finding an appropriately |
| + // shared prototype? |
| if (!function->shared()->is_generator()) { |
| if (prototype->IsTheHole()) { |
| prototype = NewFunctionPrototype(function); |
| @@ -1327,9 +1330,9 @@ Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { |
| // can be from a different context. |
| Handle<Context> native_context(function->context()->native_context()); |
| Handle<Map> new_map; |
| - if (function->shared()->is_generator()) { |
| - // Generator prototypes can share maps since they don't have "constructor" |
| - // properties. |
| + if (function->shared()->is_resumable()) { |
|
caitp (gmail)
2016/05/20 13:35:56
Based on how generator_object_prototype_map is cre
Dan Ehrenberg
2016/05/20 14:59:19
Oh you're right, oops. The new patch asserts that
|
| + // Generator and async function prototypes can share maps since they don't |
| + // have "constructor" properties. |
| new_map = handle(native_context->generator_object_prototype_map()); |
| } else { |
| // Each function prototype gets a fresh map to avoid unwanted sharing of |
| @@ -1342,7 +1345,7 @@ Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { |
| DCHECK(!new_map->is_prototype_map()); |
| Handle<JSObject> prototype = NewJSObjectFromMap(new_map); |
| - if (!function->shared()->is_generator()) { |
| + if (!function->shared()->is_resumable()) { |
| JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM); |
| } |
| @@ -1676,7 +1679,7 @@ void Factory::NewJSArrayStorage(Handle<JSArray> array, |
| Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( |
| Handle<JSFunction> function) { |
| - DCHECK(function->shared()->is_resumable()); |
| + DCHECK(function->shared()->is_generator()); |
| JSFunction::EnsureHasInitialMap(function); |
| Handle<Map> map(function->initial_map()); |
| DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); |