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

Side by Side Diff: src/objects.cc

Issue 796503002: Create optimized versions of the Map/Set clear method (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.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 // 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 #include <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 15970 matching lines...) Expand 10 before | Expand all | Expand 10 after
15981 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Clear( 15981 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Clear(
15982 Handle<Derived> table) { 15982 Handle<Derived> table) {
15983 DCHECK(!table->IsObsolete()); 15983 DCHECK(!table->IsObsolete());
15984 15984
15985 Handle<Derived> new_table = 15985 Handle<Derived> new_table =
15986 Allocate(table->GetIsolate(), 15986 Allocate(table->GetIsolate(),
15987 kMinCapacity, 15987 kMinCapacity,
15988 table->GetHeap()->InNewSpace(*table) ? NOT_TENURED : TENURED); 15988 table->GetHeap()->InNewSpace(*table) ? NOT_TENURED : TENURED);
15989 15989
15990 table->SetNextTable(*new_table); 15990 table->SetNextTable(*new_table);
15991 table->SetNumberOfDeletedElements(-1); 15991 table->SetNumberOfDeletedElements(kClearedTableSentinel);
15992 15992
15993 return new_table; 15993 return new_table;
15994 } 15994 }
15995 15995
15996 15996
15997 template<class Derived, class Iterator, int entrysize> 15997 template<class Derived, class Iterator, int entrysize>
15998 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Remove( 15998 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Remove(
15999 Handle<Derived> table, Handle<Object> key, bool* was_present) { 15999 Handle<Derived> table, Handle<Object> key, bool* was_present) {
16000 int entry = table->FindEntry(key); 16000 int entry = table->FindEntry(key);
16001 if (entry == kNotFound) { 16001 if (entry == kNotFound) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
16226 TableType* table = TableType::cast(this->table()); 16226 TableType* table = TableType::cast(this->table());
16227 if (!table->IsObsolete()) return; 16227 if (!table->IsObsolete()) return;
16228 16228
16229 int index = Smi::cast(this->index())->value(); 16229 int index = Smi::cast(this->index())->value();
16230 while (table->IsObsolete()) { 16230 while (table->IsObsolete()) {
16231 TableType* next_table = table->NextTable(); 16231 TableType* next_table = table->NextTable();
16232 16232
16233 if (index > 0) { 16233 if (index > 0) {
16234 int nod = table->NumberOfDeletedElements(); 16234 int nod = table->NumberOfDeletedElements();
16235 16235
16236 // When we clear the table we set the number of deleted elements to -1. 16236 if (nod == TableType::kClearedTableSentinel) {
16237 if (nod == -1) {
16238 index = 0; 16237 index = 0;
16239 } else { 16238 } else {
16240 int old_index = index; 16239 int old_index = index;
16241 for (int i = 0; i < nod; ++i) { 16240 for (int i = 0; i < nod; ++i) {
16242 int removed_index = table->RemovedIndexAt(i); 16241 int removed_index = table->RemovedIndexAt(i);
16243 if (removed_index >= old_index) break; 16242 if (removed_index >= old_index) break;
16244 --index; 16243 --index;
16245 } 16244 }
16246 } 16245 }
16247 } 16246 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
16895 Handle<DependentCode> codes = 16894 Handle<DependentCode> codes =
16896 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16895 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16897 DependentCode::kPropertyCellChangedGroup, 16896 DependentCode::kPropertyCellChangedGroup,
16898 info->object_wrapper()); 16897 info->object_wrapper());
16899 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16898 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16900 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16899 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16901 cell, info->zone()); 16900 cell, info->zone());
16902 } 16901 }
16903 16902
16904 } } // namespace v8::internal 16903 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698