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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 using namespace v8::internal; | 34 using namespace v8::internal; |
35 | 35 |
36 | 36 |
37 static MaybeObject* AllocateAfterFailures() { | 37 static MaybeObject* AllocateAfterFailures() { |
38 static int attempts = 0; | 38 static int attempts = 0; |
39 if (++attempts < 3) return Failure::RetryAfterGC(); | 39 if (++attempts < 3) return Failure::RetryAfterGC(); |
40 Heap* heap = Isolate::Current()->heap(); | 40 Heap* heap = Isolate::Current()->heap(); |
41 | 41 |
42 // New space. | 42 // New space. |
43 NewSpace* new_space = heap->new_space(); | 43 SimulateFullSpace(heap->new_space()); |
44 static const int kNewSpaceFillerSize = ByteArray::SizeFor(0); | |
45 while (new_space->Available() > kNewSpaceFillerSize) { | |
46 int available_before = static_cast<int>(new_space->Available()); | |
47 CHECK(!heap->AllocateByteArray(0)->IsFailure()); | |
48 if (available_before == new_space->Available()) { | |
49 // It seems that we are avoiding new space allocations when | |
50 // allocation is forced, so no need to fill up new space | |
51 // in order to make the test harder. | |
52 break; | |
53 } | |
54 } | |
55 CHECK(!heap->AllocateByteArray(100)->IsFailure()); | 44 CHECK(!heap->AllocateByteArray(100)->IsFailure()); |
56 CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); | 45 CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); |
57 | 46 |
58 // Make sure we can allocate through optimized allocation functions | 47 // Make sure we can allocate through optimized allocation functions |
59 // for specific kinds. | 48 // for specific kinds. |
60 CHECK(!heap->AllocateFixedArray(100)->IsFailure()); | 49 CHECK(!heap->AllocateFixedArray(100)->IsFailure()); |
61 CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); | 50 CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); |
62 CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); | 51 CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); |
63 Object* object = heap->AllocateJSObject( | 52 Object* object = heap->AllocateJSObject( |
64 *Isolate::Current()->object_function())->ToObjectChecked(); | 53 *Isolate::Current()->object_function())->ToObjectChecked(); |
(...skipping 18 matching lines...) Expand all Loading... |
83 } | 72 } |
84 CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)-> | 73 CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)-> |
85 IsFailure()); | 74 IsFailure()); |
86 | 75 |
87 // Map space. | 76 // Map space. |
88 SimulateFullSpace(heap->map_space()); | 77 SimulateFullSpace(heap->map_space()); |
89 int instance_size = JSObject::kHeaderSize; | 78 int instance_size = JSObject::kHeaderSize; |
90 CHECK(!heap->AllocateMap(JS_OBJECT_TYPE, instance_size)->IsFailure()); | 79 CHECK(!heap->AllocateMap(JS_OBJECT_TYPE, instance_size)->IsFailure()); |
91 | 80 |
92 // Test that we can allocate in old pointer space and code space. | 81 // Test that we can allocate in old pointer space and code space. |
| 82 SimulateFullSpace(heap->code_space()); |
93 CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure()); | 83 CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure()); |
94 CHECK(!heap->CopyCode(Isolate::Current()->builtins()->builtin( | 84 CHECK(!heap->CopyCode(Isolate::Current()->builtins()->builtin( |
95 Builtins::kIllegal))->IsFailure()); | 85 Builtins::kIllegal))->IsFailure()); |
96 | 86 |
97 // Return success. | 87 // Return success. |
98 return Smi::FromInt(42); | 88 return Smi::FromInt(42); |
99 } | 89 } |
100 | 90 |
101 | 91 |
102 static Handle<Object> Test() { | 92 static Handle<Object> Test() { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 blocks[index] = blocks.RemoveLast(); | 218 blocks[index] = blocks.RemoveLast(); |
229 } else { | 219 } else { |
230 blocks.RemoveLast(); | 220 blocks.RemoveLast(); |
231 } | 221 } |
232 } | 222 } |
233 } | 223 } |
234 | 224 |
235 code_range->TearDown(); | 225 code_range->TearDown(); |
236 delete code_range; | 226 delete code_range; |
237 } | 227 } |
OLD | NEW |