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 // 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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 static v8::Persistent<v8::Context> env; | 38 static v8::Persistent<v8::Context> env; |
39 | 39 |
40 static void InitializeVM() { | 40 static void InitializeVM() { |
41 if (env.IsEmpty()) env = v8::Context::New(); | 41 if (env.IsEmpty()) env = v8::Context::New(); |
42 v8::HandleScope scope; | 42 v8::HandleScope scope; |
43 env->Enter(); | 43 env->Enter(); |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 TEST(MarkingStack) { | 47 TEST(MarkingDeque) { |
48 int mem_size = 20 * kPointerSize; | 48 int mem_size = 20 * kPointerSize; |
49 byte* mem = NewArray<byte>(20*kPointerSize); | 49 byte* mem = NewArray<byte>(20*kPointerSize); |
50 Address low = reinterpret_cast<Address>(mem); | 50 Address low = reinterpret_cast<Address>(mem); |
51 Address high = low + mem_size; | 51 Address high = low + mem_size; |
52 MarkingStack s; | 52 MarkingDeque s; |
53 s.Initialize(low, high); | 53 s.Initialize(low, high); |
54 | 54 |
55 Address address = NULL; | 55 Address address = NULL; |
56 while (!s.is_full()) { | 56 while (!s.IsFull()) { |
57 s.Push(HeapObject::FromAddress(address)); | 57 s.Push(HeapObject::FromAddress(address)); |
58 address += kPointerSize; | 58 address += kPointerSize; |
59 } | 59 } |
60 | 60 |
61 while (!s.is_empty()) { | 61 while (!s.IsEmpty()) { |
62 Address value = s.Pop()->address(); | 62 Address value = s.Pop()->address(); |
63 address -= kPointerSize; | 63 address -= kPointerSize; |
64 CHECK_EQ(address, value); | 64 CHECK_EQ(address, value); |
65 } | 65 } |
66 | 66 |
67 CHECK_EQ(NULL, address); | 67 CHECK_EQ(NULL, address); |
68 DeleteArray(mem); | 68 DeleteArray(mem); |
69 } | 69 } |
70 | 70 |
71 | 71 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 global_handles->MakeWeak(g1c1.location(), | 398 global_handles->MakeWeak(g1c1.location(), |
399 reinterpret_cast<void*>(1234), | 399 reinterpret_cast<void*>(1234), |
400 &WeakPointerCallback); | 400 &WeakPointerCallback); |
401 global_handles->MakeWeak(g2c1.location(), | 401 global_handles->MakeWeak(g2c1.location(), |
402 reinterpret_cast<void*>(1234), | 402 reinterpret_cast<void*>(1234), |
403 &WeakPointerCallback); | 403 &WeakPointerCallback); |
404 | 404 |
405 HEAP->CollectGarbage(OLD_POINTER_SPACE); | 405 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
406 CHECK_EQ(7, NumberOfWeakCalls); | 406 CHECK_EQ(7, NumberOfWeakCalls); |
407 } | 407 } |
OLD | NEW |