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 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
2022 static int CountMapTransitions(Map* map) { | 2053 static int CountMapTransitions(Map* map) { |
2023 return map->transitions()->number_of_transitions(); | 2054 return map->transitions()->number_of_transitions(); |
2024 } | 2055 } |
2025 | 2056 |
2026 | 2057 |
2027 // Test that map transitions are cleared and maps are collected with | 2058 // Test that map transitions are cleared and maps are collected with |
2028 // incremental marking as well. | 2059 // incremental marking as well. |
2029 TEST(Regress1465) { | 2060 TEST(Regress1465) { |
2030 i::FLAG_allow_natives_syntax = true; | 2061 i::FLAG_allow_natives_syntax = true; |
2031 i::FLAG_trace_incremental_marking = true; | 2062 i::FLAG_trace_incremental_marking = true; |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2924 // explicitly enqueued. | 2955 // explicitly enqueued. |
2925 SimulateIncrementalMarking(); | 2956 SimulateIncrementalMarking(); |
2926 | 2957 |
2927 // Now enable the debugger which in turn will disable code flushing. | 2958 // Now enable the debugger which in turn will disable code flushing. |
2928 CHECK(isolate->debug()->Load()); | 2959 CHECK(isolate->debug()->Load()); |
2929 | 2960 |
2930 // This cycle will bust the heap and subsequent cycles will go ballistic. | 2961 // This cycle will bust the heap and subsequent cycles will go ballistic. |
2931 heap->CollectAllGarbage(Heap::kNoGCFlags); | 2962 heap->CollectAllGarbage(Heap::kNoGCFlags); |
2932 heap->CollectAllGarbage(Heap::kNoGCFlags); | 2963 heap->CollectAllGarbage(Heap::kNoGCFlags); |
2933 } | 2964 } |
OLD | NEW |