OLD | NEW |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // Keys mapped to the hole should be removed permanently. | 66 // Keys mapped to the hole should be removed permanently. |
67 table = PutIntoObjectHashTable(table, a, factory->the_hole_value()); | 67 table = PutIntoObjectHashTable(table, a, factory->the_hole_value()); |
68 CHECK_EQ(table->NumberOfElements(), 0); | 68 CHECK_EQ(table->NumberOfElements(), 0); |
69 CHECK_EQ(table->NumberOfDeletedElements(), 1); | 69 CHECK_EQ(table->NumberOfDeletedElements(), 1); |
70 CHECK_EQ(table->Lookup(*a), HEAP->the_hole_value()); | 70 CHECK_EQ(table->Lookup(*a), 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<JSObject> 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 = PutIntoObjectHashTable(table, key, value); | 77 table = PutIntoObjectHashTable(table, key, value); |
78 CHECK_EQ(table->NumberOfElements(), i + 1); | 78 CHECK_EQ(table->NumberOfElements(), i + 1); |
79 CHECK_NE(table->FindEntry(*key), ObjectHashTable::kNotFound); | 79 CHECK_NE(table->FindEntry(*key), ObjectHashTable::kNotFound); |
80 CHECK_EQ(table->Lookup(*key), *value); | 80 CHECK_EQ(table->Lookup(*key), *value); |
81 CHECK(key->GetIdentityHash(OMIT_CREATION)->ToObjectChecked()->IsSmi()); | 81 CHECK(key->GetIdentityHash(OMIT_CREATION)->ToObjectChecked()->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<JSObject> key = factory->NewJSArray(7); | 87 Handle<JSReceiver> key = factory->NewJSArray(7); |
88 CHECK(key->GetIdentityHash(ALLOW_CREATION)->ToObjectChecked()->IsSmi()); | 88 CHECK(key->GetIdentityHash(ALLOW_CREATION)->ToObjectChecked()->IsSmi()); |
89 CHECK_EQ(table->FindEntry(*key), ObjectHashTable::kNotFound); | 89 CHECK_EQ(table->FindEntry(*key), ObjectHashTable::kNotFound); |
90 CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value()); | 90 CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value()); |
91 CHECK(key->GetIdentityHash(OMIT_CREATION)->ToObjectChecked()->IsSmi()); | 91 CHECK(key->GetIdentityHash(OMIT_CREATION)->ToObjectChecked()->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<JSObject> key = factory->NewJSArray(7); | 97 Handle<JSReceiver> key = factory->NewJSArray(7); |
98 CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value()); | 98 CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value()); |
99 CHECK_EQ(key->GetIdentityHash(OMIT_CREATION), HEAP->undefined_value()); | 99 CHECK_EQ(key->GetIdentityHash(OMIT_CREATION), HEAP->undefined_value()); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 #ifdef DEBUG | 104 #ifdef DEBUG |
105 TEST(ObjectHashSetCausesGC) { | 105 TEST(ObjectHashSetCausesGC) { |
106 i::FLAG_stress_compaction = false; | 106 i::FLAG_stress_compaction = false; |
107 LocalContext context; | 107 LocalContext context; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 SimulateFullSpace(HEAP->new_space()); | 155 SimulateFullSpace(HEAP->new_space()); |
156 SimulateFullSpace(HEAP->old_pointer_space()); | 156 SimulateFullSpace(HEAP->old_pointer_space()); |
157 | 157 |
158 // Calling Lookup() should not cause GC ever. | 158 // Calling Lookup() should not cause GC ever. |
159 CHECK(table->Lookup(*key)->IsTheHole()); | 159 CHECK(table->Lookup(*key)->IsTheHole()); |
160 | 160 |
161 // Calling Put() should request GC by returning a failure. | 161 // Calling Put() should request GC by returning a failure. |
162 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); | 162 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); |
163 } | 163 } |
164 #endif | 164 #endif |
OLD | NEW |