OLD | NEW |
---|---|
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1119 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 1119 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
1120 | 1120 |
1121 int result_int; | 1121 int result_int; |
1122 CHECK(copy_result->ToInt32(&result_int)); | 1122 CHECK(copy_result->ToInt32(&result_int)); |
1123 CHECK_EQ(7, result_int); | 1123 CHECK_EQ(7, result_int); |
1124 | 1124 |
1125 delete cache; | 1125 delete cache; |
1126 source.Dispose(); | 1126 source.Dispose(); |
1127 } | 1127 } |
1128 | 1128 |
1129 TEST(CodeSerializerLargeCodeObjectWithIncrementalMarking) { | |
1130 FLAG_serialize_toplevel = true; | |
1131 FLAG_always_opt = false; | |
1132 // This test relies on (full-codegen) code objects going to large object | |
1133 // space. Once FCG goes away, it must either be redesigned (to put some | |
1134 // other large deserialized object into LO space), or it can be deleted. | |
1135 FLAG_ignition = false; | |
1136 FLAG_turbo_filter = "NOTHING"; | |
1137 FLAG_black_allocation = true; | |
1138 FLAG_manual_evacuation_candidates_selection = true; | |
1139 | |
1140 LocalContext context; | |
1141 Isolate* isolate = CcTest::i_isolate(); | |
1142 Heap* heap = isolate->heap(); | |
1143 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. | |
1144 | |
1145 v8::HandleScope scope(CcTest::isolate()); | |
1146 | |
1147 Vector<const uint8_t> source = ConstructSource( | |
1148 STATIC_CHAR_VECTOR("var j=1; if (j == 0) {"), | |
1149 STATIC_CHAR_VECTOR("for (var i = 0; i < Object.prototype; i++);"), | |
1150 STATIC_CHAR_VECTOR("} j=7; var s = 'happy_hippo'; j"), 1400); | |
1151 Handle<String> source_str = | |
1152 isolate->factory()->NewStringFromOneByte(source).ToHandleChecked(); | |
1153 | |
1154 // Create a string on an evacuation candidate in old space. | |
1155 Handle<String> moving_object; | |
1156 Page* ec_page; | |
1157 { | |
1158 AlwaysAllocateScope always_allocate(isolate); | |
1159 heap::SimulateFullSpace(heap->old_space()); | |
1160 moving_object = isolate->factory()->InternalizeString( | |
1161 isolate->factory()->NewStringFromAsciiChecked("happy_hippo")); | |
1162 ec_page = Page::FromAddress(moving_object->address()); | |
1163 } | |
1164 | |
1165 Handle<JSObject> global(isolate->context()->global_object()); | |
1166 ScriptData* cache = NULL; | |
1167 | |
1168 Handle<SharedFunctionInfo> orig = | |
1169 CompileScript(isolate, source_str, Handle<String>(), &cache, | |
1170 v8::ScriptCompiler::kProduceCodeCache); | |
1171 | |
1172 CHECK(heap->InSpace(orig->abstract_code(), LO_SPACE)); | |
1173 | |
1174 // Pretend that incremental marking is on when deserialization begins. | |
1175 heap::ForceEvacuationCandidate(ec_page); | |
1176 MarkCompactCollector* collector = heap->mark_compact_collector(); | |
1177 IncrementalMarking* marking = heap->incremental_marking(); | |
Michael Lippautz
2017/05/09 18:27:44
I think you can use
heap::SimulateIncrementalMar
Jakob Kummerow
2017/05/10 11:09:07
Done.
| |
1178 if (collector->sweeping_in_progress()) { | |
1179 collector->EnsureSweepingCompleted(); | |
1180 } | |
1181 CHECK(marking->IsMarking() || marking->IsStopped()); | |
1182 if (marking->IsStopped()) { | |
1183 heap->StartIncrementalMarking(Heap::kNoGCFlags, | |
1184 GarbageCollectionReason::kTesting); | |
1185 } | |
1186 CHECK(marking->IsMarking()); | |
1187 marking->StartBlackAllocationForTesting(); | |
1188 CHECK(marking->IsCompacting()); | |
1189 CHECK(MarkCompactCollector::IsOnEvacuationCandidate(*moving_object)); | |
1190 | |
1191 Handle<SharedFunctionInfo> copy; | |
1192 { | |
1193 DisallowCompilation no_compile_expected(isolate); | |
1194 copy = CompileScript(isolate, source_str, Handle<String>(), &cache, | |
1195 v8::ScriptCompiler::kConsumeCodeCache); | |
1196 } | |
1197 CHECK_NE(*orig, *copy); | |
1198 | |
1199 // We should have missed a write barrier. Complete incremental marking | |
1200 // to flush out the bug. | |
1201 while (!marking->IsComplete()) { | |
Michael Lippautz
2017/05/09 18:27:44
I think you can use
heap::SimulateIncrementalMar
Jakob Kummerow
2017/05/10 11:09:07
Done.
| |
1202 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD, | |
1203 IncrementalMarking::FORCE_COMPLETION, StepOrigin::kV8); | |
1204 if (marking->IsReadyToOverApproximateWeakClosure()) { | |
1205 marking->FinalizeIncrementally(); | |
1206 } | |
1207 } | |
1208 CcTest::CollectAllGarbage(); | |
1209 | |
1210 Handle<JSFunction> copy_fun = | |
1211 isolate->factory()->NewFunctionFromSharedFunctionInfo( | |
1212 copy, isolate->native_context()); | |
1213 | |
1214 Handle<Object> copy_result = | |
1215 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | |
1216 | |
1217 int result_int; | |
1218 CHECK(copy_result->ToInt32(&result_int)); | |
1219 CHECK_EQ(7, result_int); | |
1220 | |
1221 delete cache; | |
1222 source.Dispose(); | |
1223 } | |
1129 TEST(CodeSerializerLargeStrings) { | 1224 TEST(CodeSerializerLargeStrings) { |
1130 FLAG_serialize_toplevel = true; | 1225 FLAG_serialize_toplevel = true; |
1131 LocalContext context; | 1226 LocalContext context; |
1132 Isolate* isolate = CcTest::i_isolate(); | 1227 Isolate* isolate = CcTest::i_isolate(); |
1133 Factory* f = isolate->factory(); | 1228 Factory* f = isolate->factory(); |
1134 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. | 1229 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. |
1135 | 1230 |
1136 v8::HandleScope scope(CcTest::isolate()); | 1231 v8::HandleScope scope(CcTest::isolate()); |
1137 | 1232 |
1138 Vector<const uint8_t> source_s = ConstructSource( | 1233 Vector<const uint8_t> source_s = ConstructSource( |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2465 } | 2560 } |
2466 delete[] blob.data; | 2561 delete[] blob.data; |
2467 } | 2562 } |
2468 | 2563 |
2469 TEST(SerializationMemoryStats) { | 2564 TEST(SerializationMemoryStats) { |
2470 FLAG_profile_deserialization = true; | 2565 FLAG_profile_deserialization = true; |
2471 FLAG_always_opt = false; | 2566 FLAG_always_opt = false; |
2472 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 2567 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
2473 delete[] blob.data; | 2568 delete[] blob.data; |
2474 } | 2569 } |
OLD | NEW |