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

Unified Diff: src/objects.cc

Issue 1431593003: [es6] Fix RegExp built-in subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | test/mjsunit/es6/classes-subclass-builtins.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 10ceb58407f57ac86c41887655903e4490d44c2a..dea005155f29527b905741e2d43955bf1367c803 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8224,6 +8224,19 @@ Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size,
result->SetInObjectProperties(in_object_properties);
result->set_unused_property_fields(unused_property_fields);
+ int number_of_own_descriptors = map->NumberOfOwnDescriptors();
+ if (number_of_own_descriptors > 0) {
+ DCHECK(map->owns_descriptors());
+ // The copy will use the same descriptors array, but it's not the owner.
+ result->UpdateDescriptors(map->instance_descriptors(),
+ map->layout_descriptor());
+ result->set_owns_descriptors(false);
+ result->SetNumberOfOwnDescriptors(number_of_own_descriptors);
+
+ DCHECK_EQ(result->NumberOfFields(),
+ in_object_properties - unused_property_fields);
+ }
+
return result;
}
@@ -11906,17 +11919,25 @@ Handle<Map> JSFunction::EnsureDerivedHasInitialMap(
// Finally link initial map and constructor function if the original
// constructor is actually a subclass constructor.
if (IsSubclassConstructor(original_constructor->shared()->kind())) {
+// TODO(ishell): v8:4531, allow ES6 built-ins subclasses to have
+// in-object properties.
+#if 0
InstanceType instance_type = constructor_initial_map->instance_type();
int internal_fields =
JSObject::GetInternalFieldCount(*constructor_initial_map);
+ int pre_allocated = constructor_initial_map->GetInObjectProperties() -
+ constructor_initial_map->unused_property_fields();
int instance_size;
int in_object_properties;
original_constructor->CalculateInstanceSizeForDerivedClass(
instance_type, internal_fields, &instance_size, &in_object_properties);
+ int unused_property_fields = in_object_properties - pre_allocated;
Handle<Map> map =
Map::CopyInitialMap(constructor_initial_map, instance_size,
- in_object_properties, in_object_properties);
+ in_object_properties, unused_property_fields);
+#endif
+ Handle<Map> map = Map::CopyInitialMap(constructor_initial_map);
JSFunction::SetInitialMap(original_constructor, map, prototype);
map->SetConstructor(*constructor);
« no previous file with comments | « no previous file | test/mjsunit/es6/classes-subclass-builtins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698