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

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

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