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

Side by Side Diff: src/objects.cc

Issue 249973002: *NumberDictionary::Set() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 16039 matching lines...) Expand 10 before | Expand all | Expand 10 after
16050 } 16050 }
16051 16051
16052 16052
16053 MaybeObject* UnseededNumberDictionary::AddNumberEntry(uint32_t key, 16053 MaybeObject* UnseededNumberDictionary::AddNumberEntry(uint32_t key,
16054 Object* value) { 16054 Object* value) {
16055 SLOW_ASSERT(this->FindEntry(key) == kNotFound); 16055 SLOW_ASSERT(this->FindEntry(key) == kNotFound);
16056 return Add(key, value, PropertyDetails(NONE, NORMAL, 0)); 16056 return Add(key, value, PropertyDetails(NONE, NORMAL, 0));
16057 } 16057 }
16058 16058
16059 16059
16060 Handle<UnseededNumberDictionary> UnseededNumberDictionary::AddNumberEntry(
16061 Handle<UnseededNumberDictionary> dictionary,
16062 uint32_t key,
16063 Handle<Object> value) {
16064 CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
16065 dictionary->AddNumberEntry(key, *value),
16066 UnseededNumberDictionary);
16067 }
16068
16069
16060 MaybeObject* SeededNumberDictionary::AtNumberPut(uint32_t key, Object* value) { 16070 MaybeObject* SeededNumberDictionary::AtNumberPut(uint32_t key, Object* value) {
16061 UpdateMaxNumberKey(key); 16071 UpdateMaxNumberKey(key);
16062 return AtPut(key, value); 16072 return AtPut(key, value);
16063 } 16073 }
16064 16074
16065 16075
16066 MaybeObject* UnseededNumberDictionary::AtNumberPut(uint32_t key, 16076 MaybeObject* UnseededNumberDictionary::AtNumberPut(uint32_t key,
16067 Object* value) { 16077 Object* value) {
16068 return AtPut(key, value); 16078 return AtPut(key, value);
16069 } 16079 }
16070 16080
16071 16081
16072 Handle<SeededNumberDictionary> SeededNumberDictionary::Set( 16082 Handle<SeededNumberDictionary> SeededNumberDictionary::Set(
16073 Handle<SeededNumberDictionary> dictionary, 16083 Handle<SeededNumberDictionary> dictionary,
16074 uint32_t index, 16084 uint32_t key,
16075 Handle<Object> value, 16085 Handle<Object> value,
16076 PropertyDetails details) { 16086 PropertyDetails details) {
16077 CALL_HEAP_FUNCTION(dictionary->GetIsolate(), 16087 int entry = dictionary->FindEntry(key);
16078 dictionary->Set(index, *value, details), 16088 if (entry == kNotFound) {
16079 SeededNumberDictionary); 16089 return AddNumberEntry(dictionary, key, value, details);
16090 }
16091 // Preserve enumeration index.
16092 details = PropertyDetails(details.attributes(),
16093 details.type(),
16094 dictionary->DetailsAt(entry).dictionary_index());
16095 Handle<Object> object_key =
16096 SeededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
16097 dictionary->SetEntry(entry, *object_key, *value, details);
16098 return dictionary;
16080 } 16099 }
16081 16100
16082 16101
16083 Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set( 16102 Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set(
16084 Handle<UnseededNumberDictionary> dictionary, 16103 Handle<UnseededNumberDictionary> dictionary,
16085 uint32_t index, 16104 uint32_t key,
16086 Handle<Object> value) { 16105 Handle<Object> value) {
16087 CALL_HEAP_FUNCTION(dictionary->GetIsolate(), 16106 int entry = dictionary->FindEntry(key);
16088 dictionary->Set(index, *value), 16107 if (entry == kNotFound) return AddNumberEntry(dictionary, key, value);
16089 UnseededNumberDictionary); 16108 Handle<Object> object_key =
16109 UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
16110 dictionary->SetEntry(entry, *object_key, *value);
16111 return dictionary;
16090 } 16112 }
16091 16113
16092 16114
16093 MaybeObject* SeededNumberDictionary::Set(uint32_t key,
16094 Object* value,
16095 PropertyDetails details) {
16096 int entry = FindEntry(key);
16097 if (entry == kNotFound) return AddNumberEntry(key, value, details);
16098 // Preserve enumeration index.
16099 details = PropertyDetails(details.attributes(),
16100 details.type(),
16101 DetailsAt(entry).dictionary_index());
16102 MaybeObject* maybe_object_key =
16103 SeededNumberDictionaryShape::AsObject(GetHeap(), key);
16104 Object* object_key;
16105 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
16106 SetEntry(entry, object_key, value, details);
16107 return this;
16108 }
16109
16110
16111 MaybeObject* UnseededNumberDictionary::Set(uint32_t key,
16112 Object* value) {
16113 int entry = FindEntry(key);
16114 if (entry == kNotFound) return AddNumberEntry(key, value);
16115 MaybeObject* maybe_object_key =
16116 UnseededNumberDictionaryShape::AsObject(GetHeap(), key);
16117 Object* object_key;
16118 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
16119 SetEntry(entry, object_key, value);
16120 return this;
16121 }
16122
16123
16124 16115
16125 template<typename Derived, typename Shape, typename Key> 16116 template<typename Derived, typename Shape, typename Key>
16126 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes( 16117 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes(
16127 PropertyAttributes filter) { 16118 PropertyAttributes filter) {
16128 int capacity = DerivedHashTable::Capacity(); 16119 int capacity = DerivedHashTable::Capacity();
16129 int result = 0; 16120 int result = 0;
16130 for (int i = 0; i < capacity; i++) { 16121 for (int i = 0; i < capacity; i++) {
16131 Object* k = DerivedHashTable::KeyAt(i); 16122 Object* k = DerivedHashTable::KeyAt(i);
16132 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) { 16123 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) {
16133 PropertyDetails details = DetailsAt(i); 16124 PropertyDetails details = DetailsAt(i);
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
17426 #define ERROR_MESSAGES_TEXTS(C, T) T, 17417 #define ERROR_MESSAGES_TEXTS(C, T) T,
17427 static const char* error_messages_[] = { 17418 static const char* error_messages_[] = {
17428 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17419 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17429 }; 17420 };
17430 #undef ERROR_MESSAGES_TEXTS 17421 #undef ERROR_MESSAGES_TEXTS
17431 return error_messages_[reason]; 17422 return error_messages_[reason];
17432 } 17423 }
17433 17424
17434 17425
17435 } } // namespace v8::internal 17426 } } // 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