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

Side by Side Diff: src/api.cc

Issue 6901090: Add support for startup data (snapshot) compression. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 304 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
305 if (isolate != NULL) 305 if (isolate != NULL)
306 return isolate; 306 return isolate;
307 307
308 i::Isolate::EnterDefaultIsolate(); 308 i::Isolate::EnterDefaultIsolate();
309 isolate = i::Isolate::Current(); 309 isolate = i::Isolate::Current();
310 return isolate; 310 return isolate;
311 } 311 }
312 312
313 313
314 enum CompressedStartupDataItems {
315 kSnapshot = 0,
316 kSnapshotContext,
317 kCompressedStartupDataCount
318 };
319
320 int V8::GetCompressedStartupDataCount() {
321 #ifdef COMPRESS_STARTUP_DATA_BZ2
322 return kCompressedStartupDataCount;
323 #else
324 return 0;
325 #endif
326 }
327
328
329 void V8::GetCompressedStartupData(StartupData* compressed_data) {
330 #ifdef COMPRESS_STARTUP_DATA_BZ2
331 compressed_data->id = kSnapshot;
332 compressed_data->data = reinterpret_cast<const char*>(i::Snapshot::data());
333 compressed_data->compressed_size = i::Snapshot::size();
334 compressed_data->decompressed_size = i::Snapshot::decompressed_size();
335
336 ++compressed_data;
337 compressed_data->id = kSnapshotContext;
338 compressed_data->data =
339 reinterpret_cast<const char*>(i::Snapshot::context_data());
340 compressed_data->compressed_size = i::Snapshot::context_size();
341 compressed_data->decompressed_size = i::Snapshot::context_decompressed_size();
342 #endif
343 }
344
345
346 void V8::SetDecompressedStartupData(StartupData* decompressed_data) {
347 #ifdef COMPRESS_STARTUP_DATA_BZ2
348 for (int i = 0;
349 i < GetCompressedStartupDataCount();
350 ++i, ++decompressed_data) {
351 switch (decompressed_data->id) {
352 case kSnapshot:
353 ASSERT(i::Snapshot::decompressed_size() ==
354 decompressed_data->decompressed_size);
355 i::Snapshot::set_decompressed_data(
356 reinterpret_cast<const i::byte*>(decompressed_data->data));
357 break;
358 case kSnapshotContext:
359 ASSERT(i::Snapshot::context_decompressed_size() ==
360 decompressed_data->decompressed_size);
361 i::Snapshot::set_context_decompressed_data(
362 reinterpret_cast<const i::byte*>(decompressed_data->data));
363 break;
364 default:
365 UNREACHABLE();
366 }
367 }
368 #endif
369 }
370
371
314 void V8::SetFatalErrorHandler(FatalErrorCallback that) { 372 void V8::SetFatalErrorHandler(FatalErrorCallback that) {
315 i::Isolate* isolate = EnterIsolateIfNeeded(); 373 i::Isolate* isolate = EnterIsolateIfNeeded();
316 isolate->set_exception_behavior(that); 374 isolate->set_exception_behavior(that);
317 } 375 }
318 376
319 377
320 #ifdef DEBUG 378 #ifdef DEBUG
321 void ImplementationUtilities::ZapHandleRange(i::Object** begin, 379 void ImplementationUtilities::ZapHandleRange(i::Object** begin,
322 i::Object** end) { 380 i::Object** end) {
323 i::HandleScope::ZapRange(begin, end); 381 i::HandleScope::ZapRange(begin, end);
(...skipping 5361 matching lines...) Expand 10 before | Expand all | Expand 10 after
5685 5743
5686 5744
5687 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5745 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5688 HandleScopeImplementer* scope_implementer = 5746 HandleScopeImplementer* scope_implementer =
5689 reinterpret_cast<HandleScopeImplementer*>(storage); 5747 reinterpret_cast<HandleScopeImplementer*>(storage);
5690 scope_implementer->IterateThis(v); 5748 scope_implementer->IterateThis(v);
5691 return storage + ArchiveSpacePerThread(); 5749 return storage + ArchiveSpacePerThread();
5692 } 5750 }
5693 5751
5694 } } // namespace v8::internal 5752 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698