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 "compilation-cache.h" | 7 #include "compilation-cache.h" |
8 #include "execution.h" | 8 #include "execution.h" |
9 #include "factory.h" | 9 #include "factory.h" |
10 #include "macro-assembler.h" | 10 #include "macro-assembler.h" |
(...skipping 2132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 TEST(Regress2237) { | 2143 TEST(Regress2237) { |
2144 InitializeVM(); | 2144 InitializeVM(); |
2145 v8::HandleScope scope; | 2145 v8::HandleScope scope; |
2146 Handle<String> slice(HEAP->empty_string()); | 2146 Handle<String> slice(HEAP->empty_string()); |
2147 | 2147 |
2148 { | 2148 { |
2149 // Generate a parent that lives in new-space. | 2149 // Generate a parent that lives in new-space. |
2150 v8::HandleScope inner_scope; | 2150 v8::HandleScope inner_scope; |
2151 const char* c = "This text is long enough to trigger sliced strings."; | 2151 const char* c = "This text is long enough to trigger sliced strings."; |
2152 Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c)); | 2152 Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c)); |
2153 CHECK(s->IsSeqAsciiString()); | 2153 CHECK(s->IsSeqOneByteString()); |
2154 CHECK(HEAP->InNewSpace(*s)); | 2154 CHECK(HEAP->InNewSpace(*s)); |
2155 | 2155 |
2156 // Generate a sliced string that is based on the above parent and | 2156 // Generate a sliced string that is based on the above parent and |
2157 // lives in old-space. | 2157 // lives in old-space. |
2158 FillUpNewSpace(HEAP->new_space()); | 2158 FillUpNewSpace(HEAP->new_space()); |
2159 AlwaysAllocateScope always_allocate; | 2159 AlwaysAllocateScope always_allocate; |
2160 Handle<String> t; | 2160 Handle<String> t; |
2161 // TODO(mstarzinger): Unfortunately FillUpNewSpace() still leaves | 2161 // TODO(mstarzinger): Unfortunately FillUpNewSpace() still leaves |
2162 // some slack, so we need to allocate a few sliced strings. | 2162 // some slack, so we need to allocate a few sliced strings. |
2163 for (int i = 0; i < 16; i++) { | 2163 for (int i = 0; i < 16; i++) { |
2164 t = FACTORY->NewProperSubString(s, 5, 35); | 2164 t = FACTORY->NewProperSubString(s, 5, 35); |
2165 } | 2165 } |
2166 CHECK(t->IsSlicedString()); | 2166 CHECK(t->IsSlicedString()); |
2167 CHECK(!HEAP->InNewSpace(*t)); | 2167 CHECK(!HEAP->InNewSpace(*t)); |
2168 *slice.location() = *t.location(); | 2168 *slice.location() = *t.location(); |
2169 } | 2169 } |
2170 | 2170 |
2171 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); | 2171 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); |
2172 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2172 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
2173 CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString()); | 2173 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); |
2174 } | 2174 } |
2175 | 2175 |
2176 | 2176 |
2177 #ifdef OBJECT_PRINT | 2177 #ifdef OBJECT_PRINT |
2178 TEST(PrintSharedFunctionInfo) { | 2178 TEST(PrintSharedFunctionInfo) { |
2179 InitializeVM(); | 2179 InitializeVM(); |
2180 v8::HandleScope scope; | 2180 v8::HandleScope scope; |
2181 const char* source = "f = function() { return 987654321; }\n" | 2181 const char* source = "f = function() { return 987654321; }\n" |
2182 "g = function() { return 123456789; }\n"; | 2182 "g = function() { return 123456789; }\n"; |
2183 CompileRun(source); | 2183 CompileRun(source); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 Handle<Object> call_function(call); | 2504 Handle<Object> call_function(call); |
2505 | 2505 |
2506 // Now we are ready to mess up the heap. | 2506 // Now we are ready to mess up the heap. |
2507 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | 2507 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); |
2508 | 2508 |
2509 // Either heap verification caught the problem already or we go kaboom once | 2509 // Either heap verification caught the problem already or we go kaboom once |
2510 // the CallIC is executed the next time. | 2510 // the CallIC is executed the next time. |
2511 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); | 2511 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); |
2512 CompileRun("call();"); | 2512 CompileRun("call();"); |
2513 } | 2513 } |
OLD | NEW |