| OLD | NEW |
| 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 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 // Test that map transitions are cleared and maps are collected with | 1752 // Test that map transitions are cleared and maps are collected with |
| 1753 // incremental marking as well. | 1753 // incremental marking as well. |
| 1754 TEST(Regress1465) { | 1754 TEST(Regress1465) { |
| 1755 i::FLAG_allow_natives_syntax = true; | 1755 i::FLAG_allow_natives_syntax = true; |
| 1756 i::FLAG_trace_incremental_marking = true; | 1756 i::FLAG_trace_incremental_marking = true; |
| 1757 InitializeVM(); | 1757 InitializeVM(); |
| 1758 v8::HandleScope scope; | 1758 v8::HandleScope scope; |
| 1759 | 1759 |
| 1760 #define TRANSITION_COUNT 256 | 1760 #define TRANSITION_COUNT 256 |
| 1761 for (int i = 0; i < TRANSITION_COUNT; i++) { | 1761 for (int i = 0; i < TRANSITION_COUNT; i++) { |
| 1762 EmbeddedVector<char, 32> buffer; | 1762 EmbeddedVector<char, 64> buffer; |
| 1763 OS::SNPrintF(buffer, "var o = {}; o.prop%d = %d;", i); | 1763 OS::SNPrintF(buffer, "var o = new Object; o.prop%d = %d;", i, i); |
| 1764 CompileRun(buffer.start()); | 1764 CompileRun(buffer.start()); |
| 1765 } | 1765 } |
| 1766 CompileRun("var root = {};"); | 1766 CompileRun("var root = new Object;"); |
| 1767 Handle<JSObject> root = | 1767 Handle<JSObject> root = |
| 1768 v8::Utils::OpenHandle( | 1768 v8::Utils::OpenHandle( |
| 1769 *v8::Handle<v8::Object>::Cast( | 1769 *v8::Handle<v8::Object>::Cast( |
| 1770 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); | 1770 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); |
| 1771 | 1771 |
| 1772 // Count number of live transitions before marking. | 1772 // Count number of live transitions before marking. |
| 1773 int transitions_before = CountMapTransitions(root->map()); | 1773 int transitions_before = CountMapTransitions(root->map()); |
| 1774 CompileRun("%DebugPrint(root);"); | 1774 CompileRun("%DebugPrint(root);"); |
| 1775 CHECK_EQ(TRANSITION_COUNT, transitions_before); | 1775 CHECK_EQ(TRANSITION_COUNT, transitions_before); |
| 1776 | 1776 |
| 1777 // Go through all incremental marking steps in one swoop. | 1777 // Go through all incremental marking steps in one swoop. |
| 1778 IncrementalMarking* marking = HEAP->incremental_marking(); | 1778 IncrementalMarking* marking = HEAP->incremental_marking(); |
| 1779 CHECK(marking->IsStopped()); | 1779 CHECK(marking->IsStopped()); |
| 1780 marking->Start(); | 1780 marking->Start(); |
| 1781 CHECK(marking->IsMarking()); | 1781 CHECK(marking->IsMarking()); |
| 1782 while (!marking->IsComplete()) { | 1782 while (!marking->IsComplete()) { |
| 1783 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 1783 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
| 1784 } | 1784 } |
| 1785 CHECK(marking->IsComplete()); | 1785 CHECK(marking->IsComplete()); |
| 1786 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1786 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 1787 CHECK(marking->IsStopped()); | 1787 CHECK(marking->IsStopped()); |
| 1788 | 1788 |
| 1789 // Count number of live transitions after marking. Note that one transition | 1789 // Count number of live transitions after marking. Note that one transition |
| 1790 // is left, because 'o' still holds an instance of one transition target. | 1790 // is left, because 'o' still holds an instance of one transition target. |
| 1791 int transitions_after = CountMapTransitions(root->map()); | 1791 int transitions_after = CountMapTransitions(root->map()); |
| 1792 CompileRun("%DebugPrint(root);"); | 1792 CompileRun("%DebugPrint(root);"); |
| 1793 CHECK_EQ(1, transitions_after); | 1793 CHECK_EQ(1, transitions_after); |
| 1794 } | 1794 } |
| OLD | NEW |