| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 13135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13146 some_object.Reset(isolate, v8::Object::New()); | 13146 some_object.Reset(isolate, v8::Object::New()); |
| 13147 handle1.Reset(isolate, v8::Object::New()); | 13147 handle1.Reset(isolate, v8::Object::New()); |
| 13148 handle2.Reset(isolate, v8::Object::New()); | 13148 handle2.Reset(isolate, v8::Object::New()); |
| 13149 } | 13149 } |
| 13150 // Note: order is implementation dependent alas: currently | 13150 // Note: order is implementation dependent alas: currently |
| 13151 // global handle nodes are processed by PostGarbageCollectionProcessing | 13151 // global handle nodes are processed by PostGarbageCollectionProcessing |
| 13152 // in reverse allocation order, so if second allocated handle is deleted, | 13152 // in reverse allocation order, so if second allocated handle is deleted, |
| 13153 // weak callback of the first handle would be able to 'reallocate' it. | 13153 // weak callback of the first handle would be able to 'reallocate' it. |
| 13154 handle1.SetWeak(&handle1, NewPersistentHandleCallback); | 13154 handle1.SetWeak(&handle1, NewPersistentHandleCallback); |
| 13155 handle2.Reset(); | 13155 handle2.Reset(); |
| 13156 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13156 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 13157 } | 13157 } |
| 13158 | 13158 |
| 13159 | 13159 |
| 13160 v8::Persistent<v8::Object> to_be_disposed; | 13160 v8::Persistent<v8::Object> to_be_disposed; |
| 13161 | 13161 |
| 13162 void DisposeAndForceGcCallback( | 13162 void DisposeAndForceGcCallback( |
| 13163 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13163 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
| 13164 to_be_disposed.Reset(); | 13164 to_be_disposed.Reset(); |
| 13165 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13165 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 13166 data.GetParameter()->Reset(); | 13166 data.GetParameter()->Reset(); |
| 13167 } | 13167 } |
| 13168 | 13168 |
| 13169 | 13169 |
| 13170 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 13170 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
| 13171 LocalContext context; | 13171 LocalContext context; |
| 13172 v8::Isolate* isolate = context->GetIsolate(); | 13172 v8::Isolate* isolate = context->GetIsolate(); |
| 13173 | 13173 |
| 13174 v8::Persistent<v8::Object> handle1, handle2; | 13174 v8::Persistent<v8::Object> handle1, handle2; |
| 13175 { | 13175 { |
| 13176 v8::HandleScope scope(isolate); | 13176 v8::HandleScope scope(isolate); |
| 13177 handle1.Reset(isolate, v8::Object::New()); | 13177 handle1.Reset(isolate, v8::Object::New()); |
| 13178 handle2.Reset(isolate, v8::Object::New()); | 13178 handle2.Reset(isolate, v8::Object::New()); |
| 13179 } | 13179 } |
| 13180 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); | 13180 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); |
| 13181 to_be_disposed.Reset(isolate, handle2); | 13181 to_be_disposed.Reset(isolate, handle2); |
| 13182 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13182 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 13183 } | 13183 } |
| 13184 | 13184 |
| 13185 void DisposingCallback( | 13185 void DisposingCallback( |
| 13186 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13186 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
| 13187 data.GetParameter()->Reset(); | 13187 data.GetParameter()->Reset(); |
| 13188 } | 13188 } |
| 13189 | 13189 |
| 13190 void HandleCreatingCallback( | 13190 void HandleCreatingCallback( |
| 13191 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13191 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
| 13192 v8::HandleScope scope(data.GetIsolate()); | 13192 v8::HandleScope scope(data.GetIsolate()); |
| 13193 v8::Persistent<v8::Object>(data.GetIsolate(), v8::Object::New()); | 13193 v8::Persistent<v8::Object>(data.GetIsolate(), v8::Object::New()); |
| 13194 data.GetParameter()->Reset(); | 13194 data.GetParameter()->Reset(); |
| 13195 } | 13195 } |
| 13196 | 13196 |
| 13197 | 13197 |
| 13198 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 13198 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
| 13199 LocalContext context; | 13199 LocalContext context; |
| 13200 v8::Isolate* isolate = context->GetIsolate(); | 13200 v8::Isolate* isolate = context->GetIsolate(); |
| 13201 | 13201 |
| 13202 v8::Persistent<v8::Object> handle1, handle2, handle3; | 13202 v8::Persistent<v8::Object> handle1, handle2, handle3; |
| 13203 { | 13203 { |
| 13204 v8::HandleScope scope(isolate); | 13204 v8::HandleScope scope(isolate); |
| 13205 handle3.Reset(isolate, v8::Object::New()); | 13205 handle3.Reset(isolate, v8::Object::New()); |
| 13206 handle2.Reset(isolate, v8::Object::New()); | 13206 handle2.Reset(isolate, v8::Object::New()); |
| 13207 handle1.Reset(isolate, v8::Object::New()); | 13207 handle1.Reset(isolate, v8::Object::New()); |
| 13208 } | 13208 } |
| 13209 handle2.SetWeak(&handle2, DisposingCallback); | 13209 handle2.SetWeak(&handle2, DisposingCallback); |
| 13210 handle3.SetWeak(&handle3, HandleCreatingCallback); | 13210 handle3.SetWeak(&handle3, HandleCreatingCallback); |
| 13211 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13211 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 13212 } | 13212 } |
| 13213 | 13213 |
| 13214 | 13214 |
| 13215 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 13215 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
| 13216 v8::V8::Initialize(); | 13216 v8::V8::Initialize(); |
| 13217 | 13217 |
| 13218 const int nof = 2; | 13218 const int nof = 2; |
| 13219 const char* sources[nof] = { | 13219 const char* sources[nof] = { |
| 13220 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", | 13220 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", |
| 13221 "Object()" | 13221 "Object()" |
| (...skipping 7650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20872 } | 20872 } |
| 20873 for (int i = 0; i < runs; i++) { | 20873 for (int i = 0; i < runs; i++) { |
| 20874 Local<String> expected; | 20874 Local<String> expected; |
| 20875 if (i != 0) { | 20875 if (i != 0) { |
| 20876 CHECK_EQ(v8_str("escape value"), values[i]); | 20876 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20877 } else { | 20877 } else { |
| 20878 CHECK(values[i].IsEmpty()); | 20878 CHECK(values[i].IsEmpty()); |
| 20879 } | 20879 } |
| 20880 } | 20880 } |
| 20881 } | 20881 } |
| OLD | NEW |