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

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

Issue 12607003: Added pretenuring of array literals test. (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/heap-inl.h ('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 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 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 "f(4);"); 2012 "f(4);");
2013 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); 2013 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value());
2014 2014
2015 Handle<JSObject> o = 2015 Handle<JSObject> o =
2016 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 2016 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2017 2017
2018 CHECK(HEAP->InNewSpace(*o)); 2018 CHECK(HEAP->InNewSpace(*o));
2019 } 2019 }
2020 2020
2021 2021
2022 // Test pretenuring of array literals allocated with HAllocate.
2023 TEST(OptimizedPretenuringArrayLiterals) {
2024 i::FLAG_allow_natives_syntax = true;
2025 InitializeVM();
2026 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
2027 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2028 v8::HandleScope scope;
2029
2030 AlwaysAllocateScope always_allocate;
2031 v8::Local<v8::Value> res = CompileRun(
2032 "function f() {"
2033 " var numbers = new Array(1, 2, 3);"
2034 " numbers[0] = 3.14;"
2035 " return numbers;"
2036 "};"
2037 "f(); f(); f();"
2038 "%OptimizeFunctionOnNextCall(f);"
2039 "f();");
2040 CHECK_EQ(static_cast<int>(3.14),
2041 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2042
2043 Handle<JSObject> o =
2044 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2045
2046 // TODO(hpayer): remove InNewSpace check and test if object was allocated
2047 // in old pointer space.
2048 CHECK(!HEAP->InOldPointerSpace(*o));
2049 CHECK(HEAP->InNewSpace(*o));
2050 }
2051
2052
2053 // Test regular array literals allocation.
2054 TEST(OptimizedAllocationArrayLiterals) {
2055 i::FLAG_allow_natives_syntax = true;
2056 InitializeVM();
2057 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
2058 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
2059 v8::HandleScope scope;
2060
2061 AlwaysAllocateScope always_allocate;
2062 v8::Local<v8::Value> res = CompileRun(
2063 "function f() {"
2064 " var numbers = new Array(1, 2, 3);"
2065 " numbers[0] = 3.14;"
2066 " return numbers;"
2067 "};"
2068 "f(); f(); f();"
2069 "%OptimizeFunctionOnNextCall(f);"
2070 "f();");
2071 CHECK_EQ(static_cast<int>(3.14),
2072 v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
2073
2074 Handle<JSObject> o =
2075 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
2076
2077 CHECK(HEAP->InNewSpace(*o));
2078 }
2079
2080
2022 static int CountMapTransitions(Map* map) { 2081 static int CountMapTransitions(Map* map) {
2023 return map->transitions()->number_of_transitions(); 2082 return map->transitions()->number_of_transitions();
2024 } 2083 }
2025 2084
2026 2085
2027 // Test that map transitions are cleared and maps are collected with 2086 // Test that map transitions are cleared and maps are collected with
2028 // incremental marking as well. 2087 // incremental marking as well.
2029 TEST(Regress1465) { 2088 TEST(Regress1465) {
2030 i::FLAG_allow_natives_syntax = true; 2089 i::FLAG_allow_natives_syntax = true;
2031 i::FLAG_trace_incremental_marking = true; 2090 i::FLAG_trace_incremental_marking = true;
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
2924 // explicitly enqueued. 2983 // explicitly enqueued.
2925 SimulateIncrementalMarking(); 2984 SimulateIncrementalMarking();
2926 2985
2927 // Now enable the debugger which in turn will disable code flushing. 2986 // Now enable the debugger which in turn will disable code flushing.
2928 CHECK(isolate->debug()->Load()); 2987 CHECK(isolate->debug()->Load());
2929 2988
2930 // This cycle will bust the heap and subsequent cycles will go ballistic. 2989 // This cycle will bust the heap and subsequent cycles will go ballistic.
2931 heap->CollectAllGarbage(Heap::kNoGCFlags); 2990 heap->CollectAllGarbage(Heap::kNoGCFlags);
2932 heap->CollectAllGarbage(Heap::kNoGCFlags); 2991 heap->CollectAllGarbage(Heap::kNoGCFlags);
2933 } 2992 }
OLDNEW
« no previous file with comments | « src/heap-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698