| Index: src/snapshot/natives.h
|
| diff --git a/src/snapshot/natives.h b/src/snapshot/natives.h
|
| index 0f09e207dc4db5f1fe3591f15fb734d2c00fd469..79f7db39227bfd7fc309155b19623eacbdf6c074 100644
|
| --- a/src/snapshot/natives.h
|
| +++ b/src/snapshot/natives.h
|
| @@ -5,6 +5,7 @@
|
| #ifndef V8_SNAPSHOT_NATIVES_H_
|
| #define V8_SNAPSHOT_NATIVES_H_
|
|
|
| +#include "include/v8.h"
|
| #include "src/objects.h"
|
| #include "src/vector.h"
|
|
|
| @@ -46,10 +47,6 @@ class V8_EXPORT_PRIVATE NativesCollection {
|
| static Vector<const char> GetScriptSource(int index);
|
| static Vector<const char> GetScriptName(int index);
|
| static Vector<const char> GetScriptsSource();
|
| -
|
| - // The following methods are implemented in natives-common.cc:
|
| -
|
| - static FixedArray* GetSourceCache(Heap* heap);
|
| };
|
|
|
| typedef NativesCollection<CORE> Natives;
|
| @@ -64,6 +61,37 @@ void ReadNatives();
|
| void DisposeNatives();
|
| #endif
|
|
|
| +class NativesExternalStringResource final
|
| + : public v8::String::ExternalOneByteStringResource {
|
| + public:
|
| + NativesExternalStringResource(NativeType type, int index);
|
| +
|
| + const char* data() const override { return data_; }
|
| + size_t length() const override { return length_; }
|
| +
|
| + v8::String::ExternalOneByteStringResource* EncodeForSerialization() const {
|
| + DCHECK(type_ == CORE || type_ == EXTRAS);
|
| + intptr_t val = (index_ << 1) | ((type_ == CORE) ? 0 : 1);
|
| + val = val << kPointerSizeLog2; // Pointer align.
|
| + return reinterpret_cast<v8::String::ExternalOneByteStringResource*>(val);
|
| + }
|
| +
|
| + // Decode from serialization.
|
| + static NativesExternalStringResource* DecodeForDeserialization(
|
| + const v8::String::ExternalOneByteStringResource* encoded) {
|
| + intptr_t val = reinterpret_cast<intptr_t>(encoded) >> kPointerSizeLog2;
|
| + NativeType type = (val & 1) ? EXTRAS : CORE;
|
| + int index = static_cast<int>(val >> 1);
|
| + return new NativesExternalStringResource(type, index);
|
| + }
|
| +
|
| + private:
|
| + const char* data_;
|
| + size_t length_;
|
| + NativeType type_;
|
| + int index_;
|
| +};
|
| +
|
| } // namespace internal
|
| } // namespace v8
|
|
|
|
|