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

Side by Side Diff: src/objects.cc

Issue 249883003: Dictionary::AtPut() 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 14880 matching lines...) Expand 10 before | Expand all | Expand 10 after
14891 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: 14891 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
14892 Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure); 14892 Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure);
14893 14893
14894 template MaybeObject* Dictionary<NameDictionary, NameDictionaryShape, Name*>:: 14894 template MaybeObject* Dictionary<NameDictionary, NameDictionaryShape, Name*>::
14895 Allocate(Heap* heap, int n, PretenureFlag pretenure); 14895 Allocate(Heap* heap, int n, PretenureFlag pretenure);
14896 14896
14897 template Handle<NameDictionary> 14897 template Handle<NameDictionary>
14898 Dictionary<NameDictionary, NameDictionaryShape, Name*>:: 14898 Dictionary<NameDictionary, NameDictionaryShape, Name*>::
14899 New(Isolate* isolate, int n, PretenureFlag pretenure); 14899 New(Isolate* isolate, int n, PretenureFlag pretenure);
14900 14900
14901 template MaybeObject* 14901 template Handle<SeededNumberDictionary>
14902 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 14902 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14903 AtPut(uint32_t, Object*); 14903 AtPut(Handle<SeededNumberDictionary>, uint32_t, Handle<Object>);
14904 14904
14905 template MaybeObject* 14905 template Handle<UnseededNumberDictionary>
14906 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: 14906 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
14907 AtPut(uint32_t, Object*); 14907 AtPut(Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>);
14908 14908
14909 template Object* 14909 template Object*
14910 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 14910 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14911 SlowReverseLookup(Object* value); 14911 SlowReverseLookup(Object* value);
14912 14912
14913 template Object* 14913 template Object*
14914 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: 14914 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
14915 SlowReverseLookup(Object* value); 14915 SlowReverseLookup(Object* value);
14916 14916
14917 template Object* 14917 template Object*
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
15930 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) { 15930 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) {
15931 return heap->false_value(); 15931 return heap->false_value();
15932 } 15932 }
15933 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value()); 15933 SetEntry(entry, heap->the_hole_value(), heap->the_hole_value());
15934 DerivedHashTable::ElementRemoved(); 15934 DerivedHashTable::ElementRemoved();
15935 return heap->true_value(); 15935 return heap->true_value();
15936 } 15936 }
15937 15937
15938 15938
15939 template<typename Derived, typename Shape, typename Key> 15939 template<typename Derived, typename Shape, typename Key>
15940 MaybeObject* Dictionary<Derived, Shape, Key>::AtPut(Key key, Object* value) { 15940 Handle<Derived> Dictionary<Derived, Shape, Key>::AtPut(
15941 int entry = this->FindEntry(key); 15941 Handle<Derived> dictionary, Key key, Handle<Object> value) {
15942 int entry = dictionary->FindEntry(key);
15942 15943
15943 // If the entry is present set the value; 15944 // If the entry is present set the value;
15944 if (entry != Dictionary::kNotFound) { 15945 if (entry != Dictionary::kNotFound) {
15945 ValueAtPut(entry, value); 15946 dictionary->ValueAtPut(entry, *value);
15946 return this; 15947 return dictionary;
15947 } 15948 }
15948 15949
15949 // Check whether the dictionary should be extended. 15950 // Check whether the dictionary should be extended.
15950 Object* obj; 15951 dictionary = EnsureCapacity(dictionary, 1, key);
15951 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
15952 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
15953 }
15954 15952
15955 Object* k; 15953 Handle<Object> k = Shape::AsHandle(dictionary->GetIsolate(), key);
15956 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key); 15954 // TODO(ishell): Figure out if it is necessary to call AsHandle() here.
15957 if (!maybe_k->ToObject(&k)) return maybe_k; 15955 USE(k);
Yang 2014/04/24 06:24:39 Yeah this seems weird to have.
15958 }
15959 PropertyDetails details = PropertyDetails(NONE, NORMAL, 0); 15956 PropertyDetails details = PropertyDetails(NONE, NORMAL, 0);
15960 15957
15961 return Dictionary::cast(obj)->AddEntry( 15958 return AddEntry(dictionary, key, value, details, dictionary->Hash(key));
15962 key, value, details, Dictionary::Hash(key));
15963 } 15959 }
15964 15960
15965 15961
15966 template<typename Derived, typename Shape, typename Key> 15962 template<typename Derived, typename Shape, typename Key>
15967 MaybeObject* Dictionary<Derived, Shape, Key>::Add( 15963 MaybeObject* Dictionary<Derived, Shape, Key>::Add(
15968 Key key, 15964 Key key,
15969 Object* value, 15965 Object* value,
15970 PropertyDetails details) { 15966 PropertyDetails details) {
15971 // Valdate key is absent. 15967 // Valdate key is absent.
15972 SLOW_ASSERT((this->FindEntry(key) == Dictionary::kNotFound)); 15968 SLOW_ASSERT((this->FindEntry(key) == Dictionary::kNotFound));
15973 // Check whether the dictionary should be extended. 15969 // Check whether the dictionary should be extended.
15974 Object* obj; 15970 Object* obj;
15975 { MaybeObject* maybe_obj = EnsureCapacity(1, key); 15971 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
15976 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 15972 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
15977 } 15973 }
15978 15974
15979 return Dictionary::cast(obj)->AddEntry( 15975 return Dictionary::cast(obj)->AddEntry(
15980 key, value, details, Dictionary::Hash(key)); 15976 key, value, details, Dictionary::Hash(key));
15981 } 15977 }
15982 15978
15983 15979
15984 // Add a key, value pair to the dictionary. 15980 // Add a key, value pair to the dictionary.
15985 template<typename Derived, typename Shape, typename Key> 15981 template<typename Derived, typename Shape, typename Key>
15982 Handle<Derived> Dictionary<Derived, Shape, Key>::AddEntry(
15983 Handle<Derived> dictionary,
15984 Key key,
15985 Handle<Object> value,
15986 PropertyDetails details,
15987 uint32_t hash) {
15988 CALL_HEAP_FUNCTION(
15989 dictionary->GetIsolate(),
15990 dictionary->AddEntry(key, *value, details, hash),
15991 Derived);
15992 }
15993
15994 template<typename Derived, typename Shape, typename Key>
15986 MaybeObject* Dictionary<Derived, Shape, Key>::AddEntry( 15995 MaybeObject* Dictionary<Derived, Shape, Key>::AddEntry(
15987 Key key, 15996 Key key,
15988 Object* value, 15997 Object* value,
15989 PropertyDetails details, 15998 PropertyDetails details,
15990 uint32_t hash) { 15999 uint32_t hash) {
15991 // Compute the key object. 16000 // Compute the key object.
15992 Object* k; 16001 Object* k;
15993 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key); 16002 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key);
15994 if (!maybe_k->ToObject(&k)) return maybe_k; 16003 if (!maybe_k->ToObject(&k)) return maybe_k;
15995 } 16004 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
16056 key, *value, PropertyDetails(NONE, NORMAL, 0)), 16065 key, *value, PropertyDetails(NONE, NORMAL, 0)),
16057 UnseededNumberDictionary); 16066 UnseededNumberDictionary);
16058 } 16067 }
16059 16068
16060 16069
16061 Handle<SeededNumberDictionary> SeededNumberDictionary::AtNumberPut( 16070 Handle<SeededNumberDictionary> SeededNumberDictionary::AtNumberPut(
16062 Handle<SeededNumberDictionary> dictionary, 16071 Handle<SeededNumberDictionary> dictionary,
16063 uint32_t key, 16072 uint32_t key,
16064 Handle<Object> value) { 16073 Handle<Object> value) {
16065 dictionary->UpdateMaxNumberKey(key); 16074 dictionary->UpdateMaxNumberKey(key);
16066 CALL_HEAP_FUNCTION( 16075 return AtPut(dictionary, key, value);
16067 dictionary->GetIsolate(),
16068 dictionary->AtPut(key, *value),
16069 SeededNumberDictionary);
16070 } 16076 }
16071 16077
16072 16078
16073 Handle<UnseededNumberDictionary> UnseededNumberDictionary::AtNumberPut( 16079 Handle<UnseededNumberDictionary> UnseededNumberDictionary::AtNumberPut(
16074 Handle<UnseededNumberDictionary> dictionary, 16080 Handle<UnseededNumberDictionary> dictionary,
16075 uint32_t key, 16081 uint32_t key,
16076 Handle<Object> value) { 16082 Handle<Object> value) {
16077 CALL_HEAP_FUNCTION( 16083 return AtPut(dictionary, key, value);
16078 dictionary->GetIsolate(),
16079 dictionary->AtPut(key, *value),
16080 UnseededNumberDictionary);
16081 } 16084 }
16082 16085
16083 16086
16084 Handle<SeededNumberDictionary> SeededNumberDictionary::Set( 16087 Handle<SeededNumberDictionary> SeededNumberDictionary::Set(
16085 Handle<SeededNumberDictionary> dictionary, 16088 Handle<SeededNumberDictionary> dictionary,
16086 uint32_t key, 16089 uint32_t key,
16087 Handle<Object> value, 16090 Handle<Object> value,
16088 PropertyDetails details) { 16091 PropertyDetails details) {
16089 int entry = dictionary->FindEntry(key); 16092 int entry = dictionary->FindEntry(key);
16090 if (entry == kNotFound) { 16093 if (entry == kNotFound) {
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
17419 #define ERROR_MESSAGES_TEXTS(C, T) T, 17422 #define ERROR_MESSAGES_TEXTS(C, T) T,
17420 static const char* error_messages_[] = { 17423 static const char* error_messages_[] = {
17421 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17424 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17422 }; 17425 };
17423 #undef ERROR_MESSAGES_TEXTS 17426 #undef ERROR_MESSAGES_TEXTS
17424 return error_messages_[reason]; 17427 return error_messages_[reason];
17425 } 17428 }
17426 17429
17427 17430
17428 } } // namespace v8::internal 17431 } } // 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