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

Unified Diff: src/api-natives.cc

Issue 1218403002: Increment descriptor array slack for prototypes by a constant rather than 50% (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/api.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api-natives.cc
diff --git a/src/api-natives.cc b/src/api-natives.cc
index 72c9208992c72662f38c7a4381153b8326eb2e12..e6fc28e9ef07912a16c1462568f6ba920c789547 100644
--- a/src/api-natives.cc
+++ b/src/api-natives.cc
@@ -37,11 +37,12 @@ MaybeHandle<Object> Instantiate(Isolate* isolate, Handle<Object> data,
}
-MaybeHandle<Object> DefineAccessorProperty(
- Isolate* isolate, Handle<JSObject> object, Handle<Name> name,
- Handle<Object> getter, Handle<Object> setter, Smi* attributes) {
- DCHECK(PropertyDetails::AttributesField::is_valid(
- static_cast<PropertyAttributes>(attributes->value())));
+MaybeHandle<Object> DefineAccessorProperty(Isolate* isolate,
+ Handle<JSObject> object,
+ Handle<Name> name,
+ Handle<Object> getter,
+ Handle<Object> setter,
+ PropertyAttributes attributes) {
if (!getter->IsUndefined()) {
ASSIGN_RETURN_ON_EXCEPTION(
isolate, getter,
@@ -56,10 +57,8 @@ MaybeHandle<Object> DefineAccessorProperty(
Handle<FunctionTemplateInfo>::cast(setter)),
Object);
}
- RETURN_ON_EXCEPTION(isolate,
- JSObject::DefineAccessor(
- object, name, getter, setter,
- static_cast<PropertyAttributes>(attributes->value())),
+ RETURN_ON_EXCEPTION(isolate, JSObject::DefineAccessor(object, name, getter,
+ setter, attributes),
Object);
return object;
}
@@ -69,13 +68,7 @@ MaybeHandle<Object> DefineDataProperty(Isolate* isolate,
Handle<JSObject> object,
Handle<Name> name,
Handle<Object> prop_data,
- Smi* unchecked_attributes) {
- DCHECK((unchecked_attributes->value() &
- ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
- // Compute attributes.
- PropertyAttributes attributes =
- static_cast<PropertyAttributes>(unchecked_attributes->value());
-
+ PropertyAttributes attributes) {
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
Instantiate(isolate, prop_data, name), Object);
@@ -150,21 +143,36 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
HandleScope scope(isolate);
// Disable access checks while instantiating the object.
AccessCheckDisableScope access_check_scope(isolate, obj);
- for (int i = 0; i < properties.length();) {
+
+ int i = 0;
+ for (int c = 0; c < data->number_of_properties(); c++) {
int length = Smi::cast(properties.get(i))->value();
- if (length == 3) {
- auto name = handle(Name::cast(properties.get(i + 1)), isolate);
- auto prop_data = handle(properties.get(i + 2), isolate);
- auto attributes = Smi::cast(properties.get(i + 3));
+ PropertyKind kind = length == 3 ? kData : kAccessor;
Igor Sheludko 2015/07/03 13:56:40 Instead of writing a length we could pack kind and
+ auto name = handle(Name::cast(properties.get(i + 1)), isolate);
+ auto unchecked_attributes = Smi::cast(properties.get(i + 2));
+ PropertyAttributes attributes =
+ static_cast<PropertyAttributes>(unchecked_attributes->value());
+ DCHECK(PropertyDetails::AttributesField::is_valid(attributes));
+
+ if (TransitionArray::SearchTransition(obj->map(), kind, *name,
Igor Sheludko 2015/07/03 13:56:40 Put this call after all the simple checks.
+ attributes) == NULL &&
+ obj->map()->owns_descriptors() &&
+ obj->map()->instance_descriptors()->length() != 0 &&
+ obj->map()->instance_descriptors()->NumberOfSlackDescriptors() == 0) {
+ Map::EnsureDescriptorSlack(handle(obj->map()),
+ data->number_of_properties() - c);
+ }
+
+ if (kind == kData) {
+ auto prop_data = handle(properties.get(i + 3), isolate);
+
RETURN_ON_EXCEPTION(isolate, DefineDataProperty(isolate, obj, name,
prop_data, attributes),
JSObject);
} else {
- DCHECK(length == 4);
- auto name = handle(Name::cast(properties.get(i + 1)), isolate);
- auto getter = handle(properties.get(i + 2), isolate);
- auto setter = handle(properties.get(i + 3), isolate);
- auto attributes = Smi::cast(properties.get(i + 4));
+ DCHECK_EQ(4, length);
+ auto getter = handle(properties.get(i + 3), isolate);
+ auto setter = handle(properties.get(i + 4), isolate);
RETURN_ON_EXCEPTION(isolate,
DefineAccessorProperty(isolate, obj, name, getter,
setter, attributes),
@@ -311,6 +319,7 @@ void AddPropertyToPropertyList(Isolate* isolate, Handle<TemplateInfo> templ,
list = NeanderArray(isolate).value();
templ->set_property_list(*list);
}
+ templ->set_number_of_properties(templ->number_of_properties() + 1);
NeanderArray array(list);
array.add(isolate, isolate->factory()->NewNumberFromInt(length));
for (int i = 0; i < length; i++) {
@@ -364,7 +373,7 @@ void ApiNatives::AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
DCHECK(Smi::IsValid(static_cast<int>(attributes)));
auto attribute_handle =
handle(Smi::FromInt(static_cast<int>(attributes)), isolate);
- Handle<Object> data[kSize] = {name, value, attribute_handle};
+ Handle<Object> data[kSize] = {name, attribute_handle, value};
AddPropertyToPropertyList(isolate, info, kSize, data);
}
@@ -379,7 +388,7 @@ void ApiNatives::AddAccessorProperty(Isolate* isolate,
DCHECK(Smi::IsValid(static_cast<int>(attributes)));
auto attribute_handle =
handle(Smi::FromInt(static_cast<int>(attributes)), isolate);
- Handle<Object> data[kSize] = {name, getter, setter, attribute_handle};
+ Handle<Object> data[kSize] = {name, attribute_handle, getter, setter};
AddPropertyToPropertyList(isolate, info, kSize, data);
}
« no previous file with comments | « src/api.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698