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

Side by Side Diff: src/serialize.cc

Issue 3197010: Version 2.3.10... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 4 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/serialize.h ('k') | src/spaces.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 CASE_STATEMENT(where, how, within, OLD_DATA_SPACE) \ 824 CASE_STATEMENT(where, how, within, OLD_DATA_SPACE) \
825 CASE_STATEMENT(where, how, within, OLD_POINTER_SPACE) \ 825 CASE_STATEMENT(where, how, within, OLD_POINTER_SPACE) \
826 CASE_STATEMENT(where, how, within, CODE_SPACE) \ 826 CASE_STATEMENT(where, how, within, CODE_SPACE) \
827 CASE_STATEMENT(where, how, within, CELL_SPACE) \ 827 CASE_STATEMENT(where, how, within, CELL_SPACE) \
828 CASE_STATEMENT(where, how, within, MAP_SPACE) \ 828 CASE_STATEMENT(where, how, within, MAP_SPACE) \
829 CASE_STATEMENT(where, how, within, kLargeData) \ 829 CASE_STATEMENT(where, how, within, kLargeData) \
830 CASE_STATEMENT(where, how, within, kLargeCode) \ 830 CASE_STATEMENT(where, how, within, kLargeCode) \
831 CASE_STATEMENT(where, how, within, kLargeFixedArray) \ 831 CASE_STATEMENT(where, how, within, kLargeFixedArray) \
832 CASE_BODY(where, how, within, kAnyOldSpace, kUnknownOffsetFromStart) 832 CASE_BODY(where, how, within, kAnyOldSpace, kUnknownOffsetFromStart)
833 833
834 #define ONE_PER_CODE_SPACE(where, how, within) \
835 CASE_STATEMENT(where, how, within, CODE_SPACE) \
836 CASE_BODY(where, how, within, CODE_SPACE, kUnknownOffsetFromStart) \
837 CASE_STATEMENT(where, how, within, kLargeCode) \
838 CASE_BODY(where, how, within, LO_SPACE, kUnknownOffsetFromStart)
839
834 #define EMIT_COMMON_REFERENCE_PATTERNS(pseudo_space_number, \ 840 #define EMIT_COMMON_REFERENCE_PATTERNS(pseudo_space_number, \
835 space_number, \ 841 space_number, \
836 offset_from_start) \ 842 offset_from_start) \
837 CASE_STATEMENT(kFromStart, kPlain, kStartOfObject, pseudo_space_number) \ 843 CASE_STATEMENT(kFromStart, kPlain, kStartOfObject, pseudo_space_number) \
838 CASE_BODY(kFromStart, kPlain, kStartOfObject, space_number, offset_from_start) 844 CASE_BODY(kFromStart, kPlain, kStartOfObject, space_number, offset_from_start)
839 845
840 // We generate 15 cases and bodies that process special tags that combine 846 // We generate 15 cases and bodies that process special tags that combine
841 // the raw data tag and the length into one byte. 847 // the raw data tag and the length into one byte.
842 #define RAW_CASE(index, size) \ 848 #define RAW_CASE(index, size) \
843 case kRawData + index: { \ 849 case kRawData + index: { \
(...skipping 11 matching lines...) Expand all
855 int size = source_->GetInt(); 861 int size = source_->GetInt();
856 byte* raw_data_out = reinterpret_cast<byte*>(current); 862 byte* raw_data_out = reinterpret_cast<byte*>(current);
857 source_->CopyRaw(raw_data_out, size); 863 source_->CopyRaw(raw_data_out, size);
858 current = reinterpret_cast<Object**>(raw_data_out + size); 864 current = reinterpret_cast<Object**>(raw_data_out + size);
859 break; 865 break;
860 } 866 }
861 867
862 // Deserialize a new object and write a pointer to it to the current 868 // Deserialize a new object and write a pointer to it to the current
863 // object. 869 // object.
864 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject) 870 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject)
871 // Support for direct instruction pointers in functions
872 ONE_PER_CODE_SPACE(kNewObject, kPlain, kFirstInstruction)
865 // Deserialize a new code object and write a pointer to its first 873 // Deserialize a new code object and write a pointer to its first
866 // instruction to the current code object. 874 // instruction to the current code object.
867 ONE_PER_SPACE(kNewObject, kFromCode, kFirstInstruction) 875 ONE_PER_SPACE(kNewObject, kFromCode, kFirstInstruction)
868 // Find a recently deserialized object using its offset from the current 876 // Find a recently deserialized object using its offset from the current
869 // allocation point and write a pointer to it to the current object. 877 // allocation point and write a pointer to it to the current object.
870 ALL_SPACES(kBackref, kPlain, kStartOfObject) 878 ALL_SPACES(kBackref, kPlain, kStartOfObject)
871 // Find a recently deserialized code object using its offset from the 879 // Find a recently deserialized code object using its offset from the
872 // current allocation point and write a pointer to its first instruction 880 // current allocation point and write a pointer to its first instruction
873 // to the current code object. 881 // to the current code object or the instruction pointer in a function
882 // object.
874 ALL_SPACES(kBackref, kFromCode, kFirstInstruction) 883 ALL_SPACES(kBackref, kFromCode, kFirstInstruction)
884 ALL_SPACES(kBackref, kPlain, kFirstInstruction)
875 // Find an already deserialized object using its offset from the start 885 // Find an already deserialized object using its offset from the start
876 // and write a pointer to it to the current object. 886 // and write a pointer to it to the current object.
877 ALL_SPACES(kFromStart, kPlain, kStartOfObject) 887 ALL_SPACES(kFromStart, kPlain, kStartOfObject)
888 ALL_SPACES(kFromStart, kPlain, kFirstInstruction)
878 // Find an already deserialized code object using its offset from the 889 // Find an already deserialized code object using its offset from the
879 // start and write a pointer to its first instruction to the current code 890 // start and write a pointer to its first instruction to the current code
880 // object. 891 // object.
881 ALL_SPACES(kFromStart, kFromCode, kFirstInstruction) 892 ALL_SPACES(kFromStart, kFromCode, kFirstInstruction)
882 // Find an already deserialized object at one of the predetermined popular 893 // Find an already deserialized object at one of the predetermined popular
883 // offsets from the start and write a pointer to it in the current object. 894 // offsets from the start and write a pointer to it in the current object.
884 COMMON_REFERENCE_PATTERNS(EMIT_COMMON_REFERENCE_PATTERNS) 895 COMMON_REFERENCE_PATTERNS(EMIT_COMMON_REFERENCE_PATTERNS)
885 // Find an object in the roots array and write a pointer to it to the 896 // Find an object in the roots array and write a pointer to it to the
886 // current object. 897 // current object.
887 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) 898 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0)
888 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0, kUnknownOffsetFromStart) 899 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0, kUnknownOffsetFromStart)
889 // Find an object in the partial snapshots cache and write a pointer to it 900 // Find an object in the partial snapshots cache and write a pointer to it
890 // to the current object. 901 // to the current object.
891 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) 902 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0)
892 CASE_BODY(kPartialSnapshotCache, 903 CASE_BODY(kPartialSnapshotCache,
893 kPlain, 904 kPlain,
894 kStartOfObject, 905 kStartOfObject,
895 0, 906 0,
896 kUnknownOffsetFromStart) 907 kUnknownOffsetFromStart)
908 // Find an code entry in the partial snapshots cache and
909 // write a pointer to it to the current object.
910 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kFirstInstruction, 0)
911 CASE_BODY(kPartialSnapshotCache,
912 kPlain,
913 kFirstInstruction,
914 0,
915 kUnknownOffsetFromStart)
897 // Find an external reference and write a pointer to it to the current 916 // Find an external reference and write a pointer to it to the current
898 // object. 917 // object.
899 CASE_STATEMENT(kExternalReference, kPlain, kStartOfObject, 0) 918 CASE_STATEMENT(kExternalReference, kPlain, kStartOfObject, 0)
900 CASE_BODY(kExternalReference, 919 CASE_BODY(kExternalReference,
901 kPlain, 920 kPlain,
902 kStartOfObject, 921 kStartOfObject,
903 0, 922 0,
904 kUnknownOffsetFromStart) 923 kUnknownOffsetFromStart)
905 // Find an external reference and write a pointer to it in the current 924 // Find an external reference and write a pointer to it in the current
906 // code object. 925 // code object.
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { 1348 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) {
1330 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); 1349 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode()));
1331 Address target_start = rinfo->target_address_address(); 1350 Address target_start = rinfo->target_address_address();
1332 OutputRawData(target_start); 1351 OutputRawData(target_start);
1333 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); 1352 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
1334 serializer_->SerializeObject(target, kFromCode, kFirstInstruction); 1353 serializer_->SerializeObject(target, kFromCode, kFirstInstruction);
1335 bytes_processed_so_far_ += rinfo->target_address_size(); 1354 bytes_processed_so_far_ += rinfo->target_address_size();
1336 } 1355 }
1337 1356
1338 1357
1358 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) {
1359 Code* target = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
1360 OutputRawData(entry_address);
1361 serializer_->SerializeObject(target, kPlain, kFirstInstruction);
1362 bytes_processed_so_far_ += kPointerSize;
1363 }
1364
1365
1339 void Serializer::ObjectSerializer::VisitExternalAsciiString( 1366 void Serializer::ObjectSerializer::VisitExternalAsciiString(
1340 v8::String::ExternalAsciiStringResource** resource_pointer) { 1367 v8::String::ExternalAsciiStringResource** resource_pointer) {
1341 Address references_start = reinterpret_cast<Address>(resource_pointer); 1368 Address references_start = reinterpret_cast<Address>(resource_pointer);
1342 OutputRawData(references_start); 1369 OutputRawData(references_start);
1343 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 1370 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
1344 Object* source = Heap::natives_source_cache()->get(i); 1371 Object* source = Heap::natives_source_cache()->get(i);
1345 if (!source->IsUndefined()) { 1372 if (!source->IsUndefined()) {
1346 ExternalAsciiString* string = ExternalAsciiString::cast(source); 1373 ExternalAsciiString* string = ExternalAsciiString::cast(source);
1347 typedef v8::String::ExternalAsciiStringResource Resource; 1374 typedef v8::String::ExternalAsciiStringResource Resource;
1348 Resource* resource = string->resource(); 1375 Resource* resource = string->resource();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 1476 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
1450 } 1477 }
1451 } 1478 }
1452 int allocation_address = fullness_[space]; 1479 int allocation_address = fullness_[space];
1453 fullness_[space] = allocation_address + size; 1480 fullness_[space] = allocation_address + size;
1454 return allocation_address; 1481 return allocation_address;
1455 } 1482 }
1456 1483
1457 1484
1458 } } // namespace v8::internal 1485 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698