Commit 31c0c024 authored by yangguo's avatar yangguo Committed by Commit bot

[snapshot] remove metadata field.

The upcoming snapshot creator API will have no way to distinguish default
from custom snapshots.

R=vogelheim@chromium.org
BUG=chromium:617892

Review-Url: https://codereview.chromium.org/2040813005
Cr-Commit-Position: refs/heads/master@{#36812}
parent 3c927e07
......@@ -5543,8 +5543,8 @@ class V8_EXPORT Isolate {
* The optional entry_hook allows the host application to provide the
* address of a function that's invoked on entry to every V8-generated
* function. Note that entry_hook is invoked at the very start of each
* generated function. Furthermore, if an entry_hook is given, V8 will
* always run without a context snapshot.
* generated function. Furthermore, if an entry_hook is given, V8 will
* not use a snapshot, including custom snapshots.
*/
FunctionEntryHook entry_hook;
......
......@@ -385,7 +385,6 @@ bool RunExtraCode(Isolate* isolate, Local<Context> context,
StartupData SerializeIsolateAndContext(
Isolate* isolate, Persistent<Context>* context,
i::Snapshot::Metadata metadata,
i::StartupSerializer::FunctionCodeHandling function_code_handling) {
if (context->IsEmpty()) return {NULL, 0};
......@@ -428,7 +427,7 @@ StartupData SerializeIsolateAndContext(
context_ser.Serialize(&raw_context);
ser.SerializeWeakReferencesAndDeferred();
return i::Snapshot::CreateSnapshotBlob(ser, context_ser, metadata);
return i::Snapshot::CreateSnapshotBlob(ser, context_ser);
}
} // namespace
......@@ -460,11 +459,8 @@ StartupData V8::CreateSnapshotDataBlob(const char* embedded_source) {
}
}
i::Snapshot::Metadata metadata;
metadata.set_embeds_script(embedded_source != NULL);
result = SerializeIsolateAndContext(
isolate, &context, metadata, i::StartupSerializer::CLEAR_FUNCTION_CODE);
isolate, &context, i::StartupSerializer::CLEAR_FUNCTION_CODE);
DCHECK(context.IsEmpty());
}
isolate->Dispose();
......@@ -515,11 +511,8 @@ StartupData V8::WarmUpSnapshotDataBlob(StartupData cold_snapshot_blob,
context.Reset(isolate, new_context);
}
i::Snapshot::Metadata metadata;
metadata.set_embeds_script(i::Snapshot::EmbedsScript(internal_isolate));
result = SerializeIsolateAndContext(
isolate, &context, metadata, i::StartupSerializer::KEEP_FUNCTION_CODE);
isolate, &context, i::StartupSerializer::KEEP_FUNCTION_CODE);
DCHECK(context.IsEmpty());
}
isolate->Dispose();
......@@ -7274,14 +7267,6 @@ Isolate* Isolate::New(const Isolate::CreateParams& params) {
// TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
Isolate::Scope isolate_scope(v8_isolate);
if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
// If the isolate has a function entry hook, it needs to re-build all its
// code stubs with entry hooks embedded, so don't deserialize a snapshot.
if (i::Snapshot::EmbedsScript(isolate)) {
// If the snapshot embeds a script, we cannot initialize the isolate
// without the snapshot as a fallback. This is unlikely to happen though.
V8_Fatal(__FILE__, __LINE__,
"Initializing isolate from custom startup snapshot failed");
}
isolate->Init(NULL);
}
return v8_isolate;
......
......@@ -31,12 +31,6 @@ bool Snapshot::HaveASnapshotToStartFrom(Isolate* isolate) {
}
bool Snapshot::EmbedsScript(Isolate* isolate) {
if (!isolate->snapshot_available()) return false;
return ExtractMetadata(isolate->snapshot_blob()).embeds_script();
}
uint32_t Snapshot::SizeOfFirstPage(Isolate* isolate, AllocationSpace space) {
DCHECK(space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE);
if (!isolate->snapshot_available()) {
......@@ -92,9 +86,7 @@ MaybeHandle<Context> Snapshot::NewContextFromSnapshot(
return Handle<Context>::cast(result);
}
void CalculateFirstPageSizes(bool is_default_snapshot,
const SnapshotData& startup_snapshot,
void CalculateFirstPageSizes(const SnapshotData& startup_snapshot,
const SnapshotData& context_snapshot,
uint32_t* sizes_out) {
Vector<const SerializedData::Reservation> startup_reservations =
......@@ -142,10 +134,6 @@ void CalculateFirstPageSizes(bool is_default_snapshot,
Page::kObjectStartOffset;
// Add a small allowance to the code space for small scripts.
if (space == CODE_SPACE) required += 32 * KB;
} else if (!FLAG_debug_code) {
// We expect the vanilla snapshot to only require one page per space,
// unless we are emitting debug code.
DCHECK(!is_default_snapshot);
}
if (space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE) {
......@@ -163,10 +151,9 @@ void CalculateFirstPageSizes(bool is_default_snapshot,
DCHECK_EQ(context_reservations.length(), context_index);
}
v8::StartupData Snapshot::CreateSnapshotBlob(
const i::StartupSerializer& startup_ser,
const i::PartialSerializer& context_ser, Snapshot::Metadata metadata) {
const i::PartialSerializer& context_ser) {
SnapshotData startup_snapshot(startup_ser);
SnapshotData context_snapshot(context_ser);
Vector<const byte> startup_data = startup_snapshot.RawData();
......@@ -174,8 +161,7 @@ v8::StartupData Snapshot::CreateSnapshotBlob(
uint32_t first_page_sizes[kNumPagedSpaces];
CalculateFirstPageSizes(!metadata.embeds_script(), startup_snapshot,
context_snapshot, first_page_sizes);
CalculateFirstPageSizes(startup_snapshot, context_snapshot, first_page_sizes);
int startup_length = startup_data.length();
int context_length = context_data.length();
......@@ -184,7 +170,6 @@ v8::StartupData Snapshot::CreateSnapshotBlob(
int length = context_offset + context_length;
char* data = new char[length];
memcpy(data + kMetadataOffset, &metadata.RawValue(), kInt32Size);
memcpy(data + kFirstPageSizesOffset, first_page_sizes,
kNumPagedSpaces * kInt32Size);
memcpy(data + kStartupLengthOffset, &startup_length, kInt32Size);
......@@ -202,14 +187,6 @@ v8::StartupData Snapshot::CreateSnapshotBlob(
return result;
}
Snapshot::Metadata Snapshot::ExtractMetadata(const v8::StartupData* data) {
uint32_t raw;
memcpy(&raw, data->data + kMetadataOffset, kInt32Size);
return Metadata(raw);
}
Vector<const byte> Snapshot::ExtractStartupData(const v8::StartupData* data) {
DCHECK_LT(kIntSize, data->raw_size);
int startup_length;
......
......@@ -18,21 +18,6 @@ class StartupSerializer;
class Snapshot : public AllStatic {
public:
class Metadata {
public:
explicit Metadata(uint32_t data = 0) : data_(data) {}
bool embeds_script() { return EmbedsScriptBits::decode(data_); }
void set_embeds_script(bool v) {
data_ = EmbedsScriptBits::update(data_, v);
}
uint32_t& RawValue() { return data_; }
private:
class EmbedsScriptBits : public BitField<bool, 0, 1> {};
uint32_t data_;
};
// Initialize the Isolate from the internal snapshot. Returns false if no
// snapshot could be found.
static bool Initialize(Isolate* isolate);
......@@ -52,7 +37,7 @@ class Snapshot : public AllStatic {
static v8::StartupData CreateSnapshotBlob(
const StartupSerializer& startup_ser,
const PartialSerializer& context_ser, Snapshot::Metadata metadata);
const PartialSerializer& context_ser);
#ifdef DEBUG
static bool SnapshotIsValid(v8::StartupData* snapshot_blob);
......@@ -61,19 +46,16 @@ class Snapshot : public AllStatic {
private:
static Vector<const byte> ExtractStartupData(const v8::StartupData* data);
static Vector<const byte> ExtractContextData(const v8::StartupData* data);
static Metadata ExtractMetadata(const v8::StartupData* data);
// Snapshot blob layout:
// [0] metadata
// [1 - 6] pre-calculated first page sizes for paged spaces
// [7] serialized start up data length
// [0 - 5] pre-calculated first page sizes for paged spaces
// [6] serialized start up data length
// ... serialized start up data
// ... serialized context data
static const int kNumPagedSpaces = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1;
static const int kMetadataOffset = 0;
static const int kFirstPageSizesOffset = kMetadataOffset + kInt32Size;
static const int kFirstPageSizesOffset = 0;
static const int kStartupLengthOffset =
kFirstPageSizesOffset + kNumPagedSpaces * kInt32Size;
static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size;
......
......@@ -485,7 +485,15 @@ TEST(SizeOfFirstPageIsLargeEnough) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
if (!isolate->snapshot_available()) return;
if (Snapshot::EmbedsScript(isolate)) return;
HandleScope scope(isolate);
v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
// Skip this test on the custom snapshot builder.
if (!CcTest::global()
->Get(context, v8_str("assertEquals"))
.ToLocalChecked()
->IsUndefined()) {
return;
}
// If this test fails due to enabling experimental natives that are not part
// of the snapshot, we may need to adjust CalculateFirstPageSizes.
......@@ -498,7 +506,6 @@ TEST(SizeOfFirstPageIsLargeEnough) {
}
// Executing the empty script gets by with one page per space.
HandleScope scope(isolate);
CompileRun("/*empty*/");
for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) {
// Debug code can be very large, so skip CODE_SPACE if we are generating it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment