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

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

Issue 309663005: Split Put into Put and Remove (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove move without was_present and use that in the runtime for extra speed 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Keys still have to be valid after objects were moved. 56 // Keys still have to be valid after objects were moved.
57 CcTest::heap()->CollectGarbage(NEW_SPACE); 57 CcTest::heap()->CollectGarbage(NEW_SPACE);
58 CHECK_EQ(table->NumberOfElements(), 1); 58 CHECK_EQ(table->NumberOfElements(), 1);
59 CHECK_EQ(table->Lookup(a), *b); 59 CHECK_EQ(table->Lookup(a), *b);
60 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value()); 60 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value());
61 61
62 // Keys that are overwritten should not change number of elements. 62 // Keys that are overwritten should not change number of elements.
63 table = HashMap::Put(table, a, factory->NewJSArray(13)); 63 table = HashMap::Put(table, a, factory->NewJSArray(13));
64 CHECK_EQ(table->NumberOfElements(), 1); 64 CHECK_EQ(table->NumberOfElements(), 1);
65 CHECK_NE(table->Lookup(a), *b); 65 CHECK_NE(table->Lookup(a), *b);
66 66
Michael Starzinger 2014/06/02 13:34:04 nit: Let's add a comment along the lines of ... /
arv (Not doing code reviews) 2014/06/02 23:49:08 Done.
67 // Keys mapped to the hole should be removed permanently. 67 bool was_present = false;
68 table = HashMap::Put(table, a, factory->the_hole_value()); 68 table = HashMap::Remove(table, a, &was_present);
69 CHECK(was_present);
69 CHECK_EQ(table->NumberOfElements(), 0); 70 CHECK_EQ(table->NumberOfElements(), 0);
70 CHECK_EQ(table->Lookup(a), CcTest::heap()->the_hole_value()); 71 CHECK_EQ(table->Lookup(a), CcTest::heap()->the_hole_value());
71 72
72 // Keys should map back to their respective values and also should get 73 // Keys should map back to their respective values and also should get
73 // an identity hash code generated. 74 // an identity hash code generated.
74 for (int i = 0; i < 100; i++) { 75 for (int i = 0; i < 100; i++) {
75 Handle<JSReceiver> key = factory->NewJSArray(7); 76 Handle<JSReceiver> key = factory->NewJSArray(7);
76 Handle<JSObject> value = factory->NewJSArray(11); 77 Handle<JSObject> value = factory->NewJSArray(11);
77 table = HashMap::Put(table, key, value); 78 table = HashMap::Put(table, key, value);
78 CHECK_EQ(table->NumberOfElements(), i + 1); 79 CHECK_EQ(table->NumberOfElements(), i + 1);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 LocalContext context; 243 LocalContext context;
243 v8::HandleScope scope(context->GetIsolate()); 244 v8::HandleScope scope(context->GetIsolate());
244 Isolate* isolate = CcTest::i_isolate(); 245 Isolate* isolate = CcTest::i_isolate();
245 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1)); 246 TestHashMapCausesGC(ObjectHashTable::New(isolate, 1));
246 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap()); 247 TestHashMapCausesGC(isolate->factory()->NewOrderedHashMap());
247 } 248 }
248 #endif 249 #endif
249 250
250 251
251 } 252 }
OLDNEW
« src/objects.cc ('K') | « 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