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

Unified Diff: src/factory.cc

Issue 1996943002: [esnext] Fix various callsites to use is_resumable, not is_generator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
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());

Powered by Google App Engine
This is Rietveld 408576698