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

Side by Side Diff: src/api.cc

Issue 750543002: Rip out bzip compression for native sources. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: compressed_size Created 6 years 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 | « samples/shell.cc ('k') | src/d8.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { 190 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
191 if (isolate->has_scheduled_exception()) { 191 if (isolate->has_scheduled_exception()) {
192 return isolate->scheduled_exception() == 192 return isolate->scheduled_exception() ==
193 isolate->heap()->termination_exception(); 193 isolate->heap()->termination_exception();
194 } 194 }
195 return false; 195 return false;
196 } 196 }
197 197
198 198
199 StartupDataDecompressor::StartupDataDecompressor()
200 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) {
201 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
202 raw_data[i] = NULL;
203 }
204 }
205
206
207 StartupDataDecompressor::~StartupDataDecompressor() {
208 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
209 i::DeleteArray(raw_data[i]);
210 }
211 i::DeleteArray(raw_data);
212 }
213
214
215 int StartupDataDecompressor::Decompress() {
216 int compressed_data_count = V8::GetCompressedStartupDataCount();
217 StartupData* compressed_data =
218 i::NewArray<StartupData>(compressed_data_count);
219 V8::GetCompressedStartupData(compressed_data);
220 for (int i = 0; i < compressed_data_count; ++i) {
221 char* decompressed = raw_data[i] =
222 i::NewArray<char>(compressed_data[i].raw_size);
223 if (compressed_data[i].compressed_size != 0) {
224 int result = DecompressData(decompressed,
225 &compressed_data[i].raw_size,
226 compressed_data[i].data,
227 compressed_data[i].compressed_size);
228 if (result != 0) return result;
229 } else {
230 DCHECK_EQ(0, compressed_data[i].raw_size);
231 }
232 compressed_data[i].data = decompressed;
233 }
234 V8::SetDecompressedStartupData(compressed_data);
235 i::DeleteArray(compressed_data);
236 return 0;
237 }
238
239
240 StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() {
241 #ifdef COMPRESS_STARTUP_DATA_BZ2
242 return StartupData::kBZip2;
243 #else
244 return StartupData::kUncompressed;
245 #endif
246 }
247
248
249 enum CompressedStartupDataItems {
250 kSnapshot = 0,
251 kSnapshotContext,
252 kLibraries,
253 kExperimentalLibraries,
254 kCompressedStartupDataCount
255 };
256
257
258 int V8::GetCompressedStartupDataCount() {
259 #ifdef COMPRESS_STARTUP_DATA_BZ2
260 return kCompressedStartupDataCount;
261 #else
262 return 0;
263 #endif
264 }
265
266
267 void V8::GetCompressedStartupData(StartupData* compressed_data) {
268 #ifdef COMPRESS_STARTUP_DATA_BZ2
269 compressed_data[kSnapshot].data =
270 reinterpret_cast<const char*>(i::Snapshot::data());
271 compressed_data[kSnapshot].compressed_size = i::Snapshot::size();
272 compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size();
273
274 compressed_data[kSnapshotContext].data =
275 reinterpret_cast<const char*>(i::Snapshot::context_data());
276 compressed_data[kSnapshotContext].compressed_size =
277 i::Snapshot::context_size();
278 compressed_data[kSnapshotContext].raw_size = i::Snapshot::context_raw_size();
279
280 i::Vector<const i::byte> libraries_source = i::Natives::GetScriptsSource();
281 compressed_data[kLibraries].data =
282 reinterpret_cast<const char*>(libraries_source.start());
283 compressed_data[kLibraries].compressed_size = libraries_source.length();
284 compressed_data[kLibraries].raw_size = i::Natives::GetRawScriptsSize();
285
286 i::Vector<const i::byte> exp_libraries_source =
287 i::ExperimentalNatives::GetScriptsSource();
288 compressed_data[kExperimentalLibraries].data =
289 reinterpret_cast<const char*>(exp_libraries_source.start());
290 compressed_data[kExperimentalLibraries].compressed_size =
291 exp_libraries_source.length();
292 compressed_data[kExperimentalLibraries].raw_size =
293 i::ExperimentalNatives::GetRawScriptsSize();
294 #endif
295 }
296
297
298 void V8::SetDecompressedStartupData(StartupData* decompressed_data) {
299 #ifdef COMPRESS_STARTUP_DATA_BZ2
300 DCHECK_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size);
301 i::Snapshot::set_raw_data(
302 reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data));
303
304 DCHECK_EQ(i::Snapshot::context_raw_size(),
305 decompressed_data[kSnapshotContext].raw_size);
306 i::Snapshot::set_context_raw_data(
307 reinterpret_cast<const i::byte*>(
308 decompressed_data[kSnapshotContext].data));
309
310 DCHECK_EQ(i::Natives::GetRawScriptsSize(),
311 decompressed_data[kLibraries].raw_size);
312 i::Vector<const char> libraries_source(
313 decompressed_data[kLibraries].data,
314 decompressed_data[kLibraries].raw_size);
315 i::Natives::SetRawScriptsSource(libraries_source);
316
317 DCHECK_EQ(i::ExperimentalNatives::GetRawScriptsSize(),
318 decompressed_data[kExperimentalLibraries].raw_size);
319 i::Vector<const char> exp_libraries_source(
320 decompressed_data[kExperimentalLibraries].data,
321 decompressed_data[kExperimentalLibraries].raw_size);
322 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source);
323 #endif
324 }
325
326
327 void V8::SetNativesDataBlob(StartupData* natives_blob) { 199 void V8::SetNativesDataBlob(StartupData* natives_blob) {
328 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 200 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
329 i::SetNativesFromFile(natives_blob); 201 i::SetNativesFromFile(natives_blob);
330 #else 202 #else
331 CHECK(false); 203 CHECK(false);
332 #endif 204 #endif
333 } 205 }
334 206
335 207
336 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { 208 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) {
(...skipping 7449 matching lines...) Expand 10 before | Expand all | Expand 10 after
7786 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7658 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7787 Address callback_address = 7659 Address callback_address =
7788 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7660 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7789 VMState<EXTERNAL> state(isolate); 7661 VMState<EXTERNAL> state(isolate);
7790 ExternalCallbackScope call_scope(isolate, callback_address); 7662 ExternalCallbackScope call_scope(isolate, callback_address);
7791 callback(info); 7663 callback(info);
7792 } 7664 }
7793 7665
7794 7666
7795 } } // namespace v8::internal 7667 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « samples/shell.cc ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698