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

Side by Side Diff: src/snapshot-common.cc

Issue 1000063002: Hide RegExp and String initialization in a closure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 5 years, 9 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/regexp.js ('k') | src/string.js » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The common functionality when building with or without snapshots. 5 // The common functionality when building with or without snapshots.
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 int startup_total = 0; 103 int startup_total = 0;
104 int context_total = 0; 104 int context_total = 0;
105 for (auto& reservation : startup_reservations) { 105 for (auto& reservation : startup_reservations) {
106 startup_total += reservation.chunk_size(); 106 startup_total += reservation.chunk_size();
107 } 107 }
108 for (auto& reservation : context_reservations) { 108 for (auto& reservation : context_reservations) {
109 context_total += reservation.chunk_size(); 109 context_total += reservation.chunk_size();
110 } 110 }
111 PrintF( 111 PrintF(
112 "Deserialization will reserve:\n" 112 "Deserialization will reserve:\n"
113 "%*d bytes for startup\n" 113 "%10d bytes for startup\n"
114 "%*d bytes per context\n", 114 "%10d bytes per context\n",
115 10, startup_total, 10, context_total); 115 startup_total, context_total);
116 } 116 }
117 117
118 for (int space = 0; space < i::Serializer::kNumberOfSpaces; space++) { 118 for (int space = 0; space < i::Serializer::kNumberOfSpaces; space++) {
119 bool single_chunk = true; 119 bool single_chunk = true;
120 while (!startup_reservations[startup_index].is_last()) { 120 while (!startup_reservations[startup_index].is_last()) {
121 single_chunk = false; 121 single_chunk = false;
122 startup_index++; 122 startup_index++;
123 } 123 }
124 while (!context_reservations[context_index].is_last()) { 124 while (!context_reservations[context_index].is_last()) {
125 single_chunk = false; 125 single_chunk = false;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 memcpy(data + kFirstPageSizesOffset, first_page_sizes, 180 memcpy(data + kFirstPageSizesOffset, first_page_sizes,
181 kNumPagedSpaces * kInt32Size); 181 kNumPagedSpaces * kInt32Size);
182 memcpy(data + kStartupLengthOffset, &startup_length, kInt32Size); 182 memcpy(data + kStartupLengthOffset, &startup_length, kInt32Size);
183 memcpy(data + kStartupDataOffset, startup_data.begin(), startup_length); 183 memcpy(data + kStartupDataOffset, startup_data.begin(), startup_length);
184 memcpy(data + context_offset, context_data.begin(), context_length); 184 memcpy(data + context_offset, context_data.begin(), context_length);
185 v8::StartupData result = {data, length}; 185 v8::StartupData result = {data, length};
186 186
187 if (FLAG_profile_deserialization) { 187 if (FLAG_profile_deserialization) {
188 PrintF( 188 PrintF(
189 "Snapshot blob consists of:\n" 189 "Snapshot blob consists of:\n"
190 "%*d bytes for startup\n" 190 "%10d bytes for startup\n"
191 "%*d bytes for context\n", 191 "%10d bytes for context\n",
192 10, startup_length, 10, context_length); 192 startup_length, context_length);
193 } 193 }
194 return result; 194 return result;
195 } 195 }
196 196
197 197
198 Snapshot::Metadata Snapshot::ExtractMetadata(const v8::StartupData* data) { 198 Snapshot::Metadata Snapshot::ExtractMetadata(const v8::StartupData* data) {
199 uint32_t raw; 199 uint32_t raw;
200 memcpy(&raw, data->data + kMetadataOffset, kInt32Size); 200 memcpy(&raw, data->data + kMetadataOffset, kInt32Size);
201 return Metadata(raw); 201 return Metadata(raw);
202 } 202 }
(...skipping 15 matching lines...) Expand all
218 int startup_length; 218 int startup_length;
219 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); 219 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize);
220 int context_offset = ContextOffset(startup_length); 220 int context_offset = ContextOffset(startup_length);
221 const byte* context_data = 221 const byte* context_data =
222 reinterpret_cast<const byte*>(data->data + context_offset); 222 reinterpret_cast<const byte*>(data->data + context_offset);
223 DCHECK_LT(context_offset, data->raw_size); 223 DCHECK_LT(context_offset, data->raw_size);
224 int context_length = data->raw_size - context_offset; 224 int context_length = data->raw_size - context_offset;
225 return Vector<const byte>(context_data, context_length); 225 return Vector<const byte>(context_data, context_length);
226 } 226 }
227 } } // namespace v8::internal 227 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp.js ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698