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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 static v8::Persistent<v8::Context> env; | 39 static v8::Persistent<v8::Context> env; |
40 | 40 |
41 static void InitializeVM() { | 41 static void InitializeVM() { |
42 if (env.IsEmpty()) env = v8::Context::New(); | 42 if (env.IsEmpty()) env = v8::Context::New(); |
43 v8::HandleScope scope; | 43 v8::HandleScope scope; |
44 env->Enter(); | 44 env->Enter(); |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 TEST(MarkingStack) { | |
49 int mem_size = 20 * kPointerSize; | |
50 byte* mem = NewArray<byte>(20*kPointerSize); | |
51 Address low = reinterpret_cast<Address>(mem); | |
52 Address high = low + mem_size; | |
53 MarkingStack s; | |
54 s.Initialize(low, high); | |
55 | |
56 Address address = NULL; | |
57 while (!s.is_full()) { | |
58 s.Push(HeapObject::FromAddress(address)); | |
59 address += kPointerSize; | |
60 } | |
61 | |
62 while (!s.is_empty()) { | |
63 Address value = s.Pop()->address(); | |
64 address -= kPointerSize; | |
65 CHECK_EQ(address, value); | |
66 } | |
67 | |
68 CHECK_EQ(NULL, address); | |
69 DeleteArray(mem); | |
70 } | |
71 | |
72 | |
73 TEST(Promotion) { | 48 TEST(Promotion) { |
74 // Ensure that we get a compacting collection so that objects are promoted | 49 // Ensure that we get a compacting collection so that objects are promoted |
75 // from new space. | 50 // from new space. |
76 FLAG_gc_global = true; | 51 FLAG_gc_global = true; |
77 FLAG_always_compact = true; | 52 FLAG_always_compact = true; |
78 Heap::ConfigureHeap(2*256*KB, 4*MB); | 53 Heap::ConfigureHeap(2*256*KB, 4*MB); |
79 | 54 |
80 InitializeVM(); | 55 InitializeVM(); |
81 | 56 |
82 v8::HandleScope sc; | 57 v8::HandleScope sc; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 308 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
334 GlobalHandles::AddGroup(g1_objects, 2); | 309 GlobalHandles::AddGroup(g1_objects, 2); |
335 GlobalHandles::AddGroup(g2_objects, 2); | 310 GlobalHandles::AddGroup(g2_objects, 2); |
336 } | 311 } |
337 | 312 |
338 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); | 313 CHECK(Heap::CollectGarbage(0, OLD_POINTER_SPACE)); |
339 | 314 |
340 // All objects should be gone. 5 global handles in total. | 315 // All objects should be gone. 5 global handles in total. |
341 CHECK_EQ(5, NumberOfWeakCalls); | 316 CHECK_EQ(5, NumberOfWeakCalls); |
342 } | 317 } |
OLD | NEW |