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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); | 1925 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); |
1926 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); | 1926 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); |
1927 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); | 1927 HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); |
1928 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2); | 1928 CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2); |
1929 | 1929 |
1930 // Triggering a last-resort GC should cause all pages to be released | 1930 // Triggering a last-resort GC should cause all pages to be released |
1931 // to the OS so that other processes can seize the memory. | 1931 // to the OS so that other processes can seize the memory. |
1932 HEAP->CollectAllAvailableGarbage("triggered really hard"); | 1932 HEAP->CollectAllAvailableGarbage("triggered really hard"); |
1933 CHECK_EQ(1, old_pointer_space->CountTotalPages()); | 1933 CHECK_EQ(1, old_pointer_space->CountTotalPages()); |
1934 } | 1934 } |
| 1935 |
| 1936 |
| 1937 TEST(Regress2237) { |
| 1938 InitializeVM(); |
| 1939 v8::HandleScope scope; |
| 1940 Handle<String> slice(HEAP->empty_string()); |
| 1941 |
| 1942 { |
| 1943 // Generate a parent that lives in new-space. |
| 1944 v8::HandleScope inner_scope; |
| 1945 const char* c = "This text is long enough to trigger sliced strings."; |
| 1946 Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c)); |
| 1947 CHECK(s->IsSeqAsciiString()); |
| 1948 CHECK(HEAP->InNewSpace(*s)); |
| 1949 |
| 1950 // Generate a sliced string that is based on the above parent and |
| 1951 // lives in old-space. |
| 1952 FillUpNewSpace(HEAP->new_space()); |
| 1953 AlwaysAllocateScope always_allocate; |
| 1954 Handle<String> t; |
| 1955 // TODO(mstarzinger): Unfortunately FillUpNewSpace() still leaves |
| 1956 // some slack, so we need to allocate a few sliced strings. |
| 1957 for (int i = 0; i < 16; i++) { |
| 1958 t = FACTORY->NewProperSubString(s, 5, 35); |
| 1959 } |
| 1960 CHECK(t->IsSlicedString()); |
| 1961 CHECK(!HEAP->InNewSpace(*t)); |
| 1962 *slice.location() = *t.location(); |
| 1963 } |
| 1964 |
| 1965 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); |
| 1966 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 1967 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); |
| 1968 } |
OLD | NEW |