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

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

Issue 12314155: Allow direct allocation in old pointer space. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « src/x64/stub-cache-x64.cc ('k') | no next file » | 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 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 Handle<JSObject> o = 2044 Handle<JSObject> o =
2045 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2045 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2046 2046
2047 CHECK(HEAP->InNewSpace(*o)); 2047 CHECK(HEAP->InNewSpace(*o));
2048 } 2048 }
2049 2049
2050 2050
2051 // Test pretenuring of array literals allocated with HAllocate. 2051 // Test pretenuring of array literals allocated with HAllocate.
2052 TEST(OptimizedPretenuringArrayLiterals) { 2052 TEST(OptimizedPretenuringArrayLiterals) {
2053 i::FLAG_allow_natives_syntax = true; 2053 i::FLAG_allow_natives_syntax = true;
2054 i::FLAG_pretenure_literals = true;
2054 InitializeVM(); 2055 InitializeVM();
2055 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2056 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
2056 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2057 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2057 v8::HandleScope scope; 2058 v8::HandleScope scope;
2058 2059
2059 AlwaysAllocateScope always_allocate; 2060 AlwaysAllocateScope always_allocate;
2060 v8::Local<v8::Value> res = CompileRun( 2061 v8::Local<v8::Value> res = CompileRun(
2061 "function f() {" 2062 "function f() {"
2062 " var numbers = new Array(1, 2, 3);" 2063 " var numbers = [1, 2, 3];"
2063 " numbers[0] = 3.14;" 2064 " numbers[0] = {};"
2064 " return numbers;" 2065 " return numbers;"
2065 "};" 2066 "};"
2066 "f(); f(); f();" 2067 "f(); f(); f();"
2067 "%OptimizeFunctionOnNextCall(f);" 2068 "%OptimizeFunctionOnNextCall(f);"
2068 "f();"); 2069 "f();");
2069 CHECK_EQ(static_cast<int>(3.14),
2070 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2071 2070
2072 Handle<JSObject> o = 2071 Handle<JSObject> o =
2073 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2072 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2074 2073
2075 // TODO(hpayer): remove InNewSpace check and test if object was allocated 2074 CHECK(HEAP->InOldPointerSpace(o->elements()));
2076 // in old pointer space.
2077 CHECK(!HEAP->InOldPointerSpace(*o));
2078 CHECK(HEAP->InNewSpace(*o));
2079 } 2075 }
2080 2076
2081 2077
2082 // Test regular array literals allocation. 2078 // Test regular array literals allocation.
2083 TEST(OptimizedAllocationArrayLiterals) { 2079 TEST(OptimizedAllocationArrayLiterals) {
2084 i::FLAG_allow_natives_syntax = true; 2080 i::FLAG_allow_natives_syntax = true;
2085 InitializeVM(); 2081 InitializeVM();
2086 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; 2082 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
2087 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; 2083 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2088 v8::HandleScope scope; 2084 v8::HandleScope scope;
2089 2085
2090 AlwaysAllocateScope always_allocate; 2086 AlwaysAllocateScope always_allocate;
2091 v8::Local<v8::Value> res = CompileRun( 2087 v8::Local<v8::Value> res = CompileRun(
2092 "function f() {" 2088 "function f() {"
2093 " var numbers = new Array(1, 2, 3);" 2089 " var numbers = new Array(1, 2, 3);"
2094 " numbers[0] = 3.14;" 2090 " numbers[0] = 3.14;"
2095 " return numbers;" 2091 " return numbers;"
2096 "};" 2092 "};"
2097 "f(); f(); f();" 2093 "f(); f(); f();"
2098 "%OptimizeFunctionOnNextCall(f);" 2094 "%OptimizeFunctionOnNextCall(f);"
2099 "f();"); 2095 "f();");
2100 CHECK_EQ(static_cast<int>(3.14), 2096 CHECK_EQ(static_cast<int>(3.14),
2101 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value()); 2097 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2102 2098
2103 Handle<JSObject> o = 2099 Handle<JSObject> o =
2104 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2100 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2105 2101
2106 CHECK(HEAP->InNewSpace(*o)); 2102 CHECK(HEAP->InNewSpace(o->elements()));
2107 } 2103 }
2108 2104
2109 2105
2110 static int CountMapTransitions(Map* map) { 2106 static int CountMapTransitions(Map* map) {
2111 return map->transitions()->number_of_transitions(); 2107 return map->transitions()->number_of_transitions();
2112 } 2108 }
2113 2109
2114 2110
2115 // Test that map transitions are cleared and maps are collected with 2111 // Test that map transitions are cleared and maps are collected with
2116 // incremental marking as well. 2112 // incremental marking as well.
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 // explicitly enqueued. 3008 // explicitly enqueued.
3013 SimulateIncrementalMarking(); 3009 SimulateIncrementalMarking();
3014 3010
3015 // Now enable the debugger which in turn will disable code flushing. 3011 // Now enable the debugger which in turn will disable code flushing.
3016 CHECK(isolate->debug()->Load()); 3012 CHECK(isolate->debug()->Load());
3017 3013
3018 // This cycle will bust the heap and subsequent cycles will go ballistic. 3014 // This cycle will bust the heap and subsequent cycles will go ballistic.
3019 heap->CollectAllGarbage(Heap::kNoGCFlags); 3015 heap->CollectAllGarbage(Heap::kNoGCFlags);
3020 heap->CollectAllGarbage(Heap::kNoGCFlags); 3016 heap->CollectAllGarbage(Heap::kNoGCFlags);
3021 } 3017 }
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698