Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 09489b8b2cd943cace03e27ba00431f10c63ec80..507cf473bf3f638f77295fe3962b38fad6b8bef5 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -38,6 +38,7 @@ |
#include "global-handles.h" |
#include "heap-profiler.h" |
#include "messages.h" |
+#include "natives.h" |
#include "parser.h" |
#include "platform.h" |
#include "profile-generator-inl.h" |
@@ -323,12 +324,14 @@ StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() { |
enum CompressedStartupDataItems { |
kSnapshot = 0, |
kSnapshotContext, |
- kCompressedStartupDataCount |
+ kSnapshotDataCount |
}; |
int V8::GetCompressedStartupDataCount() { |
#ifdef COMPRESS_STARTUP_DATA_BZ2 |
- return kCompressedStartupDataCount; |
+ return kSnapshotDataCount + |
+ i::Natives::GetBuiltinsCount() + |
+ i::ExperimentalNatives::GetBuiltinsCount(); |
#else |
return 0; |
#endif |
@@ -347,6 +350,28 @@ void V8::GetCompressedStartupData(StartupData* compressed_data) { |
compressed_data[kSnapshotContext].compressed_size = |
i::Snapshot::context_size(); |
compressed_data[kSnapshotContext].raw_size = i::Snapshot::context_raw_size(); |
+ |
+ for (int i = 0, idx = kSnapshotDataCount; |
Vitaly Repeshko
2011/06/06 10:08:23
It may be easier to read to maintain a separate of
mnaganov (inactive)
2011/06/06 13:40:18
Done.
|
+ i < i::Natives::GetBuiltinsCount(); |
Vitaly Repeshko
2011/06/06 10:08:23
I hope no compiler will have trouble with 'i' both
mnaganov (inactive)
2011/06/06 13:40:18
Bots will tell ;)
|
+ ++i, ++idx) { |
+ i::Vector<const i::byte> source = i::Natives::GetScriptSource(i); |
+ compressed_data[idx].data = |
+ reinterpret_cast<const char*>(source.start()); |
+ compressed_data[idx].compressed_size = source.length(); |
+ compressed_data[idx].raw_size = i::Natives::GetRawScriptSize(i); |
+ } |
+ |
+ for (int i = 0, idx = kSnapshotDataCount + i::Natives::GetBuiltinsCount(); |
+ i < i::ExperimentalNatives::GetBuiltinsCount(); |
+ ++i, ++idx) { |
+ i::Vector<const i::byte> source = |
+ i::ExperimentalNatives::GetScriptSource(i); |
+ compressed_data[idx].data = |
+ reinterpret_cast<const char*>(source.start()); |
+ compressed_data[idx].compressed_size = source.length(); |
+ compressed_data[idx].raw_size = |
+ i::ExperimentalNatives::GetRawScriptSize(i); |
+ } |
#endif |
} |
@@ -362,6 +387,26 @@ void V8::SetDecompressedStartupData(StartupData* decompressed_data) { |
i::Snapshot::set_context_raw_data( |
reinterpret_cast<const i::byte*>( |
decompressed_data[kSnapshotContext].data)); |
+ |
+ for (int i = 0, idx = kSnapshotDataCount; |
Vitaly Repeshko
2011/06/06 10:08:23
Same here.
|
+ i < i::Natives::GetBuiltinsCount(); |
+ ++i, ++idx) { |
+ ASSERT_EQ(i::Natives::GetRawScriptSize(i), |
+ decompressed_data[idx].raw_size); |
+ i::Vector<const char> source(decompressed_data[idx].data, |
+ decompressed_data[idx].raw_size); |
+ i::Natives::SetRawScriptSource(i, source); |
+ } |
+ |
+ for (int i = 0, idx = kSnapshotDataCount + i::Natives::GetBuiltinsCount(); |
+ i < i::ExperimentalNatives::GetBuiltinsCount(); |
+ ++i, ++idx) { |
+ ASSERT_EQ(i::ExperimentalNatives::GetRawScriptSize(i), |
+ decompressed_data[idx].raw_size); |
+ i::Vector<const char> source(decompressed_data[idx].data, |
+ decompressed_data[idx].raw_size); |
+ i::ExperimentalNatives::SetRawScriptSource(i, source); |
+ } |
#endif |
} |