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

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

Issue 1768553002: [runtime] Clean up symbol access in identity hash code (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/objects-inl.h ('k') | no next file » | 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // Keys should map back to their respective values and also should get 76 // Keys should map back to their respective values and also should get
77 // an identity hash code generated. 77 // an identity hash code generated.
78 for (int i = 0; i < 100; i++) { 78 for (int i = 0; i < 100; i++) {
79 Handle<JSReceiver> key = factory->NewJSArray(7); 79 Handle<JSReceiver> key = factory->NewJSArray(7);
80 Handle<JSObject> value = factory->NewJSArray(11); 80 Handle<JSObject> value = factory->NewJSArray(11);
81 table = HashMap::Put(table, key, value); 81 table = HashMap::Put(table, key, value);
82 CHECK_EQ(table->NumberOfElements(), i + 1); 82 CHECK_EQ(table->NumberOfElements(), i + 1);
83 CHECK_NE(table->FindEntry(key), HashMap::kNotFound); 83 CHECK_NE(table->FindEntry(key), HashMap::kNotFound);
84 CHECK_EQ(table->Lookup(key), *value); 84 CHECK_EQ(table->Lookup(key), *value);
85 CHECK(key->GetIdentityHash()->IsSmi()); 85 CHECK(JSReceiver::GetIdentityHash(isolate, key)->IsSmi());
86 } 86 }
87 87
88 // Keys never added to the map which already have an identity hash 88 // Keys never added to the map which already have an identity hash
89 // code should not be found. 89 // code should not be found.
90 for (int i = 0; i < 100; i++) { 90 for (int i = 0; i < 100; i++) {
91 Handle<JSReceiver> key = factory->NewJSArray(7); 91 Handle<JSReceiver> key = factory->NewJSArray(7);
92 CHECK(JSReceiver::GetOrCreateIdentityHash(key)->IsSmi()); 92 CHECK(JSReceiver::GetOrCreateIdentityHash(key)->IsSmi());
93 CHECK_EQ(table->FindEntry(key), HashMap::kNotFound); 93 CHECK_EQ(table->FindEntry(key), HashMap::kNotFound);
94 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); 94 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value());
95 CHECK(key->GetIdentityHash()->IsSmi()); 95 CHECK(JSReceiver::GetIdentityHash(isolate, key)->IsSmi());
96 } 96 }
97 97
98 // Keys that don't have an identity hash should not be found and also 98 // Keys that don't have an identity hash should not be found and also
99 // should not get an identity hash code generated. 99 // should not get an identity hash code generated.
100 for (int i = 0; i < 100; i++) { 100 for (int i = 0; i < 100; i++) {
101 Handle<JSReceiver> key = factory->NewJSArray(7); 101 Handle<JSReceiver> key = factory->NewJSArray(7);
102 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); 102 CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value());
103 Object* identity_hash = key->GetIdentityHash(); 103 Handle<Object> identity_hash = JSReceiver::GetIdentityHash(isolate, key);
104 CHECK_EQ(identity_hash, CcTest::heap()->undefined_value()); 104 CHECK_EQ(CcTest::heap()->undefined_value(), *identity_hash);
105 } 105 }
106 } 106 }
107 107
108 108
109 TEST(HashMap) { 109 TEST(HashMap) {
110 LocalContext context; 110 LocalContext context;
111 v8::HandleScope scope(context->GetIsolate()); 111 v8::HandleScope scope(context->GetIsolate());
112 Isolate* isolate = CcTest::i_isolate(); 112 Isolate* isolate = CcTest::i_isolate();
113 TestHashMap(ObjectHashTable::New(isolate, 23)); 113 TestHashMap(ObjectHashTable::New(isolate, 23));
114 } 114 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 dict->SetRequiresCopyOnCapacityChange(); 236 dict->SetRequiresCopyOnCapacityChange();
237 Handle<Name> key = isolate->factory()->InternalizeString( 237 Handle<Name> key = isolate->factory()->InternalizeString(
238 v8::Utils::OpenHandle(*v8_str("key"))); 238 v8::Utils::OpenHandle(*v8_str("key")));
239 Handle<Object> value = handle(Smi::FromInt(0), isolate); 239 Handle<Object> value = handle(Smi::FromInt(0), isolate);
240 Handle<NameDictionary> new_dict = 240 Handle<NameDictionary> new_dict =
241 NameDictionary::Add(dict, key, value, PropertyDetails::Empty()); 241 NameDictionary::Add(dict, key, value, PropertyDetails::Empty());
242 CHECK_NE(*dict, *new_dict); 242 CHECK_NE(*dict, *new_dict);
243 } 243 }
244 244
245 } // namespace 245 } // namespace
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698