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

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

Issue 16109018: Fix serialization tests and Mac build (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/stub-cache-ia32.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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 virtual int Position() { 189 virtual int Position() {
190 return ftell(fp_); 190 return ftell(fp_);
191 } 191 }
192 void WriteSpaceUsed( 192 void WriteSpaceUsed(
193 int new_space_used, 193 int new_space_used,
194 int pointer_space_used, 194 int pointer_space_used,
195 int data_space_used, 195 int data_space_used,
196 int code_space_used, 196 int code_space_used,
197 int map_space_used, 197 int map_space_used,
198 int cell_space_used); 198 int cell_space_used,
199 int property_cell_space_used);
199 200
200 private: 201 private:
201 FILE* fp_; 202 FILE* fp_;
202 const char* file_name_; 203 const char* file_name_;
203 }; 204 };
204 205
205 206
206 void FileByteSink::WriteSpaceUsed( 207 void FileByteSink::WriteSpaceUsed(
207 int new_space_used, 208 int new_space_used,
208 int pointer_space_used, 209 int pointer_space_used,
209 int data_space_used, 210 int data_space_used,
210 int code_space_used, 211 int code_space_used,
211 int map_space_used, 212 int map_space_used,
212 int cell_space_used) { 213 int cell_space_used,
214 int property_cell_space_used) {
213 int file_name_length = StrLength(file_name_) + 10; 215 int file_name_length = StrLength(file_name_) + 10;
214 Vector<char> name = Vector<char>::New(file_name_length + 1); 216 Vector<char> name = Vector<char>::New(file_name_length + 1);
215 OS::SNPrintF(name, "%s.size", file_name_); 217 OS::SNPrintF(name, "%s.size", file_name_);
216 FILE* fp = OS::FOpen(name.start(), "w"); 218 FILE* fp = OS::FOpen(name.start(), "w");
217 name.Dispose(); 219 name.Dispose();
218 fprintf(fp, "new %d\n", new_space_used); 220 fprintf(fp, "new %d\n", new_space_used);
219 fprintf(fp, "pointer %d\n", pointer_space_used); 221 fprintf(fp, "pointer %d\n", pointer_space_used);
220 fprintf(fp, "data %d\n", data_space_used); 222 fprintf(fp, "data %d\n", data_space_used);
221 fprintf(fp, "code %d\n", code_space_used); 223 fprintf(fp, "code %d\n", code_space_used);
222 fprintf(fp, "map %d\n", map_space_used); 224 fprintf(fp, "map %d\n", map_space_used);
223 fprintf(fp, "cell %d\n", cell_space_used); 225 fprintf(fp, "cell %d\n", cell_space_used);
226 fprintf(fp, "property cell %d\n", property_cell_space_used);
224 fclose(fp); 227 fclose(fp);
225 } 228 }
226 229
227 230
228 static bool WriteToFile(const char* snapshot_file) { 231 static bool WriteToFile(const char* snapshot_file) {
229 FileByteSink file(snapshot_file); 232 FileByteSink file(snapshot_file);
230 StartupSerializer ser(&file); 233 StartupSerializer ser(&file);
231 ser.Serialize(); 234 ser.Serialize();
232 235
233 file.WriteSpaceUsed( 236 file.WriteSpaceUsed(
234 ser.CurrentAllocationAddress(NEW_SPACE), 237 ser.CurrentAllocationAddress(NEW_SPACE),
235 ser.CurrentAllocationAddress(OLD_POINTER_SPACE), 238 ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
236 ser.CurrentAllocationAddress(OLD_DATA_SPACE), 239 ser.CurrentAllocationAddress(OLD_DATA_SPACE),
237 ser.CurrentAllocationAddress(CODE_SPACE), 240 ser.CurrentAllocationAddress(CODE_SPACE),
238 ser.CurrentAllocationAddress(MAP_SPACE), 241 ser.CurrentAllocationAddress(MAP_SPACE),
239 ser.CurrentAllocationAddress(CELL_SPACE)); 242 ser.CurrentAllocationAddress(CELL_SPACE),
243 ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
240 244
241 return true; 245 return true;
242 } 246 }
243 247
244 248
245 static void Serialize() { 249 static void Serialize() {
246 // We have to create one context. One reason for this is so that the builtins 250 // We have to create one context. One reason for this is so that the builtins
247 // can be loaded from v8natives.js and their addresses can be processed. This 251 // can be loaded from v8natives.js and their addresses can be processed. This
248 // will clear the pending fixups array, which would otherwise contain GC roots 252 // will clear the pending fixups array, which would otherwise contain GC roots
249 // that would confuse the serialization/deserialization process. 253 // that would confuse the serialization/deserialization process.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 PartialSerializer p_ser(&startup_serializer, &partial_sink); 422 PartialSerializer p_ser(&startup_serializer, &partial_sink);
419 p_ser.Serialize(&raw_foo); 423 p_ser.Serialize(&raw_foo);
420 startup_serializer.SerializeWeakReferences(); 424 startup_serializer.SerializeWeakReferences();
421 425
422 partial_sink.WriteSpaceUsed( 426 partial_sink.WriteSpaceUsed(
423 p_ser.CurrentAllocationAddress(NEW_SPACE), 427 p_ser.CurrentAllocationAddress(NEW_SPACE),
424 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), 428 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
425 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), 429 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
426 p_ser.CurrentAllocationAddress(CODE_SPACE), 430 p_ser.CurrentAllocationAddress(CODE_SPACE),
427 p_ser.CurrentAllocationAddress(MAP_SPACE), 431 p_ser.CurrentAllocationAddress(MAP_SPACE),
428 p_ser.CurrentAllocationAddress(CELL_SPACE)); 432 p_ser.CurrentAllocationAddress(CELL_SPACE),
433 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
429 434
430 startup_sink.WriteSpaceUsed( 435 startup_sink.WriteSpaceUsed(
431 startup_serializer.CurrentAllocationAddress(NEW_SPACE), 436 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
432 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), 437 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
433 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), 438 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
434 startup_serializer.CurrentAllocationAddress(CODE_SPACE), 439 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
435 startup_serializer.CurrentAllocationAddress(MAP_SPACE), 440 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
436 startup_serializer.CurrentAllocationAddress(CELL_SPACE)); 441 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
442 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
437 startup_name.Dispose(); 443 startup_name.Dispose();
438 } 444 }
439 } 445 }
440 446
441 447
442 static void ReserveSpaceForSnapshot(Deserializer* deserializer, 448 static void ReserveSpaceForSnapshot(Deserializer* deserializer,
443 const char* file_name) { 449 const char* file_name) {
444 int file_name_length = StrLength(file_name) + 10; 450 int file_name_length = StrLength(file_name) + 10;
445 Vector<char> name = Vector<char>::New(file_name_length + 1); 451 Vector<char> name = Vector<char>::New(file_name_length + 1);
446 OS::SNPrintF(name, "%s.size", file_name); 452 OS::SNPrintF(name, "%s.size", file_name);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 PartialSerializer p_ser(&startup_serializer, &partial_sink); 565 PartialSerializer p_ser(&startup_serializer, &partial_sink);
560 p_ser.Serialize(&raw_context); 566 p_ser.Serialize(&raw_context);
561 startup_serializer.SerializeWeakReferences(); 567 startup_serializer.SerializeWeakReferences();
562 568
563 partial_sink.WriteSpaceUsed( 569 partial_sink.WriteSpaceUsed(
564 p_ser.CurrentAllocationAddress(NEW_SPACE), 570 p_ser.CurrentAllocationAddress(NEW_SPACE),
565 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), 571 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
566 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), 572 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
567 p_ser.CurrentAllocationAddress(CODE_SPACE), 573 p_ser.CurrentAllocationAddress(CODE_SPACE),
568 p_ser.CurrentAllocationAddress(MAP_SPACE), 574 p_ser.CurrentAllocationAddress(MAP_SPACE),
569 p_ser.CurrentAllocationAddress(CELL_SPACE)); 575 p_ser.CurrentAllocationAddress(CELL_SPACE),
576 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
570 577
571 startup_sink.WriteSpaceUsed( 578 startup_sink.WriteSpaceUsed(
572 startup_serializer.CurrentAllocationAddress(NEW_SPACE), 579 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
573 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), 580 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
574 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), 581 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
575 startup_serializer.CurrentAllocationAddress(CODE_SPACE), 582 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
576 startup_serializer.CurrentAllocationAddress(MAP_SPACE), 583 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
577 startup_serializer.CurrentAllocationAddress(CELL_SPACE)); 584 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
585 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
578 startup_name.Dispose(); 586 startup_name.Dispose();
579 } 587 }
580 } 588 }
581 589
582 590
583 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { 591 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
584 if (!Snapshot::HaveASnapshotToStartFrom()) { 592 if (!Snapshot::HaveASnapshotToStartFrom()) {
585 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 593 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
586 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 594 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
587 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 595 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 TEST(TestThatAlwaysFails) { 634 TEST(TestThatAlwaysFails) {
627 bool ArtificialFailure = false; 635 bool ArtificialFailure = false;
628 CHECK(ArtificialFailure); 636 CHECK(ArtificialFailure);
629 } 637 }
630 638
631 639
632 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 640 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
633 bool ArtificialFailure2 = false; 641 bool ArtificialFailure2 = false;
634 CHECK(ArtificialFailure2); 642 CHECK(ArtificialFailure2);
635 } 643 }
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698