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

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

Issue 136001: Changed allocation to allow large objects to be allocated in new space.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 months 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "execution.h" 7 #include "execution.h"
8 #include "factory.h" 8 #include "factory.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 #include "global-handles.h" 10 #include "global-handles.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); 201 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi());
202 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); 202 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi());
203 } 203 }
204 204
205 205
206 TEST(GarbageCollection) { 206 TEST(GarbageCollection) {
207 InitializeVM(); 207 InitializeVM();
208 208
209 v8::HandleScope sc; 209 v8::HandleScope sc;
210 // check GC when heap is empty 210 // check GC when heap is empty
211 int free_bytes = Heap::MaxHeapObjectSize(); 211 int free_bytes = Heap::MaxObjectSizeInPagedSpace();
212 CHECK(Heap::CollectGarbage(free_bytes, NEW_SPACE)); 212 CHECK(Heap::CollectGarbage(free_bytes, NEW_SPACE));
213 213
214 // allocate a function and keep it in global object's property 214 // allocate a function and keep it in global object's property
215 String* func_name = String::cast(Heap::LookupAsciiSymbol("theFunction")); 215 String* func_name = String::cast(Heap::LookupAsciiSymbol("theFunction"));
216 SharedFunctionInfo* function_share = 216 SharedFunctionInfo* function_share =
217 SharedFunctionInfo::cast(Heap::AllocateSharedFunctionInfo(func_name)); 217 SharedFunctionInfo::cast(Heap::AllocateSharedFunctionInfo(func_name));
218 JSFunction* function = 218 JSFunction* function =
219 JSFunction::cast(Heap::AllocateFunction(*Top::function_map(), 219 JSFunction::cast(Heap::AllocateFunction(*Top::function_map(),
220 function_share, 220 function_share,
221 Heap::undefined_value())); 221 Heap::undefined_value()));
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 objs[next_objs_index++] = Factory::NewJSArray(10); 775 objs[next_objs_index++] = Factory::NewJSArray(10);
776 objs[next_objs_index++] = Factory::NewJSArray(10, TENURED); 776 objs[next_objs_index++] = Factory::NewJSArray(10, TENURED);
777 777
778 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE 778 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE
779 objs[next_objs_index++] = 779 objs[next_objs_index++] =
780 Factory::NewStringFromAscii(CStrVector("abcdefghij")); 780 Factory::NewStringFromAscii(CStrVector("abcdefghij"));
781 objs[next_objs_index++] = 781 objs[next_objs_index++] =
782 Factory::NewStringFromAscii(CStrVector("abcdefghij"), TENURED); 782 Factory::NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
783 783
784 // Allocate a large string (for large object space). 784 // Allocate a large string (for large object space).
785 int large_size = Heap::MaxHeapObjectSize() + 1; 785 int large_size = Heap::MaxObjectSizeInPagedSpace() + 1;
786 char* str = new char[large_size]; 786 char* str = new char[large_size];
787 for (int i = 0; i < large_size - 1; ++i) str[i] = 'a'; 787 for (int i = 0; i < large_size - 1; ++i) str[i] = 'a';
788 str[large_size - 1] = '\0'; 788 str[large_size - 1] = '\0';
789 objs[next_objs_index++] = 789 objs[next_objs_index++] =
790 Factory::NewStringFromAscii(CStrVector(str), TENURED); 790 Factory::NewStringFromAscii(CStrVector(str), TENURED);
791 delete[] str; 791 delete[] str;
792 792
793 // Add a Map object to look for. 793 // Add a Map object to look for.
794 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); 794 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map());
795 795
796 CHECK_EQ(objs_count, next_objs_index); 796 CHECK_EQ(objs_count, next_objs_index);
797 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); 797 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count));
798 } 798 }
OLDNEW
« src/mark-compact.cc ('K') | « src/spaces.h ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698