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