| Index: third_party/WebKit/Source/bindings/core/v8/V8ValueCache.h
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ValueCache.h b/third_party/WebKit/Source/bindings/core/v8/V8ValueCache.h
|
| index 3bc2e00a289657813f6d9724aad46ce8651f8fc3..ca51342075f7850754d13b27aa161cd2e7c334fe 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/V8ValueCache.h
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/V8ValueCache.h
|
| @@ -28,6 +28,7 @@
|
|
|
| #include "bindings/core/v8/V8GlobalValueMap.h"
|
| #include "core/CoreExport.h"
|
| +#include "platform/text/CompressibleString.h"
|
| #include "wtf/Allocator.h"
|
| #include "wtf/HashMap.h"
|
| #include "wtf/Noncopyable.h"
|
| @@ -64,12 +65,41 @@ public:
|
| static void DisposeWeak(const v8::WeakCallbackInfo<WeakCallbackDataType>&);
|
| };
|
|
|
| +class CompressibleStringCacheMapTraits : public V8GlobalValueMapTraits<CompressibleStringImpl*, v8::String, v8::kWeakWithParameter> {
|
| + STATIC_ONLY(CompressibleStringCacheMapTraits);
|
| +public:
|
| + // Weak traits:
|
| + typedef CompressibleStringImpl WeakCallbackDataType;
|
| + typedef v8::GlobalValueMap<CompressibleStringImpl*, v8::String, CompressibleStringCacheMapTraits> MapType;
|
| +
|
| + static WeakCallbackDataType* WeakCallbackParameter(
|
| + MapType* map, CompressibleStringImpl* key, v8::Local<v8::String>& value) { return key; }
|
| + static void DisposeCallbackData(WeakCallbackDataType* callbackData) { }
|
| +
|
| + static MapType* MapFromWeakCallbackInfo(
|
| + const v8::WeakCallbackInfo<WeakCallbackDataType>&);
|
| +
|
| + static CompressibleStringImpl* KeyFromWeakCallbackInfo(
|
| + const v8::WeakCallbackInfo<WeakCallbackDataType>& data)
|
| + {
|
| + return data.GetParameter();
|
| + }
|
| +
|
| + static void OnWeakCallback(const v8::WeakCallbackInfo<WeakCallbackDataType>&);
|
| +
|
| + static void Dispose(v8::Isolate*, v8::Global<v8::String> value, CompressibleStringImpl* key);
|
| + static void DisposeWeak(const v8::WeakCallbackInfo<WeakCallbackDataType>&);
|
| +};
|
|
|
| class CORE_EXPORT StringCache {
|
| USING_FAST_MALLOC(StringCache);
|
| WTF_MAKE_NONCOPYABLE(StringCache);
|
| public:
|
| - explicit StringCache(v8::Isolate* isolate) : m_stringCache(isolate) { }
|
| + explicit StringCache(v8::Isolate* isolate)
|
| + : m_stringCache(isolate)
|
| + , m_compressibleStringCache(isolate)
|
| + {
|
| + }
|
|
|
| v8::Local<v8::String> v8ExternalString(v8::Isolate* isolate, StringImpl* stringImpl)
|
| {
|
| @@ -79,6 +109,13 @@ public:
|
| return v8ExternalStringSlow(isolate, stringImpl);
|
| }
|
|
|
| + v8::Local<v8::String> v8ExternalString(v8::Isolate* isolate, const CompressibleString& string)
|
| + {
|
| + // Note that the last CompressibleString is not cached.
|
| + ASSERT(!string.isNull());
|
| + return v8ExternalStringSlow(isolate, string);
|
| + }
|
| +
|
| void setReturnValueFromString(v8::ReturnValue<v8::Value> returnValue, StringImpl* stringImpl)
|
| {
|
| ASSERT(stringImpl);
|
| @@ -91,16 +128,21 @@ public:
|
| void dispose();
|
|
|
| friend class StringCacheMapTraits;
|
| + friend class CompressibleStringCacheMapTraits;
|
|
|
| private:
|
| v8::Local<v8::String> v8ExternalStringSlow(v8::Isolate*, StringImpl*);
|
| + v8::Local<v8::String> v8ExternalStringSlow(v8::Isolate*, const CompressibleString&);
|
| void setReturnValueFromStringSlow(v8::ReturnValue<v8::Value>, StringImpl*);
|
| v8::Local<v8::String> createStringAndInsertIntoCache(v8::Isolate*, StringImpl*);
|
| + v8::Local<v8::String> createStringAndInsertIntoCache(v8::Isolate*, const CompressibleString&);
|
| void InvalidateLastString();
|
|
|
| StringCacheMapTraits::MapType m_stringCache;
|
| StringCacheMapTraits::MapType::PersistentValueReference m_lastV8String;
|
|
|
| + CompressibleStringCacheMapTraits::MapType m_compressibleStringCache;
|
| +
|
| // Note: RefPtr is a must as we cache by StringImpl* equality, not identity
|
| // hence lastStringImpl might be not a key of the cache (in sense of identity)
|
| // and hence it's not refed on addition.
|
|
|