Changeset 135862 in webkit
- Timestamp:
- Nov 27, 2012 7:50:07 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r135856 r135862 1 2012-11-27 Kentaro Hara <haraken@chromium.org> 2 3 [V8] Remove V8StringResource::m_string 4 https://bugs.webkit.org/show_bug.cgi?id=103367 5 6 Reviewed by Adam Barth. 7 8 This patch cleans up V8StringResource and removes V8StringResource::m_string. 9 This patch won't change performance. (This patch just adds one redundant IsString() 10 check and one IsInt32() check.) I confirmed no performance regression in micro benchmarks 11 (https://bugs.webkit.org/attachment.cgi?id=176178). 12 13 No tests. No change in behavior. 14 15 * bindings/v8/V8Binding.cpp: 16 (WebCore::v8NonStringValueToWebCoreString): 17 * bindings/v8/V8StringResource.cpp: 18 (WebCore::int32ToWebCoreStringFast): 19 (WebCore::String): 20 (WebCore::AtomicString): 21 (WebCore): 22 * bindings/v8/V8StringResource.h: 23 (WebCore::V8StringResource::V8StringResource): 24 (WebCore::V8StringResource::prepareBase): 25 (WebCore::V8StringResource::toString): 26 (V8StringResource): 27 (WebCore::::prepare): 28 1 29 2012-11-27 Alec Flett <alecflett@chromium.org> 2 30 -
trunk/Source/WebCore/bindings/v8/V8Binding.cpp
r135703 r135862 101 101 ASSERT(!object->IsString()); 102 102 if (object->IsInt32()) 103 return int32ToWebCoreString (object->Int32Value());103 return int32ToWebCoreString<String>(object->Int32Value()); 104 104 105 105 v8::TryCatch block; -
trunk/Source/WebCore/bindings/v8/V8StringResource.cpp
r135494 r135862 191 191 // Most numbers used are <= 100. Even if they aren't used there's very little cost in using the space. 192 192 const int kLowNumbers = 100; 193 194 // FIXME: Store lowNumbers in V8PerIsolateData so that workers can also use them. 193 195 DEFINE_STATIC_LOCAL(Vector<AtomicString>, lowNumbers, (kLowNumbers + 1)); 194 196 String webCoreString; … … 205 207 } 206 208 207 String int32ToWebCoreString(int value)209 template<> String int32ToWebCoreString<String>(int value) 208 210 { 209 211 // If we are on the main thread (this should always true for non-workers), call the faster one. … … 213 215 } 214 216 217 template<> AtomicString int32ToWebCoreString<AtomicString>(int value) 218 { 219 return AtomicString(int32ToWebCoreString<String>(value)); 220 } 221 215 222 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/V8StringResource.h
r135812 r135862 143 143 template <typename StringType> 144 144 StringType v8StringToWebCoreString(v8::Handle<v8::String>, ExternalMode); 145 String int32ToWebCoreString(int value); 145 template <typename StringType> 146 StringType int32ToWebCoreString(int value); 146 147 147 148 // V8StringResource is an adapter class that converts V8 values to Strings … … 159 160 : m_v8Object(object) 160 161 , m_mode(Externalize) 161 , m_string()162 162 { 163 163 } … … 170 170 bool prepareBase() 171 171 { 172 if (m_v8Object.IsEmpty()) 172 ASSERT(!m_v8Object.IsEmpty()); 173 if (LIKELY(m_v8Object->IsString() || m_v8Object->IsInt32())) 173 174 return true; 174 175 if (LIKELY(m_v8Object->IsString()))176 return true;177 178 if (LIKELY(m_v8Object->IsInt32())) {179 setString(int32ToWebCoreString(m_v8Object->Int32Value()));180 return true;181 }182 175 183 176 m_mode = DoNotExternalize; … … 192 185 } 193 186 194 void setString(const String& string)195 {196 m_string = string;197 m_v8Object.Clear(); // To signal that String is ready.198 }199 200 187 template <class StringType> 201 188 StringType toString() 202 189 { 203 if (LIKELY(!m_v8Object.IsEmpty())) 204 return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode); 205 206 return StringType(m_string); 190 if (m_v8Object.IsEmpty()) 191 return StringType(); 192 if (m_v8Object->IsInt32()) 193 return int32ToWebCoreString<StringType>(m_v8Object->Int32Value()); 194 ASSERT(m_v8Object->IsString()); 195 return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode); 207 196 } 208 197 209 198 v8::Local<v8::Value> m_v8Object; 210 199 ExternalMode m_mode; 211 String m_string;212 200 }; 213 201 214 202 template<> inline bool V8StringResource<DefaultMode>::prepare() 215 203 { 204 if (m_v8Object.IsEmpty()) 205 return true; 216 206 return prepareBase(); 217 207 } … … 220 210 { 221 211 if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) { 222 setString(String());212 m_v8Object.Clear(); 223 213 return true; 224 214 } … … 229 219 { 230 220 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined()) { 231 setString(String());221 m_v8Object.Clear(); 232 222 return true; 233 223 }
Note: See TracChangeset
for help on using the changeset viewer.