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

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

Issue 23441029: Move global V8::UseCrankshaft() into the Isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Sven Panne. Created 7 years, 3 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 | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-random.cc » ('j') | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 1325
1326 // Create a number of global contests which gets linked together. 1326 // Create a number of global contests which gets linked together.
1327 for (int i = 0; i < kNumTestContexts; i++) { 1327 for (int i = 0; i < kNumTestContexts; i++) {
1328 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent()); 1328 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent());
1329 1329
1330 // Collect garbage that might have been created by one of the 1330 // Collect garbage that might have been created by one of the
1331 // installed extensions. 1331 // installed extensions.
1332 isolate->compilation_cache()->Clear(); 1332 isolate->compilation_cache()->Clear();
1333 heap->CollectAllGarbage(Heap::kNoGCFlags); 1333 heap->CollectAllGarbage(Heap::kNoGCFlags);
1334 1334
1335 bool opt = (FLAG_always_opt && i::V8::UseCrankshaft()); 1335 bool opt = (FLAG_always_opt && isolate->use_crankshaft());
1336 1336
1337 CHECK_EQ(i + 1, CountNativeContexts()); 1337 CHECK_EQ(i + 1, CountNativeContexts());
1338 1338
1339 ctx[i]->Enter(); 1339 ctx[i]->Enter();
1340 1340
1341 // Create a handle scope so no function objects get stuch in the outer 1341 // Create a handle scope so no function objects get stuch in the outer
1342 // handle scope 1342 // handle scope
1343 HandleScope scope(isolate); 1343 HandleScope scope(isolate);
1344 const char* source = "function f1() { };" 1344 const char* source = "function f1() { };"
1345 "function f2() { };" 1345 "function f2() { };"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 CHECK_EQ(0, CountNativeContexts()); 1469 CHECK_EQ(0, CountNativeContexts());
1470 1470
1471 // Create an number of contexts and check the length of the weak list both 1471 // Create an number of contexts and check the length of the weak list both
1472 // with and without GCs while iterating the list. 1472 // with and without GCs while iterating the list.
1473 for (int i = 0; i < kNumTestContexts; i++) { 1473 for (int i = 0; i < kNumTestContexts; i++) {
1474 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent()); 1474 ctx[i] = v8::Context::New(v8::Isolate::GetCurrent());
1475 CHECK_EQ(i + 1, CountNativeContexts()); 1475 CHECK_EQ(i + 1, CountNativeContexts());
1476 CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1)); 1476 CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1));
1477 } 1477 }
1478 1478
1479 bool opt = (FLAG_always_opt && i::V8::UseCrankshaft()); 1479 bool opt = (FLAG_always_opt && isolate->use_crankshaft());
1480 1480
1481 // Compile a number of functions the length of the weak list of optimized 1481 // Compile a number of functions the length of the weak list of optimized
1482 // functions both with and without GCs while iterating the list. 1482 // functions both with and without GCs while iterating the list.
1483 ctx[0]->Enter(); 1483 ctx[0]->Enter();
1484 const char* source = "function f1() { };" 1484 const char* source = "function f1() { };"
1485 "function f2() { };" 1485 "function f2() { };"
1486 "function f3() { };" 1486 "function f3() { };"
1487 "function f4() { };" 1487 "function f4() { };"
1488 "function f5() { };"; 1488 "function f5() { };";
1489 CompileRun(source); 1489 CompileRun(source);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 } 1869 }
1870 1870
1871 1871
1872 TEST(InstanceOfStubWriteBarrier) { 1872 TEST(InstanceOfStubWriteBarrier) {
1873 i::FLAG_allow_natives_syntax = true; 1873 i::FLAG_allow_natives_syntax = true;
1874 #ifdef VERIFY_HEAP 1874 #ifdef VERIFY_HEAP
1875 i::FLAG_verify_heap = true; 1875 i::FLAG_verify_heap = true;
1876 #endif 1876 #endif
1877 1877
1878 CcTest::InitializeVM(); 1878 CcTest::InitializeVM();
1879 if (!i::V8::UseCrankshaft()) return; 1879 if (!i::Isolate::Current()->use_crankshaft()) return;
1880 if (i::FLAG_force_marking_deque_overflows) return; 1880 if (i::FLAG_force_marking_deque_overflows) return;
1881 v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); 1881 v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
1882 1882
1883 { 1883 {
1884 v8::HandleScope scope(v8::Isolate::GetCurrent()); 1884 v8::HandleScope scope(v8::Isolate::GetCurrent());
1885 CompileRun( 1885 CompileRun(
1886 "function foo () { }" 1886 "function foo () { }"
1887 "function mkbar () { return new (new Function(\"\")) (); }" 1887 "function mkbar () { return new (new Function(\"\")) (); }"
1888 "function f (x) { return (x instanceof foo); }" 1888 "function f (x) { return (x instanceof foo); }"
1889 "function g () { f(mkbar()); }" 1889 "function g () { f(mkbar()); }"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 1986
1987 1987
1988 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { 1988 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
1989 i::FLAG_stress_compaction = false; 1989 i::FLAG_stress_compaction = false;
1990 i::FLAG_allow_natives_syntax = true; 1990 i::FLAG_allow_natives_syntax = true;
1991 #ifdef VERIFY_HEAP 1991 #ifdef VERIFY_HEAP
1992 i::FLAG_verify_heap = true; 1992 i::FLAG_verify_heap = true;
1993 #endif 1993 #endif
1994 1994
1995 CcTest::InitializeVM(); 1995 CcTest::InitializeVM();
1996 if (!i::V8::UseCrankshaft()) return; 1996 if (!i::Isolate::Current()->use_crankshaft()) return;
1997 v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); 1997 v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
1998 1998
1999 { 1999 {
2000 v8::HandleScope scope(v8::Isolate::GetCurrent()); 2000 v8::HandleScope scope(v8::Isolate::GetCurrent());
2001 CompileRun( 2001 CompileRun(
2002 "function f () {" 2002 "function f () {"
2003 " var s = 0;" 2003 " var s = 0;"
2004 " for (var i = 0; i < 100; i++) s += i;" 2004 " for (var i = 0; i < 100; i++) s += i;"
2005 " return s;" 2005 " return s;"
2006 "}" 2006 "}"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 2043
2044 2044
2045 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { 2045 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
2046 i::FLAG_stress_compaction = false; 2046 i::FLAG_stress_compaction = false;
2047 i::FLAG_allow_natives_syntax = true; 2047 i::FLAG_allow_natives_syntax = true;
2048 #ifdef VERIFY_HEAP 2048 #ifdef VERIFY_HEAP
2049 i::FLAG_verify_heap = true; 2049 i::FLAG_verify_heap = true;
2050 #endif 2050 #endif
2051 2051
2052 CcTest::InitializeVM(); 2052 CcTest::InitializeVM();
2053 if (!i::V8::UseCrankshaft()) return; 2053 if (!i::Isolate::Current()->use_crankshaft()) return;
2054 v8::HandleScope outer_scope(CcTest::isolate()); 2054 v8::HandleScope outer_scope(CcTest::isolate());
2055 2055
2056 { 2056 {
2057 v8::HandleScope scope(CcTest::isolate()); 2057 v8::HandleScope scope(CcTest::isolate());
2058 CompileRun( 2058 CompileRun(
2059 "function f () {" 2059 "function f () {"
2060 " var s = 0;" 2060 " var s = 0;"
2061 " for (var i = 0; i < 100; i++) s += i;" 2061 " for (var i = 0; i < 100; i++) s += i;"
2062 " return s;" 2062 " return s;"
2063 "}" 2063 "}"
(...skipping 18 matching lines...) Expand all
2082 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age()); 2082 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age());
2083 CHECK_EQ(0, f->shared()->opt_count()); 2083 CHECK_EQ(0, f->shared()->opt_count());
2084 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2084 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2085 } 2085 }
2086 2086
2087 2087
2088 // Test that HAllocateObject will always return an object in new-space. 2088 // Test that HAllocateObject will always return an object in new-space.
2089 TEST(OptimizedAllocationAlwaysInNewSpace) { 2089 TEST(OptimizedAllocationAlwaysInNewSpace) {
2090 i::FLAG_allow_natives_syntax = true; 2090 i::FLAG_allow_natives_syntax = true;
2091 CcTest::InitializeVM(); 2091 CcTest::InitializeVM();
2092 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2092 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2093 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2093 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2094 v8::HandleScope scope(CcTest::isolate()); 2094 v8::HandleScope scope(CcTest::isolate());
2095 2095
2096 SimulateFullSpace(HEAP->new_space()); 2096 SimulateFullSpace(HEAP->new_space());
2097 AlwaysAllocateScope always_allocate; 2097 AlwaysAllocateScope always_allocate;
2098 v8::Local<v8::Value> res = CompileRun( 2098 v8::Local<v8::Value> res = CompileRun(
2099 "function c(x) {" 2099 "function c(x) {"
2100 " this.x = x;" 2100 " this.x = x;"
2101 " for (var i = 0; i < 32; i++) {" 2101 " for (var i = 0; i < 32; i++) {"
2102 " this['x' + i] = x;" 2102 " this['x' + i] = x;"
2103 " }" 2103 " }"
2104 "}" 2104 "}"
2105 "function f(x) { return new c(x); };" 2105 "function f(x) { return new c(x); };"
2106 "f(1); f(2); f(3);" 2106 "f(1); f(2); f(3);"
2107 "%OptimizeFunctionOnNextCall(f);" 2107 "%OptimizeFunctionOnNextCall(f);"
2108 "f(4);"); 2108 "f(4);");
2109 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); 2109 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value());
2110 2110
2111 Handle<JSObject> o = 2111 Handle<JSObject> o =
2112 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2112 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2113 2113
2114 CHECK(HEAP->InNewSpace(*o)); 2114 CHECK(HEAP->InNewSpace(*o));
2115 } 2115 }
2116 2116
2117 2117
2118 TEST(OptimizedPretenuringAllocationFolding) { 2118 TEST(OptimizedPretenuringAllocationFolding) {
2119 i::FLAG_allow_natives_syntax = true; 2119 i::FLAG_allow_natives_syntax = true;
2120 CcTest::InitializeVM(); 2120 CcTest::InitializeVM();
2121 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2121 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2122 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2122 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2123 v8::HandleScope scope(CcTest::isolate()); 2123 v8::HandleScope scope(CcTest::isolate());
2124 HEAP->SetNewSpaceHighPromotionModeActive(true); 2124 HEAP->SetNewSpaceHighPromotionModeActive(true);
2125 2125
2126 v8::Local<v8::Value> res = CompileRun( 2126 v8::Local<v8::Value> res = CompileRun(
2127 "function DataObject() {" 2127 "function DataObject() {"
2128 " this.a = 1.1;" 2128 " this.a = 1.1;"
2129 " this.b = [{}];" 2129 " this.b = [{}];"
2130 " this.c = 1.2;" 2130 " this.c = 1.2;"
2131 " this.d = [{}];" 2131 " this.d = [{}];"
(...skipping 15 matching lines...) Expand all
2147 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); 2147 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2)));
2148 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3))); 2148 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3)));
2149 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4))); 2149 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4)));
2150 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5))); 2150 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5)));
2151 } 2151 }
2152 2152
2153 2153
2154 TEST(OptimizedPretenuringAllocationFoldingBlocks) { 2154 TEST(OptimizedPretenuringAllocationFoldingBlocks) {
2155 i::FLAG_allow_natives_syntax = true; 2155 i::FLAG_allow_natives_syntax = true;
2156 CcTest::InitializeVM(); 2156 CcTest::InitializeVM();
2157 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2157 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2158 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2158 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2159 v8::HandleScope scope(CcTest::isolate()); 2159 v8::HandleScope scope(CcTest::isolate());
2160 HEAP->SetNewSpaceHighPromotionModeActive(true); 2160 HEAP->SetNewSpaceHighPromotionModeActive(true);
2161 2161
2162 v8::Local<v8::Value> res = CompileRun( 2162 v8::Local<v8::Value> res = CompileRun(
2163 "function DataObject() {" 2163 "function DataObject() {"
2164 " this.a = [{}];" 2164 " this.a = [{}];"
2165 " this.b = [{}];" 2165 " this.b = [{}];"
2166 " this.c = 1.1;" 2166 " this.c = 1.1;"
2167 " this.d = 1.2;" 2167 " this.d = 1.2;"
(...skipping 15 matching lines...) Expand all
2183 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); 2183 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2)));
2184 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3))); 2184 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3)));
2185 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4))); 2185 CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4)));
2186 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5))); 2186 CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5)));
2187 } 2187 }
2188 2188
2189 2189
2190 TEST(OptimizedPretenuringObjectArrayLiterals) { 2190 TEST(OptimizedPretenuringObjectArrayLiterals) {
2191 i::FLAG_allow_natives_syntax = true; 2191 i::FLAG_allow_natives_syntax = true;
2192 CcTest::InitializeVM(); 2192 CcTest::InitializeVM();
2193 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2193 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2194 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2194 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2195 v8::HandleScope scope(CcTest::isolate()); 2195 v8::HandleScope scope(CcTest::isolate());
2196 HEAP->SetNewSpaceHighPromotionModeActive(true); 2196 HEAP->SetNewSpaceHighPromotionModeActive(true);
2197 2197
2198 v8::Local<v8::Value> res = CompileRun( 2198 v8::Local<v8::Value> res = CompileRun(
2199 "function f() {" 2199 "function f() {"
2200 " var numbers = [{}, {}, {}];" 2200 " var numbers = [{}, {}, {}];"
2201 " return numbers;" 2201 " return numbers;"
2202 "};" 2202 "};"
2203 "f(); f(); f();" 2203 "f(); f(); f();"
2204 "%OptimizeFunctionOnNextCall(f);" 2204 "%OptimizeFunctionOnNextCall(f);"
2205 "f();"); 2205 "f();");
2206 2206
2207 Handle<JSObject> o = 2207 Handle<JSObject> o =
2208 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2208 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2209 2209
2210 CHECK(HEAP->InOldPointerSpace(o->elements())); 2210 CHECK(HEAP->InOldPointerSpace(o->elements()));
2211 CHECK(HEAP->InOldPointerSpace(*o)); 2211 CHECK(HEAP->InOldPointerSpace(*o));
2212 } 2212 }
2213 2213
2214 2214
2215 TEST(OptimizedPretenuringMixedInObjectProperties) { 2215 TEST(OptimizedPretenuringMixedInObjectProperties) {
2216 i::FLAG_allow_natives_syntax = true; 2216 i::FLAG_allow_natives_syntax = true;
2217 CcTest::InitializeVM(); 2217 CcTest::InitializeVM();
2218 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2218 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2219 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2219 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2220 v8::HandleScope scope(CcTest::isolate()); 2220 v8::HandleScope scope(CcTest::isolate());
2221 HEAP->SetNewSpaceHighPromotionModeActive(true); 2221 HEAP->SetNewSpaceHighPromotionModeActive(true);
2222 2222
2223 v8::Local<v8::Value> res = CompileRun( 2223 v8::Local<v8::Value> res = CompileRun(
2224 "function f() {" 2224 "function f() {"
2225 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};" 2225 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};"
2226 " return numbers;" 2226 " return numbers;"
2227 "};" 2227 "};"
2228 "f(); f(); f();" 2228 "f(); f(); f();"
(...skipping 10 matching lines...) Expand all
2239 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); 2239 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0));
2240 CHECK(HEAP->InOldPointerSpace(inner_object)); 2240 CHECK(HEAP->InOldPointerSpace(inner_object));
2241 CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0))); 2241 CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0)));
2242 CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); 2242 CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1)));
2243 } 2243 }
2244 2244
2245 2245
2246 TEST(OptimizedPretenuringDoubleArrayProperties) { 2246 TEST(OptimizedPretenuringDoubleArrayProperties) {
2247 i::FLAG_allow_natives_syntax = true; 2247 i::FLAG_allow_natives_syntax = true;
2248 CcTest::InitializeVM(); 2248 CcTest::InitializeVM();
2249 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2249 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2250 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2250 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2251 v8::HandleScope scope(CcTest::isolate()); 2251 v8::HandleScope scope(CcTest::isolate());
2252 HEAP->SetNewSpaceHighPromotionModeActive(true); 2252 HEAP->SetNewSpaceHighPromotionModeActive(true);
2253 2253
2254 v8::Local<v8::Value> res = CompileRun( 2254 v8::Local<v8::Value> res = CompileRun(
2255 "function f() {" 2255 "function f() {"
2256 " var numbers = {a: 1.1, b: 2.2};" 2256 " var numbers = {a: 1.1, b: 2.2};"
2257 " return numbers;" 2257 " return numbers;"
2258 "};" 2258 "};"
2259 "f(); f(); f();" 2259 "f(); f(); f();"
2260 "%OptimizeFunctionOnNextCall(f);" 2260 "%OptimizeFunctionOnNextCall(f);"
2261 "f();"); 2261 "f();");
2262 2262
2263 Handle<JSObject> o = 2263 Handle<JSObject> o =
2264 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2264 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2265 2265
2266 CHECK(HEAP->InOldPointerSpace(*o)); 2266 CHECK(HEAP->InOldPointerSpace(*o));
2267 CHECK(HEAP->InOldDataSpace(o->properties())); 2267 CHECK(HEAP->InOldDataSpace(o->properties()));
2268 } 2268 }
2269 2269
2270 2270
2271 TEST(OptimizedPretenuringdoubleArrayLiterals) { 2271 TEST(OptimizedPretenuringdoubleArrayLiterals) {
2272 i::FLAG_allow_natives_syntax = true; 2272 i::FLAG_allow_natives_syntax = true;
2273 CcTest::InitializeVM(); 2273 CcTest::InitializeVM();
2274 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2274 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2275 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2275 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2276 v8::HandleScope scope(CcTest::isolate()); 2276 v8::HandleScope scope(CcTest::isolate());
2277 HEAP->SetNewSpaceHighPromotionModeActive(true); 2277 HEAP->SetNewSpaceHighPromotionModeActive(true);
2278 2278
2279 v8::Local<v8::Value> res = CompileRun( 2279 v8::Local<v8::Value> res = CompileRun(
2280 "function f() {" 2280 "function f() {"
2281 " var numbers = [1.1, 2.2, 3.3];" 2281 " var numbers = [1.1, 2.2, 3.3];"
2282 " return numbers;" 2282 " return numbers;"
2283 "};" 2283 "};"
2284 "f(); f(); f();" 2284 "f(); f(); f();"
2285 "%OptimizeFunctionOnNextCall(f);" 2285 "%OptimizeFunctionOnNextCall(f);"
2286 "f();"); 2286 "f();");
2287 2287
2288 Handle<JSObject> o = 2288 Handle<JSObject> o =
2289 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2289 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2290 2290
2291 CHECK(HEAP->InOldDataSpace(o->elements())); 2291 CHECK(HEAP->InOldDataSpace(o->elements()));
2292 CHECK(HEAP->InOldPointerSpace(*o)); 2292 CHECK(HEAP->InOldPointerSpace(*o));
2293 } 2293 }
2294 2294
2295 2295
2296 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { 2296 TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
2297 i::FLAG_allow_natives_syntax = true; 2297 i::FLAG_allow_natives_syntax = true;
2298 CcTest::InitializeVM(); 2298 CcTest::InitializeVM();
2299 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2299 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2300 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2300 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2301 v8::HandleScope scope(CcTest::isolate()); 2301 v8::HandleScope scope(CcTest::isolate());
2302 HEAP->SetNewSpaceHighPromotionModeActive(true); 2302 HEAP->SetNewSpaceHighPromotionModeActive(true);
2303 2303
2304 v8::Local<v8::Value> res = CompileRun( 2304 v8::Local<v8::Value> res = CompileRun(
2305 "function f() {" 2305 "function f() {"
2306 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];" 2306 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];"
2307 " return numbers;" 2307 " return numbers;"
2308 "};" 2308 "};"
2309 "f(); f(); f();" 2309 "f(); f(); f();"
(...skipping 13 matching lines...) Expand all
2323 CHECK(HEAP->InOldPointerSpace(*int_array_handle)); 2323 CHECK(HEAP->InOldPointerSpace(*int_array_handle));
2324 CHECK(HEAP->InOldPointerSpace(int_array_handle->elements())); 2324 CHECK(HEAP->InOldPointerSpace(int_array_handle->elements()));
2325 CHECK(HEAP->InOldPointerSpace(*double_array_handle)); 2325 CHECK(HEAP->InOldPointerSpace(*double_array_handle));
2326 CHECK(HEAP->InOldDataSpace(double_array_handle->elements())); 2326 CHECK(HEAP->InOldDataSpace(double_array_handle->elements()));
2327 } 2327 }
2328 2328
2329 2329
2330 TEST(OptimizedPretenuringNestedObjectLiterals) { 2330 TEST(OptimizedPretenuringNestedObjectLiterals) {
2331 i::FLAG_allow_natives_syntax = true; 2331 i::FLAG_allow_natives_syntax = true;
2332 CcTest::InitializeVM(); 2332 CcTest::InitializeVM();
2333 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2333 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2334 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2334 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2335 v8::HandleScope scope(CcTest::isolate()); 2335 v8::HandleScope scope(CcTest::isolate());
2336 HEAP->SetNewSpaceHighPromotionModeActive(true); 2336 HEAP->SetNewSpaceHighPromotionModeActive(true);
2337 2337
2338 v8::Local<v8::Value> res = CompileRun( 2338 v8::Local<v8::Value> res = CompileRun(
2339 "function f() {" 2339 "function f() {"
2340 " var numbers = [[{}, {}, {}],[{}, {}, {}]];" 2340 " var numbers = [[{}, {}, {}],[{}, {}, {}]];"
2341 " return numbers;" 2341 " return numbers;"
2342 "};" 2342 "};"
2343 "f(); f(); f();" 2343 "f(); f(); f();"
(...skipping 13 matching lines...) Expand all
2357 CHECK(HEAP->InOldPointerSpace(*int_array_handle_1)); 2357 CHECK(HEAP->InOldPointerSpace(*int_array_handle_1));
2358 CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements())); 2358 CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements()));
2359 CHECK(HEAP->InOldPointerSpace(*int_array_handle_2)); 2359 CHECK(HEAP->InOldPointerSpace(*int_array_handle_2));
2360 CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements())); 2360 CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements()));
2361 } 2361 }
2362 2362
2363 2363
2364 TEST(OptimizedPretenuringNestedDoubleLiterals) { 2364 TEST(OptimizedPretenuringNestedDoubleLiterals) {
2365 i::FLAG_allow_natives_syntax = true; 2365 i::FLAG_allow_natives_syntax = true;
2366 CcTest::InitializeVM(); 2366 CcTest::InitializeVM();
2367 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2367 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2368 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2368 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2369 v8::HandleScope scope(CcTest::isolate()); 2369 v8::HandleScope scope(CcTest::isolate());
2370 HEAP->SetNewSpaceHighPromotionModeActive(true); 2370 HEAP->SetNewSpaceHighPromotionModeActive(true);
2371 2371
2372 v8::Local<v8::Value> res = CompileRun( 2372 v8::Local<v8::Value> res = CompileRun(
2373 "function f() {" 2373 "function f() {"
2374 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" 2374 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];"
2375 " return numbers;" 2375 " return numbers;"
2376 "};" 2376 "};"
2377 "f(); f(); f();" 2377 "f(); f(); f();"
(...skipping 16 matching lines...) Expand all
2394 CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements())); 2394 CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements()));
2395 CHECK(HEAP->InOldPointerSpace(*double_array_handle_2)); 2395 CHECK(HEAP->InOldPointerSpace(*double_array_handle_2));
2396 CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements())); 2396 CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements()));
2397 } 2397 }
2398 2398
2399 2399
2400 // Test regular array literals allocation. 2400 // Test regular array literals allocation.
2401 TEST(OptimizedAllocationArrayLiterals) { 2401 TEST(OptimizedAllocationArrayLiterals) {
2402 i::FLAG_allow_natives_syntax = true; 2402 i::FLAG_allow_natives_syntax = true;
2403 CcTest::InitializeVM(); 2403 CcTest::InitializeVM();
2404 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2404 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2405 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2405 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2406 v8::HandleScope scope(CcTest::isolate()); 2406 v8::HandleScope scope(CcTest::isolate());
2407 2407
2408 v8::Local<v8::Value> res = CompileRun( 2408 v8::Local<v8::Value> res = CompileRun(
2409 "function f() {" 2409 "function f() {"
2410 " var numbers = new Array(1, 2, 3);" 2410 " var numbers = new Array(1, 2, 3);"
2411 " numbers[0] = 3.14;" 2411 " numbers[0] = 3.14;"
2412 " return numbers;" 2412 " return numbers;"
2413 "};" 2413 "};"
2414 "f(); f(); f();" 2414 "f(); f(); f();"
2415 "%OptimizeFunctionOnNextCall(f);" 2415 "%OptimizeFunctionOnNextCall(f);"
2416 "f();"); 2416 "f();");
2417 CHECK_EQ(static_cast<int>(3.14), 2417 CHECK_EQ(static_cast<int>(3.14),
2418 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value()); 2418 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2419 2419
2420 Handle<JSObject> o = 2420 Handle<JSObject> o =
2421 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2421 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2422 2422
2423 CHECK(HEAP->InNewSpace(o->elements())); 2423 CHECK(HEAP->InNewSpace(o->elements()));
2424 } 2424 }
2425 2425
2426 2426
2427 TEST(OptimizedPretenuringCallNew) { 2427 TEST(OptimizedPretenuringCallNew) {
2428 i::FLAG_allow_natives_syntax = true; 2428 i::FLAG_allow_natives_syntax = true;
2429 i::FLAG_pretenuring_call_new = true; 2429 i::FLAG_pretenuring_call_new = true;
2430 CcTest::InitializeVM(); 2430 CcTest::InitializeVM();
2431 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2431 if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return;
2432 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2432 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2433 v8::HandleScope scope(CcTest::isolate()); 2433 v8::HandleScope scope(CcTest::isolate());
2434 HEAP->SetNewSpaceHighPromotionModeActive(true); 2434 HEAP->SetNewSpaceHighPromotionModeActive(true);
2435 2435
2436 AlwaysAllocateScope always_allocate; 2436 AlwaysAllocateScope always_allocate;
2437 v8::Local<v8::Value> res = CompileRun( 2437 v8::Local<v8::Value> res = CompileRun(
2438 "function g() { this.a = 0; }" 2438 "function g() { this.a = 0; }"
2439 "function f() {" 2439 "function f() {"
2440 " return new g();" 2440 " return new g();"
2441 "};" 2441 "};"
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 " var a = new Array(n);" 3444 " var a = new Array(n);"
3445 " for (var i = 0; i < n; i += 100) a[i] = i;" 3445 " for (var i = 0; i < n; i += 100) a[i] = i;"
3446 "};" 3446 "};"
3447 "f(10 * 1024 * 1024);"); 3447 "f(10 * 1024 * 1024);");
3448 IncrementalMarking* marking = HEAP->incremental_marking(); 3448 IncrementalMarking* marking = HEAP->incremental_marking();
3449 if (marking->IsStopped()) marking->Start(); 3449 if (marking->IsStopped()) marking->Start();
3450 // This big step should be sufficient to mark the whole array. 3450 // This big step should be sufficient to mark the whole array.
3451 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3451 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3452 ASSERT(marking->IsComplete()); 3452 ASSERT(marking->IsComplete());
3453 } 3453 }
OLDNEW
« no previous file with comments | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-random.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698