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

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

Issue 2310143002: [heap] Introduce enum of garbage collection reasons. (Closed)
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-feedback-vector.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 Handle<JSObject> a = factory->NewJSArray(7); 50 Handle<JSObject> a = factory->NewJSArray(7);
51 Handle<JSObject> b = factory->NewJSArray(11); 51 Handle<JSObject> b = factory->NewJSArray(11);
52 table = HashMap::Put(table, a, b); 52 table = HashMap::Put(table, a, b);
53 CHECK_EQ(table->NumberOfElements(), 1); 53 CHECK_EQ(table->NumberOfElements(), 1);
54 CHECK_EQ(table->Lookup(a), *b); 54 CHECK_EQ(table->Lookup(a), *b);
55 // When the key does not exist in the map, Lookup returns the hole. 55 // When the key does not exist in the map, Lookup returns the hole.
56 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value()); 56 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value());
57 57
58 // Keys still have to be valid after objects were moved. 58 // Keys still have to be valid after objects were moved.
59 CcTest::heap()->CollectGarbage(NEW_SPACE); 59 CcTest::CollectGarbage(NEW_SPACE);
60 CHECK_EQ(table->NumberOfElements(), 1); 60 CHECK_EQ(table->NumberOfElements(), 1);
61 CHECK_EQ(table->Lookup(a), *b); 61 CHECK_EQ(table->Lookup(a), *b);
62 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value()); 62 CHECK_EQ(table->Lookup(b), CcTest::heap()->the_hole_value());
63 63
64 // Keys that are overwritten should not change number of elements. 64 // Keys that are overwritten should not change number of elements.
65 table = HashMap::Put(table, a, factory->NewJSArray(13)); 65 table = HashMap::Put(table, a, factory->NewJSArray(13));
66 CHECK_EQ(table->NumberOfElements(), 1); 66 CHECK_EQ(table->NumberOfElements(), 1);
67 CHECK_NE(table->Lookup(a), *b); 67 CHECK_NE(table->Lookup(a), *b);
68 68
69 // Keys that have been removed are mapped to the hole. 69 // Keys that have been removed are mapped to the hole.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 Factory* factory = isolate->factory(); 119 Factory* factory = isolate->factory();
120 120
121 Handle<JSObject> a = factory->NewJSArray(7); 121 Handle<JSObject> a = factory->NewJSArray(7);
122 Handle<JSObject> b = factory->NewJSArray(11); 122 Handle<JSObject> b = factory->NewJSArray(11);
123 table = HashSet::Add(table, a); 123 table = HashSet::Add(table, a);
124 CHECK_EQ(table->NumberOfElements(), 1); 124 CHECK_EQ(table->NumberOfElements(), 1);
125 CHECK(table->Has(isolate, a)); 125 CHECK(table->Has(isolate, a));
126 CHECK(!table->Has(isolate, b)); 126 CHECK(!table->Has(isolate, b));
127 127
128 // Keys still have to be valid after objects were moved. 128 // Keys still have to be valid after objects were moved.
129 CcTest::heap()->CollectGarbage(NEW_SPACE); 129 CcTest::CollectGarbage(NEW_SPACE);
130 CHECK_EQ(table->NumberOfElements(), 1); 130 CHECK_EQ(table->NumberOfElements(), 1);
131 CHECK(table->Has(isolate, a)); 131 CHECK(table->Has(isolate, a));
132 CHECK(!table->Has(isolate, b)); 132 CHECK(!table->Has(isolate, b));
133 133
134 // Keys that are overwritten should not change number of elements. 134 // Keys that are overwritten should not change number of elements.
135 table = HashSet::Add(table, a); 135 table = HashSet::Add(table, a);
136 CHECK_EQ(table->NumberOfElements(), 1); 136 CHECK_EQ(table->NumberOfElements(), 1);
137 CHECK(table->Has(isolate, a)); 137 CHECK(table->Has(isolate, a));
138 CHECK(!table->Has(isolate, b)); 138 CHECK(!table->Has(isolate, b));
139 139
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 dict->SetRequiresCopyOnCapacityChange(); 304 dict->SetRequiresCopyOnCapacityChange();
305 Handle<Name> key = isolate->factory()->InternalizeString( 305 Handle<Name> key = isolate->factory()->InternalizeString(
306 v8::Utils::OpenHandle(*v8_str("key"))); 306 v8::Utils::OpenHandle(*v8_str("key")));
307 Handle<Object> value = handle(Smi::FromInt(0), isolate); 307 Handle<Object> value = handle(Smi::FromInt(0), isolate);
308 Handle<NameDictionary> new_dict = 308 Handle<NameDictionary> new_dict =
309 NameDictionary::Add(dict, key, value, PropertyDetails::Empty()); 309 NameDictionary::Add(dict, key, value, PropertyDetails::Empty());
310 CHECK_NE(*dict, *new_dict); 310 CHECK_NE(*dict, *new_dict);
311 } 311 }
312 312
313 } // namespace 313 } // namespace
OLDNEW
« no previous file with comments | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698