OLD | NEW |
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 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 "%OptimizeFunctionOnNextCall(f);" | 2065 "%OptimizeFunctionOnNextCall(f);" |
2066 "f();"); | 2066 "f();"); |
2067 | 2067 |
2068 Handle<JSObject> o = | 2068 Handle<JSObject> o = |
2069 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2069 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2070 | 2070 |
2071 CHECK(HEAP->InOldPointerSpace(o->elements())); | 2071 CHECK(HEAP->InOldPointerSpace(o->elements())); |
2072 } | 2072 } |
2073 | 2073 |
2074 | 2074 |
| 2075 TEST(OptimizedPretenuringSimpleArrayLiterals) { |
| 2076 i::FLAG_allow_natives_syntax = true; |
| 2077 i::FLAG_pretenure_literals = false; |
| 2078 CcTest::InitializeVM(); |
| 2079 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; |
| 2080 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2081 v8::HandleScope scope(CcTest::isolate()); |
| 2082 |
| 2083 AlwaysAllocateScope always_allocate; |
| 2084 v8::Local<v8::Value> res = CompileRun( |
| 2085 "function f() {" |
| 2086 " return [1, 2, 3];" |
| 2087 "};" |
| 2088 "f(); f(); f();" |
| 2089 "%OptimizeFunctionOnNextCall(f);" |
| 2090 "f();"); |
| 2091 |
| 2092 Handle<JSObject> o = |
| 2093 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2094 |
| 2095 CHECK(HEAP->InNewSpace(*o)); |
| 2096 } |
| 2097 |
| 2098 |
2075 // Test regular array literals allocation. | 2099 // Test regular array literals allocation. |
2076 TEST(OptimizedAllocationArrayLiterals) { | 2100 TEST(OptimizedAllocationArrayLiterals) { |
2077 i::FLAG_allow_natives_syntax = true; | 2101 i::FLAG_allow_natives_syntax = true; |
2078 CcTest::InitializeVM(); | 2102 CcTest::InitializeVM(); |
2079 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; | 2103 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; |
2080 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2104 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2081 v8::HandleScope scope(CcTest::isolate()); | 2105 v8::HandleScope scope(CcTest::isolate()); |
2082 | 2106 |
2083 AlwaysAllocateScope always_allocate; | 2107 AlwaysAllocateScope always_allocate; |
2084 v8::Local<v8::Value> res = CompileRun( | 2108 v8::Local<v8::Value> res = CompileRun( |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3035 } | 3059 } |
3036 // An entire block of handles has been filled. | 3060 // An entire block of handles has been filled. |
3037 // Next handle would require a new block. | 3061 // Next handle would require a new block. |
3038 ASSERT(data->next == data->limit); | 3062 ASSERT(data->next == data->limit); |
3039 | 3063 |
3040 DeferredHandleScope deferred(isolate); | 3064 DeferredHandleScope deferred(isolate); |
3041 DummyVisitor visitor; | 3065 DummyVisitor visitor; |
3042 isolate->handle_scope_implementer()->Iterate(&visitor); | 3066 isolate->handle_scope_implementer()->Iterate(&visitor); |
3043 deferred.Detach(); | 3067 deferred.Detach(); |
3044 } | 3068 } |
OLD | NEW |