OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #include "arguments.h" | 32 #include "arguments.h" |
33 #include "bootstrapper.h" | 33 #include "bootstrapper.h" |
34 #include "compiler.h" | 34 #include "compiler.h" |
35 #include "debug.h" | 35 #include "debug.h" |
36 #include "deoptimizer.h" | 36 #include "deoptimizer.h" |
37 #include "execution.h" | 37 #include "execution.h" |
38 #include "global-handles.h" | 38 #include "global-handles.h" |
39 #include "heap-profiler.h" | 39 #include "heap-profiler.h" |
40 #include "messages.h" | 40 #include "messages.h" |
| 41 #include "natives.h" |
41 #include "parser.h" | 42 #include "parser.h" |
42 #include "platform.h" | 43 #include "platform.h" |
43 #include "profile-generator-inl.h" | 44 #include "profile-generator-inl.h" |
44 #include "runtime-profiler.h" | 45 #include "runtime-profiler.h" |
45 #include "serialize.h" | 46 #include "serialize.h" |
46 #include "snapshot.h" | 47 #include "snapshot.h" |
47 #include "v8threads.h" | 48 #include "v8threads.h" |
48 #include "version.h" | 49 #include "version.h" |
49 #include "vm-state-inl.h" | 50 #include "vm-state-inl.h" |
50 | 51 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 305 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
305 if (isolate != NULL) | 306 if (isolate != NULL) |
306 return isolate; | 307 return isolate; |
307 | 308 |
308 i::Isolate::EnterDefaultIsolate(); | 309 i::Isolate::EnterDefaultIsolate(); |
309 isolate = i::Isolate::Current(); | 310 isolate = i::Isolate::Current(); |
310 return isolate; | 311 return isolate; |
311 } | 312 } |
312 | 313 |
313 | 314 |
| 315 StartupDataDecompressor::StartupDataDecompressor() |
| 316 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) { |
| 317 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { |
| 318 raw_data[i] = NULL; |
| 319 } |
| 320 } |
| 321 |
| 322 |
| 323 StartupDataDecompressor::~StartupDataDecompressor() { |
| 324 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { |
| 325 i::DeleteArray(raw_data[i]); |
| 326 } |
| 327 i::DeleteArray(raw_data); |
| 328 } |
| 329 |
| 330 |
| 331 int StartupDataDecompressor::Decompress() { |
| 332 int compressed_data_count = V8::GetCompressedStartupDataCount(); |
| 333 StartupData* compressed_data = |
| 334 i::NewArray<StartupData>(compressed_data_count); |
| 335 V8::GetCompressedStartupData(compressed_data); |
| 336 for (int i = 0; i < compressed_data_count; ++i) { |
| 337 char* decompressed = raw_data[i] = |
| 338 i::NewArray<char>(compressed_data[i].raw_size); |
| 339 if (compressed_data[i].compressed_size != 0) { |
| 340 int result = DecompressData(decompressed, |
| 341 &compressed_data[i].raw_size, |
| 342 compressed_data[i].data, |
| 343 compressed_data[i].compressed_size); |
| 344 if (result != 0) return result; |
| 345 } else { |
| 346 ASSERT_EQ(0, compressed_data[i].raw_size); |
| 347 } |
| 348 compressed_data[i].data = decompressed; |
| 349 } |
| 350 V8::SetDecompressedStartupData(compressed_data); |
| 351 return 0; |
| 352 } |
| 353 |
| 354 |
314 StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() { | 355 StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() { |
315 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 356 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
316 return StartupData::kBZip2; | 357 return StartupData::kBZip2; |
317 #else | 358 #else |
318 return StartupData::kUncompressed; | 359 return StartupData::kUncompressed; |
319 #endif | 360 #endif |
320 } | 361 } |
321 | 362 |
322 | 363 |
323 enum CompressedStartupDataItems { | 364 enum CompressedStartupDataItems { |
324 kSnapshot = 0, | 365 kSnapshot = 0, |
325 kSnapshotContext, | 366 kSnapshotContext, |
| 367 kLibraries, |
| 368 kExperimentalLibraries, |
326 kCompressedStartupDataCount | 369 kCompressedStartupDataCount |
327 }; | 370 }; |
328 | 371 |
329 int V8::GetCompressedStartupDataCount() { | 372 int V8::GetCompressedStartupDataCount() { |
330 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 373 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
331 return kCompressedStartupDataCount; | 374 return kCompressedStartupDataCount; |
332 #else | 375 #else |
333 return 0; | 376 return 0; |
334 #endif | 377 #endif |
335 } | 378 } |
336 | 379 |
337 | 380 |
338 void V8::GetCompressedStartupData(StartupData* compressed_data) { | 381 void V8::GetCompressedStartupData(StartupData* compressed_data) { |
339 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 382 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
340 compressed_data[kSnapshot].data = | 383 compressed_data[kSnapshot].data = |
341 reinterpret_cast<const char*>(i::Snapshot::data()); | 384 reinterpret_cast<const char*>(i::Snapshot::data()); |
342 compressed_data[kSnapshot].compressed_size = i::Snapshot::size(); | 385 compressed_data[kSnapshot].compressed_size = i::Snapshot::size(); |
343 compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size(); | 386 compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size(); |
344 | 387 |
345 compressed_data[kSnapshotContext].data = | 388 compressed_data[kSnapshotContext].data = |
346 reinterpret_cast<const char*>(i::Snapshot::context_data()); | 389 reinterpret_cast<const char*>(i::Snapshot::context_data()); |
347 compressed_data[kSnapshotContext].compressed_size = | 390 compressed_data[kSnapshotContext].compressed_size = |
348 i::Snapshot::context_size(); | 391 i::Snapshot::context_size(); |
349 compressed_data[kSnapshotContext].raw_size = i::Snapshot::context_raw_size(); | 392 compressed_data[kSnapshotContext].raw_size = i::Snapshot::context_raw_size(); |
| 393 |
| 394 i::Vector<const i::byte> libraries_source = i::Natives::GetScriptsSource(); |
| 395 compressed_data[kLibraries].data = |
| 396 reinterpret_cast<const char*>(libraries_source.start()); |
| 397 compressed_data[kLibraries].compressed_size = libraries_source.length(); |
| 398 compressed_data[kLibraries].raw_size = i::Natives::GetRawScriptsSize(); |
| 399 |
| 400 i::Vector<const i::byte> exp_libraries_source = |
| 401 i::ExperimentalNatives::GetScriptsSource(); |
| 402 compressed_data[kExperimentalLibraries].data = |
| 403 reinterpret_cast<const char*>(exp_libraries_source.start()); |
| 404 compressed_data[kExperimentalLibraries].compressed_size = |
| 405 exp_libraries_source.length(); |
| 406 compressed_data[kExperimentalLibraries].raw_size = |
| 407 i::ExperimentalNatives::GetRawScriptsSize(); |
350 #endif | 408 #endif |
351 } | 409 } |
352 | 410 |
353 | 411 |
354 void V8::SetDecompressedStartupData(StartupData* decompressed_data) { | 412 void V8::SetDecompressedStartupData(StartupData* decompressed_data) { |
355 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 413 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
356 ASSERT_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size); | 414 ASSERT_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size); |
357 i::Snapshot::set_raw_data( | 415 i::Snapshot::set_raw_data( |
358 reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data)); | 416 reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data)); |
359 | 417 |
360 ASSERT_EQ(i::Snapshot::context_raw_size(), | 418 ASSERT_EQ(i::Snapshot::context_raw_size(), |
361 decompressed_data[kSnapshotContext].raw_size); | 419 decompressed_data[kSnapshotContext].raw_size); |
362 i::Snapshot::set_context_raw_data( | 420 i::Snapshot::set_context_raw_data( |
363 reinterpret_cast<const i::byte*>( | 421 reinterpret_cast<const i::byte*>( |
364 decompressed_data[kSnapshotContext].data)); | 422 decompressed_data[kSnapshotContext].data)); |
| 423 |
| 424 ASSERT_EQ(i::Natives::GetRawScriptsSize(), |
| 425 decompressed_data[kLibraries].raw_size); |
| 426 i::Vector<const char> libraries_source( |
| 427 decompressed_data[kLibraries].data, |
| 428 decompressed_data[kLibraries].raw_size); |
| 429 i::Natives::SetRawScriptsSource(libraries_source); |
| 430 |
| 431 ASSERT_EQ(i::ExperimentalNatives::GetRawScriptsSize(), |
| 432 decompressed_data[kExperimentalLibraries].raw_size); |
| 433 i::Vector<const char> exp_libraries_source( |
| 434 decompressed_data[kExperimentalLibraries].data, |
| 435 decompressed_data[kExperimentalLibraries].raw_size); |
| 436 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source); |
365 #endif | 437 #endif |
366 } | 438 } |
367 | 439 |
368 | 440 |
369 void V8::SetFatalErrorHandler(FatalErrorCallback that) { | 441 void V8::SetFatalErrorHandler(FatalErrorCallback that) { |
370 i::Isolate* isolate = EnterIsolateIfNeeded(); | 442 i::Isolate* isolate = EnterIsolateIfNeeded(); |
371 isolate->set_exception_behavior(that); | 443 isolate->set_exception_behavior(that); |
372 } | 444 } |
373 | 445 |
374 | 446 |
(...skipping 5653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6028 | 6100 |
6029 | 6101 |
6030 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6102 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6031 HandleScopeImplementer* scope_implementer = | 6103 HandleScopeImplementer* scope_implementer = |
6032 reinterpret_cast<HandleScopeImplementer*>(storage); | 6104 reinterpret_cast<HandleScopeImplementer*>(storage); |
6033 scope_implementer->IterateThis(v); | 6105 scope_implementer->IterateThis(v); |
6034 return storage + ArchiveSpacePerThread(); | 6106 return storage + ArchiveSpacePerThread(); |
6035 } | 6107 } |
6036 | 6108 |
6037 } } // namespace v8::internal | 6109 } } // namespace v8::internal |
OLD | NEW |