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

Side by Side Diff: src/objects.cc

Issue 12764003: Added an Isolate parameter to some HashTable/Dictionary methods. TypeFeedbackOracle tweaks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: TypeFeedbackOracle Created 7 years, 9 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/objects.h ('k') | src/objects-inl.h » ('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 3707 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 3718
3719 // Allocate new content. 3719 // Allocate new content.
3720 int real_size = map_of_this->NumberOfOwnDescriptors(); 3720 int real_size = map_of_this->NumberOfOwnDescriptors();
3721 int property_count = real_size; 3721 int property_count = real_size;
3722 if (expected_additional_properties > 0) { 3722 if (expected_additional_properties > 0) {
3723 property_count += expected_additional_properties; 3723 property_count += expected_additional_properties;
3724 } else { 3724 } else {
3725 property_count += 2; // Make space for two more properties. 3725 property_count += 2; // Make space for two more properties.
3726 } 3726 }
3727 NameDictionary* dictionary; 3727 NameDictionary* dictionary;
3728 MaybeObject* maybe_dictionary = NameDictionary::Allocate(property_count); 3728 MaybeObject* maybe_dictionary =
3729 NameDictionary::Allocate(GetHeap(), property_count);
3729 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; 3730 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
3730 3731
3731 DescriptorArray* descs = map_of_this->instance_descriptors(); 3732 DescriptorArray* descs = map_of_this->instance_descriptors();
3732 for (int i = 0; i < real_size; i++) { 3733 for (int i = 0; i < real_size; i++) {
3733 PropertyDetails details = descs->GetDetails(i); 3734 PropertyDetails details = descs->GetDetails(i);
3734 switch (details.type()) { 3735 switch (details.type()) {
3735 case CONSTANT_FUNCTION: { 3736 case CONSTANT_FUNCTION: {
3736 PropertyDetails d = PropertyDetails(details.attributes(), 3737 PropertyDetails d = PropertyDetails(details.attributes(),
3737 NORMAL, 3738 NORMAL,
3738 details.descriptor_index()); 3739 details.descriptor_index());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3856 HasFastArgumentsElements()); 3857 HasFastArgumentsElements());
3857 // Compute the effective length and allocate a new backing store. 3858 // Compute the effective length and allocate a new backing store.
3858 int length = IsJSArray() 3859 int length = IsJSArray()
3859 ? Smi::cast(JSArray::cast(this)->length())->value() 3860 ? Smi::cast(JSArray::cast(this)->length())->value()
3860 : array->length(); 3861 : array->length();
3861 int old_capacity = 0; 3862 int old_capacity = 0;
3862 int used_elements = 0; 3863 int used_elements = 0;
3863 GetElementsCapacityAndUsage(&old_capacity, &used_elements); 3864 GetElementsCapacityAndUsage(&old_capacity, &used_elements);
3864 SeededNumberDictionary* dictionary = NULL; 3865 SeededNumberDictionary* dictionary = NULL;
3865 { Object* object; 3866 { Object* object;
3866 MaybeObject* maybe = SeededNumberDictionary::Allocate(used_elements); 3867 MaybeObject* maybe =
3868 SeededNumberDictionary::Allocate(GetHeap(), used_elements);
3867 if (!maybe->ToObject(&object)) return maybe; 3869 if (!maybe->ToObject(&object)) return maybe;
3868 dictionary = SeededNumberDictionary::cast(object); 3870 dictionary = SeededNumberDictionary::cast(object);
3869 } 3871 }
3870 3872
3871 // Copy the elements to the new backing store. 3873 // Copy the elements to the new backing store.
3872 bool has_double_elements = array->IsFixedDoubleArray(); 3874 bool has_double_elements = array->IsFixedDoubleArray();
3873 for (int i = 0; i < length; i++) { 3875 for (int i = 0; i < length; i++) {
3874 Object* value = NULL; 3876 Object* value = NULL;
3875 if (has_double_elements) { 3877 if (has_double_elements) {
3876 FixedDoubleArray* double_array = FixedDoubleArray::cast(array); 3878 FixedDoubleArray* double_array = FixedDoubleArray::cast(array);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 } 4144 }
4143 4145
4144 if (init_option == ONLY_RETURN_INLINE_VALUE || 4146 if (init_option == ONLY_RETURN_INLINE_VALUE ||
4145 inline_value->IsHashTable()) { 4147 inline_value->IsHashTable()) {
4146 return inline_value; 4148 return inline_value;
4147 } 4149 }
4148 4150
4149 ObjectHashTable* hashtable; 4151 ObjectHashTable* hashtable;
4150 static const int kInitialCapacity = 4; 4152 static const int kInitialCapacity = 4;
4151 MaybeObject* maybe_obj = 4153 MaybeObject* maybe_obj =
4152 ObjectHashTable::Allocate(kInitialCapacity, 4154 ObjectHashTable::Allocate(GetHeap(),
4155 kInitialCapacity,
4153 ObjectHashTable::USE_CUSTOM_MINIMUM_CAPACITY); 4156 ObjectHashTable::USE_CUSTOM_MINIMUM_CAPACITY);
4154 if (!maybe_obj->To<ObjectHashTable>(&hashtable)) return maybe_obj; 4157 if (!maybe_obj->To<ObjectHashTable>(&hashtable)) return maybe_obj;
4155 4158
4156 if (inline_value->IsSmi()) { 4159 if (inline_value->IsSmi()) {
4157 // We were storing the identity hash inline and now allocated an actual 4160 // We were storing the identity hash inline and now allocated an actual
4158 // dictionary. Put the identity hash into the new dictionary. 4161 // dictionary. Put the identity hash into the new dictionary.
4159 MaybeObject* insert_result = 4162 MaybeObject* insert_result =
4160 hashtable->Put(GetHeap()->identity_hash_string(), inline_value); 4163 hashtable->Put(GetHeap()->identity_hash_string(), inline_value);
4161 ObjectHashTable* new_table; 4164 ObjectHashTable* new_table;
4162 if (!insert_result->To(&new_table)) return insert_result; 4165 if (!insert_result->To(&new_table)) return insert_result;
(...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after
6029 6032
6030 MaybeObject* CodeCache::Update(Name* name, Code* code) { 6033 MaybeObject* CodeCache::Update(Name* name, Code* code) {
6031 // The number of monomorphic stubs for normal load/store/call IC's can grow to 6034 // The number of monomorphic stubs for normal load/store/call IC's can grow to
6032 // a large number and therefore they need to go into a hash table. They are 6035 // a large number and therefore they need to go into a hash table. They are
6033 // used to load global properties from cells. 6036 // used to load global properties from cells.
6034 if (code->type() == Code::NORMAL) { 6037 if (code->type() == Code::NORMAL) {
6035 // Make sure that a hash table is allocated for the normal load code cache. 6038 // Make sure that a hash table is allocated for the normal load code cache.
6036 if (normal_type_cache()->IsUndefined()) { 6039 if (normal_type_cache()->IsUndefined()) {
6037 Object* result; 6040 Object* result;
6038 { MaybeObject* maybe_result = 6041 { MaybeObject* maybe_result =
6039 CodeCacheHashTable::Allocate(CodeCacheHashTable::kInitialSize); 6042 CodeCacheHashTable::Allocate(GetHeap(),
6043 CodeCacheHashTable::kInitialSize);
6040 if (!maybe_result->ToObject(&result)) return maybe_result; 6044 if (!maybe_result->ToObject(&result)) return maybe_result;
6041 } 6045 }
6042 set_normal_type_cache(result); 6046 set_normal_type_cache(result);
6043 } 6047 }
6044 return UpdateNormalTypeCache(name, code); 6048 return UpdateNormalTypeCache(name, code);
6045 } else { 6049 } else {
6046 ASSERT(default_cache()->IsFixedArray()); 6050 ASSERT(default_cache()->IsFixedArray());
6047 return UpdateDefaultCache(name, code); 6051 return UpdateDefaultCache(name, code);
6048 } 6052 }
6049 } 6053 }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
6310 6314
6311 6315
6312 MaybeObject* PolymorphicCodeCache::Update(MapHandleList* maps, 6316 MaybeObject* PolymorphicCodeCache::Update(MapHandleList* maps,
6313 Code::Flags flags, 6317 Code::Flags flags,
6314 Code* code) { 6318 Code* code) {
6315 // Initialize cache if necessary. 6319 // Initialize cache if necessary.
6316 if (cache()->IsUndefined()) { 6320 if (cache()->IsUndefined()) {
6317 Object* result; 6321 Object* result;
6318 { MaybeObject* maybe_result = 6322 { MaybeObject* maybe_result =
6319 PolymorphicCodeCacheHashTable::Allocate( 6323 PolymorphicCodeCacheHashTable::Allocate(
6324 GetHeap(),
6320 PolymorphicCodeCacheHashTable::kInitialSize); 6325 PolymorphicCodeCacheHashTable::kInitialSize);
6321 if (!maybe_result->ToObject(&result)) return maybe_result; 6326 if (!maybe_result->ToObject(&result)) return maybe_result;
6322 } 6327 }
6323 set_cache(result); 6328 set_cache(result);
6324 } else { 6329 } else {
6325 // This entry shouldn't be contained in the cache yet. 6330 // This entry shouldn't be contained in the cache yet.
6326 ASSERT(PolymorphicCodeCacheHashTable::cast(cache()) 6331 ASSERT(PolymorphicCodeCacheHashTable::cast(cache())
6327 ->Lookup(maps, flags)->IsUndefined()); 6332 ->Lookup(maps, flags)->IsUndefined());
6328 } 6333 }
6329 PolymorphicCodeCacheHashTable* hash_table = 6334 PolymorphicCodeCacheHashTable* hash_table =
(...skipping 5736 matching lines...) Expand 10 before | Expand all | Expand 10 after
12066 12071
12067 template<typename Shape, typename Key> 12072 template<typename Shape, typename Key>
12068 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) { 12073 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) {
12069 IteratePointers(v, 12074 IteratePointers(v,
12070 kElementsStartOffset, 12075 kElementsStartOffset,
12071 kHeaderSize + length() * kPointerSize); 12076 kHeaderSize + length() * kPointerSize);
12072 } 12077 }
12073 12078
12074 12079
12075 template<typename Shape, typename Key> 12080 template<typename Shape, typename Key>
12076 MaybeObject* HashTable<Shape, Key>::Allocate(int at_least_space_for, 12081 MaybeObject* HashTable<Shape, Key>::Allocate(Heap* heap,
12082 int at_least_space_for,
12077 MinimumCapacity capacity_option, 12083 MinimumCapacity capacity_option,
12078 PretenureFlag pretenure) { 12084 PretenureFlag pretenure) {
12079 ASSERT(!capacity_option || IS_POWER_OF_TWO(at_least_space_for)); 12085 ASSERT(!capacity_option || IS_POWER_OF_TWO(at_least_space_for));
12080 int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY) 12086 int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
12081 ? at_least_space_for 12087 ? at_least_space_for
12082 : ComputeCapacity(at_least_space_for); 12088 : ComputeCapacity(at_least_space_for);
12083 if (capacity > HashTable::kMaxCapacity) { 12089 if (capacity > HashTable::kMaxCapacity) {
12084 return Failure::OutOfMemoryException(0x10); 12090 return Failure::OutOfMemoryException(0x10);
12085 } 12091 }
12086 12092
12087 Object* obj; 12093 Object* obj;
12088 { MaybeObject* maybe_obj = Isolate::Current()->heap()-> 12094 { MaybeObject* maybe_obj =
12089 AllocateHashTable(EntryToIndex(capacity), pretenure); 12095 heap-> AllocateHashTable(EntryToIndex(capacity), pretenure);
12090 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 12096 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
12091 } 12097 }
12092 HashTable::cast(obj)->SetNumberOfElements(0); 12098 HashTable::cast(obj)->SetNumberOfElements(0);
12093 HashTable::cast(obj)->SetNumberOfDeletedElements(0); 12099 HashTable::cast(obj)->SetNumberOfDeletedElements(0);
12094 HashTable::cast(obj)->SetCapacity(capacity); 12100 HashTable::cast(obj)->SetCapacity(capacity);
12095 return obj; 12101 return obj;
12096 } 12102 }
12097 12103
12098 12104
12099 // Find entry for key otherwise return kNotFound. 12105 // Find entry for key otherwise return kNotFound.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
12181 if (nod <= (capacity - nof) >> 1) { 12187 if (nod <= (capacity - nof) >> 1) {
12182 int needed_free = nof >> 1; 12188 int needed_free = nof >> 1;
12183 if (nof + needed_free <= capacity) return this; 12189 if (nof + needed_free <= capacity) return this;
12184 } 12190 }
12185 12191
12186 const int kMinCapacityForPretenure = 256; 12192 const int kMinCapacityForPretenure = 256;
12187 bool pretenure = 12193 bool pretenure =
12188 (capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this); 12194 (capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this);
12189 Object* obj; 12195 Object* obj;
12190 { MaybeObject* maybe_obj = 12196 { MaybeObject* maybe_obj =
12191 Allocate(nof * 2, 12197 Allocate(GetHeap(),
12198 nof * 2,
12192 USE_DEFAULT_MINIMUM_CAPACITY, 12199 USE_DEFAULT_MINIMUM_CAPACITY,
12193 pretenure ? TENURED : NOT_TENURED); 12200 pretenure ? TENURED : NOT_TENURED);
12194 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 12201 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
12195 } 12202 }
12196 12203
12197 return Rehash(HashTable::cast(obj), key); 12204 return Rehash(HashTable::cast(obj), key);
12198 } 12205 }
12199 12206
12200 12207
12201 template<typename Shape, typename Key> 12208 template<typename Shape, typename Key>
(...skipping 10 matching lines...) Expand all
12212 // lower than room for 16 elements. 12219 // lower than room for 16 elements.
12213 int at_least_room_for = nof; 12220 int at_least_room_for = nof;
12214 if (at_least_room_for < 16) return this; 12221 if (at_least_room_for < 16) return this;
12215 12222
12216 const int kMinCapacityForPretenure = 256; 12223 const int kMinCapacityForPretenure = 256;
12217 bool pretenure = 12224 bool pretenure =
12218 (at_least_room_for > kMinCapacityForPretenure) && 12225 (at_least_room_for > kMinCapacityForPretenure) &&
12219 !GetHeap()->InNewSpace(this); 12226 !GetHeap()->InNewSpace(this);
12220 Object* obj; 12227 Object* obj;
12221 { MaybeObject* maybe_obj = 12228 { MaybeObject* maybe_obj =
12222 Allocate(at_least_room_for, 12229 Allocate(GetHeap(),
12230 at_least_room_for,
12223 USE_DEFAULT_MINIMUM_CAPACITY, 12231 USE_DEFAULT_MINIMUM_CAPACITY,
12224 pretenure ? TENURED : NOT_TENURED); 12232 pretenure ? TENURED : NOT_TENURED);
12225 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 12233 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
12226 } 12234 }
12227 12235
12228 return Rehash(HashTable::cast(obj), key); 12236 return Rehash(HashTable::cast(obj), key);
12229 } 12237 }
12230 12238
12231 12239
12232 template<typename Shape, typename Key> 12240 template<typename Shape, typename Key>
(...skipping 23 matching lines...) Expand all
12256 12264
12257 template class HashTable<ObjectHashTableShape<2>, Object*>; 12265 template class HashTable<ObjectHashTableShape<2>, Object*>;
12258 12266
12259 template class Dictionary<NameDictionaryShape, Name*>; 12267 template class Dictionary<NameDictionaryShape, Name*>;
12260 12268
12261 template class Dictionary<SeededNumberDictionaryShape, uint32_t>; 12269 template class Dictionary<SeededNumberDictionaryShape, uint32_t>;
12262 12270
12263 template class Dictionary<UnseededNumberDictionaryShape, uint32_t>; 12271 template class Dictionary<UnseededNumberDictionaryShape, uint32_t>;
12264 12272
12265 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>:: 12273 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::
12266 Allocate(int at_least_space_for); 12274 Allocate(Heap* heap, int at_least_space_for);
12267 12275
12268 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>:: 12276 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>::
12269 Allocate(int at_least_space_for); 12277 Allocate(Heap* heap, int at_least_space_for);
12270 12278
12271 template MaybeObject* Dictionary<NameDictionaryShape, Name*>::Allocate(int n); 12279 template MaybeObject* Dictionary<NameDictionaryShape, Name*>::
12280 Allocate(Heap* heap, int n);
12272 12281
12273 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::AtPut( 12282 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>::AtPut(
12274 uint32_t, Object*); 12283 uint32_t, Object*);
12275 12284
12276 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>:: 12285 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>::
12277 AtPut(uint32_t, Object*); 12286 AtPut(uint32_t, Object*);
12278 12287
12279 template Object* Dictionary<SeededNumberDictionaryShape, uint32_t>:: 12288 template Object* Dictionary<SeededNumberDictionaryShape, uint32_t>::
12280 SlowReverseLookup(Object* value); 12289 SlowReverseLookup(Object* value);
12281 12290
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
12367 // Allocate space for result before we start mutating the object. 12376 // Allocate space for result before we start mutating the object.
12368 Object* new_double; 12377 Object* new_double;
12369 { MaybeObject* maybe_new_double = GetHeap()->AllocateHeapNumber(0.0); 12378 { MaybeObject* maybe_new_double = GetHeap()->AllocateHeapNumber(0.0);
12370 if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double; 12379 if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double;
12371 } 12380 }
12372 result_double = HeapNumber::cast(new_double); 12381 result_double = HeapNumber::cast(new_double);
12373 } 12382 }
12374 12383
12375 Object* obj; 12384 Object* obj;
12376 { MaybeObject* maybe_obj = 12385 { MaybeObject* maybe_obj =
12377 SeededNumberDictionary::Allocate(dict->NumberOfElements()); 12386 SeededNumberDictionary::Allocate(GetHeap(), dict->NumberOfElements());
12378 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 12387 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
12379 } 12388 }
12380 SeededNumberDictionary* new_dict = SeededNumberDictionary::cast(obj); 12389 SeededNumberDictionary* new_dict = SeededNumberDictionary::cast(obj);
12381 12390
12382 AssertNoAllocation no_alloc; 12391 AssertNoAllocation no_alloc;
12383 12392
12384 uint32_t pos = 0; 12393 uint32_t pos = 0;
12385 uint32_t undefs = 0; 12394 uint32_t undefs = 0;
12386 int capacity = dict->Capacity(); 12395 int capacity = dict->Capacity();
12387 for (int i = 0; i < capacity; i++) { 12396 for (int i = 0; i < capacity; i++) {
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
13151 MapCache* cache = reinterpret_cast<MapCache*>(obj); 13160 MapCache* cache = reinterpret_cast<MapCache*>(obj);
13152 int entry = cache->FindInsertionEntry(key.Hash()); 13161 int entry = cache->FindInsertionEntry(key.Hash());
13153 cache->set(EntryToIndex(entry), array); 13162 cache->set(EntryToIndex(entry), array);
13154 cache->set(EntryToIndex(entry) + 1, value); 13163 cache->set(EntryToIndex(entry) + 1, value);
13155 cache->ElementAdded(); 13164 cache->ElementAdded();
13156 return cache; 13165 return cache;
13157 } 13166 }
13158 13167
13159 13168
13160 template<typename Shape, typename Key> 13169 template<typename Shape, typename Key>
13161 MaybeObject* Dictionary<Shape, Key>::Allocate(int at_least_space_for) { 13170 MaybeObject* Dictionary<Shape, Key>::Allocate(Heap* heap,
13171 int at_least_space_for) {
13162 Object* obj; 13172 Object* obj;
13163 { MaybeObject* maybe_obj = 13173 { MaybeObject* maybe_obj =
13164 HashTable<Shape, Key>::Allocate(at_least_space_for); 13174 HashTable<Shape, Key>::Allocate(heap, at_least_space_for);
13165 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 13175 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
13166 } 13176 }
13167 // Initialize the next enumeration index. 13177 // Initialize the next enumeration index.
13168 Dictionary<Shape, Key>::cast(obj)-> 13178 Dictionary<Shape, Key>::cast(obj)->
13169 SetNextEnumerationIndex(PropertyDetails::kInitialIndex); 13179 SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
13170 return obj; 13180 return obj;
13171 } 13181 }
13172 13182
13173 13183
13174 void NameDictionary::DoGenerateNewEnumerationIndices( 13184 void NameDictionary::DoGenerateNewEnumerationIndices(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
13282 return this; 13292 return this;
13283 } 13293 }
13284 13294
13285 // Check whether the dictionary should be extended. 13295 // Check whether the dictionary should be extended.
13286 Object* obj; 13296 Object* obj;
13287 { MaybeObject* maybe_obj = EnsureCapacity(1, key); 13297 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
13288 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 13298 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
13289 } 13299 }
13290 13300
13291 Object* k; 13301 Object* k;
13292 { MaybeObject* maybe_k = Shape::AsObject(key); 13302 { MaybeObject* maybe_k = Shape::AsObject(this->GetIsolate(), key);
13293 if (!maybe_k->ToObject(&k)) return maybe_k; 13303 if (!maybe_k->ToObject(&k)) return maybe_k;
13294 } 13304 }
13295 PropertyDetails details = PropertyDetails(NONE, NORMAL); 13305 PropertyDetails details = PropertyDetails(NONE, NORMAL);
13296 13306
13297 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details, 13307 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details,
13298 Dictionary<Shape, Key>::Hash(key)); 13308 Dictionary<Shape, Key>::Hash(key));
13299 } 13309 }
13300 13310
13301 13311
13302 template<typename Shape, typename Key> 13312 template<typename Shape, typename Key>
(...skipping 16 matching lines...) Expand all
13319 13329
13320 13330
13321 // Add a key, value pair to the dictionary. 13331 // Add a key, value pair to the dictionary.
13322 template<typename Shape, typename Key> 13332 template<typename Shape, typename Key>
13323 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key, 13333 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key,
13324 Object* value, 13334 Object* value,
13325 PropertyDetails details, 13335 PropertyDetails details,
13326 uint32_t hash) { 13336 uint32_t hash) {
13327 // Compute the key object. 13337 // Compute the key object.
13328 Object* k; 13338 Object* k;
13329 { MaybeObject* maybe_k = Shape::AsObject(key); 13339 { MaybeObject* maybe_k = Shape::AsObject(this->GetIsolate(), key);
13330 if (!maybe_k->ToObject(&k)) return maybe_k; 13340 if (!maybe_k->ToObject(&k)) return maybe_k;
13331 } 13341 }
13332 13342
13333 uint32_t entry = Dictionary<Shape, Key>::FindInsertionEntry(hash); 13343 uint32_t entry = Dictionary<Shape, Key>::FindInsertionEntry(hash);
13334 // Insert element at empty or deleted entry 13344 // Insert element at empty or deleted entry
13335 if (!details.IsDeleted() && 13345 if (!details.IsDeleted() &&
13336 details.dictionary_index() == 0 && 13346 details.dictionary_index() == 0 &&
13337 Shape::kIsEnumerable) { 13347 Shape::kIsEnumerable) {
13338 // Assign an enumeration index to the property and update 13348 // Assign an enumeration index to the property and update
13339 // SetNextEnumerationIndex. 13349 // SetNextEnumerationIndex.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
13419 13429
13420 MaybeObject* SeededNumberDictionary::Set(uint32_t key, 13430 MaybeObject* SeededNumberDictionary::Set(uint32_t key,
13421 Object* value, 13431 Object* value,
13422 PropertyDetails details) { 13432 PropertyDetails details) {
13423 int entry = FindEntry(key); 13433 int entry = FindEntry(key);
13424 if (entry == kNotFound) return AddNumberEntry(key, value, details); 13434 if (entry == kNotFound) return AddNumberEntry(key, value, details);
13425 // Preserve enumeration index. 13435 // Preserve enumeration index.
13426 details = PropertyDetails(details.attributes(), 13436 details = PropertyDetails(details.attributes(),
13427 details.type(), 13437 details.type(),
13428 DetailsAt(entry).dictionary_index()); 13438 DetailsAt(entry).dictionary_index());
13429 MaybeObject* maybe_object_key = SeededNumberDictionaryShape::AsObject(key); 13439 MaybeObject* maybe_object_key =
13440 SeededNumberDictionaryShape::AsObject(GetIsolate(), key);
13430 Object* object_key; 13441 Object* object_key;
13431 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; 13442 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
13432 SetEntry(entry, object_key, value, details); 13443 SetEntry(entry, object_key, value, details);
13433 return this; 13444 return this;
13434 } 13445 }
13435 13446
13436 13447
13437 MaybeObject* UnseededNumberDictionary::Set(uint32_t key, 13448 MaybeObject* UnseededNumberDictionary::Set(uint32_t key,
13438 Object* value) { 13449 Object* value) {
13439 int entry = FindEntry(key); 13450 int entry = FindEntry(key);
13440 if (entry == kNotFound) return AddNumberEntry(key, value); 13451 if (entry == kNotFound) return AddNumberEntry(key, value);
13441 MaybeObject* maybe_object_key = UnseededNumberDictionaryShape::AsObject(key); 13452 MaybeObject* maybe_object_key =
13453 UnseededNumberDictionaryShape::AsObject(GetIsolate(), key);
13442 Object* object_key; 13454 Object* object_key;
13443 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; 13455 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
13444 SetEntry(entry, object_key, value); 13456 SetEntry(entry, object_key, value);
13445 return this; 13457 return this;
13446 } 13458 }
13447 13459
13448 13460
13449 13461
13450 template<typename Shape, typename Key> 13462 template<typename Shape, typename Key>
13451 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( 13463 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes(
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
14279 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 14291 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
14280 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 14292 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
14281 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 14293 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
14282 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 14294 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
14283 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 14295 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
14284 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 14296 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
14285 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 14297 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
14286 } 14298 }
14287 14299
14288 } } // namespace v8::internal 14300 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698