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

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

Issue 676393002: Reland "Limit the number of transitions allowed per hidden class." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make sure TransitionArray::Insert() is called only when it is allowed Created 6 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 | « src/transitions-inl.h ('k') | 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 // 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 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 2841
2842 // Count number of live transitions before marking. 2842 // Count number of live transitions before marking.
2843 int transitions_before = CountMapTransitions(root->map()); 2843 int transitions_before = CountMapTransitions(root->map());
2844 CHECK_EQ(transitions_count, transitions_before); 2844 CHECK_EQ(transitions_count, transitions_before);
2845 2845
2846 // Get rid of o 2846 // Get rid of o
2847 CompileRun("o = new F;" 2847 CompileRun("o = new F;"
2848 "root = new F"); 2848 "root = new F");
2849 root = GetByName("root"); 2849 root = GetByName("root");
2850 AddPropertyTo(2, root, "funny"); 2850 AddPropertyTo(2, root, "funny");
2851 CcTest::heap()->CollectGarbage(NEW_SPACE);
2851 2852
2852 // Count number of live transitions after marking. Note that one transition 2853 // Count number of live transitions after marking. Note that one transition
2853 // is left, because 'o' still holds an instance of one transition target. 2854 // is left, because 'o' still holds an instance of one transition target.
2854 int transitions_after = CountMapTransitions( 2855 int transitions_after = CountMapTransitions(
2855 Map::cast(root->map()->GetBackPointer())); 2856 Map::cast(root->map()->GetBackPointer()));
2856 CHECK_EQ(1, transitions_after); 2857 CHECK_EQ(1, transitions_after);
2857 } 2858 }
2858 2859
2859 2860
2860 TEST(TransitionArrayShrinksDuringAllocToOne) { 2861 TEST(TransitionArrayShrinksDuringAllocToOne) {
2861 i::FLAG_stress_compaction = false; 2862 i::FLAG_stress_compaction = false;
2862 i::FLAG_allow_natives_syntax = true; 2863 i::FLAG_allow_natives_syntax = true;
2863 CcTest::InitializeVM(); 2864 CcTest::InitializeVM();
2864 v8::HandleScope scope(CcTest::isolate()); 2865 v8::HandleScope scope(CcTest::isolate());
2865 static const int transitions_count = 10; 2866 static const int transitions_count = 10;
2866 CompileRun("function F() {}"); 2867 CompileRun("function F() {}");
2867 AddTransitions(transitions_count); 2868 AddTransitions(transitions_count);
2868 CompileRun("var root = new F;"); 2869 CompileRun("var root = new F;");
2869 Handle<JSObject> root = GetByName("root"); 2870 Handle<JSObject> root = GetByName("root");
2870 2871
2871 // Count number of live transitions before marking. 2872 // Count number of live transitions before marking.
2872 int transitions_before = CountMapTransitions(root->map()); 2873 int transitions_before = CountMapTransitions(root->map());
2873 CHECK_EQ(transitions_count, transitions_before); 2874 CHECK_EQ(transitions_count, transitions_before);
2874 2875
2875 root = GetByName("root"); 2876 root = GetByName("root");
2876 AddPropertyTo(2, root, "funny"); 2877 AddPropertyTo(2, root, "funny");
2878 CcTest::heap()->CollectGarbage(NEW_SPACE);
2877 2879
2878 // Count number of live transitions after marking. Note that one transition 2880 // Count number of live transitions after marking. Note that one transition
2879 // is left, because 'o' still holds an instance of one transition target. 2881 // is left, because 'o' still holds an instance of one transition target.
2880 int transitions_after = CountMapTransitions( 2882 int transitions_after = CountMapTransitions(
2881 Map::cast(root->map()->GetBackPointer())); 2883 Map::cast(root->map()->GetBackPointer()));
2882 CHECK_EQ(2, transitions_after); 2884 CHECK_EQ(2, transitions_after);
2883 } 2885 }
2884 2886
2885 2887
2886 TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) { 2888 TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) {
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after
4611 #ifdef DEBUG 4613 #ifdef DEBUG
4612 TEST(PathTracer) { 4614 TEST(PathTracer) {
4613 CcTest::InitializeVM(); 4615 CcTest::InitializeVM();
4614 v8::HandleScope scope(CcTest::isolate()); 4616 v8::HandleScope scope(CcTest::isolate());
4615 4617
4616 v8::Local<v8::Value> result = CompileRun("'abc'"); 4618 v8::Local<v8::Value> result = CompileRun("'abc'");
4617 Handle<Object> o = v8::Utils::OpenHandle(*result); 4619 Handle<Object> o = v8::Utils::OpenHandle(*result);
4618 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4620 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4619 } 4621 }
4620 #endif // DEBUG 4622 #endif // DEBUG
OLDNEW
« no previous file with comments | « src/transitions-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698