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 17 matching lines...) Expand all Loading... |
28 #include "v8.h" | 28 #include "v8.h" |
29 #include "accessors.h" | 29 #include "accessors.h" |
30 #include "api.h" | 30 #include "api.h" |
31 | 31 |
32 #include "cctest.h" | 32 #include "cctest.h" |
33 | 33 |
34 | 34 |
35 using namespace v8::internal; | 35 using namespace v8::internal; |
36 | 36 |
37 | 37 |
38 static MaybeObject* AllocateAfterFailures() { | 38 static AllocationResult AllocateAfterFailures() { |
39 static int attempts = 0; | 39 static int attempts = 0; |
40 if (++attempts < 3) return Failure::RetryAfterGC(); | 40 |
| 41 if (++attempts < 3) return AllocationResult::Retry(); |
41 TestHeap* heap = CcTest::test_heap(); | 42 TestHeap* heap = CcTest::test_heap(); |
42 | 43 |
43 // New space. | 44 // New space. |
44 SimulateFullSpace(heap->new_space()); | 45 SimulateFullSpace(heap->new_space()); |
45 CHECK(!heap->AllocateByteArray(100)->IsFailure()); | 46 heap->AllocateByteArray(100).ToObjectChecked(); |
46 CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); | 47 heap->AllocateFixedArray(100, NOT_TENURED).ToObjectChecked(); |
47 | 48 |
48 // Make sure we can allocate through optimized allocation functions | 49 // Make sure we can allocate through optimized allocation functions |
49 // for specific kinds. | 50 // for specific kinds. |
50 CHECK(!heap->AllocateFixedArray(100)->IsFailure()); | 51 heap->AllocateFixedArray(100).ToObjectChecked(); |
51 CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); | 52 heap->AllocateHeapNumber(0.42).ToObjectChecked(); |
52 CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); | 53 heap->AllocateArgumentsObject(Smi::FromInt(87), 10).ToObjectChecked(); |
53 Object* object = heap->AllocateJSObject( | 54 Object* object = heap->AllocateJSObject( |
54 *CcTest::i_isolate()->object_function())->ToObjectChecked(); | 55 *CcTest::i_isolate()->object_function()).ToObjectChecked(); |
55 CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure()); | 56 heap->CopyJSObject(JSObject::cast(object)).ToObjectChecked(); |
56 | 57 |
57 // Old data space. | 58 // Old data space. |
58 SimulateFullSpace(heap->old_data_space()); | 59 SimulateFullSpace(heap->old_data_space()); |
59 CHECK(!heap->AllocateByteArray(100, TENURED)->IsFailure()); | 60 heap->AllocateByteArray(100, TENURED).ToObjectChecked(); |
60 | 61 |
61 // Old pointer space. | 62 // Old pointer space. |
62 SimulateFullSpace(heap->old_pointer_space()); | 63 SimulateFullSpace(heap->old_pointer_space()); |
63 CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); | 64 heap->AllocateFixedArray(10000, TENURED).ToObjectChecked(); |
64 | 65 |
65 // Large object space. | 66 // Large object space. |
66 static const int kLargeObjectSpaceFillerLength = 300000; | 67 static const int kLargeObjectSpaceFillerLength = 300000; |
67 static const int kLargeObjectSpaceFillerSize = FixedArray::SizeFor( | 68 static const int kLargeObjectSpaceFillerSize = FixedArray::SizeFor( |
68 kLargeObjectSpaceFillerLength); | 69 kLargeObjectSpaceFillerLength); |
69 ASSERT(kLargeObjectSpaceFillerSize > heap->old_pointer_space()->AreaSize()); | 70 ASSERT(kLargeObjectSpaceFillerSize > heap->old_pointer_space()->AreaSize()); |
70 while (heap->OldGenerationSpaceAvailable() > kLargeObjectSpaceFillerSize) { | 71 while (heap->OldGenerationSpaceAvailable() > kLargeObjectSpaceFillerSize) { |
71 CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)-> | 72 heap->AllocateFixedArray( |
72 IsFailure()); | 73 kLargeObjectSpaceFillerLength, TENURED).ToObjectChecked(); |
73 } | 74 } |
74 CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)-> | 75 heap->AllocateFixedArray( |
75 IsFailure()); | 76 kLargeObjectSpaceFillerLength, TENURED).ToObjectChecked(); |
76 | 77 |
77 // Map space. | 78 // Map space. |
78 SimulateFullSpace(heap->map_space()); | 79 SimulateFullSpace(heap->map_space()); |
79 int instance_size = JSObject::kHeaderSize; | 80 int instance_size = JSObject::kHeaderSize; |
80 CHECK(!heap->AllocateMap(JS_OBJECT_TYPE, instance_size)->IsFailure()); | 81 heap->AllocateMap(JS_OBJECT_TYPE, instance_size).ToObjectChecked(); |
81 | 82 |
82 // Test that we can allocate in old pointer space and code space. | 83 // Test that we can allocate in old pointer space and code space. |
83 SimulateFullSpace(heap->code_space()); | 84 SimulateFullSpace(heap->code_space()); |
84 CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure()); | 85 heap->AllocateFixedArray(100, TENURED).ToObjectChecked(); |
85 CHECK(!heap->CopyCode(CcTest::i_isolate()->builtins()->builtin( | 86 heap->CopyCode(CcTest::i_isolate()->builtins()->builtin( |
86 Builtins::kIllegal))->IsFailure()); | 87 Builtins::kIllegal)).ToObjectChecked(); |
87 | 88 |
88 // Return success. | 89 // Return success. |
89 return Smi::FromInt(42); | 90 return Smi::FromInt(42); |
90 } | 91 } |
91 | 92 |
92 | 93 |
93 static Handle<Object> Test() { | 94 static Handle<Object> Test() { |
94 CALL_HEAP_FUNCTION(CcTest::i_isolate(), AllocateAfterFailures(), Object); | 95 CALL_HEAP_FUNCTION(CcTest::i_isolate(), AllocateAfterFailures(), Object); |
95 } | 96 } |
96 | 97 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 if (index < blocks.length() - 1) { | 230 if (index < blocks.length() - 1) { |
230 blocks[index] = blocks.RemoveLast(); | 231 blocks[index] = blocks.RemoveLast(); |
231 } else { | 232 } else { |
232 blocks.RemoveLast(); | 233 blocks.RemoveLast(); |
233 } | 234 } |
234 } | 235 } |
235 } | 236 } |
236 | 237 |
237 code_range.TearDown(); | 238 code_range.TearDown(); |
238 } | 239 } |
OLD | NEW |