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

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

Issue 2868103002: [deserializer] Make large object deserialization GC safe (Closed)
Patch Set: fix tests for --noopt Created 3 years, 7 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
« no previous file with comments | « src/snapshot/deserializer.cc ('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 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
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 const char* filter_flag = "--turbo-filter=NOTHING";
1137 FlagList::SetFlagsFromString(filter_flag, StrLength(filter_flag));
1138 FLAG_black_allocation = true;
1139 FLAG_manual_evacuation_candidates_selection = true;
1140
1141 LocalContext context;
1142 Isolate* isolate = CcTest::i_isolate();
1143 Heap* heap = isolate->heap();
1144 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
1145
1146 v8::HandleScope scope(CcTest::isolate());
1147
1148 Vector<const uint8_t> source = ConstructSource(
1149 STATIC_CHAR_VECTOR("var j=1; if (j == 0) {"),
1150 STATIC_CHAR_VECTOR("for (var i = 0; i < Object.prototype; i++);"),
1151 STATIC_CHAR_VECTOR("} j=7; var s = 'happy_hippo'; j"), 2100);
1152 Handle<String> source_str =
1153 isolate->factory()->NewStringFromOneByte(source).ToHandleChecked();
1154
1155 // Create a string on an evacuation candidate in old space.
1156 Handle<String> moving_object;
1157 Page* ec_page;
1158 {
1159 AlwaysAllocateScope always_allocate(isolate);
1160 heap::SimulateFullSpace(heap->old_space());
1161 moving_object = isolate->factory()->InternalizeString(
1162 isolate->factory()->NewStringFromAsciiChecked("happy_hippo"));
1163 ec_page = Page::FromAddress(moving_object->address());
1164 }
1165
1166 Handle<JSObject> global(isolate->context()->global_object());
1167 ScriptData* cache = NULL;
1168
1169 Handle<SharedFunctionInfo> orig =
1170 CompileScript(isolate, source_str, Handle<String>(), &cache,
1171 v8::ScriptCompiler::kProduceCodeCache);
1172
1173 CHECK(heap->InSpace(orig->abstract_code(), LO_SPACE));
1174
1175 // Pretend that incremental marking is on when deserialization begins.
1176 heap::ForceEvacuationCandidate(ec_page);
1177 heap::SimulateIncrementalMarking(heap, false);
1178 IncrementalMarking* marking = heap->incremental_marking();
1179 marking->StartBlackAllocationForTesting();
1180 CHECK(marking->IsCompacting());
1181 CHECK(MarkCompactCollector::IsOnEvacuationCandidate(*moving_object));
1182
1183 Handle<SharedFunctionInfo> copy;
1184 {
1185 DisallowCompilation no_compile_expected(isolate);
1186 copy = CompileScript(isolate, source_str, Handle<String>(), &cache,
1187 v8::ScriptCompiler::kConsumeCodeCache);
1188 }
1189 CHECK_NE(*orig, *copy);
1190
1191 // We should have missed a write barrier. Complete incremental marking
1192 // to flush out the bug.
1193 heap::SimulateIncrementalMarking(heap, true);
1194 CcTest::CollectAllGarbage();
1195
1196 Handle<JSFunction> copy_fun =
1197 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1198 copy, isolate->native_context());
1199
1200 Handle<Object> copy_result =
1201 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
1202
1203 int result_int;
1204 CHECK(copy_result->ToInt32(&result_int));
1205 CHECK_EQ(7, result_int);
1206
1207 delete cache;
1208 source.Dispose();
1209 }
1129 TEST(CodeSerializerLargeStrings) { 1210 TEST(CodeSerializerLargeStrings) {
1130 FLAG_serialize_toplevel = true; 1211 FLAG_serialize_toplevel = true;
1131 LocalContext context; 1212 LocalContext context;
1132 Isolate* isolate = CcTest::i_isolate(); 1213 Isolate* isolate = CcTest::i_isolate();
1133 Factory* f = isolate->factory(); 1214 Factory* f = isolate->factory();
1134 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. 1215 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
1135 1216
1136 v8::HandleScope scope(CcTest::isolate()); 1217 v8::HandleScope scope(CcTest::isolate());
1137 1218
1138 Vector<const uint8_t> source_s = ConstructSource( 1219 Vector<const uint8_t> source_s = ConstructSource(
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 } 2546 }
2466 delete[] blob.data; 2547 delete[] blob.data;
2467 } 2548 }
2468 2549
2469 TEST(SerializationMemoryStats) { 2550 TEST(SerializationMemoryStats) {
2470 FLAG_profile_deserialization = true; 2551 FLAG_profile_deserialization = true;
2471 FLAG_always_opt = false; 2552 FLAG_always_opt = false;
2472 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2553 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2473 delete[] blob.data; 2554 delete[] blob.data;
2474 } 2555 }
OLDNEW
« no previous file with comments | « src/snapshot/deserializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698