Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: test/cctest/test-alloc.cc

Issue 3970005: Make Failure inherit from MaybeObject instead of Object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 17 matching lines...) Expand all
28 #include "v8.h" 28 #include "v8.h"
29 #include "accessors.h" 29 #include "accessors.h"
30 #include "top.h" 30 #include "top.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 Object* AllocateAfterFailures() { 38 static MaybeObject* AllocateAfterFailures() {
39 static int attempts = 0; 39 static int attempts = 0;
40 if (++attempts < 3) return Failure::RetryAfterGC(); 40 if (++attempts < 3) return Failure::RetryAfterGC();
41 41
42 // New space. 42 // New space.
43 NewSpace* new_space = Heap::new_space(); 43 NewSpace* new_space = Heap::new_space();
44 static const int kNewSpaceFillerSize = ByteArray::SizeFor(0); 44 static const int kNewSpaceFillerSize = ByteArray::SizeFor(0);
45 while (new_space->Available() > kNewSpaceFillerSize) { 45 while (new_space->Available() > kNewSpaceFillerSize) {
46 int available_before = static_cast<int>(new_space->Available()); 46 int available_before = static_cast<int>(new_space->Available());
47 CHECK(!Heap::AllocateByteArray(0)->IsFailure()); 47 CHECK(!Heap::AllocateByteArray(0)->IsFailure());
48 if (available_before == new_space->Available()) { 48 if (available_before == new_space->Available()) {
49 // It seems that we are avoiding new space allocations when 49 // It seems that we are avoiding new space allocations when
50 // allocation is forced, so no need to fill up new space 50 // allocation is forced, so no need to fill up new space
51 // in order to make the test harder. 51 // in order to make the test harder.
52 break; 52 break;
53 } 53 }
54 } 54 }
55 CHECK(!Heap::AllocateByteArray(100)->IsFailure()); 55 CHECK(!Heap::AllocateByteArray(100)->IsFailure());
56 CHECK(!Heap::AllocateFixedArray(100, NOT_TENURED)->IsFailure()); 56 CHECK(!Heap::AllocateFixedArray(100, NOT_TENURED)->IsFailure());
57 57
58 // Make sure we can allocate through optimized allocation functions 58 // Make sure we can allocate through optimized allocation functions
59 // for specific kinds. 59 // for specific kinds.
60 CHECK(!Heap::AllocateFixedArray(100)->IsFailure()); 60 CHECK(!Heap::AllocateFixedArray(100)->IsFailure());
61 CHECK(!Heap::AllocateHeapNumber(0.42)->IsFailure()); 61 CHECK(!Heap::AllocateHeapNumber(0.42)->IsFailure());
62 CHECK(!Heap::AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); 62 CHECK(!Heap::AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure());
63 Object* object = Heap::AllocateJSObject(*Top::object_function()); 63 Object* object =
64 Heap::AllocateJSObject(*Top::object_function())->ToObjectChecked();
64 CHECK(!Heap::CopyJSObject(JSObject::cast(object))->IsFailure()); 65 CHECK(!Heap::CopyJSObject(JSObject::cast(object))->IsFailure());
65 66
66 // Old data space. 67 // Old data space.
67 OldSpace* old_data_space = Heap::old_data_space(); 68 OldSpace* old_data_space = Heap::old_data_space();
68 static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0); 69 static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0);
69 while (old_data_space->Available() > kOldDataSpaceFillerSize) { 70 while (old_data_space->Available() > kOldDataSpaceFillerSize) {
70 CHECK(!Heap::AllocateByteArray(0, TENURED)->IsFailure()); 71 CHECK(!Heap::AllocateByteArray(0, TENURED)->IsFailure());
71 } 72 }
72 CHECK(!Heap::AllocateRawAsciiString(100, TENURED)->IsFailure()); 73 CHECK(!Heap::AllocateRawAsciiString(100, TENURED)->IsFailure());
73 74
(...skipping 30 matching lines...) Expand all
104 TEST(StressHandles) { 105 TEST(StressHandles) {
105 v8::Persistent<v8::Context> env = v8::Context::New(); 106 v8::Persistent<v8::Context> env = v8::Context::New();
106 v8::HandleScope scope; 107 v8::HandleScope scope;
107 env->Enter(); 108 env->Enter();
108 Handle<Object> o = Test(); 109 Handle<Object> o = Test();
109 CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42); 110 CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42);
110 env->Exit(); 111 env->Exit();
111 } 112 }
112 113
113 114
114 static Object* TestAccessorGet(Object* object, void*) { 115 static MaybeObject* TestAccessorGet(Object* object, void*) {
115 return AllocateAfterFailures(); 116 return AllocateAfterFailures();
116 } 117 }
117 118
118 119
119 const AccessorDescriptor kDescriptor = { 120 const AccessorDescriptor kDescriptor = {
120 TestAccessorGet, 121 TestAccessorGet,
121 0, 122 0,
122 0 123 0
123 }; 124 };
124 125
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (index < blocks.length() - 1) { 207 if (index < blocks.length() - 1) {
207 blocks[index] = blocks.RemoveLast(); 208 blocks[index] = blocks.RemoveLast();
208 } else { 209 } else {
209 blocks.RemoveLast(); 210 blocks.RemoveLast();
210 } 211 }
211 } 212 }
212 } 213 }
213 214
214 CodeRange::TearDown(); 215 CodeRange::TearDown();
215 } 216 }
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698