| 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 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 } | 1937 } |
| 1938 | 1938 |
| 1939 | 1939 |
| 1940 // Test that HAllocateObject will always return an object in new-space. | 1940 // Test that HAllocateObject will always return an object in new-space. |
| 1941 TEST(OptimizedAllocationAlwaysInNewSpace) { | 1941 TEST(OptimizedAllocationAlwaysInNewSpace) { |
| 1942 i::FLAG_allow_natives_syntax = true; | 1942 i::FLAG_allow_natives_syntax = true; |
| 1943 InitializeVM(); | 1943 InitializeVM(); |
| 1944 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; | 1944 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; |
| 1945 v8::HandleScope scope; | 1945 v8::HandleScope scope; |
| 1946 | 1946 |
| 1947 FillUpNewSpace(HEAP->new_space()); | 1947 SimulateFullSpace(HEAP->new_space()); |
| 1948 AlwaysAllocateScope always_allocate; | 1948 AlwaysAllocateScope always_allocate; |
| 1949 v8::Local<v8::Value> res = CompileRun( | 1949 v8::Local<v8::Value> res = CompileRun( |
| 1950 "function c(x) {" | 1950 "function c(x) {" |
| 1951 " this.x = x;" | 1951 " this.x = x;" |
| 1952 " for (var i = 0; i < 32; i++) {" | 1952 " for (var i = 0; i < 32; i++) {" |
| 1953 " this['x' + i] = x;" | 1953 " this['x' + i] = x;" |
| 1954 " }" | 1954 " }" |
| 1955 "}" | 1955 "}" |
| 1956 "function f(x) { return new c(x); };" | 1956 "function f(x) { return new c(x); };" |
| 1957 "f(1); f(2); f(3);" | 1957 "f(1); f(2); f(3);" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 { | 2146 { |
| 2147 // Generate a parent that lives in new-space. | 2147 // Generate a parent that lives in new-space. |
| 2148 v8::HandleScope inner_scope; | 2148 v8::HandleScope inner_scope; |
| 2149 const char* c = "This text is long enough to trigger sliced strings."; | 2149 const char* c = "This text is long enough to trigger sliced strings."; |
| 2150 Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c)); | 2150 Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c)); |
| 2151 CHECK(s->IsSeqOneByteString()); | 2151 CHECK(s->IsSeqOneByteString()); |
| 2152 CHECK(HEAP->InNewSpace(*s)); | 2152 CHECK(HEAP->InNewSpace(*s)); |
| 2153 | 2153 |
| 2154 // Generate a sliced string that is based on the above parent and | 2154 // Generate a sliced string that is based on the above parent and |
| 2155 // lives in old-space. | 2155 // lives in old-space. |
| 2156 FillUpNewSpace(HEAP->new_space()); | 2156 SimulateFullSpace(HEAP->new_space()); |
| 2157 AlwaysAllocateScope always_allocate; | 2157 AlwaysAllocateScope always_allocate; |
| 2158 Handle<String> t; | 2158 Handle<String> t = FACTORY->NewProperSubString(s, 5, 35); |
| 2159 // TODO(mstarzinger): Unfortunately FillUpNewSpace() still leaves | |
| 2160 // some slack, so we need to allocate a few sliced strings. | |
| 2161 for (int i = 0; i < 16; i++) { | |
| 2162 t = FACTORY->NewProperSubString(s, 5, 35); | |
| 2163 } | |
| 2164 CHECK(t->IsSlicedString()); | 2159 CHECK(t->IsSlicedString()); |
| 2165 CHECK(!HEAP->InNewSpace(*t)); | 2160 CHECK(!HEAP->InNewSpace(*t)); |
| 2166 *slice.location() = *t.location(); | 2161 *slice.location() = *t.location(); |
| 2167 } | 2162 } |
| 2168 | 2163 |
| 2169 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); | 2164 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); |
| 2170 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2165 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 2171 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); | 2166 CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); |
| 2172 } | 2167 } |
| 2173 | 2168 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 Handle<Object> call_function(call); | 2497 Handle<Object> call_function(call); |
| 2503 | 2498 |
| 2504 // Now we are ready to mess up the heap. | 2499 // Now we are ready to mess up the heap. |
| 2505 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | 2500 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); |
| 2506 | 2501 |
| 2507 // Either heap verification caught the problem already or we go kaboom once | 2502 // Either heap verification caught the problem already or we go kaboom once |
| 2508 // the CallIC is executed the next time. | 2503 // the CallIC is executed the next time. |
| 2509 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); | 2504 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); |
| 2510 CompileRun("call();"); | 2505 CompileRun("call();"); |
| 2511 } | 2506 } |
| OLD | NEW |