Changeset 136188 in webkit
- Timestamp:
- Nov 29, 2012, 5:13:33 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
bindings/v8/V8Binding.cpp (modified) (1 diff)
-
bindings/v8/V8StringResource.cpp (modified) (3 diffs)
-
bindings/v8/V8StringResource.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r136187 r136188 1 2012-11-29 Kentaro Hara <haraken@chromium.org> 2 3 Unreviewed, rolling out r135862. 4 http://trac.webkit.org/changeset/135862 5 https://bugs.webkit.org/show_bug.cgi?id=103367 6 7 We've been observing 'Fatal error in 8 v8::V8::AddMessageListener()' in bots 9 10 * bindings/v8/V8Binding.cpp: 11 (WebCore::v8NonStringValueToWebCoreString): 12 * bindings/v8/V8StringResource.cpp: 13 (WebCore::int32ToWebCoreStringFast): 14 (WebCore::int32ToWebCoreString): 15 * bindings/v8/V8StringResource.h: 16 (WebCore::V8StringResource::V8StringResource): 17 (WebCore::V8StringResource::prepareBase): 18 (WebCore::V8StringResource::setString): 19 (V8StringResource): 20 (WebCore::V8StringResource::toString): 21 (WebCore::::prepare): 22 1 23 2012-11-29 Pavel Feldman <pfeldman@chromium.org> 2 24 -
trunk/Source/WebCore/bindings/v8/V8Binding.cpp
r135862 r136188 101 101 ASSERT(!object->IsString()); 102 102 if (object->IsInt32()) 103 return int32ToWebCoreString <String>(object->Int32Value());103 return int32ToWebCoreString(object->Int32Value()); 104 104 105 105 v8::TryCatch block; -
trunk/Source/WebCore/bindings/v8/V8StringResource.cpp
r135862 r136188 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.195 193 DEFINE_STATIC_LOCAL(Vector<AtomicString>, lowNumbers, (kLowNumbers + 1)); 196 194 String webCoreString; … … 207 205 } 208 206 209 template<> String int32ToWebCoreString<String>(int value)207 String int32ToWebCoreString(int value) 210 208 { 211 209 // If we are on the main thread (this should always true for non-workers), call the faster one. … … 215 213 } 216 214 217 template<> AtomicString int32ToWebCoreString<AtomicString>(int value)218 {219 return AtomicString(int32ToWebCoreString<String>(value));220 }221 222 215 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/V8StringResource.h
r135862 r136188 143 143 template <typename StringType> 144 144 StringType v8StringToWebCoreString(v8::Handle<v8::String>, ExternalMode); 145 template <typename StringType> 146 StringType int32ToWebCoreString(int value); 145 String int32ToWebCoreString(int value); 147 146 148 147 // V8StringResource is an adapter class that converts V8 values to Strings … … 160 159 : m_v8Object(object) 161 160 , m_mode(Externalize) 161 , m_string() 162 162 { 163 163 } … … 170 170 bool prepareBase() 171 171 { 172 ASSERT(!m_v8Object.IsEmpty()); 173 if (LIKELY(m_v8Object->IsString() || m_v8Object->IsInt32())) 172 if (m_v8Object.IsEmpty()) 174 173 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 } 175 182 176 183 m_mode = DoNotExternalize; … … 185 192 } 186 193 194 void setString(const String& string) 195 { 196 m_string = string; 197 m_v8Object.Clear(); // To signal that String is ready. 198 } 199 187 200 template <class StringType> 188 201 StringType toString() 189 202 { 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); 203 if (LIKELY(!m_v8Object.IsEmpty())) 204 return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode); 205 206 return StringType(m_string); 196 207 } 197 208 198 209 v8::Local<v8::Value> m_v8Object; 199 210 ExternalMode m_mode; 211 String m_string; 200 212 }; 201 213 202 214 template<> inline bool V8StringResource<DefaultMode>::prepare() 203 215 { 204 if (m_v8Object.IsEmpty())205 return true;206 216 return prepareBase(); 207 217 } … … 210 220 { 211 221 if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) { 212 m_v8Object.Clear();222 setString(String()); 213 223 return true; 214 224 } … … 219 229 { 220 230 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined()) { 221 m_v8Object.Clear();231 setString(String()); 222 232 return true; 223 233 }
Note:
See TracChangeset
for help on using the changeset viewer.