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

Side by Side Diff: src/objects.h

Issue 309663005: Split Put into Put and Remove (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.cc » ('j') | src/runtime.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include "allocation.h" 8 #include "allocation.h"
9 #include "assert-scope.h" 9 #include "assert-scope.h"
10 #include "builtins.h" 10 #include "builtins.h"
(...skipping 4116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 4127
4128 // Attempt to shrink hash table after removal of key. 4128 // Attempt to shrink hash table after removal of key.
4129 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( 4129 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink(
4130 Handle<ObjectHashTable> table, 4130 Handle<ObjectHashTable> table,
4131 Handle<Object> key); 4131 Handle<Object> key);
4132 4132
4133 // Looks up the value associated with the given key. The hole value is 4133 // Looks up the value associated with the given key. The hole value is
4134 // returned in case the key is not present. 4134 // returned in case the key is not present.
4135 Object* Lookup(Handle<Object> key); 4135 Object* Lookup(Handle<Object> key);
4136 4136
4137 // Adds (or overwrites) the value associated with the given key. Mapping a 4137 // Adds (or overwrites) the value associated with the given key.
4138 // key to the hole value causes removal of the whole entry.
4139 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, 4138 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
4140 Handle<Object> key, 4139 Handle<Object> key,
4141 Handle<Object> value); 4140 Handle<Object> value);
4142 4141
4142 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed.
4143 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table,
arv (Not doing code reviews) 2014/05/30 18:47:08 I wasn't sure if I should add a `bool* was_present
4144 Handle<Object> key);
4145
4143 private: 4146 private:
4144 friend class MarkCompactCollector; 4147 friend class MarkCompactCollector;
4145 4148
4146 void AddEntry(int entry, Object* key, Object* value); 4149 void AddEntry(int entry, Object* key, Object* value);
4147 void RemoveEntry(int entry); 4150 void RemoveEntry(int entry);
4148 4151
4149 // Returns the index to the value of an entry. 4152 // Returns the index to the value of an entry.
4150 static inline int EntryToValueIndex(int entry) { 4153 static inline int EntryToValueIndex(int entry) {
4151 return EntryToIndex(entry) + 1; 4154 return EntryToIndex(entry) + 1;
4152 } 4155 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4197 Isolate* isolate, int capacity, PretenureFlag pretenure = NOT_TENURED); 4200 Isolate* isolate, int capacity, PretenureFlag pretenure = NOT_TENURED);
4198 4201
4199 // Returns an OrderedHashTable (possibly |table|) with enough space 4202 // Returns an OrderedHashTable (possibly |table|) with enough space
4200 // to add at least one new element. 4203 // to add at least one new element.
4201 static Handle<Derived> EnsureGrowable(Handle<Derived> table); 4204 static Handle<Derived> EnsureGrowable(Handle<Derived> table);
4202 4205
4203 // Returns an OrderedHashTable (possibly |table|) that's shrunken 4206 // Returns an OrderedHashTable (possibly |table|) that's shrunken
4204 // if possible. 4207 // if possible.
4205 static Handle<Derived> Shrink(Handle<Derived> table); 4208 static Handle<Derived> Shrink(Handle<Derived> table);
4206 4209
4207 // Returns a new empty OrderedHashTable and updates all the iterators to 4210 // Returns a new empty OrderedHashTable and records the clearing so that
4208 // point to the new table. 4211 // exisiting iterators can be updated.
4209 static Handle<Derived> Clear(Handle<Derived> table); 4212 static Handle<Derived> Clear(Handle<Derived> table);
4210 4213
4214 // Returns an OrderedHashTable (possibly |table|) where |key| has been
4215 // removed.
4216 static Handle<Derived> Remove(Handle<Derived> table, Handle<Object> key,
4217 bool* was_present);
4218
4219 static Handle<Derived> Remove(Handle<Derived> table, Handle<Object> key);
adamk 2014/05/30 20:13:58 I'm not sure you need this anywhere after you upda
arv (Not doing code reviews) 2014/05/30 20:53:07 Done.
4220
4211 // Returns kNotFound if the key isn't present. 4221 // Returns kNotFound if the key isn't present.
4212 int FindEntry(Handle<Object> key); 4222 int FindEntry(Handle<Object> key);
4213 4223
4214 int NumberOfElements() { 4224 int NumberOfElements() {
4215 return Smi::cast(get(kNumberOfElementsIndex))->value(); 4225 return Smi::cast(get(kNumberOfElementsIndex))->value();
4216 } 4226 }
4217 4227
4218 int NumberOfDeletedElements() { 4228 int NumberOfDeletedElements() {
4219 return Smi::cast(get(kNumberOfDeletedElementsIndex))->value(); 4229 return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
4220 } 4230 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
4324 OrderedHashSet, JSSetIterator, 1> { 4334 OrderedHashSet, JSSetIterator, 1> {
4325 public: 4335 public:
4326 static OrderedHashSet* cast(Object* obj) { 4336 static OrderedHashSet* cast(Object* obj) {
4327 ASSERT(obj->IsOrderedHashTable()); 4337 ASSERT(obj->IsOrderedHashTable());
4328 return reinterpret_cast<OrderedHashSet*>(obj); 4338 return reinterpret_cast<OrderedHashSet*>(obj);
4329 } 4339 }
4330 4340
4331 bool Contains(Handle<Object> key); 4341 bool Contains(Handle<Object> key);
4332 static Handle<OrderedHashSet> Add( 4342 static Handle<OrderedHashSet> Add(
4333 Handle<OrderedHashSet> table, Handle<Object> key); 4343 Handle<OrderedHashSet> table, Handle<Object> key);
4334 static Handle<OrderedHashSet> Remove(
4335 Handle<OrderedHashSet> table, Handle<Object> key, bool* was_present);
4336 }; 4344 };
4337 4345
4338 4346
4339 class JSMapIterator; 4347 class JSMapIterator;
4340 4348
4341 4349
4342 class OrderedHashMap:public OrderedHashTable< 4350 class OrderedHashMap:public OrderedHashTable<
4343 OrderedHashMap, JSMapIterator, 2> { 4351 OrderedHashMap, JSMapIterator, 2> {
4344 public: 4352 public:
4345 static OrderedHashMap* cast(Object* obj) { 4353 static OrderedHashMap* cast(Object* obj) {
(...skipping 6728 matching lines...) Expand 10 before | Expand all | Expand 10 after
11074 } else { 11082 } else {
11075 value &= ~(1 << bit_position); 11083 value &= ~(1 << bit_position);
11076 } 11084 }
11077 return value; 11085 return value;
11078 } 11086 }
11079 }; 11087 };
11080 11088
11081 } } // namespace v8::internal 11089 } } // namespace v8::internal
11082 11090
11083 #endif // V8_OBJECTS_H_ 11091 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698