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

Side by Side Diff: src/objects.cc

Issue 251293002: WeakHashTable::Lookup() handlified and ObjectHashTable's interface cleaned up. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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-debug.cc » ('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 "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "allocation-site-scopes.h" 8 #include "allocation-site-scopes.h"
9 #include "api.h" 9 #include "api.h"
10 #include "arguments.h" 10 #include "arguments.h"
(...skipping 16047 matching lines...) Expand 10 before | Expand all | Expand 10 after
16058 Object* hash = key->GetHash(); 16058 Object* hash = key->GetHash();
16059 if (hash->IsUndefined()) { 16059 if (hash->IsUndefined()) {
16060 return GetHeap()->the_hole_value(); 16060 return GetHeap()->the_hole_value();
16061 } 16061 }
16062 int entry = FindEntry(key); 16062 int entry = FindEntry(key);
16063 if (entry == kNotFound) return GetHeap()->the_hole_value(); 16063 if (entry == kNotFound) return GetHeap()->the_hole_value();
16064 return get(EntryToIndex(entry) + 1); 16064 return get(EntryToIndex(entry) + 1);
16065 } 16065 }
16066 16066
16067 16067
16068 // TODO(ishell): Try to remove this when FindEntry(Object* key) is removed
16069 int ObjectHashTable::FindEntry(Handle<Object> key) {
16070 return DerivedHashTable::FindEntry(key);
16071 }
16072
16073
16074 // TODO(ishell): Remove this when all the callers are handlified.
16075 int ObjectHashTable::FindEntry(Object* key) {
16076 DisallowHeapAllocation no_allocation;
16077 Isolate* isolate = GetIsolate();
16078 HandleScope scope(isolate);
16079 return FindEntry(handle(key, isolate));
16080 }
16081
16082
16083 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, 16068 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
16084 Handle<Object> key, 16069 Handle<Object> key,
16085 Handle<Object> value) { 16070 Handle<Object> value) {
16086 ASSERT(table->IsKey(*key)); 16071 ASSERT(table->IsKey(*key));
16087 16072
16088 Isolate* isolate = table->GetIsolate(); 16073 Isolate* isolate = table->GetIsolate();
16089 16074
16090 // Make sure the key object has an identity hash code. 16075 // Make sure the key object has an identity hash code.
16091 Handle<Object> hash = Object::GetOrCreateHash(key, isolate); 16076 Handle<Object> hash = Object::GetOrCreateHash(key, isolate);
16092 16077
(...skipping 28 matching lines...) Expand all
16121 } 16106 }
16122 16107
16123 16108
16124 void ObjectHashTable::RemoveEntry(int entry) { 16109 void ObjectHashTable::RemoveEntry(int entry) {
16125 set_the_hole(EntryToIndex(entry)); 16110 set_the_hole(EntryToIndex(entry));
16126 set_the_hole(EntryToIndex(entry) + 1); 16111 set_the_hole(EntryToIndex(entry) + 1);
16127 ElementRemoved(); 16112 ElementRemoved();
16128 } 16113 }
16129 16114
16130 16115
16131 Object* WeakHashTable::Lookup(Object* key) { 16116 Object* WeakHashTable::Lookup(Handle<Object> key) {
16132 ASSERT(IsKey(key)); 16117 DisallowHeapAllocation no_gc;
16118 ASSERT(IsKey(*key));
16133 int entry = FindEntry(key); 16119 int entry = FindEntry(key);
16134 if (entry == kNotFound) return GetHeap()->the_hole_value(); 16120 if (entry == kNotFound) return GetHeap()->the_hole_value();
16135 return get(EntryToValueIndex(entry)); 16121 return get(EntryToValueIndex(entry));
16136 } 16122 }
16137 16123
16138 16124
16139 // TODO(ishell): Try to remove this when FindEntry(Object* key) is removed
16140 int WeakHashTable::FindEntry(Handle<Object> key) {
16141 return DerivedHashTable::FindEntry(key);
16142 }
16143
16144
16145 // TODO(ishell): Remove this when all the callers are handlified.
16146 int WeakHashTable::FindEntry(Object* key) {
16147 DisallowHeapAllocation no_allocation;
16148 Isolate* isolate = GetIsolate();
16149 HandleScope scope(isolate);
16150 return FindEntry(handle(key, isolate));
16151 }
16152
16153
16154 Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table, 16125 Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table,
16155 Handle<Object> key, 16126 Handle<Object> key,
16156 Handle<Object> value) { 16127 Handle<Object> value) {
16157 ASSERT(table->IsKey(*key)); 16128 ASSERT(table->IsKey(*key));
16158 int entry = table->FindEntry(key); 16129 int entry = table->FindEntry(key);
16159 // Key is already in table, just overwrite value. 16130 // Key is already in table, just overwrite value.
16160 if (entry != kNotFound) { 16131 if (entry != kNotFound) {
16161 table->set(EntryToValueIndex(entry), *value); 16132 table->set(EntryToValueIndex(entry), *value);
16162 return table; 16133 return table;
16163 } 16134 }
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
17263 #define ERROR_MESSAGES_TEXTS(C, T) T, 17234 #define ERROR_MESSAGES_TEXTS(C, T) T,
17264 static const char* error_messages_[] = { 17235 static const char* error_messages_[] = {
17265 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17236 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17266 }; 17237 };
17267 #undef ERROR_MESSAGES_TEXTS 17238 #undef ERROR_MESSAGES_TEXTS
17268 return error_messages_[reason]; 17239 return error_messages_[reason];
17269 } 17240 }
17270 17241
17271 17242
17272 } } // namespace v8::internal 17243 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698