Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 } | 67 } |
| 68 | 68 |
| 69 static void OnWeakCallback(const v8::WeakCallbackInfo<WeakCallbackDataType>&); | 69 static void OnWeakCallback(const v8::WeakCallbackInfo<WeakCallbackDataType>&); |
| 70 | 70 |
| 71 static void Dispose(v8::Isolate*, | 71 static void Dispose(v8::Isolate*, |
| 72 v8::Global<v8::String> value, | 72 v8::Global<v8::String> value, |
| 73 StringImpl* key); | 73 StringImpl* key); |
| 74 static void DisposeWeak(const v8::WeakCallbackInfo<WeakCallbackDataType>&); | 74 static void DisposeWeak(const v8::WeakCallbackInfo<WeakCallbackDataType>&); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 // String cache helps convert WTF strings (StringImpl*) into v8 strings by | |
| 78 // only creating a v8::String for a particular StringImpl* once and caching it | |
| 79 // for future use. It is held by and can be retrieved from V8PerIsolateData. | |
|
haraken
2017/04/29 02:39:11
Add a comment about how the cache is maintained (w
adithyas
2017/05/01 17:41:16
Done.
| |
| 77 class PLATFORM_EXPORT StringCache { | 80 class PLATFORM_EXPORT StringCache { |
| 78 USING_FAST_MALLOC(StringCache); | 81 USING_FAST_MALLOC(StringCache); |
| 79 WTF_MAKE_NONCOPYABLE(StringCache); | 82 WTF_MAKE_NONCOPYABLE(StringCache); |
| 80 | 83 |
| 81 public: | 84 public: |
| 82 explicit StringCache(v8::Isolate* isolate) : string_cache_(isolate) {} | 85 explicit StringCache(v8::Isolate* isolate) : string_cache_(isolate) {} |
| 83 | 86 |
| 84 v8::Local<v8::String> V8ExternalString(v8::Isolate* isolate, | 87 v8::Local<v8::String> V8ExternalString(v8::Isolate* isolate, |
| 85 StringImpl* string_impl) { | 88 StringImpl* string_impl) { |
| 86 DCHECK(string_impl); | 89 DCHECK(string_impl); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 114 | 117 |
| 115 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity | 118 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity |
| 116 // hence lastStringImpl might be not a key of the cache (in sense of identity) | 119 // hence lastStringImpl might be not a key of the cache (in sense of identity) |
| 117 // and hence it's not refed on addition. | 120 // and hence it's not refed on addition. |
| 118 RefPtr<StringImpl> last_string_impl_; | 121 RefPtr<StringImpl> last_string_impl_; |
| 119 }; | 122 }; |
| 120 | 123 |
| 121 } // namespace blink | 124 } // namespace blink |
| 122 | 125 |
| 123 #endif // V8ValueCache_h | 126 #endif // V8ValueCache_h |
| OLD | NEW |