From ec6984e48b09628698743cbef796ef53983fe3c2 Mon Sep 17 00:00:00 2001 From: mjs Date: Fri, 15 Apr 2005 16:45:20 +0000 Subject: [PATCH] Reviewed by Richard. - use custom single-threaded malloc for all non-GC JavaScriptCore allocations, for a 9.1% speedup on JavaScript iBench * khtml/ecma/kjs_binding.cpp: (UString::UString): * khtml/ecma/kjs_proxy.cpp: (KJSProxyImpl::evaluate): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9019 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog-2005-08-23 | 12 ++++++++++++ WebCore/khtml/ecma/kjs_binding.cpp | 15 ++++++--------- WebCore/khtml/ecma/kjs_events.cpp | 9 +++++++-- WebCore/khtml/ecma/kjs_proxy.cpp | 3 +++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23 index 176fd013172f..9c63fe9d777b 100644 --- a/WebCore/ChangeLog-2005-08-23 +++ b/WebCore/ChangeLog-2005-08-23 @@ -1,3 +1,15 @@ +2005-04-12 Maciej Stachowiak + + Reviewed by Richard. + + - use custom single-threaded malloc for all non-GC JavaScriptCore + allocations, for a 9.1% speedup on JavaScript iBench + + * khtml/ecma/kjs_binding.cpp: + (UString::UString): + * khtml/ecma/kjs_proxy.cpp: + (KJSProxyImpl::evaluate): + 2005-04-15 David Hyatt Fix the six pixel gap between rows nine and ten of the Acid2 test. Make sure that percentage heights that diff --git a/WebCore/khtml/ecma/kjs_binding.cpp b/WebCore/khtml/ecma/kjs_binding.cpp index da512f192a3d..f5aca1ae6f9a 100644 --- a/WebCore/khtml/ecma/kjs_binding.cpp +++ b/WebCore/khtml/ecma/kjs_binding.cpp @@ -317,10 +317,9 @@ void *ScriptInterpreter::createLanguageInstanceForValue (ExecState *exec, Bindin UString::UString(const QString &d) { - unsigned int len = d.length(); - UChar *dat = new UChar[len]; - memcpy(dat, d.unicode(), len * sizeof(UChar)); - rep = UString::Rep::create(dat, len); + // reinterpret_cast is ugly but in this case safe, since QChar and UChar have the same + // memory layout + rep = UString::Rep::createCopying(reinterpret_cast(d.unicode()), d.length()); } UString::UString(const DOMString &d) @@ -329,11 +328,9 @@ UString::UString(const DOMString &d) attach(&Rep::null); return; } - - unsigned int len = d.length(); - UChar *dat = new UChar[len]; - memcpy(dat, d.unicode(), len * sizeof(UChar)); - rep = UString::Rep::create(dat, len); + // reinterpret_cast is ugly but in this case safe, since QChar and UChar have the same + // memory layout + rep = UString::Rep::createCopying(reinterpret_cast(d.unicode()), d.length()); } DOMString UString::string() const diff --git a/WebCore/khtml/ecma/kjs_events.cpp b/WebCore/khtml/ecma/kjs_events.cpp index 8e7cdd92dfef..0b71f780c7f8 100644 --- a/WebCore/khtml/ecma/kjs_events.cpp +++ b/WebCore/khtml/ecma/kjs_events.cpp @@ -98,12 +98,17 @@ void JSAbstractEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent) KJS::Interpreter::lock(); char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii(); int lineNumber = exec->exception().toObject(exec).get(exec, "line").toInt32(exec); - UString sourceURL = exec->exception().toObject(exec).get(exec, "sourceURL").toString(exec); + QString sourceURL; + { + // put this in a block to make sure UString is deallocated inside the lock + UString uSourceURL = exec->exception().toObject(exec).get(exec, "sourceURL").toString(exec); + sourceURL = uSourceURL.qstring(); + } KJS::Interpreter::unlock(); if (Interpreter::shouldPrintExceptions()) { printf("(event handler):%s\n", message); } - KWQ(part)->addMessageToConsole(message, lineNumber, sourceURL.qstring()); + KWQ(part)->addMessageToConsole(message, lineNumber, sourceURL); exec->clearException(); } #else diff --git a/WebCore/khtml/ecma/kjs_proxy.cpp b/WebCore/khtml/ecma/kjs_proxy.cpp index b315e021461d..80da404e4f64 100644 --- a/WebCore/khtml/ecma/kjs_proxy.cpp +++ b/WebCore/khtml/ecma/kjs_proxy.cpp @@ -114,7 +114,10 @@ QVariant KJSProxyImpl::evaluate(QString filename, int baseLine, m_script->setInlineCode(inlineCode); KJS::Value thisNode = n.isNull() ? Window::retrieve( m_part ) : getDOMNode(m_script->globalExec(),n); + KJS::Interpreter::lock(); UString code( str ); + KJS::Interpreter::unlock(); + Completion comp = m_script->evaluate(filename, baseLine, code, thisNode); bool success = ( comp.complType() == Normal ) || ( comp.complType() == ReturnValue ); #ifdef KJS_DEBUGGER -- 2.36.0