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

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

Issue 10041025: Merged r11143, r11162, r11174, r11208, r11213, r11222 into 3.9 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.9
Patch Set: Created 8 years, 8 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 | « src/version.cc ('k') | no next file » | 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 "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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 1514
1515 Handle<JSFunction> f = 1515 Handle<JSFunction> f =
1516 v8::Utils::OpenHandle( 1516 v8::Utils::OpenHandle(
1517 *v8::Handle<v8::Function>::Cast( 1517 *v8::Handle<v8::Function>::Cast(
1518 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 1518 v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
1519 1519
1520 CHECK(f->IsOptimized()); 1520 CHECK(f->IsOptimized());
1521 1521
1522 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && 1522 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) &&
1523 !marking->IsStopped()) { 1523 !marking->IsStopped()) {
1524 marking->Step(MB); 1524 // Discard any pending GC requests otherwise we will get GC when we enter
1525 // code below.
1526 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
1525 } 1527 }
1526 1528
1527 CHECK(marking->IsMarking()); 1529 CHECK(marking->IsMarking());
1528 1530
1529 // Discard any pending GC requests otherwise we will get GC when we enter
1530 // code below.
1531 if (ISOLATE->stack_guard()->IsGCRequest()) {
1532 ISOLATE->stack_guard()->Continue(GC_REQUEST);
1533 }
1534
1535 { 1531 {
1536 v8::HandleScope scope; 1532 v8::HandleScope scope;
1537 v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global(); 1533 v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global();
1538 v8::Handle<v8::Function> g = 1534 v8::Handle<v8::Function> g =
1539 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); 1535 v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
1540 g->Call(global, 0, NULL); 1536 g->Call(global, 0, NULL);
1541 } 1537 }
1542 1538
1543 HEAP->incremental_marking()->set_should_hurry(true); 1539 HEAP->incremental_marking()->set_should_hurry(true);
1544 HEAP->CollectGarbage(OLD_POINTER_SPACE); 1540 HEAP->CollectGarbage(OLD_POINTER_SPACE);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 // clearing correctly records slots in prototype transition array. 1586 // clearing correctly records slots in prototype transition array.
1591 i::FLAG_always_compact = true; 1587 i::FLAG_always_compact = true;
1592 Handle<Map> map(baseObject->map()); 1588 Handle<Map> map(baseObject->map());
1593 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address())); 1589 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address()));
1594 CHECK(space->LastPage()->Contains(prototype->address())); 1590 CHECK(space->LastPage()->Contains(prototype->address()));
1595 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); 1591 baseObject->SetPrototype(*prototype, false)->ToObjectChecked();
1596 CHECK(map->GetPrototypeTransition(*prototype)->IsMap()); 1592 CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
1597 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1593 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1598 CHECK(map->GetPrototypeTransition(*prototype)->IsMap()); 1594 CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
1599 } 1595 }
1596
1597
1598 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
1599 i::FLAG_allow_natives_syntax = true;
1600 #ifdef DEBUG
1601 i::FLAG_verify_heap = true;
1602 #endif
1603 InitializeVM();
1604 if (!i::V8::UseCrankshaft()) return;
1605 v8::HandleScope outer_scope;
1606
1607 {
1608 v8::HandleScope scope;
1609 CompileRun(
1610 "function f () {"
1611 " var s = 0;"
1612 " for (var i = 0; i < 100; i++) s += i;"
1613 " return s;"
1614 "}"
1615 "f(); f();"
1616 "%OptimizeFunctionOnNextCall(f);"
1617 "f();");
1618 }
1619 Handle<JSFunction> f =
1620 v8::Utils::OpenHandle(
1621 *v8::Handle<v8::Function>::Cast(
1622 v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
1623 CHECK(f->IsOptimized());
1624
1625 IncrementalMarking* marking = HEAP->incremental_marking();
1626 marking->Abort();
1627 marking->Start();
1628
1629 // The following two calls will increment HEAP->global_ic_age().
1630 const int kLongIdlePauseInMs = 1000;
1631 v8::V8::ContextDisposedNotification();
1632 v8::V8::IdleNotification(kLongIdlePauseInMs);
1633
1634 while (!marking->IsStopped() && !marking->IsComplete()) {
1635 marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
1636 }
1637
1638 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age());
1639 CHECK_EQ(0, f->shared()->opt_count());
1640 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
1641 }
1642
1643
1644 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
1645 i::FLAG_allow_natives_syntax = true;
1646 #ifdef DEBUG
1647 i::FLAG_verify_heap = true;
1648 #endif
1649 InitializeVM();
1650 if (!i::V8::UseCrankshaft()) return;
1651 v8::HandleScope outer_scope;
1652
1653 {
1654 v8::HandleScope scope;
1655 CompileRun(
1656 "function f () {"
1657 " var s = 0;"
1658 " for (var i = 0; i < 100; i++) s += i;"
1659 " return s;"
1660 "}"
1661 "f(); f();"
1662 "%OptimizeFunctionOnNextCall(f);"
1663 "f();");
1664 }
1665 Handle<JSFunction> f =
1666 v8::Utils::OpenHandle(
1667 *v8::Handle<v8::Function>::Cast(
1668 v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
1669 CHECK(f->IsOptimized());
1670
1671 HEAP->incremental_marking()->Abort();
1672
1673 // The following two calls will increment HEAP->global_ic_age().
1674 // Since incremental marking is off, IdleNotification will do full GC.
1675 const int kLongIdlePauseInMs = 1000;
1676 v8::V8::ContextDisposedNotification();
1677 v8::V8::IdleNotification(kLongIdlePauseInMs);
1678
1679 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age());
1680 CHECK_EQ(0, f->shared()->opt_count());
1681 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
1682 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698