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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 #ifdef DEBUG | 102 #ifdef DEBUG |
103 TEST(ObjectHashSetCausesGC) { | 103 TEST(ObjectHashSetCausesGC) { |
104 v8::HandleScope scope; | 104 v8::HandleScope scope; |
105 LocalContext context; | 105 LocalContext context; |
106 Handle<ObjectHashSet> table = FACTORY->NewObjectHashSet(1); | 106 Handle<ObjectHashSet> table = FACTORY->NewObjectHashSet(1); |
107 Handle<JSObject> key = FACTORY->NewJSArray(0); | 107 Handle<JSObject> key = FACTORY->NewJSArray(0); |
| 108 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); |
| 109 |
| 110 // Force allocation of hash table backing store for hidden properties. |
| 111 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); |
| 112 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); |
| 113 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); |
108 | 114 |
109 // Simulate a full heap so that generating an identity hash code | 115 // Simulate a full heap so that generating an identity hash code |
110 // in subsequent calls will request GC. | 116 // in subsequent calls will request GC. |
111 FLAG_gc_interval = 0; | 117 FLAG_gc_interval = 0; |
112 | 118 |
113 // Calling Contains() should not cause GC ever. | 119 // Calling Contains() should not cause GC ever. |
114 CHECK(!table->Contains(*key)); | 120 CHECK(!table->Contains(*key)); |
115 | 121 |
116 // Calling Remove() should not cause GC ever. | 122 // Calling Remove() should not cause GC ever. |
117 CHECK(!table->Remove(*key)->IsFailure()); | 123 CHECK(!table->Remove(*key)->IsFailure()); |
118 | 124 |
119 // Calling Add() should request GC by returning a failure. | 125 // Calling Add() should request GC by returning a failure. |
120 CHECK(table->Add(*key)->IsRetryAfterGC()); | 126 CHECK(table->Add(*key)->IsRetryAfterGC()); |
121 } | 127 } |
122 #endif | 128 #endif |
123 | 129 |
124 | 130 |
125 #ifdef DEBUG | 131 #ifdef DEBUG |
126 TEST(ObjectHashTableCausesGC) { | 132 TEST(ObjectHashTableCausesGC) { |
127 v8::HandleScope scope; | 133 v8::HandleScope scope; |
128 LocalContext context; | 134 LocalContext context; |
129 Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(1); | 135 Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(1); |
130 Handle<JSObject> key = FACTORY->NewJSArray(0); | 136 Handle<JSObject> key = FACTORY->NewJSArray(0); |
| 137 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); |
| 138 |
| 139 // Force allocation of hash table backing store for hidden properties. |
| 140 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); |
| 141 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); |
| 142 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); |
131 | 143 |
132 // Simulate a full heap so that generating an identity hash code | 144 // Simulate a full heap so that generating an identity hash code |
133 // in subsequent calls will request GC. | 145 // in subsequent calls will request GC. |
134 FLAG_gc_interval = 0; | 146 FLAG_gc_interval = 0; |
135 | 147 |
136 // Calling Lookup() should not cause GC ever. | 148 // Calling Lookup() should not cause GC ever. |
137 CHECK(table->Lookup(*key)->IsTheHole()); | 149 CHECK(table->Lookup(*key)->IsTheHole()); |
138 | 150 |
139 // Calling Put() should request GC by returning a failure. | 151 // Calling Put() should request GC by returning a failure. |
140 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); | 152 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); |
141 } | 153 } |
142 #endif | 154 #endif |
OLD | NEW |