| Index: src/natives-external.cc
|
| diff --git a/src/natives-external.cc b/src/natives-external.cc
|
| index 109f9c5f47bfe14cf25a69365502ac1ef7993df7..437addc213ddbd5a34524f4b0c185d987afefd74 100644
|
| --- a/src/natives-external.cc
|
| +++ b/src/natives-external.cc
|
| @@ -132,9 +132,10 @@ class NativesHolder {
|
| DCHECK(store);
|
| holder_ = store;
|
| }
|
| + static bool empty() { return holder_ == NULL; }
|
| static void Dispose() {
|
| - DCHECK(holder_);
|
| delete holder_;
|
| + holder_ = NULL;
|
| }
|
|
|
| private:
|
| @@ -145,19 +146,36 @@ template<NativeType type>
|
| NativesStore* NativesHolder<type>::holder_ = NULL;
|
|
|
|
|
| +// The natives blob. Memory is owned by caller.
|
| +static StartupData* natives_blob_ = NULL;
|
| +
|
| +
|
| +/**
|
| + * Read the Natives blob, as previously set by SetNativesFromFile.
|
| + */
|
| +void ReadNatives() {
|
| + if (natives_blob_ && NativesHolder<CORE>::empty()) {
|
| + SnapshotByteSource bytes(natives_blob_->data, natives_blob_->raw_size);
|
| + NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes));
|
| + NativesHolder<EXPERIMENTAL>::set(
|
| + NativesStore::MakeFromScriptsSource(&bytes));
|
| + DCHECK(!bytes.HasMore());
|
| + }
|
| +}
|
| +
|
| +
|
| /**
|
| - * Read the Natives (library sources) blob, as generated by js2c + the build
|
| + * Set the Natives (library sources) blob, as generated by js2c + the build
|
| * system.
|
| */
|
| void SetNativesFromFile(StartupData* natives_blob) {
|
| + DCHECK(!natives_blob_);
|
| DCHECK(natives_blob);
|
| DCHECK(natives_blob->data);
|
| DCHECK(natives_blob->raw_size > 0);
|
|
|
| - SnapshotByteSource bytes(natives_blob->data, natives_blob->raw_size);
|
| - NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes));
|
| - NativesHolder<EXPERIMENTAL>::set(NativesStore::MakeFromScriptsSource(&bytes));
|
| - DCHECK(!bytes.HasMore());
|
| + natives_blob_ = natives_blob;
|
| + ReadNatives();
|
| }
|
|
|
|
|
|
|