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

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

Issue 11092081: Reland r12342: Flush monomorphic ICs on context disposal instead of context exit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 8 years, 2 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/test-api.cc ('k') | test/mjsunit/debug-script.js » ('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 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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 // Remove function f1, and 1060 // Remove function f1, and
1061 CompileRun("f1=null"); 1061 CompileRun("f1=null");
1062 1062
1063 // Scavenge treats these references as strong. 1063 // Scavenge treats these references as strong.
1064 for (int j = 0; j < 10; j++) { 1064 for (int j = 0; j < 10; j++) {
1065 HEAP->PerformScavenge(); 1065 HEAP->PerformScavenge();
1066 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); 1066 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i]));
1067 } 1067 }
1068 1068
1069 // Mark compact handles the weak references. 1069 // Mark compact handles the weak references.
1070 ISOLATE->compilation_cache()->Clear();
1070 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1071 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1071 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); 1072 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
1072 1073
1073 // Get rid of f3 and f5 in the same way. 1074 // Get rid of f3 and f5 in the same way.
1074 CompileRun("f3=null"); 1075 CompileRun("f3=null");
1075 for (int j = 0; j < 10; j++) { 1076 for (int j = 0; j < 10; j++) {
1076 HEAP->PerformScavenge(); 1077 HEAP->PerformScavenge();
1077 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); 1078 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
1078 } 1079 }
1079 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1080 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 v8::Local<v8::Value> res = CompileRun( 1392 v8::Local<v8::Value> res = CompileRun(
1392 "function f() { return o.x; }" 1393 "function f() { return o.x; }"
1393 "for (var i = 0; i < 10; ++i) f();" 1394 "for (var i = 0; i < 10; ++i) f();"
1394 "%OptimizeFunctionOnNextCall(f);" 1395 "%OptimizeFunctionOnNextCall(f);"
1395 "f();"); 1396 "f();");
1396 CHECK_EQ(42, res->Int32Value()); 1397 CHECK_EQ(42, res->Int32Value());
1397 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1398 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1398 ctx2->Exit(); 1399 ctx2->Exit();
1399 ctx1->Exit(); 1400 ctx1->Exit();
1400 ctx1.Dispose(); 1401 ctx1.Dispose();
1402 v8::V8::ContextDisposedNotification();
1401 } 1403 }
1402 HEAP->CollectAllAvailableGarbage(); 1404 HEAP->CollectAllAvailableGarbage();
1403 CHECK_EQ(2, NumberOfGlobalObjects()); 1405 CHECK_EQ(2, NumberOfGlobalObjects());
1404 ctx2.Dispose(); 1406 ctx2.Dispose();
1405 HEAP->CollectAllAvailableGarbage(); 1407 HEAP->CollectAllAvailableGarbage();
1406 CHECK_EQ(0, NumberOfGlobalObjects()); 1408 CHECK_EQ(0, NumberOfGlobalObjects());
1407 } 1409 }
1408 1410
1409 1411
1410 // Test that we don't embed functions from foreign contexts into 1412 // Test that we don't embed functions from foreign contexts into
(...skipping 17 matching lines...) Expand all
1428 v8::Local<v8::Value> res = CompileRun( 1430 v8::Local<v8::Value> res = CompileRun(
1429 "function f(x) { return x(); }" 1431 "function f(x) { return x(); }"
1430 "for (var i = 0; i < 10; ++i) f(o);" 1432 "for (var i = 0; i < 10; ++i) f(o);"
1431 "%OptimizeFunctionOnNextCall(f);" 1433 "%OptimizeFunctionOnNextCall(f);"
1432 "f(o);"); 1434 "f(o);");
1433 CHECK_EQ(42, res->Int32Value()); 1435 CHECK_EQ(42, res->Int32Value());
1434 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1436 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1435 ctx2->Exit(); 1437 ctx2->Exit();
1436 ctx1->Exit(); 1438 ctx1->Exit();
1437 ctx1.Dispose(); 1439 ctx1.Dispose();
1440 v8::V8::ContextDisposedNotification();
1438 } 1441 }
1439 HEAP->CollectAllAvailableGarbage(); 1442 HEAP->CollectAllAvailableGarbage();
1440 CHECK_EQ(2, NumberOfGlobalObjects()); 1443 CHECK_EQ(2, NumberOfGlobalObjects());
1441 ctx2.Dispose(); 1444 ctx2.Dispose();
1442 HEAP->CollectAllAvailableGarbage(); 1445 HEAP->CollectAllAvailableGarbage();
1443 CHECK_EQ(0, NumberOfGlobalObjects()); 1446 CHECK_EQ(0, NumberOfGlobalObjects());
1444 } 1447 }
1445 1448
1446 1449
1447 TEST(LeakNativeContextViaMapKeyed) { 1450 TEST(LeakNativeContextViaMapKeyed) {
(...skipping 15 matching lines...) Expand all
1463 v8::Local<v8::Value> res = CompileRun( 1466 v8::Local<v8::Value> res = CompileRun(
1464 "function f() { return o[0]; }" 1467 "function f() { return o[0]; }"
1465 "for (var i = 0; i < 10; ++i) f();" 1468 "for (var i = 0; i < 10; ++i) f();"
1466 "%OptimizeFunctionOnNextCall(f);" 1469 "%OptimizeFunctionOnNextCall(f);"
1467 "f();"); 1470 "f();");
1468 CHECK_EQ(42, res->Int32Value()); 1471 CHECK_EQ(42, res->Int32Value());
1469 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1472 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1470 ctx2->Exit(); 1473 ctx2->Exit();
1471 ctx1->Exit(); 1474 ctx1->Exit();
1472 ctx1.Dispose(); 1475 ctx1.Dispose();
1476 v8::V8::ContextDisposedNotification();
1473 } 1477 }
1474 HEAP->CollectAllAvailableGarbage(); 1478 HEAP->CollectAllAvailableGarbage();
1475 CHECK_EQ(2, NumberOfGlobalObjects()); 1479 CHECK_EQ(2, NumberOfGlobalObjects());
1476 ctx2.Dispose(); 1480 ctx2.Dispose();
1477 HEAP->CollectAllAvailableGarbage(); 1481 HEAP->CollectAllAvailableGarbage();
1478 CHECK_EQ(0, NumberOfGlobalObjects()); 1482 CHECK_EQ(0, NumberOfGlobalObjects());
1479 } 1483 }
1480 1484
1481 1485
1482 TEST(LeakNativeContextViaMapProto) { 1486 TEST(LeakNativeContextViaMapProto) {
(...skipping 19 matching lines...) Expand all
1502 " return p.x;" 1506 " return p.x;"
1503 "}" 1507 "}"
1504 "for (var i = 0; i < 10; ++i) f();" 1508 "for (var i = 0; i < 10; ++i) f();"
1505 "%OptimizeFunctionOnNextCall(f);" 1509 "%OptimizeFunctionOnNextCall(f);"
1506 "f();"); 1510 "f();");
1507 CHECK_EQ(42, res->Int32Value()); 1511 CHECK_EQ(42, res->Int32Value());
1508 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1512 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1509 ctx2->Exit(); 1513 ctx2->Exit();
1510 ctx1->Exit(); 1514 ctx1->Exit();
1511 ctx1.Dispose(); 1515 ctx1.Dispose();
1516 v8::V8::ContextDisposedNotification();
1512 } 1517 }
1513 HEAP->CollectAllAvailableGarbage(); 1518 HEAP->CollectAllAvailableGarbage();
1514 CHECK_EQ(2, NumberOfGlobalObjects()); 1519 CHECK_EQ(2, NumberOfGlobalObjects());
1515 ctx2.Dispose(); 1520 ctx2.Dispose();
1516 HEAP->CollectAllAvailableGarbage(); 1521 HEAP->CollectAllAvailableGarbage();
1517 CHECK_EQ(0, NumberOfGlobalObjects()); 1522 CHECK_EQ(0, NumberOfGlobalObjects());
1518 } 1523 }
1519 1524
1520 1525
1521 TEST(InstanceOfStubWriteBarrier) { 1526 TEST(InstanceOfStubWriteBarrier) {
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 2106 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
2102 "function f(o) { return o.x; } f(obj); f(obj);"); 2107 "function f(o) { return o.x; } f(obj); f(obj);");
2103 Handle<JSFunction> f = 2108 Handle<JSFunction> f =
2104 v8::Utils::OpenHandle( 2109 v8::Utils::OpenHandle(
2105 *v8::Handle<v8::Function>::Cast( 2110 *v8::Handle<v8::Function>::Cast(
2106 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2111 v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2107 2112
2108 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2113 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2109 CHECK(ic_before->ic_state() == MONOMORPHIC); 2114 CHECK(ic_before->ic_state() == MONOMORPHIC);
2110 2115
2111 // Fire context dispose notification.
2112 v8::V8::ContextDisposedNotification();
2113 SimulateIncrementalMarking(); 2116 SimulateIncrementalMarking();
2114 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2117 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2115 2118
2116 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2119 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2117 CHECK(ic_after->ic_state() == MONOMORPHIC); 2120 CHECK(ic_after->ic_state() == MONOMORPHIC);
2118 } 2121 }
2119 2122
2120 2123
2121 TEST(IncrementalMarkingClearsMonomorhpicIC) { 2124 TEST(IncrementalMarkingClearsMonomorhpicIC) {
2122 if (i::FLAG_always_opt) return; 2125 if (i::FLAG_always_opt) return;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 Handle<Object> call_function(call); 2301 Handle<Object> call_function(call);
2299 2302
2300 // Now we are ready to mess up the heap. 2303 // Now we are ready to mess up the heap.
2301 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); 2304 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
2302 2305
2303 // Either heap verification caught the problem already or we go kaboom once 2306 // Either heap verification caught the problem already or we go kaboom once
2304 // the CallIC is executed the next time. 2307 // the CallIC is executed the next time.
2305 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); 2308 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode));
2306 CompileRun("call();"); 2309 CompileRun("call();");
2307 } 2310 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/debug-script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698