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 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 ctx2->Exit(); | 1440 ctx2->Exit(); |
1441 ctx1->Exit(); | 1441 ctx1->Exit(); |
1442 ctx1.Dispose(); | 1442 ctx1.Dispose(); |
1443 } | 1443 } |
1444 HEAP->CollectAllAvailableGarbage(); | 1444 HEAP->CollectAllAvailableGarbage(); |
1445 CHECK_EQ(2, NumberOfGlobalObjects()); | 1445 CHECK_EQ(2, NumberOfGlobalObjects()); |
1446 ctx2.Dispose(); | 1446 ctx2.Dispose(); |
1447 HEAP->CollectAllAvailableGarbage(); | 1447 HEAP->CollectAllAvailableGarbage(); |
1448 CHECK_EQ(0, NumberOfGlobalObjects()); | 1448 CHECK_EQ(0, NumberOfGlobalObjects()); |
1449 } | 1449 } |
| 1450 |
| 1451 |
| 1452 TEST(InstanceOfStubWriteBarrier) { |
| 1453 if (!i::FLAG_crankshaft) return; |
| 1454 i::FLAG_allow_natives_syntax = true; |
| 1455 #ifdef DEBUG |
| 1456 i::FLAG_verify_heap = true; |
| 1457 #endif |
| 1458 InitializeVM(); |
| 1459 v8::HandleScope outer_scope; |
| 1460 |
| 1461 { |
| 1462 v8::HandleScope scope; |
| 1463 CompileRun( |
| 1464 "function foo () { }" |
| 1465 "function mkbar () { return new (new Function(\"\")) (); }" |
| 1466 "function f (x) { return (x instanceof foo); }" |
| 1467 "function g () { f(mkbar()); }" |
| 1468 "f(new foo()); f(new foo());" |
| 1469 "%OptimizeFunctionOnNextCall(f);" |
| 1470 "f(new foo()); g();"); |
| 1471 } |
| 1472 |
| 1473 IncrementalMarking* marking = HEAP->incremental_marking(); |
| 1474 marking->Abort(); |
| 1475 marking->Start(); |
| 1476 |
| 1477 Handle<JSFunction> f = |
| 1478 v8::Utils::OpenHandle( |
| 1479 *v8::Handle<v8::Function>::Cast( |
| 1480 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| 1481 |
| 1482 CHECK(f->IsOptimized()); |
| 1483 |
| 1484 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && |
| 1485 !marking->IsStopped()) { |
| 1486 marking->Step(MB); |
| 1487 } |
| 1488 |
| 1489 CHECK(marking->IsMarking()); |
| 1490 |
| 1491 // Discard any pending GC requests otherwise we will get GC when we enter |
| 1492 // code below. |
| 1493 if (ISOLATE->stack_guard()->IsGCRequest()) { |
| 1494 ISOLATE->stack_guard()->Continue(GC_REQUEST); |
| 1495 } |
| 1496 |
| 1497 { |
| 1498 v8::HandleScope scope; |
| 1499 v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global(); |
| 1500 v8::Handle<v8::Function> g = |
| 1501 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); |
| 1502 g->Call(global, 0, NULL); |
| 1503 } |
| 1504 |
| 1505 HEAP->incremental_marking()->set_should_hurry(true); |
| 1506 HEAP->CollectGarbage(OLD_POINTER_SPACE); |
| 1507 } |
OLD | NEW |