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

Side by Side Diff: test/cctest/test-dictionary.cc

Issue 260313003: OrderedHashTable::FindEntry() handlified. (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/runtime.cc ('k') | test/cctest/test-ordered-hash-table.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 CHECK_EQ(table->NumberOfElements(), 0); 69 CHECK_EQ(table->NumberOfElements(), 0);
70 CHECK_EQ(table->Lookup(a), CcTest::heap()->the_hole_value()); 70 CHECK_EQ(table->Lookup(a), CcTest::heap()->the_hole_value());
71 71
72 // Keys should map back to their respective values and also should get 72 // Keys should map back to their respective values and also should get
73 // an identity hash code generated. 73 // an identity hash code generated.
74 for (int i = 0; i < 100; i++) { 74 for (int i = 0; i < 100; i++) {
75 Handle<JSReceiver> key = factory->NewJSArray(7); 75 Handle<JSReceiver> key = factory->NewJSArray(7);
76 Handle<JSObject> value = factory->NewJSArray(11); 76 Handle<JSObject> value = factory->NewJSArray(11);
77 table = HashMap::Put(table, key, value); 77 table = HashMap::Put(table, key, value);
78 CHECK_EQ(table->NumberOfElements(), i + 1); 78 CHECK_EQ(table->NumberOfElements(), i + 1);
79 CHECK_NE(table->FindEntry(*key), HashMap::kNotFound); 79 CHECK_NE(table->FindEntry(key), HashMap::kNotFound);
80 CHECK_EQ(table->Lookup(key), *value); 80 CHECK_EQ(table->Lookup(key), *value);
81 CHECK(key->GetIdentityHash()->IsSmi()); 81 CHECK(key->GetIdentityHash()->IsSmi());
82 } 82 }
83 83
84 // Keys never added to the map which already have an identity hash 84 // Keys never added to the map which already have an identity hash
85 // code should not be found. 85 // code should not be found.
86 for (int i = 0; i < 100; i++) { 86 for (int i = 0; i < 100; i++) {
87 Handle<JSReceiver> key = factory->NewJSArray(7); 87 Handle<JSReceiver> key = factory->NewJSArray(7);
88 CHECK(JSReceiver::GetOrCreateIdentityHash(key)->IsSmi()); 88 CHECK(JSReceiver::GetOrCreateIdentityHash(key)->IsSmi());
89 CHECK_EQ(table->FindEntry(*key), HashMap::kNotFound); 89 CHECK_EQ(table->FindEntry(key), HashMap::kNotFound);
90 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); 90 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value());
91 CHECK(key->GetIdentityHash()->IsSmi()); 91 CHECK(key->GetIdentityHash()->IsSmi());
92 } 92 }
93 93
94 // Keys that don't have an identity hash should not be found and also 94 // Keys that don't have an identity hash should not be found and also
95 // should not get an identity hash code generated. 95 // should not get an identity hash code generated.
96 for (int i = 0; i < 100; i++) { 96 for (int i = 0; i < 100; i++) {
97 Handle<JSReceiver> key = factory->NewJSArray(7); 97 Handle<JSReceiver> key = factory->NewJSArray(7);
98 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); 98 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value());
99 CHECK_EQ(key->GetIdentityHash(), 99 CHECK_EQ(key->GetIdentityHash(),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); 176 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2"));
177 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); 177 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3"));
178 178
179 // Simulate a full heap so that generating an identity hash code 179 // Simulate a full heap so that generating an identity hash code
180 // in subsequent calls will request GC. 180 // in subsequent calls will request GC.
181 SimulateFullSpace(CcTest::heap()->new_space()); 181 SimulateFullSpace(CcTest::heap()->new_space());
182 SimulateFullSpace(CcTest::heap()->old_pointer_space()); 182 SimulateFullSpace(CcTest::heap()->old_pointer_space());
183 183
184 // Calling Contains() should not cause GC ever. 184 // Calling Contains() should not cause GC ever.
185 int gc_count = isolate->heap()->gc_count(); 185 int gc_count = isolate->heap()->gc_count();
186 CHECK(!table->Contains(*key)); 186 CHECK(!table->Contains(key));
187 CHECK(gc_count == isolate->heap()->gc_count()); 187 CHECK(gc_count == isolate->heap()->gc_count());
188 188
189 // Calling Remove() will not cause GC in this case. 189 // Calling Remove() will not cause GC in this case.
190 table = HashSet::Remove(table, key); 190 table = HashSet::Remove(table, key);
191 CHECK(gc_count == isolate->heap()->gc_count()); 191 CHECK(gc_count == isolate->heap()->gc_count());
192 192
193 // Calling Add() should cause GC. 193 // Calling Add() should cause GC.
194 table = HashSet::Add(table, key); 194 table = HashSet::Add(table, key);
195 CHECK(gc_count < isolate->heap()->gc_count()); 195 CHECK(gc_count < isolate->heap()->gc_count());
196 } 196 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 LocalContext context; 240 LocalContext context;
241 v8::HandleScope scope(context->GetIsolate()); 241 v8::HandleScope scope(context->GetIsolate());
242 Isolate* isolate = CcTest::i_isolate(); 242 Isolate* isolate = CcTest::i_isolate();
243 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); 243 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1));
244 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); 244 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap());
245 } 245 }
246 #endif 246 #endif
247 247
248 248
249 } 249 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-ordered-hash-table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698