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

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

Issue 10868068: Revert r12342 "Flush monomorphic ICs on context disposal instead of context exit." because of canar… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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/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"
8 #include "execution.h" 7 #include "execution.h"
9 #include "factory.h" 8 #include "factory.h"
10 #include "macro-assembler.h" 9 #include "macro-assembler.h"
11 #include "global-handles.h" 10 #include "global-handles.h"
12 #include "cctest.h" 11 #include "cctest.h"
13 12
14 using namespace v8::internal; 13 using namespace v8::internal;
15 14
16 static v8::Persistent<v8::Context> env; 15 static v8::Persistent<v8::Context> env;
17 16
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 // Remove function f1, and 1058 // Remove function f1, and
1060 CompileRun("f1=null"); 1059 CompileRun("f1=null");
1061 1060
1062 // Scavenge treats these references as strong. 1061 // Scavenge treats these references as strong.
1063 for (int j = 0; j < 10; j++) { 1062 for (int j = 0; j < 10; j++) {
1064 HEAP->PerformScavenge(); 1063 HEAP->PerformScavenge();
1065 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); 1064 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i]));
1066 } 1065 }
1067 1066
1068 // Mark compact handles the weak references. 1067 // Mark compact handles the weak references.
1069 ISOLATE->compilation_cache()->Clear();
1070 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1068 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1071 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); 1069 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
1072 1070
1073 // Get rid of f3 and f5 in the same way. 1071 // Get rid of f3 and f5 in the same way.
1074 CompileRun("f3=null"); 1072 CompileRun("f3=null");
1075 for (int j = 0; j < 10; j++) { 1073 for (int j = 0; j < 10; j++) {
1076 HEAP->PerformScavenge(); 1074 HEAP->PerformScavenge();
1077 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); 1075 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
1078 } 1076 }
1079 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1077 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 v8::Local<v8::Value> res = CompileRun( 1388 v8::Local<v8::Value> res = CompileRun(
1391 "function f() { return o.x; }" 1389 "function f() { return o.x; }"
1392 "for (var i = 0; i < 10; ++i) f();" 1390 "for (var i = 0; i < 10; ++i) f();"
1393 "%OptimizeFunctionOnNextCall(f);" 1391 "%OptimizeFunctionOnNextCall(f);"
1394 "f();"); 1392 "f();");
1395 CHECK_EQ(42, res->Int32Value()); 1393 CHECK_EQ(42, res->Int32Value());
1396 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1394 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1397 ctx2->Exit(); 1395 ctx2->Exit();
1398 ctx1->Exit(); 1396 ctx1->Exit();
1399 ctx1.Dispose(); 1397 ctx1.Dispose();
1400 v8::V8::ContextDisposedNotification();
1401 } 1398 }
1402 HEAP->CollectAllAvailableGarbage(); 1399 HEAP->CollectAllAvailableGarbage();
1403 CHECK_EQ(2, NumberOfGlobalObjects()); 1400 CHECK_EQ(2, NumberOfGlobalObjects());
1404 ctx2.Dispose(); 1401 ctx2.Dispose();
1405 HEAP->CollectAllAvailableGarbage(); 1402 HEAP->CollectAllAvailableGarbage();
1406 CHECK_EQ(0, NumberOfGlobalObjects()); 1403 CHECK_EQ(0, NumberOfGlobalObjects());
1407 } 1404 }
1408 1405
1409 1406
1410 // Test that we don't embed functions from foreign contexts into 1407 // Test that we don't embed functions from foreign contexts into
(...skipping 17 matching lines...) Expand all
1428 v8::Local<v8::Value> res = CompileRun( 1425 v8::Local<v8::Value> res = CompileRun(
1429 "function f(x) { return x(); }" 1426 "function f(x) { return x(); }"
1430 "for (var i = 0; i < 10; ++i) f(o);" 1427 "for (var i = 0; i < 10; ++i) f(o);"
1431 "%OptimizeFunctionOnNextCall(f);" 1428 "%OptimizeFunctionOnNextCall(f);"
1432 "f(o);"); 1429 "f(o);");
1433 CHECK_EQ(42, res->Int32Value()); 1430 CHECK_EQ(42, res->Int32Value());
1434 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1431 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1435 ctx2->Exit(); 1432 ctx2->Exit();
1436 ctx1->Exit(); 1433 ctx1->Exit();
1437 ctx1.Dispose(); 1434 ctx1.Dispose();
1438 v8::V8::ContextDisposedNotification();
1439 } 1435 }
1440 HEAP->CollectAllAvailableGarbage(); 1436 HEAP->CollectAllAvailableGarbage();
1441 CHECK_EQ(2, NumberOfGlobalObjects()); 1437 CHECK_EQ(2, NumberOfGlobalObjects());
1442 ctx2.Dispose(); 1438 ctx2.Dispose();
1443 HEAP->CollectAllAvailableGarbage(); 1439 HEAP->CollectAllAvailableGarbage();
1444 CHECK_EQ(0, NumberOfGlobalObjects()); 1440 CHECK_EQ(0, NumberOfGlobalObjects());
1445 } 1441 }
1446 1442
1447 1443
1448 TEST(LeakNativeContextViaMapKeyed) { 1444 TEST(LeakNativeContextViaMapKeyed) {
(...skipping 15 matching lines...) Expand all
1464 v8::Local<v8::Value> res = CompileRun( 1460 v8::Local<v8::Value> res = CompileRun(
1465 "function f() { return o[0]; }" 1461 "function f() { return o[0]; }"
1466 "for (var i = 0; i < 10; ++i) f();" 1462 "for (var i = 0; i < 10; ++i) f();"
1467 "%OptimizeFunctionOnNextCall(f);" 1463 "%OptimizeFunctionOnNextCall(f);"
1468 "f();"); 1464 "f();");
1469 CHECK_EQ(42, res->Int32Value()); 1465 CHECK_EQ(42, res->Int32Value());
1470 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1466 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1471 ctx2->Exit(); 1467 ctx2->Exit();
1472 ctx1->Exit(); 1468 ctx1->Exit();
1473 ctx1.Dispose(); 1469 ctx1.Dispose();
1474 v8::V8::ContextDisposedNotification();
1475 } 1470 }
1476 HEAP->CollectAllAvailableGarbage(); 1471 HEAP->CollectAllAvailableGarbage();
1477 CHECK_EQ(2, NumberOfGlobalObjects()); 1472 CHECK_EQ(2, NumberOfGlobalObjects());
1478 ctx2.Dispose(); 1473 ctx2.Dispose();
1479 HEAP->CollectAllAvailableGarbage(); 1474 HEAP->CollectAllAvailableGarbage();
1480 CHECK_EQ(0, NumberOfGlobalObjects()); 1475 CHECK_EQ(0, NumberOfGlobalObjects());
1481 } 1476 }
1482 1477
1483 1478
1484 TEST(LeakNativeContextViaMapProto) { 1479 TEST(LeakNativeContextViaMapProto) {
(...skipping 19 matching lines...) Expand all
1504 " return p.x;" 1499 " return p.x;"
1505 "}" 1500 "}"
1506 "for (var i = 0; i < 10; ++i) f();" 1501 "for (var i = 0; i < 10; ++i) f();"
1507 "%OptimizeFunctionOnNextCall(f);" 1502 "%OptimizeFunctionOnNextCall(f);"
1508 "f();"); 1503 "f();");
1509 CHECK_EQ(42, res->Int32Value()); 1504 CHECK_EQ(42, res->Int32Value());
1510 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1505 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1511 ctx2->Exit(); 1506 ctx2->Exit();
1512 ctx1->Exit(); 1507 ctx1->Exit();
1513 ctx1.Dispose(); 1508 ctx1.Dispose();
1514 v8::V8::ContextDisposedNotification();
1515 } 1509 }
1516 HEAP->CollectAllAvailableGarbage(); 1510 HEAP->CollectAllAvailableGarbage();
1517 CHECK_EQ(2, NumberOfGlobalObjects()); 1511 CHECK_EQ(2, NumberOfGlobalObjects());
1518 ctx2.Dispose(); 1512 ctx2.Dispose();
1519 HEAP->CollectAllAvailableGarbage(); 1513 HEAP->CollectAllAvailableGarbage();
1520 CHECK_EQ(0, NumberOfGlobalObjects()); 1514 CHECK_EQ(0, NumberOfGlobalObjects());
1521 } 1515 }
1522 1516
1523 1517
1524 TEST(InstanceOfStubWriteBarrier) { 1518 TEST(InstanceOfStubWriteBarrier) {
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 2093 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
2100 "function f(o) { return o.x; } f(obj); f(obj);"); 2094 "function f(o) { return o.x; } f(obj); f(obj);");
2101 Handle<JSFunction> f = 2095 Handle<JSFunction> f =
2102 v8::Utils::OpenHandle( 2096 v8::Utils::OpenHandle(
2103 *v8::Handle<v8::Function>::Cast( 2097 *v8::Handle<v8::Function>::Cast(
2104 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2098 v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2105 2099
2106 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2100 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2107 CHECK(ic_before->ic_state() == MONOMORPHIC); 2101 CHECK(ic_before->ic_state() == MONOMORPHIC);
2108 2102
2103 // Fire context dispose notification.
2104 v8::V8::ContextDisposedNotification();
2109 SimulateIncrementalMarking(); 2105 SimulateIncrementalMarking();
2110 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2106 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2111 2107
2112 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2108 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2113 CHECK(ic_after->ic_state() == MONOMORPHIC); 2109 CHECK(ic_after->ic_state() == MONOMORPHIC);
2114 } 2110 }
2115 2111
2116 2112
2117 TEST(IncrementalMarkingClearsMonomorhpicIC) { 2113 TEST(IncrementalMarkingClearsMonomorhpicIC) {
2118 if (i::FLAG_always_opt) return; 2114 if (i::FLAG_always_opt) return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 CHECK(ic_before->ic_state() == MEGAMORPHIC); 2176 CHECK(ic_before->ic_state() == MEGAMORPHIC);
2181 2177
2182 // Fire context dispose notification. 2178 // Fire context dispose notification.
2183 v8::V8::ContextDisposedNotification(); 2179 v8::V8::ContextDisposedNotification();
2184 SimulateIncrementalMarking(); 2180 SimulateIncrementalMarking();
2185 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2181 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2186 2182
2187 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 2183 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2188 CHECK(ic_after->ic_state() == UNINITIALIZED); 2184 CHECK(ic_after->ic_state() == UNINITIALIZED);
2189 } 2185 }
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