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

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

Issue 439233002: Remove all encountered weak maps from the list of weak collections when incremental marking is abor… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | « test/cctest/cctest.h ('k') | test/cctest/test-weakmaps.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 22 matching lines...) Expand all
33 #include "src/compilation-cache.h" 33 #include "src/compilation-cache.h"
34 #include "src/execution.h" 34 #include "src/execution.h"
35 #include "src/factory.h" 35 #include "src/factory.h"
36 #include "src/global-handles.h" 36 #include "src/global-handles.h"
37 #include "src/macro-assembler.h" 37 #include "src/macro-assembler.h"
38 #include "src/stub-cache.h" 38 #include "src/stub-cache.h"
39 #include "test/cctest/cctest.h" 39 #include "test/cctest/cctest.h"
40 40
41 using namespace v8::internal; 41 using namespace v8::internal;
42 42
43 // Go through all incremental marking steps in one swoop.
44 static void SimulateIncrementalMarking() {
45 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
46 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
47 if (collector->sweeping_in_progress()) {
48 collector->EnsureSweepingCompleted();
49 }
50 CHECK(marking->IsMarking() || marking->IsStopped());
51 if (marking->IsStopped()) {
52 marking->Start();
53 }
54 CHECK(marking->IsMarking());
55 while (!marking->IsComplete()) {
56 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
57 }
58 CHECK(marking->IsComplete());
59 }
60
61
62 static void CheckMap(Map* map, int type, int instance_size) { 43 static void CheckMap(Map* map, int type, int instance_size) {
63 CHECK(map->IsHeapObject()); 44 CHECK(map->IsHeapObject());
64 #ifdef DEBUG 45 #ifdef DEBUG
65 CHECK(CcTest::heap()->Contains(map)); 46 CHECK(CcTest::heap()->Contains(map));
66 #endif 47 #endif
67 CHECK_EQ(CcTest::heap()->meta_map(), map->map()); 48 CHECK_EQ(CcTest::heap()->meta_map(), map->map());
68 CHECK_EQ(type, map->instance_type()); 49 CHECK_EQ(type, map->instance_type());
69 CHECK_EQ(instance_size, map->instance_size()); 50 CHECK_EQ(instance_size, map->instance_size());
70 } 51 }
71 52
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 CHECK(function->shared()->is_compiled()); 1197 CHECK(function->shared()->is_compiled());
1217 1198
1218 // The code will survive at least two GCs. 1199 // The code will survive at least two GCs.
1219 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1200 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1220 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1201 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1221 CHECK(function->shared()->is_compiled()); 1202 CHECK(function->shared()->is_compiled());
1222 1203
1223 // Simulate several GCs that use incremental marking. 1204 // Simulate several GCs that use incremental marking.
1224 const int kAgingThreshold = 6; 1205 const int kAgingThreshold = 6;
1225 for (int i = 0; i < kAgingThreshold; i++) { 1206 for (int i = 0; i < kAgingThreshold; i++) {
1226 SimulateIncrementalMarking(); 1207 SimulateIncrementalMarking(CcTest::heap());
1227 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1208 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1228 } 1209 }
1229 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 1210 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1230 CHECK(!function->is_compiled() || function->IsOptimized()); 1211 CHECK(!function->is_compiled() || function->IsOptimized());
1231 1212
1232 // This compile will compile the function again. 1213 // This compile will compile the function again.
1233 { v8::HandleScope scope(CcTest::isolate()); 1214 { v8::HandleScope scope(CcTest::isolate());
1234 CompileRun("foo();"); 1215 CompileRun("foo();");
1235 } 1216 }
1236 1217
1237 // Simulate several GCs that use incremental marking but make sure 1218 // Simulate several GCs that use incremental marking but make sure
1238 // the loop breaks once the function is enqueued as a candidate. 1219 // the loop breaks once the function is enqueued as a candidate.
1239 for (int i = 0; i < kAgingThreshold; i++) { 1220 for (int i = 0; i < kAgingThreshold; i++) {
1240 SimulateIncrementalMarking(); 1221 SimulateIncrementalMarking(CcTest::heap());
1241 if (!function->next_function_link()->IsUndefined()) break; 1222 if (!function->next_function_link()->IsUndefined()) break;
1242 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1223 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1243 } 1224 }
1244 1225
1245 // Force optimization while incremental marking is active and while 1226 // Force optimization while incremental marking is active and while
1246 // the function is enqueued as a candidate. 1227 // the function is enqueued as a candidate.
1247 { v8::HandleScope scope(CcTest::isolate()); 1228 { v8::HandleScope scope(CcTest::isolate());
1248 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); 1229 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();");
1249 } 1230 }
1250 1231
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 // object is still located in new-space. 1287 // object is still located in new-space.
1307 const int kAgingThreshold = 6; 1288 const int kAgingThreshold = 6;
1308 for (int i = 0; i < kAgingThreshold; i++) { 1289 for (int i = 0; i < kAgingThreshold; i++) {
1309 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 1290 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1310 function2->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 1291 function2->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1311 } 1292 }
1312 1293
1313 // Simulate incremental marking so that the functions are enqueued as 1294 // Simulate incremental marking so that the functions are enqueued as
1314 // code flushing candidates. Then kill one of the functions. Finally 1295 // code flushing candidates. Then kill one of the functions. Finally
1315 // perform a scavenge while incremental marking is still running. 1296 // perform a scavenge while incremental marking is still running.
1316 SimulateIncrementalMarking(); 1297 SimulateIncrementalMarking(CcTest::heap());
1317 *function2.location() = NULL; 1298 *function2.location() = NULL;
1318 CcTest::heap()->CollectGarbage(NEW_SPACE, "test scavenge while marking"); 1299 CcTest::heap()->CollectGarbage(NEW_SPACE, "test scavenge while marking");
1319 1300
1320 // Simulate one final GC to make sure the candidate queue is sane. 1301 // Simulate one final GC to make sure the candidate queue is sane.
1321 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 1302 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
1322 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 1303 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1323 CHECK(!function->is_compiled() || function->IsOptimized()); 1304 CHECK(!function->is_compiled() || function->IsOptimized());
1324 } 1305 }
1325 1306
1326 1307
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 CHECK(function->shared()->is_compiled()); 1341 CHECK(function->shared()->is_compiled());
1361 1342
1362 // Bump the code age so that flushing is triggered. 1343 // Bump the code age so that flushing is triggered.
1363 const int kAgingThreshold = 6; 1344 const int kAgingThreshold = 6;
1364 for (int i = 0; i < kAgingThreshold; i++) { 1345 for (int i = 0; i < kAgingThreshold; i++) {
1365 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 1346 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1366 } 1347 }
1367 1348
1368 // Simulate incremental marking so that the function is enqueued as 1349 // Simulate incremental marking so that the function is enqueued as
1369 // code flushing candidate. 1350 // code flushing candidate.
1370 SimulateIncrementalMarking(); 1351 SimulateIncrementalMarking(heap);
1371 1352
1372 // Enable the debugger and add a breakpoint while incremental marking 1353 // Enable the debugger and add a breakpoint while incremental marking
1373 // is running so that incremental marking aborts and code flushing is 1354 // is running so that incremental marking aborts and code flushing is
1374 // disabled. 1355 // disabled.
1375 int position = 0; 1356 int position = 0;
1376 Handle<Object> breakpoint_object(Smi::FromInt(0), isolate); 1357 Handle<Object> breakpoint_object(Smi::FromInt(0), isolate);
1377 isolate->debug()->SetBreakPoint(function, breakpoint_object, &position); 1358 isolate->debug()->SetBreakPoint(function, breakpoint_object, &position);
1378 isolate->debug()->ClearAllBreakPoints(); 1359 isolate->debug()->ClearAllBreakPoints();
1379 1360
1380 // Force optimization now that code flushing is disabled. 1361 // Force optimization now that code flushing is disabled.
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 Handle<JSObject> root = 2732 Handle<JSObject> root =
2752 v8::Utils::OpenHandle( 2733 v8::Utils::OpenHandle(
2753 *v8::Handle<v8::Object>::Cast( 2734 *v8::Handle<v8::Object>::Cast(
2754 CcTest::global()->Get(v8_str("root")))); 2735 CcTest::global()->Get(v8_str("root"))));
2755 2736
2756 // Count number of live transitions before marking. 2737 // Count number of live transitions before marking.
2757 int transitions_before = CountMapTransitions(root->map()); 2738 int transitions_before = CountMapTransitions(root->map());
2758 CompileRun("%DebugPrint(root);"); 2739 CompileRun("%DebugPrint(root);");
2759 CHECK_EQ(transitions_count, transitions_before); 2740 CHECK_EQ(transitions_count, transitions_before);
2760 2741
2761 SimulateIncrementalMarking(); 2742 SimulateIncrementalMarking(CcTest::heap());
2762 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2743 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2763 2744
2764 // Count number of live transitions after marking. Note that one transition 2745 // Count number of live transitions after marking. Note that one transition
2765 // is left, because 'o' still holds an instance of one transition target. 2746 // is left, because 'o' still holds an instance of one transition target.
2766 int transitions_after = CountMapTransitions(root->map()); 2747 int transitions_after = CountMapTransitions(root->map());
2767 CompileRun("%DebugPrint(root);"); 2748 CompileRun("%DebugPrint(root);");
2768 CHECK_EQ(1, transitions_after); 2749 CHECK_EQ(1, transitions_after);
2769 } 2750 }
2770 2751
2771 2752
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 i::FLAG_incremental_marking = true; 2897 i::FLAG_incremental_marking = true;
2917 CcTest::InitializeVM(); 2898 CcTest::InitializeVM();
2918 v8::HandleScope scope(CcTest::isolate()); 2899 v8::HandleScope scope(CcTest::isolate());
2919 2900
2920 // Prepare a map transition from the root object together with a yet 2901 // Prepare a map transition from the root object together with a yet
2921 // untransitioned root object. 2902 // untransitioned root object.
2922 CompileRun("var root = new Object;" 2903 CompileRun("var root = new Object;"
2923 "root.foo = 0;" 2904 "root.foo = 0;"
2924 "root = new Object;"); 2905 "root = new Object;");
2925 2906
2926 SimulateIncrementalMarking(); 2907 SimulateIncrementalMarking(CcTest::heap());
2927 2908
2928 // Compile a StoreIC that performs the prepared map transition. This 2909 // Compile a StoreIC that performs the prepared map transition. This
2929 // will restart incremental marking and should make sure the root is 2910 // will restart incremental marking and should make sure the root is
2930 // marked grey again. 2911 // marked grey again.
2931 CompileRun("function f(o) {" 2912 CompileRun("function f(o) {"
2932 " o.foo = 0;" 2913 " o.foo = 0;"
2933 "}" 2914 "}"
2934 "f(new Object);" 2915 "f(new Object);"
2935 "f(root);"); 2916 "f(root);");
2936 2917
(...skipping 20 matching lines...) Expand all
2957 i::FLAG_allow_natives_syntax = true; 2938 i::FLAG_allow_natives_syntax = true;
2958 CcTest::InitializeVM(); 2939 CcTest::InitializeVM();
2959 v8::HandleScope scope(CcTest::isolate()); 2940 v8::HandleScope scope(CcTest::isolate());
2960 2941
2961 // Prepare a map transition from the root object together with a yet 2942 // Prepare a map transition from the root object together with a yet
2962 // untransitioned root object. 2943 // untransitioned root object.
2963 CompileRun("var root = new Object;" 2944 CompileRun("var root = new Object;"
2964 "root.foo = 0;" 2945 "root.foo = 0;"
2965 "root = new Object;"); 2946 "root = new Object;");
2966 2947
2967 SimulateIncrementalMarking(); 2948 SimulateIncrementalMarking(CcTest::heap());
2968 2949
2969 // Compile an optimized LStoreNamedField that performs the prepared 2950 // Compile an optimized LStoreNamedField that performs the prepared
2970 // map transition. This will restart incremental marking and should 2951 // map transition. This will restart incremental marking and should
2971 // make sure the root is marked grey again. 2952 // make sure the root is marked grey again.
2972 CompileRun("function f(o) {" 2953 CompileRun("function f(o) {"
2973 " o.foo = 0;" 2954 " o.foo = 0;"
2974 "}" 2955 "}"
2975 "f(new Object);" 2956 "f(new Object);"
2976 "f(new Object);" 2957 "f(new Object);"
2977 "%OptimizeFunctionOnNextCall(f);" 2958 "%OptimizeFunctionOnNextCall(f);"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
3160 Handle<FixedArray> feedback_vector(f->shared()->feedback_vector()); 3141 Handle<FixedArray> feedback_vector(f->shared()->feedback_vector());
3161 3142
3162 int expected_length = FLAG_vector_ics ? 4 : 2; 3143 int expected_length = FLAG_vector_ics ? 4 : 2;
3163 CHECK_EQ(expected_length, feedback_vector->length()); 3144 CHECK_EQ(expected_length, feedback_vector->length());
3164 for (int i = 0; i < expected_length; i++) { 3145 for (int i = 0; i < expected_length; i++) {
3165 if ((i % 2) == 1) { 3146 if ((i % 2) == 1) {
3166 CHECK(feedback_vector->get(i)->IsJSFunction()); 3147 CHECK(feedback_vector->get(i)->IsJSFunction());
3167 } 3148 }
3168 } 3149 }
3169 3150
3170 SimulateIncrementalMarking(); 3151 SimulateIncrementalMarking(CcTest::heap());
3171 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 3152 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
3172 3153
3173 CHECK_EQ(expected_length, feedback_vector->length()); 3154 CHECK_EQ(expected_length, feedback_vector->length());
3174 for (int i = 0; i < expected_length; i++) { 3155 for (int i = 0; i < expected_length; i++) {
3175 CHECK_EQ(feedback_vector->get(i), 3156 CHECK_EQ(feedback_vector->get(i),
3176 *TypeFeedbackInfo::UninitializedSentinel(CcTest::i_isolate())); 3157 *TypeFeedbackInfo::UninitializedSentinel(CcTest::i_isolate()));
3177 } 3158 }
3178 } 3159 }
3179 3160
3180 3161
(...skipping 22 matching lines...) Expand all
3203 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 3184 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
3204 "function f(o) { return o.x; } f(obj); f(obj);"); 3185 "function f(o) { return o.x; } f(obj); f(obj);");
3205 Handle<JSFunction> f = 3186 Handle<JSFunction> f =
3206 v8::Utils::OpenHandle( 3187 v8::Utils::OpenHandle(
3207 *v8::Handle<v8::Function>::Cast( 3188 *v8::Handle<v8::Function>::Cast(
3208 CcTest::global()->Get(v8_str("f")))); 3189 CcTest::global()->Get(v8_str("f"))));
3209 3190
3210 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3191 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3211 CHECK(ic_before->ic_state() == MONOMORPHIC); 3192 CHECK(ic_before->ic_state() == MONOMORPHIC);
3212 3193
3213 SimulateIncrementalMarking(); 3194 SimulateIncrementalMarking(CcTest::heap());
3214 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 3195 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
3215 3196
3216 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3197 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3217 CHECK(ic_after->ic_state() == MONOMORPHIC); 3198 CHECK(ic_after->ic_state() == MONOMORPHIC);
3218 } 3199 }
3219 3200
3220 3201
3221 TEST(IncrementalMarkingClearsMonomorphicIC) { 3202 TEST(IncrementalMarkingClearsMonomorphicIC) {
3222 if (i::FLAG_always_opt) return; 3203 if (i::FLAG_always_opt) return;
3223 CcTest::InitializeVM(); 3204 CcTest::InitializeVM();
(...skipping 13 matching lines...) Expand all
3237 Handle<JSFunction> f = 3218 Handle<JSFunction> f =
3238 v8::Utils::OpenHandle( 3219 v8::Utils::OpenHandle(
3239 *v8::Handle<v8::Function>::Cast( 3220 *v8::Handle<v8::Function>::Cast(
3240 CcTest::global()->Get(v8_str("f")))); 3221 CcTest::global()->Get(v8_str("f"))));
3241 3222
3242 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3223 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3243 CHECK(ic_before->ic_state() == MONOMORPHIC); 3224 CHECK(ic_before->ic_state() == MONOMORPHIC);
3244 3225
3245 // Fire context dispose notification. 3226 // Fire context dispose notification.
3246 CcTest::isolate()->ContextDisposedNotification(); 3227 CcTest::isolate()->ContextDisposedNotification();
3247 SimulateIncrementalMarking(); 3228 SimulateIncrementalMarking(CcTest::heap());
3248 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 3229 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
3249 3230
3250 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3231 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3251 CHECK(IC::IsCleared(ic_after)); 3232 CHECK(IC::IsCleared(ic_after));
3252 } 3233 }
3253 3234
3254 3235
3255 TEST(IncrementalMarkingClearsPolymorphicIC) { 3236 TEST(IncrementalMarkingClearsPolymorphicIC) {
3256 if (i::FLAG_always_opt) return; 3237 if (i::FLAG_always_opt) return;
3257 CcTest::InitializeVM(); 3238 CcTest::InitializeVM();
(...skipping 20 matching lines...) Expand all
3278 Handle<JSFunction> f = 3259 Handle<JSFunction> f =
3279 v8::Utils::OpenHandle( 3260 v8::Utils::OpenHandle(
3280 *v8::Handle<v8::Function>::Cast( 3261 *v8::Handle<v8::Function>::Cast(
3281 CcTest::global()->Get(v8_str("f")))); 3262 CcTest::global()->Get(v8_str("f"))));
3282 3263
3283 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3264 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3284 CHECK(ic_before->ic_state() == POLYMORPHIC); 3265 CHECK(ic_before->ic_state() == POLYMORPHIC);
3285 3266
3286 // Fire context dispose notification. 3267 // Fire context dispose notification.
3287 CcTest::isolate()->ContextDisposedNotification(); 3268 CcTest::isolate()->ContextDisposedNotification();
3288 SimulateIncrementalMarking(); 3269 SimulateIncrementalMarking(CcTest::heap());
3289 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 3270 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
3290 3271
3291 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3272 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3292 CHECK(IC::IsCleared(ic_after)); 3273 CHECK(IC::IsCleared(ic_after));
3293 } 3274 }
3294 3275
3295 3276
3296 class SourceResource: public v8::String::ExternalAsciiStringResource { 3277 class SourceResource: public v8::String::ExternalAsciiStringResource {
3297 public: 3278 public:
3298 explicit SourceResource(const char* data) 3279 explicit SourceResource(const char* data)
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 for (int i = 0; i < kAgingThreshold; i++) { 3420 for (int i = 0; i < kAgingThreshold; i++) {
3440 g->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3421 g->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3441 } 3422 }
3442 3423
3443 code = inner_scope.CloseAndEscape(Handle<Code>(f->code())); 3424 code = inner_scope.CloseAndEscape(Handle<Code>(f->code()));
3444 } 3425 }
3445 3426
3446 // Simulate incremental marking so that the functions are enqueued as 3427 // Simulate incremental marking so that the functions are enqueued as
3447 // code flushing candidates. Then optimize one function. Finally 3428 // code flushing candidates. Then optimize one function. Finally
3448 // finish the GC to complete code flushing. 3429 // finish the GC to complete code flushing.
3449 SimulateIncrementalMarking(); 3430 SimulateIncrementalMarking(heap);
3450 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); 3431 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);");
3451 heap->CollectAllGarbage(Heap::kNoGCFlags); 3432 heap->CollectAllGarbage(Heap::kNoGCFlags);
3452 3433
3453 // Unoptimized code is missing and the deoptimizer will go ballistic. 3434 // Unoptimized code is missing and the deoptimizer will go ballistic.
3454 CompileRun("g('bozo');"); 3435 CompileRun("g('bozo');");
3455 } 3436 }
3456 3437
3457 3438
3458 TEST(Regress165495) { 3439 TEST(Regress165495) {
3459 i::FLAG_allow_natives_syntax = true; 3440 i::FLAG_allow_natives_syntax = true;
(...skipping 26 matching lines...) Expand all
3486 const int kAgingThreshold = 6; 3467 const int kAgingThreshold = 6;
3487 for (int i = 0; i < kAgingThreshold; i++) { 3468 for (int i = 0; i < kAgingThreshold; i++) {
3488 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3469 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3489 } 3470 }
3490 3471
3491 CompileRun("f = null;"); 3472 CompileRun("f = null;");
3492 } 3473 }
3493 3474
3494 // Simulate incremental marking so that unoptimized code is flushed 3475 // Simulate incremental marking so that unoptimized code is flushed
3495 // even though it still is cached in the optimized code map. 3476 // even though it still is cached in the optimized code map.
3496 SimulateIncrementalMarking(); 3477 SimulateIncrementalMarking(heap);
3497 heap->CollectAllGarbage(Heap::kNoGCFlags); 3478 heap->CollectAllGarbage(Heap::kNoGCFlags);
3498 3479
3499 // Make a new closure that will get code installed from the code map. 3480 // Make a new closure that will get code installed from the code map.
3500 // Unoptimized code is missing and the deoptimizer will go ballistic. 3481 // Unoptimized code is missing and the deoptimizer will go ballistic.
3501 CompileRun("var g = mkClosure(); g('bozo');"); 3482 CompileRun("var g = mkClosure(); g('bozo');");
3502 } 3483 }
3503 3484
3504 3485
3505 TEST(Regress169209) { 3486 TEST(Regress169209) {
3506 i::FLAG_stress_compaction = false; 3487 i::FLAG_stress_compaction = false;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3554 CHECK(f->is_compiled()); 3535 CHECK(f->is_compiled());
3555 const int kAgingThreshold = 6; 3536 const int kAgingThreshold = 6;
3556 for (int i = 0; i < kAgingThreshold; i++) { 3537 for (int i = 0; i < kAgingThreshold; i++) {
3557 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3538 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3558 } 3539 }
3559 3540
3560 shared2 = inner_scope.CloseAndEscape(handle(f->shared(), isolate)); 3541 shared2 = inner_scope.CloseAndEscape(handle(f->shared(), isolate));
3561 } 3542 }
3562 3543
3563 // Simulate incremental marking and collect code flushing candidates. 3544 // Simulate incremental marking and collect code flushing candidates.
3564 SimulateIncrementalMarking(); 3545 SimulateIncrementalMarking(heap);
3565 CHECK(shared1->code()->gc_metadata() != NULL); 3546 CHECK(shared1->code()->gc_metadata() != NULL);
3566 3547
3567 // Optimize function and make sure the unoptimized code is replaced. 3548 // Optimize function and make sure the unoptimized code is replaced.
3568 #ifdef DEBUG 3549 #ifdef DEBUG
3569 FLAG_stop_at = "f"; 3550 FLAG_stop_at = "f";
3570 #endif 3551 #endif
3571 CompileRun("%OptimizeFunctionOnNextCall(g);" 3552 CompileRun("%OptimizeFunctionOnNextCall(g);"
3572 "g(false);"); 3553 "g(false);");
3573 3554
3574 // Finish garbage collection cycle. 3555 // Finish garbage collection cycle.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3700 for (int i = 0; i < kAgingThreshold; i++) { 3681 for (int i = 0; i < kAgingThreshold; i++) {
3701 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3682 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3702 } 3683 }
3703 3684
3704 function = inner_scope.CloseAndEscape(handle(*f, isolate)); 3685 function = inner_scope.CloseAndEscape(handle(*f, isolate));
3705 } 3686 }
3706 3687
3707 // Simulate incremental marking so that unoptimized function is enqueued as a 3688 // Simulate incremental marking so that unoptimized function is enqueued as a
3708 // candidate for code flushing. The shared function info however will not be 3689 // candidate for code flushing. The shared function info however will not be
3709 // explicitly enqueued. 3690 // explicitly enqueued.
3710 SimulateIncrementalMarking(); 3691 SimulateIncrementalMarking(heap);
3711 3692
3712 // Now optimize the function so that it is taken off the candidate list. 3693 // Now optimize the function so that it is taken off the candidate list.
3713 { 3694 {
3714 HandleScope inner_scope(isolate); 3695 HandleScope inner_scope(isolate);
3715 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);"); 3696 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);");
3716 } 3697 }
3717 3698
3718 // This cycle will bust the heap and subsequent cycles will go ballistic. 3699 // This cycle will bust the heap and subsequent cycles will go ballistic.
3719 heap->CollectAllGarbage(Heap::kNoGCFlags); 3700 heap->CollectAllGarbage(Heap::kNoGCFlags);
3720 heap->CollectAllGarbage(Heap::kNoGCFlags); 3701 heap->CollectAllGarbage(Heap::kNoGCFlags);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3757 for (int i = 0; i < kAgingThreshold; i++) { 3738 for (int i = 0; i < kAgingThreshold; i++) {
3758 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 3739 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
3759 } 3740 }
3760 3741
3761 function = inner_scope.CloseAndEscape(handle(*f, isolate)); 3742 function = inner_scope.CloseAndEscape(handle(*f, isolate));
3762 } 3743 }
3763 3744
3764 // Simulate incremental marking so that unoptimized function is enqueued as a 3745 // Simulate incremental marking so that unoptimized function is enqueued as a
3765 // candidate for code flushing. The shared function info however will not be 3746 // candidate for code flushing. The shared function info however will not be
3766 // explicitly enqueued. 3747 // explicitly enqueued.
3767 SimulateIncrementalMarking(); 3748 SimulateIncrementalMarking(heap);
3768 3749
3769 // Now enable the debugger which in turn will disable code flushing. 3750 // Now enable the debugger which in turn will disable code flushing.
3770 CHECK(isolate->debug()->Load()); 3751 CHECK(isolate->debug()->Load());
3771 3752
3772 // This cycle will bust the heap and subsequent cycles will go ballistic. 3753 // This cycle will bust the heap and subsequent cycles will go ballistic.
3773 heap->CollectAllGarbage(Heap::kNoGCFlags); 3754 heap->CollectAllGarbage(Heap::kNoGCFlags);
3774 heap->CollectAllGarbage(Heap::kNoGCFlags); 3755 heap->CollectAllGarbage(Heap::kNoGCFlags);
3775 } 3756 }
3776 3757
3777 3758
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
4005 i::FLAG_weak_embedded_objects_in_optimized_code = true; 3986 i::FLAG_weak_embedded_objects_in_optimized_code = true;
4006 i::FLAG_allow_natives_syntax = true; 3987 i::FLAG_allow_natives_syntax = true;
4007 i::FLAG_compilation_cache = false; 3988 i::FLAG_compilation_cache = false;
4008 CcTest::InitializeVM(); 3989 CcTest::InitializeVM();
4009 Isolate* isolate = CcTest::i_isolate(); 3990 Isolate* isolate = CcTest::i_isolate();
4010 v8::internal::Heap* heap = CcTest::heap(); 3991 v8::internal::Heap* heap = CcTest::heap();
4011 3992
4012 if (!isolate->use_crankshaft()) return; 3993 if (!isolate->use_crankshaft()) return;
4013 HandleScope outer_scope(heap->isolate()); 3994 HandleScope outer_scope(heap->isolate());
4014 for (int i = 0; i < 3; i++) { 3995 for (int i = 0; i < 3; i++) {
4015 SimulateIncrementalMarking(); 3996 SimulateIncrementalMarking(heap);
4016 { 3997 {
4017 LocalContext context; 3998 LocalContext context;
4018 HandleScope scope(heap->isolate()); 3999 HandleScope scope(heap->isolate());
4019 EmbeddedVector<char, 256> source; 4000 EmbeddedVector<char, 256> source;
4020 SNPrintF(source, 4001 SNPrintF(source,
4021 "function bar%d() {" 4002 "function bar%d() {"
4022 " return foo%d(1);" 4003 " return foo%d(1);"
4023 "};" 4004 "};"
4024 "function foo%d(x) { with (x) { return 1 + x; } };" 4005 "function foo%d(x) { with (x) { return 1 + x; } };"
4025 "bar%d();" 4006 "bar%d();"
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
4496 #ifdef DEBUG 4477 #ifdef DEBUG
4497 TEST(PathTracer) { 4478 TEST(PathTracer) {
4498 CcTest::InitializeVM(); 4479 CcTest::InitializeVM();
4499 v8::HandleScope scope(CcTest::isolate()); 4480 v8::HandleScope scope(CcTest::isolate());
4500 4481
4501 v8::Local<v8::Value> result = CompileRun("'abc'"); 4482 v8::Local<v8::Value> result = CompileRun("'abc'");
4502 Handle<Object> o = v8::Utils::OpenHandle(*result); 4483 Handle<Object> o = v8::Utils::OpenHandle(*result);
4503 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4484 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4504 } 4485 }
4505 #endif // DEBUG 4486 #endif // DEBUG
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | test/cctest/test-weakmaps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698