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

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

Issue 982143002: Revert of Simplify and compact transitions storage (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/transitions-inl.h ('k') | test/cctest/test-migrations.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 v8::Handle<v8::Function> g = 2134 v8::Handle<v8::Function> g =
2135 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); 2135 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
2136 g->Call(global, 0, NULL); 2136 g->Call(global, 0, NULL);
2137 } 2137 }
2138 2138
2139 CcTest::heap()->incremental_marking()->set_should_hurry(true); 2139 CcTest::heap()->incremental_marking()->set_should_hurry(true);
2140 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); 2140 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE);
2141 } 2141 }
2142 2142
2143 2143
2144 static int NumberOfProtoTransitions(Map* map) {
2145 return TransitionArray::NumberOfPrototypeTransitions(
2146 TransitionArray::GetPrototypeTransitions(map));
2147 }
2148
2149
2150 TEST(PrototypeTransitionClearing) { 2144 TEST(PrototypeTransitionClearing) {
2151 if (FLAG_never_compact) return; 2145 if (FLAG_never_compact) return;
2152 CcTest::InitializeVM(); 2146 CcTest::InitializeVM();
2153 Isolate* isolate = CcTest::i_isolate(); 2147 Isolate* isolate = CcTest::i_isolate();
2154 Factory* factory = isolate->factory(); 2148 Factory* factory = isolate->factory();
2155 v8::HandleScope scope(CcTest::isolate()); 2149 v8::HandleScope scope(CcTest::isolate());
2156 2150
2157 CompileRun("var base = {};"); 2151 CompileRun("var base = {};");
2158 Handle<JSObject> baseObject = 2152 Handle<JSObject> baseObject =
2159 v8::Utils::OpenHandle( 2153 v8::Utils::OpenHandle(
2160 *v8::Handle<v8::Object>::Cast( 2154 *v8::Handle<v8::Object>::Cast(
2161 CcTest::global()->Get(v8_str("base")))); 2155 CcTest::global()->Get(v8_str("base"))));
2162 int initialTransitions = NumberOfProtoTransitions(baseObject->map()); 2156 int initialTransitions = baseObject->map()->NumberOfProtoTransitions();
2163 2157
2164 CompileRun( 2158 CompileRun(
2165 "var live = [];" 2159 "var live = [];"
2166 "for (var i = 0; i < 10; i++) {" 2160 "for (var i = 0; i < 10; i++) {"
2167 " var object = {};" 2161 " var object = {};"
2168 " var prototype = {};" 2162 " var prototype = {};"
2169 " object.__proto__ = prototype;" 2163 " object.__proto__ = prototype;"
2170 " if (i >= 3) live.push(object, prototype);" 2164 " if (i >= 3) live.push(object, prototype);"
2171 "}"); 2165 "}");
2172 2166
2173 // Verify that only dead prototype transitions are cleared. 2167 // Verify that only dead prototype transitions are cleared.
2174 CHECK_EQ(initialTransitions + 10, 2168 CHECK_EQ(initialTransitions + 10,
2175 NumberOfProtoTransitions(baseObject->map())); 2169 baseObject->map()->NumberOfProtoTransitions());
2176 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 2170 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2177 const int transitions = 10 - 3; 2171 const int transitions = 10 - 3;
2178 CHECK_EQ(initialTransitions + transitions, 2172 CHECK_EQ(initialTransitions + transitions,
2179 NumberOfProtoTransitions(baseObject->map())); 2173 baseObject->map()->NumberOfProtoTransitions());
2180 2174
2181 // Verify that prototype transitions array was compacted. 2175 // Verify that prototype transitions array was compacted.
2182 FixedArray* trans = 2176 FixedArray* trans = baseObject->map()->GetPrototypeTransitions();
2183 TransitionArray::GetPrototypeTransitions(baseObject->map());
2184 for (int i = initialTransitions; i < initialTransitions + transitions; i++) { 2177 for (int i = initialTransitions; i < initialTransitions + transitions; i++) {
2185 int j = TransitionArray::kProtoTransitionHeaderSize + i; 2178 int j = Map::kProtoTransitionHeaderSize + i;
2186 CHECK(trans->get(j)->IsMap()); 2179 CHECK(trans->get(j)->IsMap());
2187 } 2180 }
2188 2181
2189 // Make sure next prototype is placed on an old-space evacuation candidate. 2182 // Make sure next prototype is placed on an old-space evacuation candidate.
2190 Handle<JSObject> prototype; 2183 Handle<JSObject> prototype;
2191 PagedSpace* space = CcTest::heap()->old_pointer_space(); 2184 PagedSpace* space = CcTest::heap()->old_pointer_space();
2192 { 2185 {
2193 AlwaysAllocateScope always_allocate(isolate); 2186 AlwaysAllocateScope always_allocate(isolate);
2194 SimulateFullSpace(space); 2187 SimulateFullSpace(space);
2195 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); 2188 prototype = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
2196 } 2189 }
2197 2190
2198 // Add a prototype on an evacuation candidate and verify that transition 2191 // Add a prototype on an evacuation candidate and verify that transition
2199 // clearing correctly records slots in prototype transition array. 2192 // clearing correctly records slots in prototype transition array.
2200 i::FLAG_always_compact = true; 2193 i::FLAG_always_compact = true;
2201 Handle<Map> map(baseObject->map()); 2194 Handle<Map> map(baseObject->map());
2202 CHECK(!space->LastPage()->Contains( 2195 CHECK(!space->LastPage()->Contains(
2203 TransitionArray::GetPrototypeTransitions(*map)->address())); 2196 map->GetPrototypeTransitions()->address()));
2204 CHECK(space->LastPage()->Contains(prototype->address())); 2197 CHECK(space->LastPage()->Contains(prototype->address()));
2205 } 2198 }
2206 2199
2207 2200
2208 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { 2201 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
2209 i::FLAG_stress_compaction = false; 2202 i::FLAG_stress_compaction = false;
2210 i::FLAG_allow_natives_syntax = true; 2203 i::FLAG_allow_natives_syntax = true;
2211 #ifdef VERIFY_HEAP 2204 #ifdef VERIFY_HEAP
2212 i::FLAG_verify_heap = true; 2205 i::FLAG_verify_heap = true;
2213 #endif 2206 #endif
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value()); 2869 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2877 2870
2878 Handle<JSObject> o = 2871 Handle<JSObject> o =
2879 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2872 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2880 2873
2881 CHECK(CcTest::heap()->InNewSpace(o->elements())); 2874 CHECK(CcTest::heap()->InNewSpace(o->elements()));
2882 } 2875 }
2883 2876
2884 2877
2885 static int CountMapTransitions(Map* map) { 2878 static int CountMapTransitions(Map* map) {
2886 return TransitionArray::NumberOfTransitions(map->raw_transitions()); 2879 return map->transitions()->number_of_transitions();
2887 } 2880 }
2888 2881
2889 2882
2890 // Test that map transitions are cleared and maps are collected with 2883 // Test that map transitions are cleared and maps are collected with
2891 // incremental marking as well. 2884 // incremental marking as well.
2892 TEST(Regress1465) { 2885 TEST(Regress1465) {
2893 i::FLAG_stress_compaction = false; 2886 i::FLAG_stress_compaction = false;
2894 i::FLAG_allow_natives_syntax = true; 2887 i::FLAG_allow_natives_syntax = true;
2895 i::FLAG_trace_incremental_marking = true; 2888 i::FLAG_trace_incremental_marking = true;
2896 CcTest::InitializeVM(); 2889 CcTest::InitializeVM();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 CompileRun("var root = new F;"); 3048 CompileRun("var root = new F;");
3056 Handle<JSObject> root = GetByName("root"); 3049 Handle<JSObject> root = GetByName("root");
3057 3050
3058 // Count number of live transitions before marking. 3051 // Count number of live transitions before marking.
3059 int transitions_before = CountMapTransitions(root->map()); 3052 int transitions_before = CountMapTransitions(root->map());
3060 CHECK_EQ(transitions_count, transitions_before); 3053 CHECK_EQ(transitions_count, transitions_before);
3061 3054
3062 CompileRun("o = new F;" 3055 CompileRun("o = new F;"
3063 "root = new F"); 3056 "root = new F");
3064 root = GetByName("root"); 3057 root = GetByName("root");
3065 DCHECK(TransitionArray::IsSimpleTransition(root->map()->raw_transitions())); 3058 DCHECK(root->map()->transitions()->IsSimpleTransition());
3066 AddPropertyTo(2, root, "happy"); 3059 AddPropertyTo(2, root, "happy");
3067 3060
3068 // Count number of live transitions after marking. Note that one transition 3061 // Count number of live transitions after marking. Note that one transition
3069 // is left, because 'o' still holds an instance of one transition target. 3062 // is left, because 'o' still holds an instance of one transition target.
3070 int transitions_after = CountMapTransitions( 3063 int transitions_after = CountMapTransitions(
3071 Map::cast(root->map()->GetBackPointer())); 3064 Map::cast(root->map()->GetBackPointer()));
3072 CHECK_EQ(1, transitions_after); 3065 CHECK_EQ(1, transitions_after);
3073 } 3066 }
3074 #endif // DEBUG 3067 #endif // DEBUG
3075 3068
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after
5092 #ifdef DEBUG 5085 #ifdef DEBUG
5093 TEST(PathTracer) { 5086 TEST(PathTracer) {
5094 CcTest::InitializeVM(); 5087 CcTest::InitializeVM();
5095 v8::HandleScope scope(CcTest::isolate()); 5088 v8::HandleScope scope(CcTest::isolate());
5096 5089
5097 v8::Local<v8::Value> result = CompileRun("'abc'"); 5090 v8::Local<v8::Value> result = CompileRun("'abc'");
5098 Handle<Object> o = v8::Utils::OpenHandle(*result); 5091 Handle<Object> o = v8::Utils::OpenHandle(*result);
5099 CcTest::i_isolate()->heap()->TracePathToObject(*o); 5092 CcTest::i_isolate()->heap()->TracePathToObject(*o);
5100 } 5093 }
5101 #endif // DEBUG 5094 #endif // DEBUG
OLDNEW
« no previous file with comments | « src/transitions-inl.h ('k') | test/cctest/test-migrations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698