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

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

Issue 10170030: Implement tracking and optimizations of packed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 years, 7 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
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/mjsunit/array-construct-transition.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // Allocate the object. 666 // Allocate the object.
667 Handle<JSObject> object = FACTORY->NewJSObject(function); 667 Handle<JSObject> object = FACTORY->NewJSObject(function);
668 Handle<JSArray> array = Handle<JSArray>::cast(object); 668 Handle<JSArray> array = Handle<JSArray>::cast(object);
669 // We just initialized the VM, no heap allocation failure yet. 669 // We just initialized the VM, no heap allocation failure yet.
670 array->Initialize(0)->ToObjectChecked(); 670 array->Initialize(0)->ToObjectChecked();
671 671
672 // Set array length to 0. 672 // Set array length to 0.
673 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); 673 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked();
674 CHECK_EQ(Smi::FromInt(0), array->length()); 674 CHECK_EQ(Smi::FromInt(0), array->length());
675 // Must be in fast mode. 675 // Must be in fast mode.
676 CHECK(array->HasFastTypeElements()); 676 CHECK(array->HasFastSmiOrObjectElements());
677 677
678 // array[length] = name. 678 // array[length] = name.
679 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked(); 679 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked();
680 CHECK_EQ(Smi::FromInt(1), array->length()); 680 CHECK_EQ(Smi::FromInt(1), array->length());
681 CHECK_EQ(array->GetElement(0), *name); 681 CHECK_EQ(array->GetElement(0), *name);
682 682
683 // Set array length with larger than smi value. 683 // Set array length with larger than smi value.
684 Handle<Object> length = 684 Handle<Object> length =
685 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); 685 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
686 array->SetElementsLength(*length)->ToObjectChecked(); 686 array->SetElementsLength(*length)->ToObjectChecked();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 InitializeVM(); 804 InitializeVM();
805 v8::HandleScope scope; 805 v8::HandleScope scope;
806 806
807 // Array of objects to scan haep for. 807 // Array of objects to scan haep for.
808 const int objs_count = 6; 808 const int objs_count = 6;
809 Handle<Object> objs[objs_count]; 809 Handle<Object> objs[objs_count];
810 int next_objs_index = 0; 810 int next_objs_index = 0;
811 811
812 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE 812 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE
813 objs[next_objs_index++] = FACTORY->NewJSArray(10); 813 objs[next_objs_index++] = FACTORY->NewJSArray(10);
814 objs[next_objs_index++] = FACTORY->NewJSArray(10, FAST_ELEMENTS, TENURED); 814 objs[next_objs_index++] = FACTORY->NewJSArray(10,
815 FAST_HOLEY_ELEMENTS,
816 TENURED);
815 817
816 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE 818 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE
817 objs[next_objs_index++] = 819 objs[next_objs_index++] =
818 FACTORY->NewStringFromAscii(CStrVector("abcdefghij")); 820 FACTORY->NewStringFromAscii(CStrVector("abcdefghij"));
819 objs[next_objs_index++] = 821 objs[next_objs_index++] =
820 FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED); 822 FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED);
821 823
822 // Allocate a large string (for large object space). 824 // Allocate a large string (for large object space).
823 int large_size = Page::kMaxNonCodeHeapObjectSize + 1; 825 int large_size = Page::kMaxNonCodeHeapObjectSize + 1;
824 char* str = new char[large_size]; 826 char* str = new char[large_size];
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 int j = Map::kProtoTransitionHeaderSize + 1590 int j = Map::kProtoTransitionHeaderSize +
1589 i * Map::kProtoTransitionElementsPerEntry; 1591 i * Map::kProtoTransitionElementsPerEntry;
1590 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); 1592 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
1591 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject()); 1593 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject());
1592 } 1594 }
1593 1595
1594 // Make sure next prototype is placed on an old-space evacuation candidate. 1596 // Make sure next prototype is placed on an old-space evacuation candidate.
1595 Handle<JSObject> prototype; 1597 Handle<JSObject> prototype;
1596 PagedSpace* space = HEAP->old_pointer_space(); 1598 PagedSpace* space = HEAP->old_pointer_space();
1597 do { 1599 do {
1598 prototype = FACTORY->NewJSArray(32 * KB, FAST_ELEMENTS, TENURED); 1600 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
1599 } while (space->FirstPage() == space->LastPage() || 1601 } while (space->FirstPage() == space->LastPage() ||
1600 !space->LastPage()->Contains(prototype->address())); 1602 !space->LastPage()->Contains(prototype->address()));
1601 1603
1602 // Add a prototype on an evacuation candidate and verify that transition 1604 // Add a prototype on an evacuation candidate and verify that transition
1603 // clearing correctly records slots in prototype transition array. 1605 // clearing correctly records slots in prototype transition array.
1604 i::FLAG_always_compact = true; 1606 i::FLAG_always_compact = true;
1605 Handle<Map> map(baseObject->map()); 1607 Handle<Map> map(baseObject->map());
1606 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address())); 1608 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address()));
1607 CHECK(space->LastPage()->Contains(prototype->address())); 1609 CHECK(space->LastPage()->Contains(prototype->address()));
1608 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); 1610 baseObject->SetPrototype(*prototype, false)->ToObjectChecked();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 CHECK(marking->IsComplete()); 1787 CHECK(marking->IsComplete());
1786 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1788 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1787 CHECK(marking->IsStopped()); 1789 CHECK(marking->IsStopped());
1788 1790
1789 // Count number of live transitions after marking. Note that one transition 1791 // Count number of live transitions after marking. Note that one transition
1790 // is left, because 'o' still holds an instance of one transition target. 1792 // is left, because 'o' still holds an instance of one transition target.
1791 int transitions_after = CountMapTransitions(root->map()); 1793 int transitions_after = CountMapTransitions(root->map());
1792 CompileRun("%DebugPrint(root);"); 1794 CompileRun("%DebugPrint(root);");
1793 CHECK_EQ(1, transitions_after); 1795 CHECK_EQ(1, transitions_after);
1794 } 1796 }
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/mjsunit/array-construct-transition.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698