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

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

Issue 11411031: Make PrototypeTransitionClearing work with GC interval. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « no previous file | no next file » | 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 "compilation-cache.h" 7 #include "compilation-cache.h"
8 #include "execution.h" 8 #include "execution.h"
9 #include "factory.h" 9 #include "factory.h"
10 #include "macro-assembler.h" 10 #include "macro-assembler.h"
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 v8::Handle<v8::Function> g = 1774 v8::Handle<v8::Function> g =
1775 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); 1775 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
1776 g->Call(global, 0, NULL); 1776 g->Call(global, 0, NULL);
1777 } 1777 }
1778 1778
1779 HEAP->incremental_marking()->set_should_hurry(true); 1779 HEAP->incremental_marking()->set_should_hurry(true);
1780 HEAP->CollectGarbage(OLD_POINTER_SPACE); 1780 HEAP->CollectGarbage(OLD_POINTER_SPACE);
1781 } 1781 }
1782 1782
1783 1783
1784 // Implemented in the test-alloc.cc test suite.
1785 void SimulateFullSpace(PagedSpace* space);
1786
1787
1784 TEST(PrototypeTransitionClearing) { 1788 TEST(PrototypeTransitionClearing) {
1785 InitializeVM(); 1789 InitializeVM();
1786 v8::HandleScope scope; 1790 v8::HandleScope scope;
1787 1791
1788 CompileRun( 1792 CompileRun(
1789 "var base = {};" 1793 "var base = {};"
1790 "var live = [];" 1794 "var live = [];"
1791 "for (var i = 0; i < 10; i++) {" 1795 "for (var i = 0; i < 10; i++) {"
1792 " var object = {};" 1796 " var object = {};"
1793 " var prototype = {};" 1797 " var prototype = {};"
(...skipping 18 matching lines...) Expand all
1812 int j = Map::kProtoTransitionHeaderSize + 1816 int j = Map::kProtoTransitionHeaderSize +
1813 i * Map::kProtoTransitionElementsPerEntry; 1817 i * Map::kProtoTransitionElementsPerEntry;
1814 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); 1818 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
1815 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); 1819 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset);
1816 CHECK(proto->IsTheHole() || proto->IsJSObject()); 1820 CHECK(proto->IsTheHole() || proto->IsJSObject());
1817 } 1821 }
1818 1822
1819 // Make sure next prototype is placed on an old-space evacuation candidate. 1823 // Make sure next prototype is placed on an old-space evacuation candidate.
1820 Handle<JSObject> prototype; 1824 Handle<JSObject> prototype;
1821 PagedSpace* space = HEAP->old_pointer_space(); 1825 PagedSpace* space = HEAP->old_pointer_space();
1822 do { 1826 {
1827 AlwaysAllocateScope always_allocate;
1828 SimulateFullSpace(space);
1823 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); 1829 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
1824 } while (space->FirstPage() == space->LastPage() || 1830 }
1825 !space->LastPage()->Contains(prototype->address()));
1826 1831
1827 // Add a prototype on an evacuation candidate and verify that transition 1832 // Add a prototype on an evacuation candidate and verify that transition
1828 // clearing correctly records slots in prototype transition array. 1833 // clearing correctly records slots in prototype transition array.
1829 i::FLAG_always_compact = true; 1834 i::FLAG_always_compact = true;
1830 Handle<Map> map(baseObject->map()); 1835 Handle<Map> map(baseObject->map());
1831 CHECK(!space->LastPage()->Contains( 1836 CHECK(!space->LastPage()->Contains(
1832 map->GetPrototypeTransitions()->address())); 1837 map->GetPrototypeTransitions()->address()));
1833 CHECK(space->LastPage()->Contains(prototype->address())); 1838 CHECK(space->LastPage()->Contains(prototype->address()));
1834 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); 1839 baseObject->SetPrototype(*prototype, false)->ToObjectChecked();
1835 CHECK(map->GetPrototypeTransition(*prototype)->IsMap()); 1840 CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 v8::Utils::OpenHandle( 2092 v8::Utils::OpenHandle(
2088 *v8::Handle<v8::Object>::Cast( 2093 *v8::Handle<v8::Object>::Cast(
2089 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); 2094 v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
2090 2095
2091 // The root object should be in a sane state. 2096 // The root object should be in a sane state.
2092 CHECK(root->IsJSObject()); 2097 CHECK(root->IsJSObject());
2093 CHECK(root->map()->IsMap()); 2098 CHECK(root->map()->IsMap());
2094 } 2099 }
2095 2100
2096 2101
2097 // Implemented in the test-alloc.cc test suite.
2098 void SimulateFullSpace(PagedSpace* space);
2099
2100
2101 TEST(ReleaseOverReservedPages) { 2102 TEST(ReleaseOverReservedPages) {
2102 i::FLAG_trace_gc = true; 2103 i::FLAG_trace_gc = true;
2103 // The optimizer can allocate stuff, messing up the test. 2104 // The optimizer can allocate stuff, messing up the test.
2104 i::FLAG_crankshaft = false; 2105 i::FLAG_crankshaft = false;
2105 i::FLAG_always_opt = false; 2106 i::FLAG_always_opt = false;
2106 InitializeVM(); 2107 InitializeVM();
2107 v8::HandleScope scope; 2108 v8::HandleScope scope;
2108 static const int number_of_test_pages = 20; 2109 static const int number_of_test_pages = 20;
2109 2110
2110 // Prepare many pages with low live-bytes count. 2111 // Prepare many pages with low live-bytes count.
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 Handle<Object> call_function(call); 2506 Handle<Object> call_function(call);
2506 2507
2507 // Now we are ready to mess up the heap. 2508 // Now we are ready to mess up the heap.
2508 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); 2509 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
2509 2510
2510 // Either heap verification caught the problem already or we go kaboom once 2511 // Either heap verification caught the problem already or we go kaboom once
2511 // the CallIC is executed the next time. 2512 // the CallIC is executed the next time.
2512 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); 2513 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode));
2513 CompileRun("call();"); 2514 CompileRun("call();");
2514 } 2515 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698