JavaScriptCore:
Reviewed by Darin.
<rdar://problem/4283967> REGRESSION: 3% regression on PLT from new FastMalloc
http://bugzilla.opendarwin.org/show_bug.cgi?id=5243
A number of optimizations to the new threadsafe malloc that make it actually as fast
as dlmalloc (I measured wrong before) and as memory-efficient as the system malloc.
- use fastMalloc for everything - it now gets applied to all new/delete allocations
via a private inline operator new that is now included into every file via config.h.
- tweaked some of the numeric parameters for size classes and amount of wasted memory
allowed per allocation - this saves on memory use and consequently improves speed.
- so long as the allocator is not being used on background threads, get the per-thread
cache from a global variable instead of from pthread_getspecific, since the latter is slow.
- inline more functions, and force the ones GCC refuses to inline with
attribute(always_inline), nearly all of these have one call site so inlining them has
to be a win.
- use some tricks to calculate allocation size more efficiently and fewer times for small
allocations, to avoid hitting the huge size table array.
- avoid hitting the per-thread cache on code paths that don't need it.
- implement inline assembly version of spinlock for PowerPC (was already done for x86)
* bindings/NP_jsobject.cpp:
* bindings/c/c_class.cpp:
* bindings/c/c_instance.cpp:
* bindings/c/c_runtime.cpp:
* bindings/c/c_utility.cpp:
* bindings/jni/jni_class.cpp:
* bindings/jni/jni_instance.cpp:
* bindings/jni/jni_jsobject.cpp:
* bindings/jni/jni_objc.mm:
* bindings/jni/jni_runtime.cpp:
* bindings/jni/jni_utility.cpp:
* bindings/npruntime.cpp:
* bindings/objc/WebScriptObject.mm:
* bindings/objc/objc_class.mm:
* bindings/objc/objc_instance.mm:
* bindings/objc/objc_runtime.mm:
* bindings/objc/objc_utility.mm:
* bindings/runtime.cpp:
* bindings/runtime_array.cpp:
* bindings/runtime_method.cpp:
* bindings/runtime_object.cpp:
* bindings/runtime_root.cpp:
* bindings/testbindings.cpp:
* bindings/testbindings.mm:
* kjs/array_object.cpp:
(ArrayInstanceImp::ArrayInstanceImp):
(ArrayInstanceImp::~ArrayInstanceImp):
(ArrayInstanceImp::resizeStorage):
* kjs/bool_object.cpp:
* kjs/collector.cpp:
(KJS::Collector::registerThread):
* kjs/config.h:
* kjs/debugger.cpp:
* kjs/error_object.cpp:
* kjs/function.cpp:
* kjs/function_object.cpp:
* kjs/identifier.cpp:
(KJS::Identifier::rehash):
* kjs/internal.cpp:
(KJS::Parser::saveNewNode):
(KJS::clearNewNodes):
* kjs/interpreter.cpp:
* kjs/lexer.cpp:
(Lexer::doneParsing):
(Lexer::makeIdentifier):
(Lexer::makeUString):
* kjs/list.cpp:
* kjs/math_object.cpp:
* kjs/nodes.cpp:
* kjs/nodes.h:
* kjs/nodes2string.cpp:
* kjs/number_object.cpp:
(integer_part_noexp):
(char_sequence):
* kjs/object.cpp:
* kjs/object_object.cpp:
* kjs/property_map.cpp:
* kjs/property_slot.cpp:
* kjs/protected_values.cpp:
(KJS::ProtectedValues::rehash):
* kjs/reference.cpp:
* kjs/reference_list.cpp:
* kjs/regexp.cpp:
* kjs/regexp_object.cpp:
* kjs/scope_chain.cpp:
* kjs/scope_chain.h:
* kjs/string_object.cpp:
* kjs/testkjs.cpp:
* kjs/ustring.h:
* kjs/value.cpp:
* kxmlcore/Assertions.mm:
* kxmlcore/FastMalloc.cpp:
(KXMLCore::InitSizeClasses):
(KXMLCore::DLL_IsEmpty):
(KXMLCore::DLL_Prepend):
(KXMLCore::TCMalloc_Central_FreeList::Insert):
(KXMLCore::TCMalloc_Central_FreeList::Remove):
(KXMLCore::TCMalloc_Central_FreeList::Populate):
(KXMLCore::TCMalloc_ThreadCache::Allocate):
(KXMLCore::TCMalloc_ThreadCache::FetchFromCentralCache):
(KXMLCore::fastMallocRegisterThread):
(KXMLCore::TCMalloc_ThreadCache::GetCache):
(KXMLCore::TCMalloc_ThreadCache::GetCacheIfPresent):
(KXMLCore::TCMalloc_ThreadCache::CreateCacheIfNecessary):
(KXMLCore::do_malloc):
(KXMLCore::do_free):
(KXMLCore::realloc):
* kxmlcore/FastMalloc.h:
(operator new):
(operator delete):
(operator new[]):
(operator delete[]):
* kxmlcore/HashTable.cpp:
* kxmlcore/TCSpinLock.h:
(TCMalloc_SpinLock::Lock):
(TCMalloc_SpinLock::Unlock):
(TCMalloc_SlowLock):
* kxmlcore/TCSystemAlloc.cpp:
WebCore:
Reviewed by Darin.
<rdar://problem/4283967> REGRESSION: 3% regression on PLT from new FastMalloc
http://bugzilla.opendarwin.org/show_bug.cgi?id=5243
- use fastMalloc for everything - it now gets applied to all new/delete allocations
via a private inline operator new that is now included into every file via config.h
* WebCore.xcodeproj/project.pbxproj:
* WebCorePrefix.h:
* khtml/css/css_base.cpp:
* khtml/css/css_base.h:
* khtml/css/css_computedstyle.cpp:
* khtml/css/css_ruleimpl.cpp:
* khtml/css/css_stylesheetimpl.cpp:
* khtml/css/css_valueimpl.cpp:
* khtml/css/css_valueimpl.h:
* khtml/css/csshelper.cpp:
* khtml/css/cssparser.cpp:
(ValueList::ValueList):
(ValueList::~ValueList):
(ValueList::addValue):
(CSSParser::CSSParser):
(CSSParser::~CSSParser):
(CSSParser::setupParser):
(CSSParser::addProperty):
* khtml/css/cssstyleselector.cpp:
* khtml/css/cssstyleselector.h:
* khtml/dom/dom2_events.cpp:
* khtml/dom/dom2_traversal.cpp:
* khtml/dom/dom_misc.cpp:
* khtml/dom/dom_string.cpp:
* khtml/ecma/domparser.cpp:
* khtml/ecma/kjs_binding.cpp:
* khtml/ecma/kjs_css.cpp:
* khtml/ecma/kjs_dom.cpp:
* khtml/ecma/kjs_events.cpp:
* khtml/ecma/kjs_html.cpp:
(KJS::KJS::Context2DFunction::callAsFunction):
(KJS::Gradient::~Gradient):
(KJS::Gradient::addColorStop):
(KJS::Gradient::colorStops):
* khtml/ecma/kjs_navigator.cpp:
* khtml/ecma/kjs_proxy.cpp:
* khtml/ecma/kjs_range.cpp:
* khtml/ecma/kjs_traversal.cpp:
* khtml/ecma/kjs_views.cpp:
* khtml/ecma/kjs_window.cpp:
* khtml/ecma/xmlhttprequest.cpp:
* khtml/ecma/xmlserializer.cpp:
* khtml/editing/SelectionController.cpp:
* khtml/editing/append_node_command.cpp:
* khtml/editing/apply_style_command.cpp:
* khtml/editing/break_blockquote_command.cpp:
* khtml/editing/composite_edit_command.cpp:
* khtml/editing/delete_from_text_node_command.cpp:
* khtml/editing/delete_selection_command.cpp:
* khtml/editing/edit_command.cpp:
* khtml/editing/html_interchange.cpp:
* khtml/editing/htmlediting.cpp:
* khtml/editing/insert_into_text_node_command.cpp:
* khtml/editing/insert_line_break_command.cpp:
* khtml/editing/insert_node_before_command.cpp:
* khtml/editing/insert_paragraph_separator_command.cpp:
* khtml/editing/insert_text_command.cpp:
* khtml/editing/join_text_nodes_command.cpp:
* khtml/editing/jsediting.cpp:
* khtml/editing/markup.cpp:
* khtml/editing/merge_identical_elements_command.cpp:
* khtml/editing/move_selection_command.cpp:
* khtml/editing/rebalance_whitespace_command.cpp:
* khtml/editing/remove_css_property_command.cpp:
* khtml/editing/remove_node_attribute_command.cpp:
* khtml/editing/remove_node_command.cpp:
* khtml/editing/remove_node_preserving_children_command.cpp:
* khtml/editing/replace_selection_command.cpp:
* khtml/editing/set_node_attribute_command.cpp:
* khtml/editing/split_element_command.cpp:
* khtml/editing/split_text_node_command.cpp:
* khtml/editing/split_text_node_containing_element.cpp:
* khtml/editing/typing_command.cpp:
* khtml/editing/visible_position.cpp:
* khtml/editing/visible_range.cpp:
* khtml/editing/visible_text.cpp:
(khtml::CircularSearchBuffer::~CircularSearchBuffer):
(khtml::CircularSearchBuffer::CircularSearchBuffer):
* khtml/editing/visible_units.cpp:
* khtml/editing/wrap_contents_in_dummy_span_command.cpp:
* khtml/html/html_baseimpl.cpp:
* khtml/html/html_blockimpl.cpp:
* khtml/html/html_canvasimpl.cpp:
* khtml/html/html_documentimpl.cpp:
* khtml/html/html_elementimpl.cpp:
* khtml/html/html_formimpl.cpp:
* khtml/html/html_headimpl.cpp:
* khtml/html/html_imageimpl.cpp:
* khtml/html/html_inlineimpl.cpp:
* khtml/html/html_listimpl.cpp:
* khtml/html/html_miscimpl.cpp:
* khtml/html/html_objectimpl.cpp:
* khtml/html/html_tableimpl.cpp:
* khtml/html/htmlfactory.cpp:
* khtml/html/htmlnames.cpp:
* khtml/html/htmlparser.cpp:
* khtml/html/htmltokenizer.cpp:
(khtml::HTMLTokenizer::enlargeBuffer):
(khtml::HTMLTokenizer::enlargeScriptBuffer):
* khtml/khtml_events.cpp:
* khtml/khtml_part.cpp:
* khtml/khtmlview.cpp:
* khtml/misc/arena.cpp:
* khtml/misc/arena.h:
* khtml/misc/decoder.cpp:
* khtml/misc/formdata.cpp:
* khtml/misc/helper.cpp:
* khtml/misc/loader.cpp:
* khtml/misc/stringit.cpp:
* khtml/rendering/bidi.cpp:
* khtml/rendering/break_lines.cpp:
* khtml/rendering/font.cpp:
* khtml/rendering/render_arena.cpp:
* khtml/rendering/render_block.cpp:
* khtml/rendering/render_box.cpp:
* khtml/rendering/render_br.cpp:
* khtml/rendering/render_canvas.cpp:
* khtml/rendering/render_canvasimage.cpp:
(RenderCanvasImage::~RenderCanvasImage):
(RenderCanvasImage::createDrawingContext):
* khtml/rendering/render_container.cpp:
* khtml/rendering/render_flexbox.cpp:
* khtml/rendering/render_flow.cpp:
* khtml/rendering/render_form.cpp:
* khtml/rendering/render_frames.cpp:
* khtml/rendering/render_image.cpp:
* khtml/rendering/render_inline.cpp:
* khtml/rendering/render_layer.cpp:
* khtml/rendering/render_line.cpp:
* khtml/rendering/render_list.cpp:
* khtml/rendering/render_object.cpp:
* khtml/rendering/render_replaced.cpp:
* khtml/rendering/render_style.cpp:
* khtml/rendering/render_style.h:
* khtml/rendering/render_table.cpp:
* khtml/rendering/render_text.cpp:
* khtml/rendering/render_theme.cpp:
* khtml/rendering/render_theme_mac.mm:
* khtml/rendering/table_layout.cpp:
* khtml/xbl/xbl_binding.cpp:
* khtml/xbl/xbl_binding_manager.cpp:
* khtml/xbl/xbl_docimpl.cpp:
* khtml/xbl/xbl_protobinding.cpp:
* khtml/xbl/xbl_protohandler.cpp:
* khtml/xbl/xbl_protoimplementation.cpp:
* khtml/xbl/xbl_tokenizer.cpp:
* khtml/xml/EventNames.cpp:
* khtml/xml/dom2_eventsimpl.cpp:
* khtml/xml/dom2_eventsimpl.h:
* khtml/xml/dom2_rangeimpl.cpp:
* khtml/xml/dom2_rangeimpl.h:
* khtml/xml/dom2_traversalimpl.cpp:
* khtml/xml/dom2_traversalimpl.h:
* khtml/xml/dom2_viewsimpl.cpp:
* khtml/xml/dom2_viewsimpl.h:
* khtml/xml/dom_atomicstring.cpp:
* khtml/xml/dom_docimpl.cpp:
* khtml/xml/dom_docimpl.h:
* khtml/xml/dom_elementimpl.cpp:
* khtml/xml/dom_elementimpl.h:
* khtml/xml/dom_nodeimpl.cpp:
* khtml/xml/dom_nodeimpl.h:
* khtml/xml/dom_position.cpp:
* khtml/xml/dom_qname.cpp:
* khtml/xml/dom_stringimpl.cpp:
* khtml/xml/dom_stringimpl.h:
* khtml/xml/dom_textimpl.cpp:
* khtml/xml/dom_xmlimpl.cpp:
* khtml/xml/xml_tokenizer.cpp:
* khtml/xsl/xsl_stylesheetimpl.cpp:
* khtml/xsl/xslt_processorimpl.cpp:
* kwq/DOM-CSS.mm:
* kwq/DOM.mm:
* kwq/DOMEvents.mm:
* kwq/DOMHTML.mm:
* kwq/DOMInternal.mm:
(DOMString::DOMString):
* kwq/DOMUtility.mm:
* kwq/DOMViews.mm:
* kwq/KWQAccObject.mm:
* kwq/KWQAccObjectCache.mm:
* kwq/KWQApplication.mm:
* kwq/KWQArrayImpl.h:
* kwq/KWQArrayImpl.mm:
* kwq/KWQBuffer.mm:
* kwq/KWQButton.mm:
* kwq/KWQCString.mm:
* kwq/KWQCharsets.mm:
* kwq/KWQClipboard.mm:
* kwq/KWQCollection.mm:
* kwq/KWQColor.mm:
* kwq/KWQComboBox.mm:
* kwq/KWQCursor.mm:
* kwq/KWQDateTime.mm:
* kwq/KWQDictImpl.mm:
* kwq/KWQEditCommand.mm:
* kwq/KWQEvent.mm:
* kwq/KWQExceptions.mm:
* kwq/KWQFile.mm:
* kwq/KWQFileButton.mm:
* kwq/KWQFont.mm:
* kwq/KWQFontFamily.h:
* kwq/KWQFontFamily.mm:
* kwq/KWQFontMetrics.mm:
* kwq/KWQFormData.mm:
* kwq/KWQFrame.mm:
* kwq/KWQGlobal.mm:
* kwq/KWQGuardedPtr.mm:
* kwq/KWQKCharsets.mm:
* kwq/KWQKConfigBase.mm:
* kwq/KWQKCookieJar.mm:
* kwq/KWQKCursor.mm:
* kwq/KWQKGlobal.mm:
* kwq/KWQKGlobalSettings.mm:
* kwq/KWQKHTMLFactory.mm:
* kwq/KWQKHTMLPart.cpp:
* kwq/KWQKHTMLPart.mm:
* kwq/KWQKHTMLPartBrowserExtension.mm:
* kwq/KWQKHTMLView.mm:
* kwq/KWQKHistoryProvider.mm:
* kwq/KWQKJavaAppletWidget.mm:
* kwq/KWQKJob.mm:
* kwq/KWQKJobClasses.mm:
* kwq/KWQKLocale.mm:
* kwq/KWQKPartsBrowserInterface.mm:
* kwq/KWQKPartsEvent.mm:
* kwq/KWQKPartsPart.mm:
* kwq/KWQKSSLKeyGen.mm:
* kwq/KWQKStandardDirs.mm:
* kwq/KWQKStringHandler.mm:
* kwq/KWQKURL.mm:
(KURL::KURL):
(KURL::decode_string):
(KURL::parse):
(KURL::encode_string):
(encodeRelativeString):
* kwq/KWQKWin.mm:
* kwq/KWQKWinModule.mm:
* kwq/KWQLabel.mm:
* kwq/KWQLineEdit.mm:
* kwq/KWQListBox.mm:
* kwq/KWQListImpl.mm:
* kwq/KWQLoader.mm:
(KWQIsResponseURLEqualToURL):
* kwq/KWQMapImpl.h:
* kwq/KWQMapImpl.mm:
* kwq/KWQMovie.mm:
* kwq/KWQObject.mm:
* kwq/KWQPageState.mm:
* kwq/KWQPaintDeviceMetrics.mm:
* kwq/KWQPainter.mm:
* kwq/KWQPalette.mm:
* kwq/KWQPen.mm:
* kwq/KWQPixmap.mm:
* kwq/KWQPoint.mm:
* kwq/KWQPointArray.mm:
* kwq/KWQPtrDictImpl.mm:
* kwq/KWQPushButton.mm:
* kwq/KWQRect.mm:
* kwq/KWQRegExp.mm:
* kwq/KWQRegion.mm:
* kwq/KWQRenderTreeDebug.cpp:
* kwq/KWQResourceLoader.mm:
* kwq/KWQScrollBar.mm:
* kwq/KWQScrollView.mm:
* kwq/KWQSignal.mm:
* kwq/KWQSignalStubs.mm:
* kwq/KWQSize.mm:
* kwq/KWQSlider.mm:
* kwq/KWQSlot.mm:
* kwq/KWQString.h:
* kwq/KWQString.mm:
(ALLOC_CHAR):
(REALLOC_CHAR):
(DELETE_CHAR):
(ALLOC_QCHAR):
(REALLOC_QCHAR):
(DELETE_QCHAR):
(_printQStringAllocationStatistics):
(allocateHandle):
(KWQStringData::operator new):
(KWQStringData::operator delete):
(freeHandle):
* kwq/KWQStringList.mm:
* kwq/KWQStyle.mm:
* kwq/KWQTextArea.mm:
* kwq/KWQTextCodec.mm:
* kwq/KWQTextEdit.mm:
* kwq/KWQTextField.mm:
* kwq/KWQTextStream.mm:
* kwq/KWQTextUtilities.mm:
* kwq/KWQTimer.mm:
* kwq/KWQValueListImpl.h:
* kwq/KWQValueListImpl.mm:
* kwq/KWQVariant.mm:
* kwq/KWQVectorImpl.mm:
(KWQVectorImpl::KWQVectorImpl):
(KWQVectorImpl::~KWQVectorImpl):
(KWQVectorImpl::clear):
(KWQVectorImpl::resize):
(KWQVectorImpl::assign):
* kwq/KWQWMatrix.mm:
* kwq/KWQWidget.mm:
* kwq/KWQWindowWidget.mm:
* kwq/WebCoreBridge.mm:
* kwq/WebCoreCache.mm:
* kwq/WebCoreEncodings.mm:
* kwq/WebCoreJavaScript.mm:
* kwq/WebCoreScriptDebugger.mm:
* kwq/WebCoreSettings.mm:
* kwq/WebCoreTextRendererFactory.mm:
* kwq/can-convert.mm:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@10701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 280c47f..6371782 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "config.h"
#include "array_object.h"
#include "error_object.h"
@@ -49,7 +50,7 @@
, length(initialLength)
, storageLength(initialLength < sparseArrayCutoff ? initialLength : 0)
, capacity(storageLength)
- , storage(capacity ? (ValueImp **)calloc(capacity, sizeof(ValueImp *)) : 0)
+ , storage(capacity ? (ValueImp **)fastCalloc(capacity, sizeof(ValueImp *)) : 0)
{
}
@@ -58,7 +59,7 @@
, length(list.size())
, storageLength(length)
, capacity(storageLength)
- , storage(capacity ? (ValueImp **)malloc(sizeof(ValueImp *) * capacity) : 0)
+ , storage(capacity ? (ValueImp **)fastMalloc(sizeof(ValueImp *) * capacity) : 0)
{
ListIterator it = list.begin();
unsigned l = length;
@@ -69,7 +70,7 @@
ArrayInstanceImp::~ArrayInstanceImp()
{
- free(storage);
+ fastFree(storage);
}
ValueImp *ArrayInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
@@ -215,7 +216,7 @@
newCapacity = sparseArrayCutoff;
}
}
- storage = (ValueImp **)realloc(storage, newCapacity * sizeof (ValueImp *));
+ storage = (ValueImp **)fastRealloc(storage, newCapacity * sizeof (ValueImp *));
memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity));
capacity = newCapacity;
}
diff --git a/JavaScriptCore/kjs/bool_object.cpp b/JavaScriptCore/kjs/bool_object.cpp
index f07583c..8e29b0e 100644
--- a/JavaScriptCore/kjs/bool_object.cpp
+++ b/JavaScriptCore/kjs/bool_object.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "config.h"
#include "value.h"
#include "object.h"
#include "types.h"
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index 2e90a41..f126ccc 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -19,9 +19,11 @@
*
*/
+#include "config.h"
#include "collector.h"
#include <kxmlcore/FastMalloc.h>
+#include <kxmlcore/FastMallocInternal.h>
#include "internal.h"
#include "list.h"
#include "value.h"
@@ -224,6 +226,7 @@
if (!pthread_getspecific(registeredThreadKey)) {
pthread_t pthread = pthread_self();
+ KXMLCore::fastMallocRegisterThread(pthread);
Collector::Thread *thread = new Collector::Thread(pthread, pthread_mach_thread_np(pthread));
thread->next = registeredThreads;
registeredThreads = thread;
diff --git a/JavaScriptCore/kjs/config.h b/JavaScriptCore/kjs/config.h
index 8501b43..42f28fb 100644
--- a/JavaScriptCore/kjs/config.h
+++ b/JavaScriptCore/kjs/config.h
@@ -32,3 +32,9 @@
#undef DEBUG_COLLECTOR
#define KXC_CHANGES 1
+
+#ifdef __cplusplus
+#undef new
+#undef delete
+#include <kxmlcore/FastMalloc.h>
+#endif
diff --git a/JavaScriptCore/kjs/debugger.cpp b/JavaScriptCore/kjs/debugger.cpp
index 89e467f..56d7fbd 100644
--- a/JavaScriptCore/kjs/debugger.cpp
+++ b/JavaScriptCore/kjs/debugger.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "config.h"
#include "debugger.h"
#include "value.h"
#include "object.h"
diff --git a/JavaScriptCore/kjs/error_object.cpp b/JavaScriptCore/kjs/error_object.cpp
index 9ef1f1e..96fc895 100644
--- a/JavaScriptCore/kjs/error_object.cpp
+++ b/JavaScriptCore/kjs/error_object.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "config.h"
#include "value.h"
#include "object.h"
#include "types.h"
diff --git a/JavaScriptCore/kjs/fpconst.cpp b/JavaScriptCore/kjs/fpconst.cpp
index ad5d29c..d732f45 100644
--- a/JavaScriptCore/kjs/fpconst.cpp
+++ b/JavaScriptCore/kjs/fpconst.cpp
@@ -17,7 +17,7 @@
*
*/
-#include <config.h>
+#include "config.h"
// This file exists because JavaScriptCore needs to define the NaN and Inf globals in a way
// that does not use a static initializer so we don't have a framework initialization routine.
diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp
index 41ea9e4..4d00561 100644
--- a/JavaScriptCore/kjs/function.cpp
+++ b/JavaScriptCore/kjs/function.cpp
@@ -22,6 +22,7 @@
*
*/
+#include "config.h"
#include "function.h"
#include "internal.h"
diff --git a/JavaScriptCore/kjs/function_object.cpp b/JavaScriptCore/kjs/function_object.cpp
index 8d645c1..ca27633 100644
--- a/JavaScriptCore/kjs/function_object.cpp
+++ b/JavaScriptCore/kjs/function_object.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "config.h"
#include "function_object.h"
#include "internal.h"
#include "function.h"
diff --git a/JavaScriptCore/kjs/identifier.cpp b/JavaScriptCore/kjs/identifier.cpp
index 80b770f..c64a5d2 100644
--- a/JavaScriptCore/kjs/identifier.cpp
+++ b/JavaScriptCore/kjs/identifier.cpp
@@ -33,6 +33,7 @@
#define KJS_IDENTIFIER_HIDE_GLOBALS 1
#endif
+#include "config.h"
#include "identifier.h"
#include <kxmlcore/FastMalloc.h>
@@ -287,13 +288,13 @@
_tableSize = newTableSize;
_tableSizeMask = newTableSize - 1;
- _table = (UString::Rep **)calloc(newTableSize, sizeof(UString::Rep *));
+ _table = (UString::Rep **)fastCalloc(newTableSize, sizeof(UString::Rep *));
for (int i = 0; i != oldTableSize; ++i)
if (UString::Rep *key = oldTable[i])
insert(key);
- free(oldTable);
+ fastFree(oldTable);
}
// Global constants for property name strings.
diff --git a/JavaScriptCore/kjs/internal.cpp b/JavaScriptCore/kjs/internal.cpp
index 1036c3c..9ae3d01 100644
--- a/JavaScriptCore/kjs/internal.cpp
+++ b/JavaScriptCore/kjs/internal.cpp
@@ -21,6 +21,7 @@
*
*/
+#include "config.h"
#include <stdio.h>
#include <math.h>
#include <assert.h>
@@ -367,7 +368,7 @@
{
if (numNewNodes == newNodesCapacity) {
newNodesCapacity = (newNodesCapacity == 0) ? initialCapacity : newNodesCapacity * growthFactor;
- newNodes = (Node **)realloc(newNodes, sizeof(Node *) * newNodesCapacity);
+ newNodes = (Node **)fastRealloc(newNodes, sizeof(Node *) * newNodesCapacity);
}
newNodes[numNewNodes++] = node;
@@ -379,7 +380,7 @@
if (newNodes[i]->refcount() == 0)
delete newNodes[i];
}
- delete newNodes;
+ fastFree(newNodes);
newNodes = 0;
numNewNodes = 0;
newNodesCapacity = 0;
diff --git a/JavaScriptCore/kjs/interpreter.cpp b/JavaScriptCore/kjs/interpreter.cpp
index e91dc0b..067c06d 100644
--- a/JavaScriptCore/kjs/interpreter.cpp
+++ b/JavaScriptCore/kjs/interpreter.cpp
@@ -22,6 +22,7 @@
*
*/
+#include "config.h"
#include "value.h"
#include "object.h"
#include "types.h"
diff --git a/JavaScriptCore/kjs/lexer.cpp b/JavaScriptCore/kjs/lexer.cpp
index 8e879fc..7232400 100644
--- a/JavaScriptCore/kjs/lexer.cpp
+++ b/JavaScriptCore/kjs/lexer.cpp
@@ -834,7 +834,7 @@
for (unsigned i = 0; i < numIdentifiers; i++) {
delete identifiers[i];
}
- free (identifiers);
+ fastFree(identifiers);
identifiers = 0;
numIdentifiers = 0;
identifiersCapacity = 0;
@@ -842,7 +842,7 @@
for (unsigned i = 0; i < numStrings; i++) {
delete strings[i];
}
- free (strings);
+ fastFree(strings);
strings = 0;
numStrings = 0;
stringsCapacity = 0;
@@ -855,7 +855,7 @@
{
if (numIdentifiers == identifiersCapacity) {
identifiersCapacity = (identifiersCapacity == 0) ? initialCapacity : identifiersCapacity *growthFactor;
- identifiers = (KJS::Identifier **)realloc(identifiers, sizeof(KJS::Identifier *) * identifiersCapacity);
+ identifiers = (KJS::Identifier **)fastRealloc(identifiers, sizeof(KJS::Identifier *) * identifiersCapacity);
}
KJS::Identifier *identifier = new KJS::Identifier(buffer16, pos16);
@@ -867,7 +867,7 @@
{
if (numStrings == stringsCapacity) {
stringsCapacity = (stringsCapacity == 0) ? initialCapacity : stringsCapacity *growthFactor;
- strings = (UString **)realloc(strings, sizeof(UString *) * stringsCapacity);
+ strings = (UString **)fastRealloc(strings, sizeof(UString *) * stringsCapacity);
}
UString *string = new UString(buffer16, pos16);
diff --git a/JavaScriptCore/kjs/list.cpp b/JavaScriptCore/kjs/list.cpp
index ed15ab4..2124a03 100644
--- a/JavaScriptCore/kjs/list.cpp
+++ b/JavaScriptCore/kjs/list.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "config.h"
#include "list.h"
#include "internal.h"
diff --git a/JavaScriptCore/kjs/lookup.cpp b/JavaScriptCore/kjs/lookup.cpp
index 50f5ccb..c0856a4 100644
--- a/JavaScriptCore/kjs/lookup.cpp
+++ b/JavaScriptCore/kjs/lookup.cpp
@@ -20,13 +20,13 @@
*
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include "lookup.h"
#ifdef HAVE_CONFIG_H
-#include <config.h>
#endif
using namespace KJS;
diff --git a/JavaScriptCore/kjs/math_object.cpp b/JavaScriptCore/kjs/math_object.cpp
index 71ec1c3..afc5f54 100644
--- a/JavaScriptCore/kjs/math_object.cpp
+++ b/JavaScriptCore/kjs/math_object.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "config.h"
#include <math.h>
#include <stdlib.h>
#include <assert.h>
diff --git a/JavaScriptCore/kjs/nodes.cpp b/JavaScriptCore/kjs/nodes.cpp
index 1d00bddc..e8be530 100644
--- a/JavaScriptCore/kjs/nodes.cpp
+++ b/JavaScriptCore/kjs/nodes.cpp
@@ -21,6 +21,7 @@
*
*/
+#include "config.h"
#include "nodes.h"
#include <math.h>
diff --git a/JavaScriptCore/kjs/nodes.h b/JavaScriptCore/kjs/nodes.h
index 0a928c7..fd60f8e 100644
--- a/JavaScriptCore/kjs/nodes.h
+++ b/JavaScriptCore/kjs/nodes.h
@@ -25,7 +25,6 @@
#ifndef _NODES_H_
#define _NODES_H_
-#include <kxmlcore/FastMalloc.h>
#include <kxmlcore/SharedPtr.h>
#include "internal.h"
@@ -71,7 +70,7 @@
OpInstanceOf
};
- class Node : public FastAllocated {
+ class Node {
public:
Node();
virtual ~Node();
diff --git a/JavaScriptCore/kjs/nodes2string.cpp b/JavaScriptCore/kjs/nodes2string.cpp
index d6d722e..04ab896 100644
--- a/JavaScriptCore/kjs/nodes2string.cpp
+++ b/JavaScriptCore/kjs/nodes2string.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "config.h"
#include "nodes.h"
namespace KJS {
diff --git a/JavaScriptCore/kjs/number_object.cpp b/JavaScriptCore/kjs/number_object.cpp
index 5744edd..f716412 100644
--- a/JavaScriptCore/kjs/number_object.cpp
+++ b/JavaScriptCore/kjs/number_object.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "config.h"
#include "value.h"
#include "object.h"
#include "types.h"
@@ -96,17 +97,17 @@
char *buf;
if (length <= decimalPoint) {
- buf = (char*)malloc(decimalPoint+1);
+ buf = (char*)fastMalloc(decimalPoint+1);
strcpy(buf,result);
memset(buf+length,'0',decimalPoint-length);
} else {
- buf = (char*)malloc(decimalPoint+1);
+ buf = (char*)fastMalloc(decimalPoint+1);
strncpy(buf,result,decimalPoint);
}
buf[decimalPoint] = '\0';
str += UString(buf);
- free(buf);
+ fastFree(buf);
}
kjs_freedtoa(result);
@@ -116,11 +117,11 @@
static UString char_sequence(char c, int count)
{
- char *buf = (char*)malloc(count+1);
+ char *buf = (char*)fastMalloc(count+1);
memset(buf,c,count);
buf[count] = '\0';
UString s(buf);
- free(buf);
+ fastFree(buf);
return s;
}
diff --git a/JavaScriptCore/kjs/object.cpp b/JavaScriptCore/kjs/object.cpp
index 53ba0e0..29907a2 100644
--- a/JavaScriptCore/kjs/object.cpp
+++ b/JavaScriptCore/kjs/object.cpp
@@ -22,6 +22,7 @@
*
*/
+#include "config.h"
#include "value.h"
#include "object.h"
#include "types.h"
diff --git a/JavaScriptCore/kjs/object_object.cpp b/JavaScriptCore/kjs/object_object.cpp
index ad81460..f6a63dc 100644
--- a/JavaScriptCore/kjs/object_object.cpp
+++ b/JavaScriptCore/kjs/object_object.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "config.h"
#include "value.h"
#include "object.h"
#include "types.h"
diff --git a/JavaScriptCore/kjs/operations.cpp b/JavaScriptCore/kjs/operations.cpp
index 60687d4..a34bfc7 100644
--- a/JavaScriptCore/kjs/operations.cpp
+++ b/JavaScriptCore/kjs/operations.cpp
@@ -20,9 +20,9 @@
*
*/
+#include "config.h"
#include "operations.h"
-#include "config.h"
#include <stdio.h>
#include <assert.h>
diff --git a/JavaScriptCore/kjs/property_map.cpp b/JavaScriptCore/kjs/property_map.cpp
index a4ac823..bcba967 100644
--- a/JavaScriptCore/kjs/property_map.cpp
+++ b/JavaScriptCore/kjs/property_map.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "config.h"
#include "property_map.h"
#include <kxmlcore/FastMalloc.h>
diff --git a/JavaScriptCore/kjs/property_slot.cpp b/JavaScriptCore/kjs/property_slot.cpp
index cb00478..4a7f4be 100644
--- a/JavaScriptCore/kjs/property_slot.cpp
+++ b/JavaScriptCore/kjs/property_slot.cpp
@@ -21,6 +21,7 @@
*/
+#include "config.h"
#include "property_slot.h"
namespace KJS {
diff --git a/JavaScriptCore/kjs/protected_values.cpp b/JavaScriptCore/kjs/protected_values.cpp
index bfc1d74..de1dd96 100644
--- a/JavaScriptCore/kjs/protected_values.cpp
+++ b/JavaScriptCore/kjs/protected_values.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "config.h"
#include "protected_values.h"
#include "pointer_hash.h"
@@ -184,13 +185,13 @@
_tableSize = newTableSize;
_tableSizeMask = newTableSize - 1;
- _table = (KeyValue *)calloc(newTableSize, sizeof(KeyValue));
+ _table = (KeyValue *)fastCalloc(newTableSize, sizeof(KeyValue));
for (int i = 0; i != oldTableSize; ++i)
if (oldTable[i].key)
insert(oldTable[i].key, oldTable[i].value);
- free(oldTable);
+ fastFree(oldTable);
}
} // namespace
diff --git a/JavaScriptCore/kjs/reference.cpp b/JavaScriptCore/kjs/reference.cpp
index 2c0a75d..bc750ba 100644
--- a/JavaScriptCore/kjs/reference.cpp
+++ b/JavaScriptCore/kjs/reference.cpp
@@ -20,7 +20,9 @@
*
*/
+#include "config.h"
#include "reference.h"
+
#include "internal.h"
namespace KJS {
diff --git a/JavaScriptCore/kjs/reference_list.cpp b/JavaScriptCore/kjs/reference_list.cpp
index 94ff983..5627c40 100644
--- a/JavaScriptCore/kjs/reference_list.cpp
+++ b/JavaScriptCore/kjs/reference_list.cpp
@@ -20,7 +20,9 @@
*
*/
+#include "config.h"
#include "reference_list.h"
+
#include "protected_reference.h"
namespace KJS {
diff --git a/JavaScriptCore/kjs/regexp.cpp b/JavaScriptCore/kjs/regexp.cpp
index 0277e86..d74e74a 100644
--- a/JavaScriptCore/kjs/regexp.cpp
+++ b/JavaScriptCore/kjs/regexp.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "config.h"
#include "regexp.h"
#include <assert.h>
diff --git a/JavaScriptCore/kjs/regexp_object.cpp b/JavaScriptCore/kjs/regexp_object.cpp
index dcb90bc..5b2228c 100644
--- a/JavaScriptCore/kjs/regexp_object.cpp
+++ b/JavaScriptCore/kjs/regexp_object.cpp
@@ -20,8 +20,10 @@
*
*/
-#include <stdio.h>
+#include "config.h"
+#include "regexp_object.h"
+#include <stdio.h>
#include "value.h"
#include "object.h"
#include "types.h"
@@ -29,7 +31,6 @@
#include "operations.h"
#include "internal.h"
#include "regexp.h"
-#include "regexp_object.h"
#include "error_object.h"
using namespace KJS;
diff --git a/JavaScriptCore/kjs/scope_chain.cpp b/JavaScriptCore/kjs/scope_chain.cpp
index ab1014b..5648dd1 100644
--- a/JavaScriptCore/kjs/scope_chain.cpp
+++ b/JavaScriptCore/kjs/scope_chain.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "config.h"
#include "scope_chain.h"
#include "object.h"
diff --git a/JavaScriptCore/kjs/scope_chain.h b/JavaScriptCore/kjs/scope_chain.h
index 1913d3c..57e70ea 100644
--- a/JavaScriptCore/kjs/scope_chain.h
+++ b/JavaScriptCore/kjs/scope_chain.h
@@ -22,13 +22,11 @@
#ifndef KJS_SCOPE_CHAIN_H
#define KJS_SCOPE_CHAIN_H
-#include <kxmlcore/FastMalloc.h>
-
namespace KJS {
class ObjectImp;
- class ScopeChainNode : public FastAllocated {
+ class ScopeChainNode {
public:
ScopeChainNode(ScopeChainNode *n, ObjectImp *o)
: next(n), object(o), refCount(1) { }
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index 8308160..87b3401 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "config.h"
+#include "string_object.h"
+
#include "value.h"
#include "object.h"
#include "types.h"
@@ -27,7 +30,6 @@
#include "operations.h"
#include "regexp.h"
#include "regexp_object.h"
-#include "string_object.h"
#include "error_object.h"
#include <stdio.h>
#include "string_object.lut.h"
diff --git a/JavaScriptCore/kjs/testkjs.cpp b/JavaScriptCore/kjs/testkjs.cpp
index d9bd449..d749f61 100644
--- a/JavaScriptCore/kjs/testkjs.cpp
+++ b/JavaScriptCore/kjs/testkjs.cpp
@@ -21,6 +21,7 @@
*
*/
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/JavaScriptCore/kjs/ustring.h b/JavaScriptCore/kjs/ustring.h
index 7320ee9..0ebd189 100644
--- a/JavaScriptCore/kjs/ustring.h
+++ b/JavaScriptCore/kjs/ustring.h
@@ -193,7 +193,7 @@
/**
* @short Unicode string class
*/
- class UString : public FastAllocated {
+ class UString {
friend bool operator==(const UString&, const UString&);
friend class UCharReference;
friend class Identifier;
@@ -205,8 +205,6 @@
*/
struct Rep {
- FAST_ALLOCATED_POD;
-
static Rep *create(UChar *d, int l);
static Rep *createCopying(const UChar *d, int l);
static Rep *create(Rep *base, int offset, int length);
diff --git a/JavaScriptCore/kjs/value.cpp b/JavaScriptCore/kjs/value.cpp
index bbce2b2..b4fe895 100644
--- a/JavaScriptCore/kjs/value.cpp
+++ b/JavaScriptCore/kjs/value.cpp
@@ -21,6 +21,7 @@
*
*/
+#include "config.h"
#include "value.h"
#include "object.h"