OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 "execution.h" | 7 #include "execution.h" |
8 #include "factory.h" | 8 #include "factory.h" |
9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
10 #include "global-handles.h" | 10 #include "global-handles.h" |
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1469 ctx2->Exit(); | 1469 ctx2->Exit(); |
1470 ctx1->Exit(); | 1470 ctx1->Exit(); |
1471 ctx1.Dispose(); | 1471 ctx1.Dispose(); |
1472 } | 1472 } |
1473 HEAP->CollectAllAvailableGarbage(); | 1473 HEAP->CollectAllAvailableGarbage(); |
1474 CHECK_EQ(2, NumberOfGlobalObjects()); | 1474 CHECK_EQ(2, NumberOfGlobalObjects()); |
1475 ctx2.Dispose(); | 1475 ctx2.Dispose(); |
1476 HEAP->CollectAllAvailableGarbage(); | 1476 HEAP->CollectAllAvailableGarbage(); |
1477 CHECK_EQ(0, NumberOfGlobalObjects()); | 1477 CHECK_EQ(0, NumberOfGlobalObjects()); |
1478 } | 1478 } |
1479 | |
1480 | |
1481 TEST(InstanceOfStubWriteBarrier) { | |
1482 if (!i::FLAG_crankshaft) return; | |
1483 i::FLAG_allow_natives_syntax = true; | |
1484 i::FLAG_verify_heap = true; | |
1485 InitializeVM(); | |
1486 v8::HandleScope outer_scope; | |
1487 | |
1488 { | |
1489 v8::HandleScope scope; | |
1490 CompileRun( | |
1491 "function foo () { }" | |
1492 "function mkbar () { return new (new Function(\"\")) (); }" | |
1493 "function f (x) { return (x instanceof foo); }" | |
1494 "function g () { f(mkbar()); }" | |
1495 "f(new foo()); f(new foo());" | |
1496 "%OptimizeFunctionOnNextCall(f);" | |
1497 "f(new foo()); g();"); | |
Michael Starzinger
2012/01/11 09:35:09
As discussed offline, the call to g() could probab
| |
1498 } | |
1499 | |
1500 IncrementalMarking* marking = HEAP->incremental_marking(); | |
1501 marking->Abort(); | |
1502 marking->Start(); | |
1503 | |
1504 Handle<JSFunction> f = | |
1505 v8::Utils::OpenHandle( | |
1506 *v8::Handle<v8::Function>::Cast( | |
1507 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); | |
1508 | |
1509 CHECK(f->IsOptimized()); | |
1510 | |
1511 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && | |
1512 !marking->IsStopped()) { | |
1513 marking->Step(MB); | |
1514 } | |
1515 | |
1516 CHECK(marking->IsMarking()); | |
1517 | |
1518 // Discard any pending GC requests otherwise we will get GC when we enter | |
1519 // code below. | |
1520 if (ISOLATE->stack_guard()->IsGCRequest()) { | |
1521 ISOLATE->stack_guard()->Continue(GC_REQUEST); | |
1522 } | |
1523 | |
1524 { | |
1525 v8::HandleScope scope; | |
1526 v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global(); | |
1527 v8::Handle<v8::Function> g = | |
1528 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); | |
1529 g->Call(global, 0, NULL); | |
1530 } | |
1531 | |
1532 HEAP->incremental_marking()->set_should_hurry(true); | |
1533 HEAP->CollectGarbage(OLD_POINTER_SPACE); | |
1534 } | |
OLD | NEW |