OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 #include "accessors.h" | 29 #include "accessors.h" |
30 #include "top.h" | |
31 | 30 |
32 #include "cctest.h" | 31 #include "cctest.h" |
33 | 32 |
34 | 33 |
35 using namespace v8::internal; | 34 using namespace v8::internal; |
36 | 35 |
37 | 36 |
38 static Object* AllocateAfterFailures() { | 37 static Object* AllocateAfterFailures() { |
39 static int attempts = 0; | 38 static int attempts = 0; |
40 if (++attempts < 3) return Failure::RetryAfterGC(0); | 39 if (++attempts < 3) return Failure::RetryAfterGC(0); |
(...skipping 13 matching lines...) Expand all Loading... |
54 } | 53 } |
55 } | 54 } |
56 CHECK(!heap->AllocateByteArray(100)->IsFailure()); | 55 CHECK(!heap->AllocateByteArray(100)->IsFailure()); |
57 CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); | 56 CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); |
58 | 57 |
59 // Make sure we can allocate through optimized allocation functions | 58 // Make sure we can allocate through optimized allocation functions |
60 // for specific kinds. | 59 // for specific kinds. |
61 CHECK(!heap->AllocateFixedArray(100)->IsFailure()); | 60 CHECK(!heap->AllocateFixedArray(100)->IsFailure()); |
62 CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); | 61 CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); |
63 CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); | 62 CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); |
64 Object* object = heap->AllocateJSObject(*Top::object_function()); | 63 Object* object = heap->AllocateJSObject( |
| 64 *Isolate::Current()->object_function()); |
65 CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure()); | 65 CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure()); |
66 | 66 |
67 // Old data space. | 67 // Old data space. |
68 OldSpace* old_data_space = heap->old_data_space(); | 68 OldSpace* old_data_space = heap->old_data_space(); |
69 static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0); | 69 static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0); |
70 while (old_data_space->Available() > kOldDataSpaceFillerSize) { | 70 while (old_data_space->Available() > kOldDataSpaceFillerSize) { |
71 CHECK(!heap->AllocateByteArray(0, TENURED)->IsFailure()); | 71 CHECK(!heap->AllocateByteArray(0, TENURED)->IsFailure()); |
72 } | 72 } |
73 CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure()); | 73 CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure()); |
74 | 74 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 if (index < blocks.length() - 1) { | 207 if (index < blocks.length() - 1) { |
208 blocks[index] = blocks.RemoveLast(); | 208 blocks[index] = blocks.RemoveLast(); |
209 } else { | 209 } else { |
210 blocks.RemoveLast(); | 210 blocks.RemoveLast(); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 CodeRange::TearDown(); | 215 CodeRange::TearDown(); |
216 } | 216 } |
OLD | NEW |