| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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<JSObject> 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 LocalContext context; | 107 LocalContext context; |
| 107 Isolate* isolate = Isolate::Current(); | 108 Isolate* isolate = Isolate::Current(); |
| 108 Factory* factory = isolate->factory(); | 109 Factory* factory = isolate->factory(); |
| 109 v8::HandleScope scope(context->GetIsolate()); | 110 v8::HandleScope scope(context->GetIsolate()); |
| 110 Handle<ObjectHashSet> table = factory->NewObjectHashSet(1); | 111 Handle<ObjectHashSet> table = factory->NewObjectHashSet(1); |
| 111 Handle<JSObject> key = factory->NewJSArray(0); | 112 Handle<JSObject> key = factory->NewJSArray(0); |
| 112 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); | 113 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); |
| 113 | 114 |
| 114 // Force allocation of hash table backing store for hidden properties. | 115 // Force allocation of hash table backing store for hidden properties. |
| 115 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); | 116 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 128 CHECK(!table->Remove(*key)->IsFailure()); | 129 CHECK(!table->Remove(*key)->IsFailure()); |
| 129 | 130 |
| 130 // Calling Add() should request GC by returning a failure. | 131 // Calling Add() should request GC by returning a failure. |
| 131 CHECK(table->Add(*key)->IsRetryAfterGC()); | 132 CHECK(table->Add(*key)->IsRetryAfterGC()); |
| 132 } | 133 } |
| 133 #endif | 134 #endif |
| 134 | 135 |
| 135 | 136 |
| 136 #ifdef DEBUG | 137 #ifdef DEBUG |
| 137 TEST(ObjectHashTableCausesGC) { | 138 TEST(ObjectHashTableCausesGC) { |
| 139 i::FLAG_stress_compaction = false; |
| 138 LocalContext context; | 140 LocalContext context; |
| 139 Isolate* isolate = Isolate::Current(); | 141 Isolate* isolate = Isolate::Current(); |
| 140 Factory* factory = isolate->factory(); | 142 Factory* factory = isolate->factory(); |
| 141 v8::HandleScope scope(context->GetIsolate()); | 143 v8::HandleScope scope(context->GetIsolate()); |
| 142 Handle<ObjectHashTable> table = factory->NewObjectHashTable(1); | 144 Handle<ObjectHashTable> table = factory->NewObjectHashTable(1); |
| 143 Handle<JSObject> key = factory->NewJSArray(0); | 145 Handle<JSObject> key = factory->NewJSArray(0); |
| 144 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); | 146 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); |
| 145 | 147 |
| 146 // Force allocation of hash table backing store for hidden properties. | 148 // Force allocation of hash table backing store for hidden properties. |
| 147 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); | 149 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); |
| 148 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); | 150 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); |
| 149 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); | 151 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); |
| 150 | 152 |
| 151 // Simulate a full heap so that generating an identity hash code | 153 // Simulate a full heap so that generating an identity hash code |
| 152 // in subsequent calls will request GC. | 154 // in subsequent calls will request GC. |
| 153 SimulateFullSpace(HEAP->new_space()); | 155 SimulateFullSpace(HEAP->new_space()); |
| 154 SimulateFullSpace(HEAP->old_pointer_space()); | 156 SimulateFullSpace(HEAP->old_pointer_space()); |
| 155 | 157 |
| 156 // Calling Lookup() should not cause GC ever. | 158 // Calling Lookup() should not cause GC ever. |
| 157 CHECK(table->Lookup(*key)->IsTheHole()); | 159 CHECK(table->Lookup(*key)->IsTheHole()); |
| 158 | 160 |
| 159 // Calling Put() should request GC by returning a failure. | 161 // Calling Put() should request GC by returning a failure. |
| 160 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); | 162 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); |
| 161 } | 163 } |
| 162 #endif | 164 #endif |
| OLD | NEW |