| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 GlobalHandles::Destroy(h2.location()); | 308 GlobalHandles::Destroy(h2.location()); |
| 309 GlobalHandles::Destroy(h4.location()); | 309 GlobalHandles::Destroy(h4.location()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 static bool WeakPointerCleared = false; | 313 static bool WeakPointerCleared = false; |
| 314 | 314 |
| 315 static void TestWeakGlobalHandleCallback(v8::Persistent<v8::Value> handle, | 315 static void TestWeakGlobalHandleCallback(v8::Persistent<v8::Value> handle, |
| 316 void* id) { | 316 void* id) { |
| 317 USE(handle); | 317 USE(handle); |
| 318 if (1234 == reinterpret_cast<int>(id)) WeakPointerCleared = true; | 318 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; |
| 319 } | 319 } |
| 320 | 320 |
| 321 | 321 |
| 322 TEST(WeakGlobalHandlesScavenge) { | 322 TEST(WeakGlobalHandlesScavenge) { |
| 323 InitializeVM(); | 323 InitializeVM(); |
| 324 | 324 |
| 325 WeakPointerCleared = false; | 325 WeakPointerCleared = false; |
| 326 | 326 |
| 327 Object* i = Heap::AllocateStringFromAscii(CStrVector("fisk")); | 327 Object* i = Heap::AllocateStringFromAscii(CStrVector("fisk")); |
| 328 Object* u = Heap::AllocateHeapNumber(1.12344); | 328 Object* u = Heap::AllocateHeapNumber(1.12344); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 CHECK(!GlobalHandles::IsNearDeath(h1.location())); | 378 CHECK(!GlobalHandles::IsNearDeath(h1.location())); |
| 379 CHECK(GlobalHandles::IsNearDeath(h2.location())); | 379 CHECK(GlobalHandles::IsNearDeath(h2.location())); |
| 380 | 380 |
| 381 GlobalHandles::Destroy(h1.location()); | 381 GlobalHandles::Destroy(h1.location()); |
| 382 GlobalHandles::Destroy(h2.location()); | 382 GlobalHandles::Destroy(h2.location()); |
| 383 } | 383 } |
| 384 | 384 |
| 385 static void TestDeleteWeakGlobalHandleCallback( | 385 static void TestDeleteWeakGlobalHandleCallback( |
| 386 v8::Persistent<v8::Value> handle, | 386 v8::Persistent<v8::Value> handle, |
| 387 void* id) { | 387 void* id) { |
| 388 if (1234 == reinterpret_cast<int>(id)) WeakPointerCleared = true; | 388 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; |
| 389 handle.Dispose(); | 389 handle.Dispose(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 TEST(DeleteWeakGlobalHandle) { | 392 TEST(DeleteWeakGlobalHandle) { |
| 393 InitializeVM(); | 393 InitializeVM(); |
| 394 | 394 |
| 395 WeakPointerCleared = false; | 395 WeakPointerCleared = false; |
| 396 | 396 |
| 397 Object* i = Heap::AllocateStringFromAscii(CStrVector("fisk")); | 397 Object* i = Heap::AllocateStringFromAscii(CStrVector("fisk")); |
| 398 Handle<Object> h = GlobalHandles::Create(i); | 398 Handle<Object> h = GlobalHandles::Create(i); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 objs[next_objs_index++] = | 776 objs[next_objs_index++] = |
| 777 Factory::NewStringFromAscii(CStrVector(str), TENURED); | 777 Factory::NewStringFromAscii(CStrVector(str), TENURED); |
| 778 delete[] str; | 778 delete[] str; |
| 779 | 779 |
| 780 // Add a Map object to look for. | 780 // Add a Map object to look for. |
| 781 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 781 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
| 782 | 782 |
| 783 CHECK_EQ(objs_count, next_objs_index); | 783 CHECK_EQ(objs_count, next_objs_index); |
| 784 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); | 784 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); |
| 785 } | 785 } |
| OLD | NEW |