| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 | 2 |
| 3 #include <stdlib.h> | 3 #include <stdlib.h> |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "execution.h" | 7 #include "execution.h" |
| 8 #include "factory.h" | 8 #include "factory.h" |
| 9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
| 10 #include "global-handles.h" | 10 #include "global-handles.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 GlobalHandles::Destroy(h3.location()); | 299 GlobalHandles::Destroy(h3.location()); |
| 300 | 300 |
| 301 CHECK_EQ(*h4, *h2); | 301 CHECK_EQ(*h4, *h2); |
| 302 GlobalHandles::Destroy(h2.location()); | 302 GlobalHandles::Destroy(h2.location()); |
| 303 GlobalHandles::Destroy(h4.location()); | 303 GlobalHandles::Destroy(h4.location()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 | 306 |
| 307 static bool WeakPointerCleared = false; | 307 static bool WeakPointerCleared = false; |
| 308 | 308 |
| 309 static void TestWeakGlobalHandleCallback(v8::Persistent<v8::Object> handle, | 309 static void TestWeakGlobalHandleCallback(v8::Persistent<v8::Value> handle, |
| 310 void* id) { | 310 void* id) { |
| 311 USE(handle); | 311 USE(handle); |
| 312 if (1234 == reinterpret_cast<int>(id)) WeakPointerCleared = true; | 312 if (1234 == reinterpret_cast<int>(id)) WeakPointerCleared = true; |
| 313 } | 313 } |
| 314 | 314 |
| 315 | 315 |
| 316 TEST(WeakGlobalHandlesScavenge) { | 316 TEST(WeakGlobalHandlesScavenge) { |
| 317 InitializeVM(); | 317 InitializeVM(); |
| 318 | 318 |
| 319 WeakPointerCleared = false; | 319 WeakPointerCleared = false; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 CHECK(WeakPointerCleared); | 371 CHECK(WeakPointerCleared); |
| 372 CHECK(!GlobalHandles::IsNearDeath(h1.location())); | 372 CHECK(!GlobalHandles::IsNearDeath(h1.location())); |
| 373 CHECK(GlobalHandles::IsNearDeath(h2.location())); | 373 CHECK(GlobalHandles::IsNearDeath(h2.location())); |
| 374 | 374 |
| 375 GlobalHandles::Destroy(h1.location()); | 375 GlobalHandles::Destroy(h1.location()); |
| 376 GlobalHandles::Destroy(h2.location()); | 376 GlobalHandles::Destroy(h2.location()); |
| 377 } | 377 } |
| 378 | 378 |
| 379 static void TestDeleteWeakGlobalHandleCallback( | 379 static void TestDeleteWeakGlobalHandleCallback( |
| 380 v8::Persistent<v8::Object> handle, | 380 v8::Persistent<v8::Value> handle, |
| 381 void* id) { | 381 void* id) { |
| 382 if (1234 == reinterpret_cast<int>(id)) WeakPointerCleared = true; | 382 if (1234 == reinterpret_cast<int>(id)) WeakPointerCleared = true; |
| 383 handle.Dispose(); | 383 handle.Dispose(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 TEST(DeleteWeakGlobalHandle) { | 386 TEST(DeleteWeakGlobalHandle) { |
| 387 InitializeVM(); | 387 InitializeVM(); |
| 388 | 388 |
| 389 WeakPointerCleared = false; | 389 WeakPointerCleared = false; |
| 390 | 390 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 objs[next_objs_index++] = | 770 objs[next_objs_index++] = |
| 771 Factory::NewStringFromAscii(CStrVector(str), TENURED); | 771 Factory::NewStringFromAscii(CStrVector(str), TENURED); |
| 772 delete[] str; | 772 delete[] str; |
| 773 | 773 |
| 774 // Add a Map object to look for. | 774 // Add a Map object to look for. |
| 775 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 775 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
| 776 | 776 |
| 777 CHECK_EQ(objs_count, next_objs_index); | 777 CHECK_EQ(objs_count, next_objs_index); |
| 778 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); | 778 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); |
| 779 } | 779 } |
| OLD | NEW |