| 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 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2119 "%OptimizeFunctionOnNextCall(f);" | 2119 "%OptimizeFunctionOnNextCall(f);" |
| 2120 "f();"); | 2120 "f();"); |
| 2121 | 2121 |
| 2122 Handle<JSObject> o = | 2122 Handle<JSObject> o = |
| 2123 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2123 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2124 | 2124 |
| 2125 CHECK(HEAP->InNewSpace(*o)); | 2125 CHECK(HEAP->InNewSpace(*o)); |
| 2126 } | 2126 } |
| 2127 | 2127 |
| 2128 | 2128 |
| 2129 TEST(OptimizedPretenuringObjectAllocation) { |
| 2130 i::FLAG_allow_natives_syntax = true; |
| 2131 i::FLAG_pretenure_hallocateobject = true; |
| 2132 CcTest::InitializeVM(); |
| 2133 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; |
| 2134 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2135 v8::HandleScope scope(CcTest::isolate()); |
| 2136 HEAP->SetNewSpaceHighPromotionModeActive(true); |
| 2137 |
| 2138 AlwaysAllocateScope always_allocate; |
| 2139 v8::Local<v8::Value> res = CompileRun( |
| 2140 "function g() { this.a = 0; }" |
| 2141 "function f() {" |
| 2142 " return new g();" |
| 2143 "};" |
| 2144 "f(); f(); f();" |
| 2145 "%OptimizeFunctionOnNextCall(f);" |
| 2146 "f();"); |
| 2147 |
| 2148 Handle<JSObject> o = |
| 2149 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2150 |
| 2151 CHECK(HEAP->InOldPointerSpace(*o)); |
| 2152 } |
| 2153 |
| 2154 |
| 2129 // Test regular array literals allocation. | 2155 // Test regular array literals allocation. |
| 2130 TEST(OptimizedAllocationArrayLiterals) { | 2156 TEST(OptimizedAllocationArrayLiterals) { |
| 2131 i::FLAG_allow_natives_syntax = true; | 2157 i::FLAG_allow_natives_syntax = true; |
| 2132 CcTest::InitializeVM(); | 2158 CcTest::InitializeVM(); |
| 2133 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; | 2159 if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; |
| 2134 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2160 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2135 v8::HandleScope scope(CcTest::isolate()); | 2161 v8::HandleScope scope(CcTest::isolate()); |
| 2136 | 2162 |
| 2137 AlwaysAllocateScope always_allocate; | 2163 AlwaysAllocateScope always_allocate; |
| 2138 v8::Local<v8::Value> res = CompileRun( | 2164 v8::Local<v8::Value> res = CompileRun( |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3096 } | 3122 } |
| 3097 // An entire block of handles has been filled. | 3123 // An entire block of handles has been filled. |
| 3098 // Next handle would require a new block. | 3124 // Next handle would require a new block. |
| 3099 ASSERT(data->next == data->limit); | 3125 ASSERT(data->next == data->limit); |
| 3100 | 3126 |
| 3101 DeferredHandleScope deferred(isolate); | 3127 DeferredHandleScope deferred(isolate); |
| 3102 DummyVisitor visitor; | 3128 DummyVisitor visitor; |
| 3103 isolate->handle_scope_implementer()->Iterate(&visitor); | 3129 isolate->handle_scope_implementer()->Iterate(&visitor); |
| 3104 deferred.Detach(); | 3130 deferred.Detach(); |
| 3105 } | 3131 } |
| OLD | NEW |