OLD | NEW |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 deserializer->set_reservation(MAP_SPACE, map_space_used_); | 79 deserializer->set_reservation(MAP_SPACE, map_space_used_); |
80 deserializer->set_reservation(CELL_SPACE, cell_space_used_); | 80 deserializer->set_reservation(CELL_SPACE, cell_space_used_); |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 bool Snapshot::Initialize(const char* snapshot_file) { | 84 bool Snapshot::Initialize(const char* snapshot_file) { |
85 if (snapshot_file) { | 85 if (snapshot_file) { |
86 int len; | 86 int len; |
87 byte* str = ReadBytes(snapshot_file, &len); | 87 byte* str = ReadBytes(snapshot_file, &len); |
88 if (!str) return false; | 88 if (!str) return false; |
89 SnapshotByteSource source(str, len); | 89 bool success; |
90 Deserializer deserializer(&source); | 90 { |
91 ReserveSpaceForSnapshot(&deserializer, snapshot_file); | 91 SnapshotByteSource source(str, len); |
92 bool success = V8::Initialize(&deserializer); | 92 Deserializer deserializer(&source); |
| 93 ReserveSpaceForSnapshot(&deserializer, snapshot_file); |
| 94 success = V8::Initialize(&deserializer); |
| 95 } |
93 DeleteArray(str); | 96 DeleteArray(str); |
94 return success; | 97 return success; |
95 } else if (size_ > 0) { | 98 } else if (size_ > 0) { |
96 SnapshotByteSource source(raw_data_, raw_size_); | 99 SnapshotByteSource source(raw_data_, raw_size_); |
97 Deserializer deserializer(&source); | 100 Deserializer deserializer(&source); |
98 ReserveSpaceForLinkedInSnapshot(&deserializer); | 101 ReserveSpaceForLinkedInSnapshot(&deserializer); |
99 return V8::Initialize(&deserializer); | 102 return V8::Initialize(&deserializer); |
100 } | 103 } |
101 return false; | 104 return false; |
102 } | 105 } |
(...skipping 17 matching lines...) Expand all Loading... |
120 deserializer.set_reservation(OLD_DATA_SPACE, context_data_space_used_); | 123 deserializer.set_reservation(OLD_DATA_SPACE, context_data_space_used_); |
121 deserializer.set_reservation(CODE_SPACE, context_code_space_used_); | 124 deserializer.set_reservation(CODE_SPACE, context_code_space_used_); |
122 deserializer.set_reservation(MAP_SPACE, context_map_space_used_); | 125 deserializer.set_reservation(MAP_SPACE, context_map_space_used_); |
123 deserializer.set_reservation(CELL_SPACE, context_cell_space_used_); | 126 deserializer.set_reservation(CELL_SPACE, context_cell_space_used_); |
124 deserializer.DeserializePartial(&root); | 127 deserializer.DeserializePartial(&root); |
125 CHECK(root->IsContext()); | 128 CHECK(root->IsContext()); |
126 return Handle<Context>(Context::cast(root)); | 129 return Handle<Context>(Context::cast(root)); |
127 } | 130 } |
128 | 131 |
129 } } // namespace v8::internal | 132 } } // namespace v8::internal |
OLD | NEW |