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

Side by Side Diff: src/objects.cc

Issue 14622005: Free up 11 bits in fast-mode PropertyDetails by removing the enumeration-index. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 int enumeration_index; 650 int enumeration_index;
651 // Preserve the enumeration index unless the property was deleted. 651 // Preserve the enumeration index unless the property was deleted.
652 if (original_details.IsDeleted()) { 652 if (original_details.IsDeleted()) {
653 enumeration_index = property_dictionary()->NextEnumerationIndex(); 653 enumeration_index = property_dictionary()->NextEnumerationIndex();
654 property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1); 654 property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1);
655 } else { 655 } else {
656 enumeration_index = original_details.dictionary_index(); 656 enumeration_index = original_details.dictionary_index();
657 ASSERT(enumeration_index > 0); 657 ASSERT(enumeration_index > 0);
658 } 658 }
659 659
660 details = PropertyDetails(details.attributes(), details.type(), 660 details = PropertyDetails(
661 Representation::None(), enumeration_index); 661 details.attributes(), details.type(), enumeration_index);
662 662
663 if (IsGlobalObject()) { 663 if (IsGlobalObject()) {
664 JSGlobalPropertyCell* cell = 664 JSGlobalPropertyCell* cell =
665 JSGlobalPropertyCell::cast(property_dictionary()->ValueAt(entry)); 665 JSGlobalPropertyCell::cast(property_dictionary()->ValueAt(entry));
666 cell->set_value(value); 666 cell->set_value(value);
667 // Please note we have to update the property details. 667 // Please note we have to update the property details.
668 property_dictionary()->DetailsAtPut(entry, details); 668 property_dictionary()->DetailsAtPut(entry, details);
669 } else { 669 } else {
670 property_dictionary()->SetEntry(entry, name, value, details); 670 property_dictionary()->SetEntry(entry, name, value, details);
671 } 671 }
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 1768 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1769 1769
1770 return AddSlowProperty(name, value, attributes); 1770 return AddSlowProperty(name, value, attributes);
1771 } 1771 }
1772 1772
1773 // Compute the new index for new field. 1773 // Compute the new index for new field.
1774 int index = map()->NextFreePropertyIndex(); 1774 int index = map()->NextFreePropertyIndex();
1775 1775
1776 // Allocate new instance descriptors with (name, index) added 1776 // Allocate new instance descriptors with (name, index) added
1777 FieldDescriptor new_field( 1777 FieldDescriptor new_field(
1778 name, index, attributes, value->OptimalRepresentation(), 0); 1778 name, index, attributes, value->OptimalRepresentation());
1779 1779
1780 ASSERT(index < map()->inobject_properties() || 1780 ASSERT(index < map()->inobject_properties() ||
1781 (index - map()->inobject_properties()) < properties()->length() || 1781 (index - map()->inobject_properties()) < properties()->length() ||
1782 map()->unused_property_fields() == 0); 1782 map()->unused_property_fields() == 0);
1783 1783
1784 FixedArray* values = NULL; 1784 FixedArray* values = NULL;
1785 1785
1786 if (map()->unused_property_fields() == 0) { 1786 if (map()->unused_property_fields() == 0) {
1787 // Make room for the new value 1787 // Make room for the new value
1788 MaybeObject* maybe_values = 1788 MaybeObject* maybe_values =
(...skipping 18 matching lines...) Expand all
1807 set_map(new_map); 1807 set_map(new_map);
1808 return FastPropertyAtPut(index, value); 1808 return FastPropertyAtPut(index, value);
1809 } 1809 }
1810 1810
1811 1811
1812 MaybeObject* JSObject::AddConstantFunctionProperty( 1812 MaybeObject* JSObject::AddConstantFunctionProperty(
1813 Name* name, 1813 Name* name,
1814 JSFunction* function, 1814 JSFunction* function,
1815 PropertyAttributes attributes) { 1815 PropertyAttributes attributes) {
1816 // Allocate new instance descriptors with (name, function) added 1816 // Allocate new instance descriptors with (name, function) added
1817 ConstantFunctionDescriptor d(name, function, attributes, 0); 1817 ConstantFunctionDescriptor d(name, function, attributes);
1818 1818
1819 TransitionFlag flag = 1819 TransitionFlag flag =
1820 // Do not add transitions to global objects. 1820 // Do not add transitions to global objects.
1821 (IsGlobalObject() || 1821 (IsGlobalObject() ||
1822 // Don't add transitions to special properties with non-trivial 1822 // Don't add transitions to special properties with non-trivial
1823 // attributes. 1823 // attributes.
1824 attributes != NONE) 1824 attributes != NONE)
1825 ? OMIT_TRANSITION 1825 ? OMIT_TRANSITION
1826 : INSERT_TRANSITION; 1826 : INSERT_TRANSITION;
1827 1827
(...skipping 15 matching lines...) Expand all
1843 Object* store_value = value; 1843 Object* store_value = value;
1844 if (IsGlobalObject()) { 1844 if (IsGlobalObject()) {
1845 // In case name is an orphaned property reuse the cell. 1845 // In case name is an orphaned property reuse the cell.
1846 int entry = dict->FindEntry(name); 1846 int entry = dict->FindEntry(name);
1847 if (entry != NameDictionary::kNotFound) { 1847 if (entry != NameDictionary::kNotFound) {
1848 store_value = dict->ValueAt(entry); 1848 store_value = dict->ValueAt(entry);
1849 JSGlobalPropertyCell::cast(store_value)->set_value(value); 1849 JSGlobalPropertyCell::cast(store_value)->set_value(value);
1850 // Assign an enumeration index to the property and update 1850 // Assign an enumeration index to the property and update
1851 // SetNextEnumerationIndex. 1851 // SetNextEnumerationIndex.
1852 int index = dict->NextEnumerationIndex(); 1852 int index = dict->NextEnumerationIndex();
1853 PropertyDetails details = PropertyDetails( 1853 PropertyDetails details = PropertyDetails(attributes, NORMAL, index);
1854 attributes, NORMAL, Representation::None(), index);
1855 dict->SetNextEnumerationIndex(index + 1); 1854 dict->SetNextEnumerationIndex(index + 1);
1856 dict->SetEntry(entry, name, store_value, details); 1855 dict->SetEntry(entry, name, store_value, details);
1857 return value; 1856 return value;
1858 } 1857 }
1859 Heap* heap = GetHeap(); 1858 Heap* heap = GetHeap();
1860 { MaybeObject* maybe_store_value = 1859 { MaybeObject* maybe_store_value =
1861 heap->AllocateJSGlobalPropertyCell(value); 1860 heap->AllocateJSGlobalPropertyCell(value);
1862 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; 1861 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value;
1863 } 1862 }
1864 JSGlobalPropertyCell::cast(store_value)->set_value(value); 1863 JSGlobalPropertyCell::cast(store_value)->set_value(value);
1865 } 1864 }
1866 PropertyDetails details = PropertyDetails( 1865 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
1867 attributes, NORMAL, Representation::None());
1868 Object* result; 1866 Object* result;
1869 { MaybeObject* maybe_result = dict->Add(name, store_value, details); 1867 { MaybeObject* maybe_result = dict->Add(name, store_value, details);
1870 if (!maybe_result->ToObject(&result)) return maybe_result; 1868 if (!maybe_result->ToObject(&result)) return maybe_result;
1871 } 1869 }
1872 if (dict != result) set_properties(NameDictionary::cast(result)); 1870 if (dict != result) set_properties(NameDictionary::cast(result));
1873 return value; 1871 return value;
1874 } 1872 }
1875 1873
1876 1874
1877 MaybeObject* JSObject::AddProperty(Name* name, 1875 MaybeObject* JSObject::AddProperty(Name* name,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 Object* value, 1996 Object* value,
1999 PropertyAttributes attributes) { 1997 PropertyAttributes attributes) {
2000 NameDictionary* dictionary = property_dictionary(); 1998 NameDictionary* dictionary = property_dictionary();
2001 int old_index = dictionary->FindEntry(name); 1999 int old_index = dictionary->FindEntry(name);
2002 int new_enumeration_index = 0; // 0 means "Use the next available index." 2000 int new_enumeration_index = 0; // 0 means "Use the next available index."
2003 if (old_index != -1) { 2001 if (old_index != -1) {
2004 // All calls to ReplaceSlowProperty have had all transitions removed. 2002 // All calls to ReplaceSlowProperty have had all transitions removed.
2005 new_enumeration_index = dictionary->DetailsAt(old_index).dictionary_index(); 2003 new_enumeration_index = dictionary->DetailsAt(old_index).dictionary_index();
2006 } 2004 }
2007 2005
2008 PropertyDetails new_details( 2006 PropertyDetails new_details(attributes, NORMAL, new_enumeration_index);
2009 attributes, NORMAL, Representation::None(), new_enumeration_index);
2010 return SetNormalizedProperty(name, value, new_details); 2007 return SetNormalizedProperty(name, value, new_details);
2011 } 2008 }
2012 2009
2013 2010
2014 MaybeObject* JSObject::ConvertTransitionToMapTransition( 2011 MaybeObject* JSObject::ConvertTransitionToMapTransition(
2015 int transition_index, 2012 int transition_index,
2016 Name* name, 2013 Name* name,
2017 Object* new_value, 2014 Object* new_value,
2018 PropertyAttributes attributes) { 2015 PropertyAttributes attributes) {
2019 Map* old_map = map(); 2016 Map* old_map = map();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 if (map()->unused_property_fields() == 0 && 2063 if (map()->unused_property_fields() == 0 &&
2067 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) { 2064 TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) {
2068 Object* obj; 2065 Object* obj;
2069 MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 2066 MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
2070 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2067 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2071 return ReplaceSlowProperty(name, new_value, attributes); 2068 return ReplaceSlowProperty(name, new_value, attributes);
2072 } 2069 }
2073 2070
2074 int index = map()->NextFreePropertyIndex(); 2071 int index = map()->NextFreePropertyIndex();
2075 FieldDescriptor new_field( 2072 FieldDescriptor new_field(
2076 name, index, attributes, new_value->OptimalRepresentation(), 0); 2073 name, index, attributes, new_value->OptimalRepresentation());
2077 2074
2078 // Make a new map for the object. 2075 // Make a new map for the object.
2079 Map* new_map; 2076 Map* new_map;
2080 MaybeObject* maybe_new_map = map()->CopyInsertDescriptor(&new_field, 2077 MaybeObject* maybe_new_map = map()->CopyInsertDescriptor(&new_field,
2081 OMIT_TRANSITION); 2078 OMIT_TRANSITION);
2082 if (!maybe_new_map->To(&new_map)) return maybe_new_map; 2079 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
2083 2080
2084 // Make new properties array if necessary. 2081 // Make new properties array if necessary.
2085 FixedArray* new_properties = NULL; 2082 FixedArray* new_properties = NULL;
2086 int new_unused_property_fields = map()->unused_property_fields() - 1; 2083 int new_unused_property_fields = map()->unused_property_fields() - 1;
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); 3748 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
3752 if (is_observed) { 3749 if (is_observed) {
3753 if (lookup.IsDataProperty()) old_value = Object::GetProperty(self, name); 3750 if (lookup.IsDataProperty()) old_value = Object::GetProperty(self, name);
3754 old_attributes = lookup.GetAttributes(); 3751 old_attributes = lookup.GetAttributes();
3755 } 3752 }
3756 3753
3757 // Check of IsReadOnly removed from here in clone. 3754 // Check of IsReadOnly removed from here in clone.
3758 MaybeObject* result = *value; 3755 MaybeObject* result = *value;
3759 switch (lookup.type()) { 3756 switch (lookup.type()) {
3760 case NORMAL: { 3757 case NORMAL: {
3761 PropertyDetails details = PropertyDetails( 3758 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
3762 attributes, NORMAL, Representation::None());
3763 result = self->SetNormalizedProperty(*name, *value, details); 3759 result = self->SetNormalizedProperty(*name, *value, details);
3764 break; 3760 break;
3765 } 3761 }
3766 case FIELD: { 3762 case FIELD: {
3767 Representation representation = lookup.representation(); 3763 Representation representation = lookup.representation();
3768 if (!value->FitsRepresentation(representation)) { 3764 if (!value->FitsRepresentation(representation)) {
3769 MaybeObject* maybe_failure = self->GeneralizeFieldRepresentation( 3765 MaybeObject* maybe_failure = self->GeneralizeFieldRepresentation(
3770 lookup.GetDescriptorIndex(), value->OptimalRepresentation()); 3766 lookup.GetDescriptorIndex(), value->OptimalRepresentation());
3771 if (maybe_failure->IsFailure()) return maybe_failure; 3767 if (maybe_failure->IsFailure()) return maybe_failure;
3772 } 3768 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
4211 NameDictionary* dictionary; 4207 NameDictionary* dictionary;
4212 MaybeObject* maybe_dictionary = 4208 MaybeObject* maybe_dictionary =
4213 NameDictionary::Allocate(GetHeap(), property_count); 4209 NameDictionary::Allocate(GetHeap(), property_count);
4214 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; 4210 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
4215 4211
4216 DescriptorArray* descs = map_of_this->instance_descriptors(); 4212 DescriptorArray* descs = map_of_this->instance_descriptors();
4217 for (int i = 0; i < real_size; i++) { 4213 for (int i = 0; i < real_size; i++) {
4218 PropertyDetails details = descs->GetDetails(i); 4214 PropertyDetails details = descs->GetDetails(i);
4219 switch (details.type()) { 4215 switch (details.type()) {
4220 case CONSTANT_FUNCTION: { 4216 case CONSTANT_FUNCTION: {
4221 PropertyDetails d = PropertyDetails(details.attributes(), 4217 PropertyDetails d = PropertyDetails(
4222 NORMAL, 4218 details.attributes(), NORMAL, i + 1);
4223 Representation::None(),
4224 details.descriptor_index());
4225 Object* value = descs->GetConstantFunction(i); 4219 Object* value = descs->GetConstantFunction(i);
4226 MaybeObject* maybe_dictionary = 4220 MaybeObject* maybe_dictionary =
4227 dictionary->Add(descs->GetKey(i), value, d); 4221 dictionary->Add(descs->GetKey(i), value, d);
4228 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; 4222 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
4229 break; 4223 break;
4230 } 4224 }
4231 case FIELD: { 4225 case FIELD: {
4232 PropertyDetails d = PropertyDetails(details.attributes(), 4226 PropertyDetails d = PropertyDetails(
4233 NORMAL, 4227 details.attributes(), NORMAL, i + 1);
4234 Representation::None(),
4235 details.descriptor_index());
4236 Object* value = FastPropertyAt(descs->GetFieldIndex(i)); 4228 Object* value = FastPropertyAt(descs->GetFieldIndex(i));
4237 MaybeObject* maybe_dictionary = 4229 MaybeObject* maybe_dictionary =
4238 dictionary->Add(descs->GetKey(i), value, d); 4230 dictionary->Add(descs->GetKey(i), value, d);
4239 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; 4231 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
4240 break; 4232 break;
4241 } 4233 }
4242 case CALLBACKS: { 4234 case CALLBACKS: {
4243 Object* value = descs->GetCallbacksObject(i); 4235 Object* value = descs->GetCallbacksObject(i);
4244 PropertyDetails d = PropertyDetails(details.attributes(), 4236 PropertyDetails d = PropertyDetails(
4245 CALLBACKS, 4237 details.attributes(), CALLBACKS, i + 1);
4246 Representation::None(),
4247 details.descriptor_index());
4248 MaybeObject* maybe_dictionary = 4238 MaybeObject* maybe_dictionary =
4249 dictionary->Add(descs->GetKey(i), value, d); 4239 dictionary->Add(descs->GetKey(i), value, d);
4250 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; 4240 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
4251 break; 4241 break;
4252 } 4242 }
4253 case INTERCEPTOR: 4243 case INTERCEPTOR:
4254 break; 4244 break;
4255 case HANDLER: 4245 case HANDLER:
4256 case NORMAL: 4246 case NORMAL:
4257 case TRANSITION: 4247 case TRANSITION:
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4373 // exceed the capacity of new space, and we would fail repeatedly 4363 // exceed the capacity of new space, and we would fail repeatedly
4374 // trying to convert the FixedDoubleArray. 4364 // trying to convert the FixedDoubleArray.
4375 MaybeObject* maybe_value_object = 4365 MaybeObject* maybe_value_object =
4376 GetHeap()->AllocateHeapNumber(double_array->get_scalar(i), TENURED); 4366 GetHeap()->AllocateHeapNumber(double_array->get_scalar(i), TENURED);
4377 if (!maybe_value_object->ToObject(&value)) return maybe_value_object; 4367 if (!maybe_value_object->ToObject(&value)) return maybe_value_object;
4378 } 4368 }
4379 } else { 4369 } else {
4380 ASSERT(old_map->has_fast_smi_or_object_elements()); 4370 ASSERT(old_map->has_fast_smi_or_object_elements());
4381 value = FixedArray::cast(array)->get(i); 4371 value = FixedArray::cast(array)->get(i);
4382 } 4372 }
4383 PropertyDetails details = PropertyDetails( 4373 PropertyDetails details = PropertyDetails(NONE, NORMAL, 0);
4384 NONE, NORMAL, Representation::None());
4385 if (!value->IsTheHole()) { 4374 if (!value->IsTheHole()) {
4386 Object* result; 4375 Object* result;
4387 MaybeObject* maybe_result = 4376 MaybeObject* maybe_result =
4388 dictionary->AddNumberEntry(i, value, details); 4377 dictionary->AddNumberEntry(i, value, details);
4389 if (!maybe_result->ToObject(&result)) return maybe_result; 4378 if (!maybe_result->ToObject(&result)) return maybe_result;
4390 dictionary = SeededNumberDictionary::cast(result); 4379 dictionary = SeededNumberDictionary::cast(result);
4391 } 4380 }
4392 } 4381 }
4393 4382
4394 // Switch to using the dictionary as the backing storage for elements. 4383 // Switch to using the dictionary as the backing storage for elements.
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
5445 PropertyAttributes attributes) { 5434 PropertyAttributes attributes) {
5446 int entry = dictionary->FindEntry(index); 5435 int entry = dictionary->FindEntry(index);
5447 if (entry != SeededNumberDictionary::kNotFound) { 5436 if (entry != SeededNumberDictionary::kNotFound) {
5448 Object* result = dictionary->ValueAt(entry); 5437 Object* result = dictionary->ValueAt(entry);
5449 PropertyDetails details = dictionary->DetailsAt(entry); 5438 PropertyDetails details = dictionary->DetailsAt(entry);
5450 if (details.type() == CALLBACKS && result->IsAccessorPair()) { 5439 if (details.type() == CALLBACKS && result->IsAccessorPair()) {
5451 ASSERT(!details.IsDontDelete()); 5440 ASSERT(!details.IsDontDelete());
5452 if (details.attributes() != attributes) { 5441 if (details.attributes() != attributes) {
5453 dictionary->DetailsAtPut( 5442 dictionary->DetailsAtPut(
5454 entry, 5443 entry,
5455 PropertyDetails( 5444 PropertyDetails(attributes, CALLBACKS, index));
5456 attributes, CALLBACKS, Representation::None(), index));
5457 } 5445 }
5458 AccessorPair::cast(result)->SetComponents(getter, setter); 5446 AccessorPair::cast(result)->SetComponents(getter, setter);
5459 return true; 5447 return true;
5460 } 5448 }
5461 } 5449 }
5462 return false; 5450 return false;
5463 } 5451 }
5464 5452
5465 5453
5466 MaybeObject* JSObject::DefineElementAccessor(uint32_t index, 5454 MaybeObject* JSObject::DefineElementAccessor(uint32_t index,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
5607 } 5595 }
5608 } 5596 }
5609 5597
5610 return true; 5598 return true;
5611 } 5599 }
5612 5600
5613 5601
5614 MaybeObject* JSObject::SetElementCallback(uint32_t index, 5602 MaybeObject* JSObject::SetElementCallback(uint32_t index,
5615 Object* structure, 5603 Object* structure,
5616 PropertyAttributes attributes) { 5604 PropertyAttributes attributes) {
5617 PropertyDetails details = PropertyDetails( 5605 PropertyDetails details = PropertyDetails(attributes, CALLBACKS, 0);
5618 attributes, CALLBACKS, Representation::None());
5619 5606
5620 // Normalize elements to make this operation simple. 5607 // Normalize elements to make this operation simple.
5621 SeededNumberDictionary* dictionary; 5608 SeededNumberDictionary* dictionary;
5622 { MaybeObject* maybe_dictionary = NormalizeElements(); 5609 { MaybeObject* maybe_dictionary = NormalizeElements();
5623 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; 5610 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
5624 } 5611 }
5625 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements()); 5612 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements());
5626 5613
5627 // Update the dictionary with the new CALLBACKS property. 5614 // Update the dictionary with the new CALLBACKS property.
5628 { MaybeObject* maybe_dictionary = dictionary->Set(index, structure, details); 5615 { MaybeObject* maybe_dictionary = dictionary->Set(index, structure, details);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5666 ASSERT(new_map->is_dictionary_map()); 5653 ASSERT(new_map->is_dictionary_map());
5667 5654
5668 set_map(new_map); 5655 set_map(new_map);
5669 // When running crankshaft, changing the map is not enough. We 5656 // When running crankshaft, changing the map is not enough. We
5670 // need to deoptimize all functions that rely on this global 5657 // need to deoptimize all functions that rely on this global
5671 // object. 5658 // object.
5672 Deoptimizer::DeoptimizeGlobalObject(this); 5659 Deoptimizer::DeoptimizeGlobalObject(this);
5673 } 5660 }
5674 5661
5675 // Update the dictionary with the new CALLBACKS property. 5662 // Update the dictionary with the new CALLBACKS property.
5676 PropertyDetails details = PropertyDetails( 5663 PropertyDetails details = PropertyDetails(attributes, CALLBACKS, 0);
5677 attributes, CALLBACKS, Representation::None());
5678 maybe_ok = SetNormalizedProperty(name, structure, details); 5664 maybe_ok = SetNormalizedProperty(name, structure, details);
5679 if (maybe_ok->IsFailure()) return maybe_ok; 5665 if (maybe_ok->IsFailure()) return maybe_ok;
5680 5666
5681 return GetHeap()->undefined_value(); 5667 return GetHeap()->undefined_value();
5682 } 5668 }
5683 5669
5684 5670
5685 void JSObject::DefineAccessor(Handle<JSObject> object, 5671 void JSObject::DefineAccessor(Handle<JSObject> object,
5686 Handle<Name> name, 5672 Handle<Name> name,
5687 Handle<Object> getter, 5673 Handle<Object> getter,
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
6329 MaybeObject* Map::CopyAddDescriptor(Descriptor* descriptor, 6315 MaybeObject* Map::CopyAddDescriptor(Descriptor* descriptor,
6330 TransitionFlag flag) { 6316 TransitionFlag flag) {
6331 DescriptorArray* descriptors = instance_descriptors(); 6317 DescriptorArray* descriptors = instance_descriptors();
6332 6318
6333 // Ensure the key is unique. 6319 // Ensure the key is unique.
6334 MaybeObject* maybe_failure = descriptor->KeyToUniqueName(); 6320 MaybeObject* maybe_failure = descriptor->KeyToUniqueName();
6335 if (maybe_failure->IsFailure()) return maybe_failure; 6321 if (maybe_failure->IsFailure()) return maybe_failure;
6336 6322
6337 int old_size = NumberOfOwnDescriptors(); 6323 int old_size = NumberOfOwnDescriptors();
6338 int new_size = old_size + 1; 6324 int new_size = old_size + 1;
6339 descriptor->SetEnumerationIndex(new_size);
6340 6325
6341 if (flag == INSERT_TRANSITION && 6326 if (flag == INSERT_TRANSITION &&
6342 owns_descriptors() && 6327 owns_descriptors() &&
6343 CanHaveMoreTransitions()) { 6328 CanHaveMoreTransitions()) {
6344 return ShareDescriptor(descriptors, descriptor); 6329 return ShareDescriptor(descriptors, descriptor);
6345 } 6330 }
6346 6331
6347 DescriptorArray* new_descriptors; 6332 DescriptorArray* new_descriptors;
6348 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(old_size, 1); 6333 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(old_size, 1);
6349 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; 6334 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6414 // Ensure the key is unique. 6399 // Ensure the key is unique.
6415 MaybeObject* maybe_failure = descriptor->KeyToUniqueName(); 6400 MaybeObject* maybe_failure = descriptor->KeyToUniqueName();
6416 if (maybe_failure->IsFailure()) return maybe_failure; 6401 if (maybe_failure->IsFailure()) return maybe_failure;
6417 6402
6418 Name* key = descriptor->GetKey(); 6403 Name* key = descriptor->GetKey();
6419 ASSERT(key == descriptors->GetKey(insertion_index)); 6404 ASSERT(key == descriptors->GetKey(insertion_index));
6420 6405
6421 int new_size = NumberOfOwnDescriptors(); 6406 int new_size = NumberOfOwnDescriptors();
6422 ASSERT(0 <= insertion_index && insertion_index < new_size); 6407 ASSERT(0 <= insertion_index && insertion_index < new_size);
6423 6408
6424 PropertyDetails details = descriptors->GetDetails(insertion_index); 6409 ASSERT_LT(insertion_index, new_size);
6425 ASSERT_LE(details.descriptor_index(), new_size);
6426 descriptor->SetEnumerationIndex(details.descriptor_index());
6427 6410
6428 DescriptorArray* new_descriptors; 6411 DescriptorArray* new_descriptors;
6429 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(new_size); 6412 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(new_size);
6430 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; 6413 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
6431 DescriptorArray::WhitenessWitness witness(new_descriptors); 6414 DescriptorArray::WhitenessWitness witness(new_descriptors);
6432 6415
6433 for (int i = 0; i < new_size; ++i) { 6416 for (int i = 0; i < new_size; ++i) {
6434 if (i == insertion_index) { 6417 if (i == insertion_index) {
6435 new_descriptors->Set(i, descriptor, witness); 6418 new_descriptors->Set(i, descriptor, witness);
6436 } else { 6419 } else {
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
7312 7295
7313 if (details.type() == FIELD || other_details.type() == FIELD || 7296 if (details.type() == FIELD || other_details.type() == FIELD ||
7314 (details.type() == CONSTANT_FUNCTION && 7297 (details.type() == CONSTANT_FUNCTION &&
7315 other_details.type() == CONSTANT_FUNCTION && 7298 other_details.type() == CONSTANT_FUNCTION &&
7316 GetValue(descriptor) != other->GetValue(descriptor))) { 7299 GetValue(descriptor) != other->GetValue(descriptor))) {
7317 Representation representation = 7300 Representation representation =
7318 details.representation().generalize(other_details.representation()); 7301 details.representation().generalize(other_details.representation());
7319 FieldDescriptor d(key, 7302 FieldDescriptor d(key,
7320 current_offset++, 7303 current_offset++,
7321 details.attributes(), 7304 details.attributes(),
7322 representation, 7305 representation);
7323 descriptor + 1);
7324 result->Set(descriptor, &d, witness); 7306 result->Set(descriptor, &d, witness);
7325 } else { 7307 } else {
7326 result->CopyFrom(descriptor, other, descriptor, witness); 7308 result->CopyFrom(descriptor, other, descriptor, witness);
7327 } 7309 }
7328 } 7310 }
7329 7311
7330 // |valid| -> |new_size| 7312 // |valid| -> |new_size|
7331 for (; descriptor < new_size; descriptor++) { 7313 for (; descriptor < new_size; descriptor++) {
7332 PropertyDetails details = other->GetDetails(descriptor); 7314 PropertyDetails details = other->GetDetails(descriptor);
7333 if (details.type() == FIELD) { 7315 if (details.type() == FIELD) {
7334 Name* key = other->GetKey(descriptor); 7316 Name* key = other->GetKey(descriptor);
7335 FieldDescriptor d(key, 7317 FieldDescriptor d(key,
7336 current_offset++, 7318 current_offset++,
7337 details.attributes(), 7319 details.attributes(),
7338 details.representation(), 7320 details.representation());
7339 descriptor + 1);
7340 result->Set(descriptor, &d, witness); 7321 result->Set(descriptor, &d, witness);
7341 } else { 7322 } else {
7342 result->CopyFrom(descriptor, other, descriptor, witness); 7323 result->CopyFrom(descriptor, other, descriptor, witness);
7343 } 7324 }
7344 } 7325 }
7345 7326
7346 result->Sort(); 7327 result->Sort();
7347 return result; 7328 return result;
7348 } 7329 }
7349 7330
(...skipping 3844 matching lines...) Expand 10 before | Expand all | Expand 10 after
11194 Object* element = dictionary->ValueAt(entry); 11175 Object* element = dictionary->ValueAt(entry);
11195 PropertyDetails details = dictionary->DetailsAt(entry); 11176 PropertyDetails details = dictionary->DetailsAt(entry);
11196 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) { 11177 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) {
11197 return SetElementWithCallback(element, index, *value, this, strict_mode); 11178 return SetElementWithCallback(element, index, *value, this, strict_mode);
11198 } else { 11179 } else {
11199 dictionary->UpdateMaxNumberKey(index); 11180 dictionary->UpdateMaxNumberKey(index);
11200 // If a value has not been initialized we allow writing to it even if it 11181 // If a value has not been initialized we allow writing to it even if it
11201 // is read-only (a declared const that has not been initialized). If a 11182 // is read-only (a declared const that has not been initialized). If a
11202 // value is being defined we skip attribute checks completely. 11183 // value is being defined we skip attribute checks completely.
11203 if (set_mode == DEFINE_PROPERTY) { 11184 if (set_mode == DEFINE_PROPERTY) {
11204 details = PropertyDetails(attributes, NORMAL, Representation::None(), 11185 details = PropertyDetails(
11205 details.dictionary_index()); 11186 attributes, NORMAL, details.dictionary_index());
11206 dictionary->DetailsAtPut(entry, details); 11187 dictionary->DetailsAtPut(entry, details);
11207 } else if (details.IsReadOnly() && !element->IsTheHole()) { 11188 } else if (details.IsReadOnly() && !element->IsTheHole()) {
11208 if (strict_mode == kNonStrictMode) { 11189 if (strict_mode == kNonStrictMode) {
11209 return isolate->heap()->undefined_value(); 11190 return isolate->heap()->undefined_value();
11210 } else { 11191 } else {
11211 Handle<Object> holder(this, isolate); 11192 Handle<Object> holder(this, isolate);
11212 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 11193 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
11213 Handle<Object> args[2] = { number, holder }; 11194 Handle<Object> args[2] = { number, holder };
11214 Handle<Object> error = 11195 Handle<Object> error =
11215 isolate->factory()->NewTypeError("strict_read_only_property", 11196 isolate->factory()->NewTypeError("strict_read_only_property",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
11247 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 11228 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
11248 Handle<String> name = isolate->factory()->NumberToString(number); 11229 Handle<String> name = isolate->factory()->NumberToString(number);
11249 Handle<Object> args[1] = { name }; 11230 Handle<Object> args[1] = { name };
11250 Handle<Object> error = 11231 Handle<Object> error =
11251 isolate->factory()->NewTypeError("object_not_extensible", 11232 isolate->factory()->NewTypeError("object_not_extensible",
11252 HandleVector(args, 1)); 11233 HandleVector(args, 1));
11253 return isolate->Throw(*error); 11234 return isolate->Throw(*error);
11254 } 11235 }
11255 } 11236 }
11256 FixedArrayBase* new_dictionary; 11237 FixedArrayBase* new_dictionary;
11257 PropertyDetails details = PropertyDetails( 11238 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
11258 attributes, NORMAL, Representation::None());
11259 MaybeObject* maybe = dictionary->AddNumberEntry(index, *value, details); 11239 MaybeObject* maybe = dictionary->AddNumberEntry(index, *value, details);
11260 if (!maybe->To(&new_dictionary)) return maybe; 11240 if (!maybe->To(&new_dictionary)) return maybe;
11261 if (*dictionary != SeededNumberDictionary::cast(new_dictionary)) { 11241 if (*dictionary != SeededNumberDictionary::cast(new_dictionary)) {
11262 if (is_arguments) { 11242 if (is_arguments) {
11263 elements->set(1, new_dictionary); 11243 elements->set(1, new_dictionary);
11264 } else { 11244 } else {
11265 self->set_elements(new_dictionary); 11245 self->set_elements(new_dictionary);
11266 } 11246 }
11267 dictionary = 11247 dictionary =
11268 handle(SeededNumberDictionary::cast(new_dictionary), isolate); 11248 handle(SeededNumberDictionary::cast(new_dictionary), isolate);
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
13242 // Adding an entry with the key beyond smi-range requires 13222 // Adding an entry with the key beyond smi-range requires
13243 // allocation. Bailout. 13223 // allocation. Bailout.
13244 return Smi::FromInt(-1); 13224 return Smi::FromInt(-1);
13245 } 13225 }
13246 new_dict->AddNumberEntry(key, value, details)->ToObjectUnchecked(); 13226 new_dict->AddNumberEntry(key, value, details)->ToObjectUnchecked();
13247 } 13227 }
13248 } 13228 }
13249 } 13229 }
13250 13230
13251 uint32_t result = pos; 13231 uint32_t result = pos;
13252 PropertyDetails no_details = PropertyDetails( 13232 PropertyDetails no_details = PropertyDetails(NONE, NORMAL, 0);
13253 NONE, NORMAL, Representation::None());
13254 Heap* heap = GetHeap(); 13233 Heap* heap = GetHeap();
13255 while (undefs > 0) { 13234 while (undefs > 0) {
13256 if (pos > static_cast<uint32_t>(Smi::kMaxValue)) { 13235 if (pos > static_cast<uint32_t>(Smi::kMaxValue)) {
13257 // Adding an entry with the key beyond smi-range requires 13236 // Adding an entry with the key beyond smi-range requires
13258 // allocation. Bailout. 13237 // allocation. Bailout.
13259 return Smi::FromInt(-1); 13238 return Smi::FromInt(-1);
13260 } 13239 }
13261 new_dict->AddNumberEntry(pos, heap->undefined_value(), no_details)-> 13240 new_dict->AddNumberEntry(pos, heap->undefined_value(), no_details)->
13262 ToObjectUnchecked(); 13241 ToObjectUnchecked();
13263 pos++; 13242 pos++;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
13626 MaybeObject* GlobalObject::EnsurePropertyCell(Name* name) { 13605 MaybeObject* GlobalObject::EnsurePropertyCell(Name* name) {
13627 ASSERT(!HasFastProperties()); 13606 ASSERT(!HasFastProperties());
13628 int entry = property_dictionary()->FindEntry(name); 13607 int entry = property_dictionary()->FindEntry(name);
13629 if (entry == NameDictionary::kNotFound) { 13608 if (entry == NameDictionary::kNotFound) {
13630 Heap* heap = GetHeap(); 13609 Heap* heap = GetHeap();
13631 Object* cell; 13610 Object* cell;
13632 { MaybeObject* maybe_cell = 13611 { MaybeObject* maybe_cell =
13633 heap->AllocateJSGlobalPropertyCell(heap->the_hole_value()); 13612 heap->AllocateJSGlobalPropertyCell(heap->the_hole_value());
13634 if (!maybe_cell->ToObject(&cell)) return maybe_cell; 13613 if (!maybe_cell->ToObject(&cell)) return maybe_cell;
13635 } 13614 }
13636 PropertyDetails details(NONE, NORMAL, Representation::None()); 13615 PropertyDetails details(NONE, NORMAL, 0);
13637 details = details.AsDeleted(); 13616 details = details.AsDeleted();
13638 Object* dictionary; 13617 Object* dictionary;
13639 { MaybeObject* maybe_dictionary = 13618 { MaybeObject* maybe_dictionary =
13640 property_dictionary()->Add(name, cell, details); 13619 property_dictionary()->Add(name, cell, details);
13641 if (!maybe_dictionary->ToObject(&dictionary)) return maybe_dictionary; 13620 if (!maybe_dictionary->ToObject(&dictionary)) return maybe_dictionary;
13642 } 13621 }
13643 set_properties(NameDictionary::cast(dictionary)); 13622 set_properties(NameDictionary::cast(dictionary));
13644 return cell; 13623 return cell;
13645 } else { 13624 } else {
13646 Object* value = property_dictionary()->ValueAt(entry); 13625 Object* value = property_dictionary()->ValueAt(entry);
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
14069 } 14048 }
14070 14049
14071 // Update the dictionary with new indices. 14050 // Update the dictionary with new indices.
14072 capacity = HashTable<Shape, Key>::Capacity(); 14051 capacity = HashTable<Shape, Key>::Capacity();
14073 pos = 0; 14052 pos = 0;
14074 for (int i = 0; i < capacity; i++) { 14053 for (int i = 0; i < capacity; i++) {
14075 if (Dictionary<Shape, Key>::IsKey(Dictionary<Shape, Key>::KeyAt(i))) { 14054 if (Dictionary<Shape, Key>::IsKey(Dictionary<Shape, Key>::KeyAt(i))) {
14076 int enum_index = Smi::cast(enumeration_order->get(pos++))->value(); 14055 int enum_index = Smi::cast(enumeration_order->get(pos++))->value();
14077 PropertyDetails details = DetailsAt(i); 14056 PropertyDetails details = DetailsAt(i);
14078 PropertyDetails new_details = PropertyDetails( 14057 PropertyDetails new_details = PropertyDetails(
14079 details.attributes(), details.type(), 14058 details.attributes(), details.type(), enum_index);
14080 Representation::None(), enum_index);
14081 DetailsAtPut(i, new_details); 14059 DetailsAtPut(i, new_details);
14082 } 14060 }
14083 } 14061 }
14084 14062
14085 // Set the next enumeration index. 14063 // Set the next enumeration index.
14086 SetNextEnumerationIndex(PropertyDetails::kInitialIndex+length); 14064 SetNextEnumerationIndex(PropertyDetails::kInitialIndex+length);
14087 return this; 14065 return this;
14088 } 14066 }
14089 14067
14090 template<typename Shape, typename Key> 14068 template<typename Shape, typename Key>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
14136 // Check whether the dictionary should be extended. 14114 // Check whether the dictionary should be extended.
14137 Object* obj; 14115 Object* obj;
14138 { MaybeObject* maybe_obj = EnsureCapacity(1, key); 14116 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
14139 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 14117 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
14140 } 14118 }
14141 14119
14142 Object* k; 14120 Object* k;
14143 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key); 14121 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key);
14144 if (!maybe_k->ToObject(&k)) return maybe_k; 14122 if (!maybe_k->ToObject(&k)) return maybe_k;
14145 } 14123 }
14146 PropertyDetails details = PropertyDetails( 14124 PropertyDetails details = PropertyDetails(NONE, NORMAL, 0);
14147 NONE, NORMAL, Representation::None());
14148 14125
14149 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details, 14126 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details,
14150 Dictionary<Shape, Key>::Hash(key)); 14127 Dictionary<Shape, Key>::Hash(key));
14151 } 14128 }
14152 14129
14153 14130
14154 template<typename Shape, typename Key> 14131 template<typename Shape, typename Key>
14155 MaybeObject* Dictionary<Shape, Key>::Add(Key key, 14132 MaybeObject* Dictionary<Shape, Key>::Add(Key key,
14156 Object* value, 14133 Object* value,
14157 PropertyDetails details) { 14134 PropertyDetails details) {
14158 ASSERT(details.dictionary_index() == details.descriptor_index());
14159
14160 // Valdate key is absent. 14135 // Valdate key is absent.
14161 SLOW_ASSERT((this->FindEntry(key) == Dictionary<Shape, Key>::kNotFound)); 14136 SLOW_ASSERT((this->FindEntry(key) == Dictionary<Shape, Key>::kNotFound));
14162 // Check whether the dictionary should be extended. 14137 // Check whether the dictionary should be extended.
14163 Object* obj; 14138 Object* obj;
14164 { MaybeObject* maybe_obj = EnsureCapacity(1, key); 14139 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
14165 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 14140 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
14166 } 14141 }
14167 14142
14168 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details, 14143 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details,
14169 Dictionary<Shape, Key>::Hash(key)); 14144 Dictionary<Shape, Key>::Hash(key));
(...skipping 13 matching lines...) Expand all
14183 } 14158 }
14184 14159
14185 uint32_t entry = Dictionary<Shape, Key>::FindInsertionEntry(hash); 14160 uint32_t entry = Dictionary<Shape, Key>::FindInsertionEntry(hash);
14186 // Insert element at empty or deleted entry 14161 // Insert element at empty or deleted entry
14187 if (!details.IsDeleted() && 14162 if (!details.IsDeleted() &&
14188 details.dictionary_index() == 0 && 14163 details.dictionary_index() == 0 &&
14189 Shape::kIsEnumerable) { 14164 Shape::kIsEnumerable) {
14190 // Assign an enumeration index to the property and update 14165 // Assign an enumeration index to the property and update
14191 // SetNextEnumerationIndex. 14166 // SetNextEnumerationIndex.
14192 int index = NextEnumerationIndex(); 14167 int index = NextEnumerationIndex();
14193 details = PropertyDetails(details.attributes(), details.type(), 14168 details = PropertyDetails(details.attributes(), details.type(), index);
14194 Representation::None(), index);
14195 SetNextEnumerationIndex(index + 1); 14169 SetNextEnumerationIndex(index + 1);
14196 } 14170 }
14197 SetEntry(entry, k, value, details); 14171 SetEntry(entry, k, value, details);
14198 ASSERT((Dictionary<Shape, Key>::KeyAt(entry)->IsNumber() || 14172 ASSERT((Dictionary<Shape, Key>::KeyAt(entry)->IsNumber() ||
14199 Dictionary<Shape, Key>::KeyAt(entry)->IsName())); 14173 Dictionary<Shape, Key>::KeyAt(entry)->IsName()));
14200 HashTable<Shape, Key>::ElementAdded(); 14174 HashTable<Shape, Key>::ElementAdded();
14201 return this; 14175 return this;
14202 } 14176 }
14203 14177
14204 14178
(...skipping 21 matching lines...) Expand all
14226 PropertyDetails details) { 14200 PropertyDetails details) {
14227 UpdateMaxNumberKey(key); 14201 UpdateMaxNumberKey(key);
14228 SLOW_ASSERT(this->FindEntry(key) == kNotFound); 14202 SLOW_ASSERT(this->FindEntry(key) == kNotFound);
14229 return Add(key, value, details); 14203 return Add(key, value, details);
14230 } 14204 }
14231 14205
14232 14206
14233 MaybeObject* UnseededNumberDictionary::AddNumberEntry(uint32_t key, 14207 MaybeObject* UnseededNumberDictionary::AddNumberEntry(uint32_t key,
14234 Object* value) { 14208 Object* value) {
14235 SLOW_ASSERT(this->FindEntry(key) == kNotFound); 14209 SLOW_ASSERT(this->FindEntry(key) == kNotFound);
14236 return Add(key, value, PropertyDetails(NONE, NORMAL, Representation::None())); 14210 return Add(key, value, PropertyDetails(NONE, NORMAL, 0));
14237 } 14211 }
14238 14212
14239 14213
14240 MaybeObject* SeededNumberDictionary::AtNumberPut(uint32_t key, Object* value) { 14214 MaybeObject* SeededNumberDictionary::AtNumberPut(uint32_t key, Object* value) {
14241 UpdateMaxNumberKey(key); 14215 UpdateMaxNumberKey(key);
14242 return AtPut(key, value); 14216 return AtPut(key, value);
14243 } 14217 }
14244 14218
14245 14219
14246 MaybeObject* UnseededNumberDictionary::AtNumberPut(uint32_t key, 14220 MaybeObject* UnseededNumberDictionary::AtNumberPut(uint32_t key,
(...skipping 24 matching lines...) Expand all
14271 14245
14272 14246
14273 MaybeObject* SeededNumberDictionary::Set(uint32_t key, 14247 MaybeObject* SeededNumberDictionary::Set(uint32_t key,
14274 Object* value, 14248 Object* value,
14275 PropertyDetails details) { 14249 PropertyDetails details) {
14276 int entry = FindEntry(key); 14250 int entry = FindEntry(key);
14277 if (entry == kNotFound) return AddNumberEntry(key, value, details); 14251 if (entry == kNotFound) return AddNumberEntry(key, value, details);
14278 // Preserve enumeration index. 14252 // Preserve enumeration index.
14279 details = PropertyDetails(details.attributes(), 14253 details = PropertyDetails(details.attributes(),
14280 details.type(), 14254 details.type(),
14281 Representation::None(),
14282 DetailsAt(entry).dictionary_index()); 14255 DetailsAt(entry).dictionary_index());
14283 MaybeObject* maybe_object_key = 14256 MaybeObject* maybe_object_key =
14284 SeededNumberDictionaryShape::AsObject(GetHeap(), key); 14257 SeededNumberDictionaryShape::AsObject(GetHeap(), key);
14285 Object* object_key; 14258 Object* object_key;
14286 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; 14259 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
14287 SetEntry(entry, object_key, value, details); 14260 SetEntry(entry, object_key, value, details);
14288 return this; 14261 return this;
14289 } 14262 }
14290 14263
14291 14264
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
14524 if (k->IsSymbol()) { 14497 if (k->IsSymbol()) {
14525 key = Symbol::cast(k); 14498 key = Symbol::cast(k);
14526 } else { 14499 } else {
14527 // Ensure the key is a unique name before writing into the 14500 // Ensure the key is a unique name before writing into the
14528 // instance descriptor. 14501 // instance descriptor.
14529 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k)); 14502 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k));
14530 if (!maybe_key->To(&key)) return maybe_key; 14503 if (!maybe_key->To(&key)) return maybe_key;
14531 } 14504 }
14532 14505
14533 PropertyDetails details = DetailsAt(i); 14506 PropertyDetails details = DetailsAt(i);
14534 ASSERT(details.descriptor_index() == details.dictionary_index()); 14507 int enumeration_index = details.dictionary_index();
14535 int enumeration_index = details.descriptor_index();
14536 PropertyType type = details.type(); 14508 PropertyType type = details.type();
14537 14509
14538 if (value->IsJSFunction()) { 14510 if (value->IsJSFunction()) {
14539 ConstantFunctionDescriptor d(key, 14511 ConstantFunctionDescriptor d(key,
14540 JSFunction::cast(value), 14512 JSFunction::cast(value),
14541 details.attributes(), 14513 details.attributes());
14542 enumeration_index);
14543 descriptors->Set(enumeration_index - 1, &d, witness); 14514 descriptors->Set(enumeration_index - 1, &d, witness);
14544 } else if (type == NORMAL) { 14515 } else if (type == NORMAL) {
14545 if (current_offset < inobject_props) { 14516 if (current_offset < inobject_props) {
14546 obj->InObjectPropertyAtPut(current_offset, 14517 obj->InObjectPropertyAtPut(current_offset,
14547 value, 14518 value,
14548 UPDATE_WRITE_BARRIER); 14519 UPDATE_WRITE_BARRIER);
14549 } else { 14520 } else {
14550 int offset = current_offset - inobject_props; 14521 int offset = current_offset - inobject_props;
14551 fields->set(offset, value); 14522 fields->set(offset, value);
14552 } 14523 }
14553 FieldDescriptor d(key, 14524 FieldDescriptor d(key,
14554 current_offset++, 14525 current_offset++,
14555 details.attributes(), 14526 details.attributes(),
14556 // TODO(verwaest): value->OptimalRepresentation(); 14527 // TODO(verwaest): value->OptimalRepresentation();
14557 Representation::Tagged(), 14528 Representation::Tagged());
14558 enumeration_index);
14559 descriptors->Set(enumeration_index - 1, &d, witness); 14529 descriptors->Set(enumeration_index - 1, &d, witness);
14560 } else if (type == CALLBACKS) { 14530 } else if (type == CALLBACKS) {
14561 CallbacksDescriptor d(key, 14531 CallbacksDescriptor d(key,
14562 value, 14532 value,
14563 details.attributes(), 14533 details.attributes());
14564 enumeration_index);
14565 descriptors->Set(enumeration_index - 1, &d, witness); 14534 descriptors->Set(enumeration_index - 1, &d, witness);
14566 } else { 14535 } else {
14567 UNREACHABLE(); 14536 UNREACHABLE();
14568 } 14537 }
14569 } 14538 }
14570 } 14539 }
14571 ASSERT(current_offset == number_of_fields); 14540 ASSERT(current_offset == number_of_fields);
14572 14541
14573 descriptors->Sort(); 14542 descriptors->Sort();
14574 14543
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
15139 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15108 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15140 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15109 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15141 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15110 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15142 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15111 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15143 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15112 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15144 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15113 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15145 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15114 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15146 } 15115 }
15147 15116
15148 } } // namespace v8::internal 15117 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698