summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/wtf
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/wtf')
-rw-r--r--JavaScriptCore/wtf/Bitmap.h131
-rw-r--r--JavaScriptCore/wtf/FastMalloc.cpp4
-rw-r--r--JavaScriptCore/wtf/Forward.h12
-rw-r--r--JavaScriptCore/wtf/PageAllocation.cpp197
-rw-r--r--JavaScriptCore/wtf/PageAllocation.h298
-rw-r--r--JavaScriptCore/wtf/PageReservation.h258
-rw-r--r--JavaScriptCore/wtf/Platform.h83
-rw-r--r--JavaScriptCore/wtf/WTFThreadData.cpp2
-rw-r--r--JavaScriptCore/wtf/WTFThreadData.h19
-rw-r--r--JavaScriptCore/wtf/dtoa.cpp1
-rw-r--r--JavaScriptCore/wtf/gobject/GOwnPtr.h2
-rw-r--r--JavaScriptCore/wtf/qt/StringQt.cpp2
-rw-r--r--JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp132
-rw-r--r--JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h120
-rw-r--r--JavaScriptCore/wtf/text/AtomicString.cpp6
-rw-r--r--JavaScriptCore/wtf/text/AtomicString.h28
-rw-r--r--JavaScriptCore/wtf/text/AtomicStringImpl.h6
-rw-r--r--JavaScriptCore/wtf/text/StringBuffer.h4
-rw-r--r--JavaScriptCore/wtf/text/StringHash.h19
-rw-r--r--JavaScriptCore/wtf/text/StringImpl.cpp13
-rw-r--r--JavaScriptCore/wtf/text/StringImpl.h44
-rw-r--r--JavaScriptCore/wtf/text/StringStatics.cpp2
-rw-r--r--JavaScriptCore/wtf/text/WTFString.cpp13
-rw-r--r--JavaScriptCore/wtf/text/WTFString.h40
-rw-r--r--JavaScriptCore/wtf/unicode/icu/CollatorICU.cpp2
25 files changed, 834 insertions, 604 deletions
diff --git a/JavaScriptCore/wtf/Bitmap.h b/JavaScriptCore/wtf/Bitmap.h
new file mode 100644
index 0000000..4dd88f6
--- /dev/null
+++ b/JavaScriptCore/wtf/Bitmap.h
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#ifndef Bitmap_h
+#define Bitmap_h
+
+#include "FixedArray.h"
+#include "StdLibExtras.h"
+
+#include <stdint.h>
+
+namespace WTF {
+
+template<size_t size>
+class Bitmap {
+private:
+ typedef uint32_t WordType;
+
+public:
+ Bitmap();
+
+ bool get(size_t) const;
+ void set(size_t);
+ void clear(size_t);
+ void clearAll();
+ void advanceToNextFreeBit(size_t&) const;
+ size_t count(size_t = 0) const;
+ size_t isEmpty() const;
+ size_t isFull() const;
+
+private:
+ static const WordType wordSize = sizeof(WordType) * 8;
+ static const WordType words = (size + wordSize - 1) / wordSize;
+
+ // the literal '1' is of type signed int. We want to use an unsigned
+ // version of the correct size when doing the calculations because if
+ // WordType is larger than int, '1 << 31' will first be sign extended
+ // and then casted to unsigned, meaning that set(31) when WordType is
+ // a 64 bit unsigned int would give 0xffff8000
+ static const WordType one = 1;
+
+ FixedArray<WordType, words> bits;
+};
+
+template<size_t size>
+inline Bitmap<size>::Bitmap()
+{
+ clearAll();
+}
+
+template<size_t size>
+inline bool Bitmap<size>::get(size_t n) const
+{
+ return !!(bits[n / wordSize] & (one << (n % wordSize)));
+}
+
+template<size_t size>
+inline void Bitmap<size>::set(size_t n)
+{
+ bits[n / wordSize] |= (one << (n % wordSize));
+}
+
+template<size_t size>
+inline void Bitmap<size>::clear(size_t n)
+{
+ bits[n / wordSize] &= ~(one << (n % wordSize));
+}
+
+template<size_t size>
+inline void Bitmap<size>::clearAll()
+{
+ memset(bits.data(), 0, sizeof(bits));
+}
+
+template<size_t size>
+inline void Bitmap<size>::advanceToNextFreeBit(size_t& start) const
+{
+ if (!~bits[start / wordSize])
+ start = ((start / wordSize) + 1) * wordSize;
+ else
+ ++start;
+}
+
+template<size_t size>
+inline size_t Bitmap<size>::count(size_t start) const
+{
+ size_t result = 0;
+ for ( ; (start % wordSize); ++start) {
+ if (get(start))
+ ++result;
+ }
+ for (size_t i = start / wordSize; i < words; ++i)
+ result += WTF::bitCount(bits[i]);
+ return result;
+}
+
+template<size_t size>
+inline size_t Bitmap<size>::isEmpty() const
+{
+ for (size_t i = 0; i < words; ++i)
+ if (bits[i])
+ return false;
+ return true;
+}
+
+template<size_t size>
+inline size_t Bitmap<size>::isFull() const
+{
+ for (size_t i = 0; i < words; ++i)
+ if (~bits[i])
+ return false;
+ return true;
+}
+
+}
+#endif
diff --git a/JavaScriptCore/wtf/FastMalloc.cpp b/JavaScriptCore/wtf/FastMalloc.cpp
index 9dfbc6b..c440417 100644
--- a/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/JavaScriptCore/wtf/FastMalloc.cpp
@@ -4454,10 +4454,10 @@ extern "C" {
malloc_introspection_t jscore_fastmalloc_introspection = { &FastMallocZone::enumerate, &FastMallocZone::goodSize, &FastMallocZone::check, &FastMallocZone::print,
&FastMallocZone::log, &FastMallocZone::forceLock, &FastMallocZone::forceUnlock, &FastMallocZone::statistics
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !OS(IPHONE_OS)
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
, 0 // zone_locked will not be called on the zone unless it advertises itself as version five or higher.
#endif
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) && !OS(IPHONE_OS)
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
, 0, 0, 0, 0 // These members will not be used unless the zone advertises itself as version seven or higher.
#endif
diff --git a/JavaScriptCore/wtf/Forward.h b/JavaScriptCore/wtf/Forward.h
index 448de7d..a2cc75b 100644
--- a/JavaScriptCore/wtf/Forward.h
+++ b/JavaScriptCore/wtf/Forward.h
@@ -31,6 +31,12 @@ namespace WTF {
template<typename T> class PassRefPtr;
template<typename T> class RefPtr;
template<typename T, size_t inlineCapacity> class Vector;
+
+ class AtomicString;
+ class AtomicStringImpl;
+ class String;
+ class StringBuffer;
+ class StringImpl;
}
using WTF::ListRefPtr;
@@ -41,4 +47,10 @@ using WTF::PassRefPtr;
using WTF::RefPtr;
using WTF::Vector;
+using WTF::AtomicString;
+using WTF::AtomicStringImpl;
+using WTF::String;
+using WTF::StringBuffer;
+using WTF::StringImpl;
+
#endif // WTF_Forward_h
diff --git a/JavaScriptCore/wtf/PageAllocation.cpp b/JavaScriptCore/wtf/PageAllocation.cpp
index 4cf2ea9..f3fe997 100644
--- a/JavaScriptCore/wtf/PageAllocation.cpp
+++ b/JavaScriptCore/wtf/PageAllocation.cpp
@@ -26,206 +26,23 @@
#include "config.h"
#include "PageAllocation.h"
-
-#if HAVE(ERRNO_H)
-#include <errno.h>
-#endif
-
-#if HAVE(MMAP)
-#include <sys/mman.h>
-#include <unistd.h>
-#endif
-
-#if OS(WINDOWS)
-#include "windows.h"
-#endif
-
-#if OS(SYMBIAN)
-#include <e32hal.h>
-#endif
+#include "PageReservation.h"
namespace WTF {
-#if HAVE(MMAP)
+size_t PageAllocation::s_pageSize = 0;
-bool PageAllocation::commit(void* start, size_t size, bool, bool) const
-{
-#if HAVE(MADV_FREE_REUSE)
- while (madvise(start, size, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { }
-#else
- UNUSED_PARAM(start);
- UNUSED_PARAM(size);
-#endif
- return true;
-}
+#ifndef NDEBUG
-void PageAllocation::decommit(void* start, size_t size) const
+int PageAllocation::lastError()
{
-#if HAVE(MADV_FREE_REUSE)
- while (madvise(start, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
-#elif HAVE(MADV_FREE)
- while (madvise(start, size, MADV_FREE) == -1 && errno == EAGAIN) { }
-#elif HAVE(MADV_DONTNEED)
- while (madvise(start, size, MADV_DONTNEED) == -1 && errno == EAGAIN) { }
+#if OS(WINCE)
+ return GetLastError();
#else
- UNUSED_PARAM(start);
- UNUSED_PARAM(size);
+ return errno;
#endif
}
-PageAllocation PageAllocation::allocate(size_t size, Usage usage, bool writable, bool executable)
-{
- return allocateAt(0, false, size, usage, writable, executable);
-}
-
-PageAllocation PageAllocation::reserve(size_t size, Usage usage, bool writable, bool executable)
-{
- return reserveAt(0, false, size, usage, writable, executable);
-}
-
-PageAllocation PageAllocation::allocateAt(void* address, bool fixed, size_t size, Usage usage, bool writable, bool executable)
-{
- int flags = MAP_PRIVATE | MAP_ANON;
- if (fixed)
- flags |= MAP_FIXED;
-
- int protection = PROT_READ;
- if (writable)
- protection |= PROT_WRITE;
- if (executable)
- protection |= PROT_EXEC;
-
- void* base = mmap(address, size, protection, flags, usage, 0);
- if (base == MAP_FAILED)
- base = 0;
-
- return PageAllocation(base, size);
-}
-
-PageAllocation PageAllocation::reserveAt(void* address, bool fixed, size_t size, Usage usage, bool writable, bool executable)
-{
- PageAllocation result = allocateAt(address, fixed, size, usage, writable, executable);
- if (!!result)
- result.decommit(result.base(), size);
- return result;
-}
-
-void PageAllocation::deallocate()
-{
- int result = munmap(m_base, m_size);
- ASSERT_UNUSED(result, !result);
- m_base = 0;
-}
-
-size_t PageAllocation::pagesize()
-{
- static size_t size = 0;
- if (!size)
- size = getpagesize();
- return size;
-}
-
-#elif HAVE(VIRTUALALLOC)
-
-static DWORD protection(bool writable, bool executable)
-{
- if (executable)
- return writable ?PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
- return writable ?PAGE_READWRITE : PAGE_READONLY;
-}
-
-bool PageAllocation::commit(void* start, size_t size, bool writable, bool executable) const
-{
- return VirtualAlloc(start, size, MEM_COMMIT, protection(writable, executable)) == start;
-}
-
-void PageAllocation::decommit(void* start, size_t size) const
-{
- VirtualFree(start, size, MEM_DECOMMIT);
-}
-
-PageAllocation PageAllocation::allocate(size_t size, Usage, bool writable, bool executable)
-{
- return PageAllocation(VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, protection(writable, executable)), size);
-}
-
-PageAllocation PageAllocation::reserve(size_t size, Usage usage, bool writable, bool executable)
-{
- return PageAllocation(VirtualAlloc(0, size, MEM_RESERVE, protection(writable, executable)), size);
-}
-
-void PageAllocation::deallocate()
-{
- VirtualFree(m_base, 0, MEM_RELEASE);
- m_base = 0;
-}
-
-size_t PageAllocation::pagesize()
-{
- static size_t size = 0;
- if (!size) {
- SYSTEM_INFO system_info;
- GetSystemInfo(&system_info);
- size = system_info.dwPageSize;
- }
- return size;
-}
-
-#elif OS(SYMBIAN)
-
-bool PageAllocation::commit(void* start, size_t size, bool writable, bool executable) const
-{
- if (m_chunk) {
- intptr_t offset = reinterpret_cast<intptr_t>(base()) - reinterpret_cast<intptr_t>(start);
- m_chunk->Commit(offset, size);
- }
- return true;
-}
-
-void PageAllocation::decommit(void* start, size_t size) const
-{
- if (m_chunk) {
- intptr_t offset = reinterpret_cast<intptr_t>(base()) - reinterpret_cast<intptr_t>(start);
- m_chunk->Decommit(offset, size);
- }
-}
-
-PageAllocation PageAllocation::allocate(size_t size, Usage usage, bool writable, bool executable)
-{
- if (!executable)
- return PageAllocation(fastMalloc(size), size, 0);
- RChunk* rchunk = new RChunk();
- TInt errorCode = rchunk->CreateLocalCode(size, size);
- return PageAllocation(rchunk->Base(), size, rchunk);
-}
-
-PageAllocation PageAllocation::reserve(size_t size, Usage usage, bool writable, bool executable)
-{
- if (!executable)
- return PageAllocation(fastMalloc(size), size, 0);
- RChunk* rchunk = new RChunk();
- TInt errorCode = rchunk->CreateLocalCode(0, size);
- return PageAllocation(rchunk->Base(), size, rchunk);
-}
-
-void PageAllocation::deallocate()
-{
- if (m_chunk) {
- m_chunk->Close();
- delete m_chunk;
- } else
- fastFree(m_base);
- m_base = 0;
-}
-
-size_t PageAllocation::pagesize()
-{
- static TInt page_size = 0;
- if (!page_size)
- UserHal::PageSizeInBytes(page_size);
- return page_size;
-}
-
#endif
}
diff --git a/JavaScriptCore/wtf/PageAllocation.h b/JavaScriptCore/wtf/PageAllocation.h
index b846482..26d53a5 100644
--- a/JavaScriptCore/wtf/PageAllocation.h
+++ b/JavaScriptCore/wtf/PageAllocation.h
@@ -26,21 +26,63 @@
#ifndef PageAllocation_h
#define PageAllocation_h
+#include <wtf/Assertions.h>
#include <wtf/UnusedParam.h>
#include <wtf/VMTags.h>
+#if OS(DARWIN)
+#include <mach/mach_init.h>
+#include <mach/vm_map.h>
+#endif
+
+#if OS(HAIKU)
+#include <OS.h>
+#endif
+
+#if OS(WINDOWS)
+#include <malloc.h>
+#include <windows.h>
+#endif
+
#if OS(SYMBIAN)
+#include <e32hal.h>
#include <e32std.h>
#endif
+#if HAVE(ERRNO_H)
+#include <errno.h>
+#endif
+
#if HAVE(MMAP)
-#define PAGE_ALLOCATION_ALLOCATE_AT 1
-#else
-#define PAGE_ALLOCATION_ALLOCATE_AT 0
+#include <sys/mman.h>
+#include <unistd.h>
#endif
namespace WTF {
+/*
+ PageAllocation
+
+ The PageAllocation class provides a cross-platform memory allocation interface
+ with similar capabilities to posix mmap/munmap. Memory is allocated by calling
+ PageAllocation::allocate, and deallocated by calling deallocate on the
+ PageAllocation object. The PageAllocation holds the allocation's base pointer
+ and size.
+
+ The allocate method is passed the size required (which must be a multiple of
+ the system page size, which can be accessed using PageAllocation::pageSize).
+ Callers may also optinally provide a flag indicating the usage (for use by
+ system memory usage tracking tools, where implemented), and boolean values
+ specifying the required protection (defaulting to writable, non-executable).
+
+ Where HAVE(PAGE_ALLOCATE_AT) and HAVE(PAGE_ALLOCATE_ALIGNED) are available
+ memory may also be allocated at a specified address, or with a specified
+ alignment respectively. PageAllocation::allocateAt take an address to try
+ to allocate at, and a boolean indicating whether this behaviour is strictly
+ required (if this address is unavailable, should memory at another address
+ be allocated instead). PageAllocation::allocateAligned requires that the
+ size is a power of two that is >= system page size.
+*/
class PageAllocation {
public:
enum Usage {
@@ -60,42 +102,56 @@ public:
{
}
- // Create a PageAllocation object representing a sub-region of an existing allocation;
- // deallocate should never be called on an object represnting a subregion, only on the
- // initial allocation.
- PageAllocation(void* base, size_t size, const PageAllocation& parent)
- : m_base(base)
- , m_size(size)
-#if OS(SYMBIAN)
- , m_chunk(parent.m_chunk)
-#endif
+ bool operator!() const { return !m_base; }
+ void* base() const { return m_base; }
+ size_t size() const { return m_size; }
+
+ static PageAllocation allocate(size_t size, Usage usage = UnknownUsage, bool writable = true, bool executable = false)
{
-#if defined(NDEBUG) && !OS(SYMBIAN)
- UNUSED_PARAM(parent);
-#endif
- ASSERT(base >= parent.m_base);
- ASSERT(size <= parent.m_size);
- ASSERT(static_cast<char*>(base) + size <= static_cast<char*>(parent.m_base) + parent.m_size);
+ ASSERT(isPageAligned(size));
+ return systemAllocate(size, usage, writable, executable);
}
- void* base() const { return m_base; }
- size_t size() const { return m_size; }
+#if HAVE(PAGE_ALLOCATE_AT)
+ static PageAllocation allocateAt(void* address, bool fixed, size_t size, Usage usage = UnknownUsage, bool writable = true, bool executable = false)
+ {
+ ASSERT(isPageAligned(address));
+ ASSERT(isPageAligned(size));
+ return systemAllocateAt(address, fixed, size, usage, writable, executable);
+ }
+#endif
- bool operator!() const { return !m_base; }
+#if HAVE(PAGE_ALLOCATE_ALIGNED)
+ static PageAllocation allocateAligned(size_t size, Usage usage = UnknownUsage)
+ {
+ ASSERT(isPageAligned(size));
+ ASSERT(isPowerOfTwo(size));
+ return systemAllocateAligned(size, usage);
+ }
+#endif
+
+ void deallocate()
+ {
+ ASSERT(m_base);
+ systemDeallocate(true);
+ }
- bool commit(void*, size_t, bool writable = true, bool executable = false) const;
- void decommit(void*, size_t) const;
- void deallocate();
+ static size_t pageSize()
+ {
+ if (!s_pageSize)
+ s_pageSize = systemPageSize();
+ ASSERT(isPowerOfTwo(s_pageSize));
+ return s_pageSize;
+ }
- static PageAllocation allocate(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false);
- static PageAllocation reserve(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false);
-#if PAGE_ALLOCATION_ALLOCATE_AT
- static PageAllocation allocateAt(void* address, bool fixed, size_t, Usage = UnknownUsage, bool writable = true, bool executable = false);
- static PageAllocation reserveAt(void* address, bool fixed, size_t, Usage = UnknownUsage, bool writable = true, bool executable = false);
+#ifndef NDEBUG
+ static bool isPageAligned(void* address) { return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); }
+ static bool isPageAligned(size_t size) { return !(size & (pageSize() - 1)); }
+ static bool isPowerOfTwo(size_t size) { return !(size & (size - 1)); }
+ static int lastError();
#endif
- static size_t pagesize();
-private:
+protected:
#if OS(SYMBIAN)
PageAllocation(void* base, size_t size, RChunk* chunk)
: m_base(base)
@@ -111,13 +167,193 @@ private:
}
#endif
+ static PageAllocation systemAllocate(size_t, Usage, bool, bool);
+#if HAVE(PAGE_ALLOCATE_AT)
+ static PageAllocation systemAllocateAt(void*, bool, size_t, Usage, bool, bool);
+#endif
+#if HAVE(PAGE_ALLOCATE_ALIGNED)
+ static PageAllocation systemAllocateAligned(size_t, Usage);
+#endif
+ // systemDeallocate takes a parameter indicating whether memory is currently committed
+ // (this should always be true for PageAllocation, false for PageReservation).
+ void systemDeallocate(bool committed);
+ static size_t systemPageSize();
+
void* m_base;
size_t m_size;
#if OS(SYMBIAN)
RChunk* m_chunk;
#endif
+
+ static JS_EXPORTDATA size_t s_pageSize;
};
+
+#if HAVE(MMAP)
+
+
+inline PageAllocation PageAllocation::systemAllocate(size_t size, Usage usage, bool writable, bool executable)
+{
+ return systemAllocateAt(0, false, size, usage, writable, executable);
+}
+
+inline PageAllocation PageAllocation::systemAllocateAt(void* address, bool fixed, size_t size, Usage usage, bool writable, bool executable)
+{
+ int protection = PROT_READ;
+ if (writable)
+ protection |= PROT_WRITE;
+ if (executable)
+ protection |= PROT_EXEC;
+
+ int flags = MAP_PRIVATE | MAP_ANON;
+ if (fixed)
+ flags |= MAP_FIXED;
+
+#if OS(DARWIN) && !defined(BUILDING_ON_TIGER)
+ int fd = usage;
+#else
+ int fd = -1;
+#endif
+
+ void* base = mmap(address, size, protection, flags, fd, 0);
+ if (base == MAP_FAILED)
+ base = 0;
+ return PageAllocation(base, size);
+}
+
+inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, Usage usage)
+{
+#if OS(DARWIN)
+ vm_address_t address = 0;
+ int flags = VM_FLAGS_ANYWHERE;
+ if (usage != -1)
+ flags |= usage;
+ vm_map(current_task(), &address, size, (size - 1), flags, MEMORY_OBJECT_NULL, 0, FALSE, PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE | PROT_EXEC, VM_INHERIT_DEFAULT);
+ return PageAllocation(reinterpret_cast<void*>(address), size);
+#elif HAVE(POSIX_MEMALIGN)
+ void* address;
+ posix_memalign(&address, size, size);
+ return PageAllocation(address, size);
+#else
+ size_t extra = size - pageSize();
+
+ // Check for overflow.
+ if ((size + extra) < size)
+ return PageAllocation(0, size);
+
+#if OS(DARWIN) && !defined(BUILDING_ON_TIGER)
+ int fd = usage;
+#else
+ int fd = -1;
+#endif
+ void* mmapResult = mmap(0, size + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, fd, 0);
+ if (mmapResult == MAP_FAILED)
+ return PageAllocation(0, size);
+ uintptr_t address = reinterpret_cast<uintptr_t>(mmapResult);
+
+ size_t adjust = 0;
+ if ((address & (size - 1)))
+ adjust = size - (address & (size - 1));
+ if (adjust > 0)
+ munmap(reinterpret_cast<char*>(address), adjust);
+ if (adjust < extra)
+ munmap(reinterpret_cast<char*>(address + adjust + size), extra - adjust);
+ address += adjust;
+
+ return PageAllocation(reinterpret_cast<void*>(address), size);
+#endif
+}
+
+inline void PageAllocation::systemDeallocate(bool)
+{
+ int result = munmap(m_base, m_size);
+ ASSERT_UNUSED(result, !result);
+ m_base = 0;
+}
+
+inline size_t PageAllocation::systemPageSize()
+{
+ return getpagesize();
+}
+
+
+#elif HAVE(VIRTUALALLOC)
+
+
+inline PageAllocation PageAllocation::systemAllocate(size_t size, Usage, bool writable, bool executable)
+{
+ DWORD protection = executable ?
+ (writable ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ) :
+ (writable ? PAGE_READWRITE : PAGE_READONLY);
+ return PageAllocation(VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, protection), size);
+}
+
+#if HAVE(ALIGNED_MALLOC)
+inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, Usage usage)
+{
+#if COMPILER(MINGW) && !COMPILER(MINGW64)
+ void* address = __mingw_aligned_malloc(size, size);
+#else
+ void* address = _aligned_malloc(size, size);
+#endif
+ memset(address, 0, size);
+ return PageAllocation(address, size);
+}
+#endif
+
+inline void PageAllocation::systemDeallocate(bool committed)
+{
+#if OS(WINCE)
+ if (committed)
+ VirtualFree(m_base, m_size, MEM_DECOMMIT);
+#else
+ UNUSED_PARAM(committed);
+#endif
+ VirtualFree(m_base, 0, MEM_RELEASE);
+ m_base = 0;
+}
+
+inline size_t PageAllocation::systemPageSize()
+{
+ static size_t size = 0;
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+ size = system_info.dwPageSize;
+ return size;
+}
+
+
+#elif OS(SYMBIAN)
+
+
+inline PageAllocation PageAllocation::systemAllocate(size_t size, Usage usage, bool writable, bool executable)
+{
+ RChunk* rchunk = new RChunk();
+ if (executable)
+ rchunk->CreateLocalCode(size, size);
+ else
+ rchunk->CreateLocal(size, size);
+ return PageAllocation(rchunk->Base(), size, rchunk);
+}
+
+inline void PageAllocation::systemDeallocate(bool)
+{
+ m_chunk->Close();
+ delete m_chunk;
+ m_base = 0;
+}
+
+inline size_t PageAllocation::systemPageSize()
+{
+ static TInt page_size = 0;
+ UserHal::PageSizeInBytes(page_size);
+ return page_size;
+}
+
+
+#endif
+
+
}
using WTF::PageAllocation;
diff --git a/JavaScriptCore/wtf/PageReservation.h b/JavaScriptCore/wtf/PageReservation.h
new file mode 100644
index 0000000..906b5a4
--- /dev/null
+++ b/JavaScriptCore/wtf/PageReservation.h
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PageReservation_h
+#define PageReservation_h
+
+#include <wtf/PageAllocation.h>
+
+namespace WTF {
+
+/*
+ PageReservation
+
+ Like PageAllocation, the PageReservation class provides a cross-platform memory
+ allocation interface, but with a set of capabilities more similar to that of
+ VirtualAlloc than posix mmap. PageReservation can be used to allocate virtual
+ memory without committing physical memory pages using PageReservation::reserve.
+ Following a call to reserve all memory in the region is in a decommited state,
+ in which the memory should not be used (accessing the memory may cause a fault).
+
+ Before using memory it must be committed by calling commit, which is passed start
+ and size values (both of which require system page size granularity). One the
+ committed memory is no longer needed 'decommit' may be called to return the
+ memory to its devommitted state. Commit should only be called on memory that is
+ currently decommitted, and decommit should only be called on memory regions that
+ are currently committed. All memory should be decommited before the reservation
+ is deallocated. Values in memory may not be retained accross a pair of calls if
+ the region of memory is decommitted and then committed again.
+
+ Where HAVE(PAGE_ALLOCATE_AT) is available a PageReservation::reserveAt method
+ also exists, with behaviour mirroring PageAllocation::allocateAt.
+
+ Memory protection should not be changed on decommitted memory, and if protection
+ is changed on memory while it is committed it should be returned to the orignal
+ protection before decommit is called.
+
+ Note: Inherits from PageAllocation privately to prevent clients accidentally
+ calling PageAllocation::deallocate on a PageReservation.
+*/
+class PageReservation : private PageAllocation {
+public:
+ PageReservation()
+ {
+ }
+
+ using PageAllocation::operator!;
+ using PageAllocation::base;
+ using PageAllocation::size;
+
+ bool commit(void* start, size_t size)
+ {
+ ASSERT(m_base);
+ ASSERT(isPageAligned(start));
+ ASSERT(isPageAligned(size));
+
+ bool commited = systemCommit(start, size);
+#ifndef NDEBUG
+ if (commited)
+ m_committed += size;
+#endif
+ return commited;
+ }
+ void decommit(void* start, size_t size)
+ {
+ ASSERT(m_base);
+ ASSERT(isPageAligned(start));
+ ASSERT(isPageAligned(size));
+
+#ifndef NDEBUG
+ m_committed -= size;
+#endif
+ systemDecommit(start, size);
+ }
+
+ static PageReservation reserve(size_t size, Usage usage = UnknownUsage, bool writable = true, bool executable = false)
+ {
+ ASSERT(isPageAligned(size));
+ return systemReserve(size, usage, writable, executable);
+ }
+
+#if HAVE(PAGE_ALLOCATE_AT)
+ static PageReservation reserveAt(void* address, bool fixed, size_t size, Usage usage = UnknownUsage, bool writable = true, bool executable = false)
+ {
+ ASSERT(isPageAligned(address));
+ ASSERT(isPageAligned(size));
+ return systemReserveAt(address, fixed, size, usage, writable, executable);
+ }
+#endif
+
+ void deallocate()
+ {
+ ASSERT(m_base);
+ ASSERT(!m_committed);
+ systemDeallocate(false);
+ }
+
+#ifndef NDEBUG
+ using PageAllocation::lastError;
+#endif
+
+private:
+#if OS(SYMBIAN)
+ PageReservation(void* base, size_t size, RChunk* chunk)
+ : PageAllocation(base, size, chunk)
+#else
+ PageReservation(void* base, size_t size)
+ : PageAllocation(base, size)
+#endif
+#ifndef NDEBUG
+ , m_committed(0)
+#endif
+ {
+ }
+
+ bool systemCommit(void*, size_t);
+ void systemDecommit(void*, size_t);
+ static PageReservation systemReserve(size_t, Usage, bool, bool);
+#if HAVE(PAGE_ALLOCATE_AT)
+ static PageReservation systemReserveAt(void*, bool, size_t, Usage, bool, bool);
+#endif
+
+#if HAVE(VIRTUALALLOC)
+ DWORD m_protection;
+#endif
+#ifndef NDEBUG
+ size_t m_committed;
+#endif
+};
+
+
+#if HAVE(MMAP)
+
+
+inline bool PageReservation::systemCommit(void* start, size_t size)
+{
+#if HAVE(MADV_FREE_REUSE)
+ while (madvise(start, size, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { }
+#else
+ UNUSED_PARAM(start);
+ UNUSED_PARAM(size);
+#endif
+ return true;
+}
+
+inline void PageReservation::systemDecommit(void* start, size_t size)
+{
+#if HAVE(MADV_FREE_REUSE)
+ while (madvise(start, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
+#elif HAVE(MADV_FREE)
+ while (madvise(start, size, MADV_FREE) == -1 && errno == EAGAIN) { }
+#elif HAVE(MADV_DONTNEED)
+ while (madvise(start, size, MADV_DONTNEED) == -1 && errno == EAGAIN) { }
+#else
+ UNUSED_PARAM(start);
+ UNUSED_PARAM(size);
+#endif
+}
+
+inline PageReservation PageReservation::systemReserve(size_t size, Usage usage, bool writable, bool executable)
+{
+ return systemReserveAt(0, false, size, usage, writable, executable);
+}
+
+inline PageReservation PageReservation::systemReserveAt(void* address, bool fixed, size_t size, Usage usage, bool writable, bool executable)
+{
+ void* base = systemAllocateAt(address, fixed, size, usage, writable, executable).base();
+#if HAVE(MADV_FREE_REUSE)
+ // When using MADV_FREE_REUSE we keep all decommitted memory marked as REUSABLE.
+ // We call REUSE on commit, and REUSABLE on decommit.
+ if (base)
+ while (madvise(base, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
+#endif
+ return PageReservation(base, size);
+}
+
+
+#elif HAVE(VIRTUALALLOC)
+
+
+inline bool PageReservation::systemCommit(void* start, size_t size)
+{
+ return VirtualAlloc(start, size, MEM_COMMIT, m_protection) == start;
+}
+
+inline void PageReservation::systemDecommit(void* start, size_t size)
+{
+ VirtualFree(start, size, MEM_DECOMMIT);
+}
+
+inline PageReservation PageReservation::systemReserve(size_t size, Usage usage, bool writable, bool executable)
+{
+ // Record the protection for use during commit.
+ DWORD protection = executable ?
+ (writable ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ) :
+ (writable ? PAGE_READWRITE : PAGE_READONLY);
+ PageReservation reservation(VirtualAlloc(0, size, MEM_RESERVE, protection), size);
+ reservation.m_protection = protection;
+ return reservation;
+}
+
+
+#elif OS(SYMBIAN)
+
+
+inline bool PageReservation::systemCommit(void* start, size_t size)
+{
+ intptr_t offset = reinterpret_cast<intptr_t>(m_base) - reinterpret_cast<intptr_t>(start);
+ m_chunk->Commit(offset, size);
+ return true;
+}
+
+inline void PageReservation::systemDecommit(void* start, size_t size)
+{
+ intptr_t offset = reinterpret_cast<intptr_t>(m_base) - reinterpret_cast<intptr_t>(start);
+ m_chunk->Decommit(offset, size);
+}
+
+inline PageReservation PageReservation::systemReserve(size_t size, Usage usage, bool writable, bool executable)
+{
+ RChunk* rchunk = new RChunk();
+ if (executable)
+ rchunk->CreateLocalCode(0, size);
+ else
+ rchunk->CreateDisconnectedLocal(0, 0, size);
+ return PageReservation(rchunk->Base(), size, rchunk);
+}
+
+
+#endif
+
+
+}
+
+using WTF::PageReservation;
+
+#endif // PageReservation_h
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h
index eca4248..95eb67f 100644
--- a/JavaScriptCore/wtf/Platform.h
+++ b/JavaScriptCore/wtf/Platform.h
@@ -142,6 +142,8 @@
#define WTF_MIPS_ARCH_REV __mips_isa_rev
#define WTF_MIPS_ISA_REV(v) (defined WTF_MIPS_ARCH_REV && WTF_MIPS_ARCH_REV == v)
#define WTF_MIPS_DOUBLE_FLOAT (defined __mips_hard_float && !defined __mips_single_float)
+/* MIPS requires allocators to use aligned memory */
+#define WTF_USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
#endif /* MIPS */
/* CPU(PPC) - PowerPC 32-bit */
@@ -368,12 +370,12 @@
#endif
-/* OS(IPHONE_OS) - iPhone OS */
-/* OS(MAC_OS_X) - Mac OS X (not including iPhone OS) */
+/* OS(IOS) - iOS */
+/* OS(MAC_OS_X) - Mac OS X (not including iOS) */
#if OS(DARWIN) && ((defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) \
|| (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) \
|| (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR))
-#define WTF_OS_IPHONE_OS 1
+#define WTF_OS_IOS 1
#elif OS(DARWIN) && defined(TARGET_OS_MAC) && TARGET_OS_MAC
#define WTF_OS_MAC_OS_X 1
#endif
@@ -481,22 +483,22 @@
#define WTF_PLATFORM_WIN 1
#endif
-/* PLATFORM(IPHONE) */
+/* PLATFORM(IOS) */
/* FIXME: this is sometimes used as an OS switch and sometimes for higher-level things */
#if (defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
-#define WTF_PLATFORM_IPHONE 1
+#define WTF_PLATFORM_IOS 1
#endif
-/* PLATFORM(IPHONE_SIMULATOR) */
+/* PLATFORM(IOS_SIMULATOR) */
#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
-#define WTF_PLATFORM_IPHONE 1
-#define WTF_PLATFORM_IPHONE_SIMULATOR 1
+#define WTF_PLATFORM_IOS 1
+#define WTF_PLATFORM_IOS_SIMULATOR 1
#else
-#define WTF_PLATFORM_IPHONE_SIMULATOR 0
+#define WTF_PLATFORM_IOS_SIMULATOR 0
#endif
-#if !defined(WTF_PLATFORM_IPHONE)
-#define WTF_PLATFORM_IPHONE 0
+#if !defined(WTF_PLATFORM_IOS)
+#define WTF_PLATFORM_IOS 0
#endif
/* PLATFORM(ANDROID) */
@@ -509,10 +511,10 @@
/* Graphics engines */
/* PLATFORM(CG) and PLATFORM(CI) */
-#if PLATFORM(MAC) || PLATFORM(IPHONE)
+#if PLATFORM(MAC) || PLATFORM(IOS)
#define WTF_PLATFORM_CG 1
#endif
-#if PLATFORM(MAC) && !PLATFORM(IPHONE)
+#if PLATFORM(MAC) && !PLATFORM(IOS)
#define WTF_PLATFORM_CI 1
#endif
@@ -543,7 +545,7 @@
#include <ce_time.h>
#endif
-#if (PLATFORM(IPHONE) || PLATFORM(MAC) || PLATFORM(WIN) || (PLATFORM(QT) && OS(DARWIN) && !ENABLE(SINGLE_THREADED))) && !defined(ENABLE_JSC_MULTIPLE_THREADS)
+#if (PLATFORM(IOS) || PLATFORM(MAC) || PLATFORM(WIN) || (PLATFORM(QT) && OS(DARWIN) && !ENABLE(SINGLE_THREADED))) && !defined(ENABLE_JSC_MULTIPLE_THREADS)
#define ENABLE_JSC_MULTIPLE_THREADS 1
#endif
@@ -579,7 +581,7 @@
#define WTF_USE_ICU_UNICODE 1
#endif
-#if PLATFORM(MAC) && !PLATFORM(IPHONE)
+#if PLATFORM(MAC) && !PLATFORM(IOS)
#define WTF_PLATFORM_CF 1
#define WTF_USE_PTHREADS 1
#define HAVE_PTHREAD_RWLOCK 1
@@ -594,7 +596,7 @@
#endif
#define HAVE_READLINE 1
#define HAVE_RUNLOOP_TIMER 1
-#endif /* PLATFORM(MAC) && !PLATFORM(IPHONE) */
+#endif /* PLATFORM(MAC) && !PLATFORM(IOS) */
#if PLATFORM(MAC)
#define WTF_USE_CARBON_SECURE_INPUT_MODE 1
@@ -615,7 +617,7 @@
#define WTF_PLATFORM_CF 1
#endif
-#if PLATFORM(IPHONE)
+#if PLATFORM(IOS)
#define ENABLE_CONTEXT_MENUS 0
#define ENABLE_DRAG_SUPPORT 0
#define ENABLE_FTPDIR 1
@@ -649,7 +651,8 @@
#endif
#if PLATFORM(WIN)
-#define WTF_USE_WININET 1
+#define WTF_PLATFORM_CF 1
+#define WTF_USE_PTHREADS 0
#endif
#if PLATFORM(WX)
@@ -686,7 +689,7 @@
#endif
#if !defined(HAVE_ACCESSIBILITY)
-#if PLATFORM(IPHONE) || PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(CHROMIUM)
+#if PLATFORM(IOS) || PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(CHROMIUM)
#define HAVE_ACCESSIBILITY 1
#endif
#endif /* !defined(HAVE_ACCESSIBILITY) */
@@ -720,7 +723,7 @@
#define HAVE_DISPATCH_H 1
#define HAVE_HOSTED_CORE_ANIMATION 1
-#if !PLATFORM(IPHONE)
+#if !PLATFORM(IOS)
#define HAVE_MADV_FREE_REUSE 1
#define HAVE_MADV_FREE 1
#define HAVE_PTHREAD_SETNAME_NP 1
@@ -728,7 +731,7 @@
#endif
-#if PLATFORM(IPHONE)
+#if PLATFORM(IOS)
#define HAVE_MADV_FREE 1
#endif
@@ -738,6 +741,7 @@
#define HAVE_ERRNO_H 0
#else
#define HAVE_SYS_TIMEB_H 1
+#define HAVE_ALIGNED_MALLOC 1
#endif
#define HAVE_VIRTUALALLOC 1
@@ -794,6 +798,13 @@
#endif
+#if HAVE(MMAP) || (HAVE(VIRTUALALLOC) && HAVE(ALIGNED_MALLOC))
+#define HAVE_PAGE_ALLOCATE_ALIGNED 1
+#endif
+#if HAVE(MMAP)
+#define HAVE_PAGE_ALLOCATE_AT 1
+#endif
+
/* ENABLE macro defaults */
#if PLATFORM(QT)
@@ -883,7 +894,7 @@
#define ENABLE_NOTIFICATIONS 0
#endif
-#if PLATFORM(IPHONE)
+#if PLATFORM(IOS)
#define ENABLE_TEXT_CARET 0
#endif
@@ -910,9 +921,10 @@
#if (CPU(X86_64) && (OS(UNIX) || OS(WINDOWS))) \
|| (CPU(IA64) && !CPU(IA64_32)) \
|| CPU(ALPHA) \
- || CPU(SPARC64)
+ || CPU(SPARC64) \
+ || CPU(PPC64)
#define WTF_USE_JSVALUE64 1
-#elif CPU(ARM_TRADITIONAL) || CPU(PPC64) || CPU(MIPS)
+#elif CPU(MIPS) || (CPU(ARM_TRADITIONAL) && COMPILER(MSVC))
#define WTF_USE_JSVALUE32 1
#elif OS(WINDOWS) && COMPILER(MINGW)
/* Using JSVALUE32_64 causes padding/alignement issues for JITStubArg
@@ -1005,7 +1017,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#endif
/* Setting this flag prevents the assembler from using RWX memory; this may improve
security but currectly comes at a significant performance cost. */
-#if PLATFORM(IPHONE)
+#if PLATFORM(IOS)
#define ENABLE_ASSEMBLER_WX_EXCLUSIVE 1
#else
#define ENABLE_ASSEMBLER_WX_EXCLUSIVE 0
@@ -1032,8 +1044,17 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#define WTF_USE_QXMLQUERY 1
#endif
-/* Accelerated compositing */
#if PLATFORM(MAC)
+/* Complex text framework */
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+#define WTF_USE_ATSUI 0
+#define WTF_USE_CORE_TEXT 1
+#else
+#define WTF_USE_ATSUI 1
+#define WTF_USE_CORE_TEXT 0
+#endif
+
+/* Accelerated compositing */
#if !defined(BUILDING_ON_TIGER)
#define WTF_USE_ACCELERATED_COMPOSITING 1
#endif
@@ -1043,7 +1064,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#define WTF_USE_ACCELERATED_COMPOSITING 1
#endif
-#if PLATFORM(IPHONE)
+#if PLATFORM(IOS)
#define WTF_USE_ACCELERATED_COMPOSITING 1
#endif
@@ -1058,7 +1079,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#endif
#endif
-#if (PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)) || PLATFORM(IPHONE)
+#if (PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)) || PLATFORM(IOS)
#define WTF_USE_PROTECTION_SPACE_AUTH_CALLBACK 1
#endif
@@ -1078,7 +1099,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#define ENABLE_JSC_ZOMBIES 0
/* FIXME: Eventually we should enable this for all platforms and get rid of the define. */
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(WIN)
#define WTF_USE_PLATFORM_STRATEGIES 1
#endif
@@ -1089,4 +1110,8 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#define WTF_USE_PREEMPT_GEOLOCATION_PERMISSION 1
#endif
+#if CPU(ARM_THUMB2)
+#define ENABLE_BRANCH_COMPACTION 1
+#endif
+
#endif /* WTF_Platform_h */
diff --git a/JavaScriptCore/wtf/WTFThreadData.cpp b/JavaScriptCore/wtf/WTFThreadData.cpp
index 0716dc9..729b48e 100644
--- a/JavaScriptCore/wtf/WTFThreadData.cpp
+++ b/JavaScriptCore/wtf/WTFThreadData.cpp
@@ -54,4 +54,4 @@ WTFThreadData::~WTFThreadData()
#endif
}
-} // namespace WebCore
+}
diff --git a/JavaScriptCore/wtf/WTFThreadData.h b/JavaScriptCore/wtf/WTFThreadData.h
index d2c379b..c596260 100644
--- a/JavaScriptCore/wtf/WTFThreadData.h
+++ b/JavaScriptCore/wtf/WTFThreadData.h
@@ -45,15 +45,6 @@
#include <wtf/Threading.h>
#endif
-// FIXME: This is a temporary layering violation while we move more string code to WTF.
-namespace WebCore {
-class AtomicStringTable;
-class StringImpl;
-}
-using WebCore::StringImpl;
-
-typedef void (*AtomicStringTableDestructor)(WebCore::AtomicStringTable*);
-
#if USE(JSC)
// FIXME: This is a temporary layering violation while we move more string code to WTF.
namespace JSC {
@@ -82,12 +73,16 @@ private:
namespace WTF {
+class AtomicStringTable;
+
+typedef void (*AtomicStringTableDestructor)(AtomicStringTable*);
+
class WTFThreadData : public Noncopyable {
public:
WTFThreadData();
~WTFThreadData();
- WebCore::AtomicStringTable* atomicStringTable()
+ AtomicStringTable* atomicStringTable()
{
return m_atomicStringTable;
}
@@ -118,7 +113,7 @@ public:
#endif
private:
- WebCore::AtomicStringTable* m_atomicStringTable;
+ AtomicStringTable* m_atomicStringTable;
AtomicStringTableDestructor m_atomicStringTableDestructor;
#if USE(JSC)
@@ -132,7 +127,7 @@ private:
static JS_EXPORTDATA WTFThreadData* staticData;
#endif
friend WTFThreadData& wtfThreadData();
- friend class WebCore::AtomicStringTable;
+ friend class AtomicStringTable;
};
inline WTFThreadData& wtfThreadData()
diff --git a/JavaScriptCore/wtf/dtoa.cpp b/JavaScriptCore/wtf/dtoa.cpp
index 9edc2a0..2c478a0 100644
--- a/JavaScriptCore/wtf/dtoa.cpp
+++ b/JavaScriptCore/wtf/dtoa.cpp
@@ -167,6 +167,7 @@
#endif
#define INFNAN_CHECK
+#define No_Hex_NaN
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_ARM) != 1
Exactly one of IEEE_8087, IEEE_ARM or IEEE_MC68k should be defined.
diff --git a/JavaScriptCore/wtf/gobject/GOwnPtr.h b/JavaScriptCore/wtf/gobject/GOwnPtr.h
index 40c0bf4..731326e 100644
--- a/JavaScriptCore/wtf/gobject/GOwnPtr.h
+++ b/JavaScriptCore/wtf/gobject/GOwnPtr.h
@@ -34,7 +34,6 @@ typedef struct _GCond GCond;
typedef struct _GMutex GMutex;
typedef struct _GPatternSpec GPatternSpec;
typedef struct _GDir GDir;
-typedef struct _GHashTable GHashTable;
typedef struct _GFile GFile;
extern "C" void g_free(void*);
@@ -47,7 +46,6 @@ template<> void freeOwnedGPtr<GCond>(GCond*);
template<> void freeOwnedGPtr<GMutex>(GMutex*);
template<> void freeOwnedGPtr<GPatternSpec>(GPatternSpec*);
template<> void freeOwnedGPtr<GDir>(GDir*);
-template<> void freeOwnedGPtr<GHashTable>(GHashTable*);
template<> void freeOwnedGPtr<GFile>(GFile*);
template <typename T> class GOwnPtr : public Noncopyable {
diff --git a/JavaScriptCore/wtf/qt/StringQt.cpp b/JavaScriptCore/wtf/qt/StringQt.cpp
index b2c621a..c02505a 100644
--- a/JavaScriptCore/wtf/qt/StringQt.cpp
+++ b/JavaScriptCore/wtf/qt/StringQt.cpp
@@ -29,7 +29,7 @@
#include <QString>
-namespace WebCore {
+namespace WTF {
// String conversions
String::String(const QString& qstr)
diff --git a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp b/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp
deleted file mode 100644
index 6a28e9e..0000000
--- a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if OS(SYMBIAN)
-
-#include "BlockAllocatorSymbian.h"
-
-
-namespace WTF {
-
-/** Efficiently allocates blocks of size blockSize with blockSize alignment.
- * Primarly designed for JSC Collector's needs.
- * Not thread-safe.
- */
-AlignedBlockAllocator::AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize )
- : m_reservation(reservationSize),
- m_blockSize(blockSize)
-{
-
- // Get system's page size value.
- SYMBIAN_PAGESIZE(m_pageSize);
-
- // We only accept multiples of system page size for both initial reservation and the alignment/block size
- m_reservation = SYMBIAN_ROUNDUPTOMULTIPLE(m_reservation, m_pageSize);
- __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_blockSize, m_pageSize), User::Panic(_L("AlignedBlockAllocator1"), KErrArgument));
-
- // Calculate max. bit flags we need to carve a reservationSize range into blockSize-sized blocks
- m_map.numBits = m_reservation / m_blockSize;
- const TUint32 bitsPerWord = 8*sizeof(TUint32);
- const TUint32 numWords = (m_map.numBits + bitsPerWord -1) / bitsPerWord;
-
- m_map.bits = new TUint32[numWords];
- __ASSERT_ALWAYS(m_map.bits, User::Panic(_L("AlignedBlockAllocator2"), KErrNoMemory));
- m_map.clearAll();
-
- // Open a Symbian RChunk, and reserve requested virtual address range
- // Any thread in this process can operate this rchunk due to EOwnerProcess access rights.
- TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reservation , EOwnerProcess);
- if (ret != KErrNone)
- User::Panic(_L("AlignedBlockAllocator3"), ret);
-
- // This is the offset to m_chunk.Base() required to make it m_blockSize-aligned
- m_offset = SYMBIAN_ROUNDUPTOMULTIPLE(TUint32(m_chunk.Base()), m_blockSize) - TUint(m_chunk.Base());
-
-}
-
-void* AlignedBlockAllocator::alloc()
-{
-
- TInt freeRam = 0;
- void* address = 0;
-
- // Look up first free slot in bit map
- const TInt freeIdx = m_map.findFree();
-
- // Pseudo OOM: We ate up the address space we reserved..
- // ..even though the device may have free RAM left
- if (freeIdx < 0)
- return 0;
-
- TInt ret = m_chunk.Commit(m_offset + (m_blockSize * freeIdx), m_blockSize);
- if (ret != KErrNone)
- return 0; // True OOM: Device didn't have physical RAM to spare
-
- // Updated bit to mark region as in use.
- m_map.set(freeIdx);
-
- // Calculate address of committed region (block)
- address = (void*)( (m_chunk.Base() + m_offset) + (TUint)(m_blockSize * freeIdx) );
-
- return address;
-}
-
-void AlignedBlockAllocator::free(void* block)
-{
- // Calculate index of block to be freed
- TInt idx = TUint(static_cast<TUint8*>(block) - m_chunk.Base() - m_offset) / m_blockSize;
-
- __ASSERT_DEBUG(idx >= 0 && idx < m_map.numBits, User::Panic(_L("AlignedBlockAllocator4"), KErrCorrupt)); // valid index check
- __ASSERT_DEBUG(m_map.get(idx), User::Panic(_L("AlignedBlockAllocator5"), KErrCorrupt)); // in-use flag check
-
- // Return committed region to system RAM pool (the physical RAM becomes usable by others)
- TInt ret = m_chunk.Decommit(m_offset + m_blockSize * idx, m_blockSize);
-
- // mark this available again
- m_map.clear(idx);
-}
-
-void AlignedBlockAllocator::destroy()
-{
- // release everything!
- m_chunk.Decommit(0, m_chunk.MaxSize());
- m_map.clearAll();
-}
-
-AlignedBlockAllocator::~AlignedBlockAllocator()
-{
- destroy();
- m_chunk.Close();
- delete [] m_map.bits;
-}
-
-} // end of namespace
-
-#endif // SYMBIAN
diff --git a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h b/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h
deleted file mode 100644
index 21422f6..0000000
--- a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BlockAllocatorSymbian_h
-#define BlockAllocatorSymbian_h
-
-#include <e32cmn.h>
-#include <e32std.h>
-#include <hal.h>
-
-
-#define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x));
-#define SYMBIAN_FREERAM(x) (HAL::Get(HALData::EMemoryRAMFree, x));
-#define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof) ( (x + multipleof - 1) & ~(multipleof - 1) )
-
-// Set sane defaults if -D<flagname=value> wasn't provided via compiler args
-#ifndef JSCCOLLECTOR_VIRTUALMEM_RESERVATION
-#if defined(__WINS__)
- // Emulator has limited virtual address space
- #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (4*1024*1024)
-#else
- // HW has plenty of virtual addresses
- #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (128*1024*1024)
-#endif
-#endif
-
-namespace WTF {
-
-/**
- * Allocates contiguous region of size blockSize with blockSize-aligned address.
- * blockSize must be a multiple of system page size (typically 4K on Symbian/ARM)
- *
- * @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes).
- * @param blockSize Size of a single allocation. Returned address will also be blockSize-aligned.
- */
-class AlignedBlockAllocator {
- public:
- AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize);
- ~AlignedBlockAllocator();
- void destroy();
- void* alloc();
- void free(void* data);
-
- private:
- RChunk m_chunk; // Symbian chunk that lets us reserve/commit/decommit
- TUint m_offset; // offset of first committed region from base
- TInt m_pageSize; // cached value of system page size, typically 4K on Symbian
- TUint32 m_reservation;
- TUint32 m_blockSize;
-
- // Tracks comitted/decommitted state of a blockSize region
- struct {
-
- TUint32 *bits; // array of bit flags
- TUint32 numBits; // number of regions to keep track of
-
- bool get(TUint32 n) const
- {
- return !!(bits[n >> 5] & (1 << (n & 0x1F)));
- }
-
- void set(TUint32 n)
- {
- bits[n >> 5] |= (1 << (n & 0x1F));
- }
-
- void clear(TUint32 n)
- {
- bits[n >> 5] &= ~(1 << (n & 0x1F));
- }
-
- void clearAll()
- {
- for (TUint32 i = 0; i < numBits; i++)
- clear(i);
- }
-
- TInt findFree() const
- {
- for (TUint32 i = 0; i < numBits; i++) {
- if (!get(i))
- return i;
- }
- return -1;
- }
-
- } m_map;
-
-};
-
-}
-
-#endif // end of BlockAllocatorSymbian_h
-
-
diff --git a/JavaScriptCore/wtf/text/AtomicString.cpp b/JavaScriptCore/wtf/text/AtomicString.cpp
index 0547b8c..6e95292 100644
--- a/JavaScriptCore/wtf/text/AtomicString.cpp
+++ b/JavaScriptCore/wtf/text/AtomicString.cpp
@@ -27,7 +27,7 @@
#include <wtf/Threading.h>
#include <wtf/WTFThreadData.h>
-namespace WebCore {
+namespace WTF {
COMPILE_ASSERT(sizeof(AtomicString) == sizeof(String), atomic_string_and_string_must_be_same_size);
@@ -164,7 +164,7 @@ struct UCharBufferTranslator {
static bool equal(StringImpl* const& str, const UCharBuffer& buf)
{
- return WebCore::equal(str, buf.s, buf.length);
+ return WTF::equal(str, buf.s, buf.length);
}
static void translate(StringImpl*& location, const UCharBuffer& buf, unsigned hash)
@@ -190,7 +190,7 @@ struct HashAndCharactersTranslator {
static bool equal(StringImpl* const& string, const HashAndCharacters& buffer)
{
- return WebCore::equal(string, buffer.characters, buffer.length);
+ return WTF::equal(string, buffer.characters, buffer.length);
}
static void translate(StringImpl*& location, const HashAndCharacters& buffer, unsigned hash)
diff --git a/JavaScriptCore/wtf/text/AtomicString.h b/JavaScriptCore/wtf/text/AtomicString.h
index 5bb2cf9..d29981a 100644
--- a/JavaScriptCore/wtf/text/AtomicString.h
+++ b/JavaScriptCore/wtf/text/AtomicString.h
@@ -32,11 +32,13 @@
#define ATOMICSTRING_CONVERSION
#endif
-// FIXME: This is a temporary layering violation while we move string code to WTF.
-// Landing the file moves in one patch, will follow on with patches to change the namespaces.
+// FIXME: this should be in WTF, too!
namespace WebCore {
-
struct AtomicStringHash;
+}
+using WebCore::AtomicStringHash;
+
+namespace WTF {
class AtomicString {
public:
@@ -156,17 +158,23 @@ inline bool equalIgnoringCase(const String& a, const AtomicString& b) { return e
extern const JS_EXPORTDATA AtomicString xmlnsAtom;
#endif
-} // namespace WebCore
-
-
-namespace WTF {
-
// AtomicStringHash is the default hash for AtomicString
template<typename T> struct DefaultHash;
- template<> struct DefaultHash<WebCore::AtomicString> {
- typedef WebCore::AtomicStringHash Hash;
+ template<> struct DefaultHash<AtomicString> {
+ typedef AtomicStringHash Hash;
};
} // namespace WTF
+#ifndef ATOMICSTRING_HIDE_GLOBALS
+using WTF::AtomicString;
+using WTF::nullAtom;
+using WTF::emptyAtom;
+using WTF::textAtom;
+using WTF::commentAtom;
+using WTF::starAtom;
+using WTF::xmlAtom;
+using WTF::xmlnsAtom;
+#endif
+
#endif // AtomicString_h
diff --git a/JavaScriptCore/wtf/text/AtomicStringImpl.h b/JavaScriptCore/wtf/text/AtomicStringImpl.h
index 4b813f8..3f0c376 100644
--- a/JavaScriptCore/wtf/text/AtomicStringImpl.h
+++ b/JavaScriptCore/wtf/text/AtomicStringImpl.h
@@ -23,9 +23,7 @@
#include "StringImpl.h"
-// FIXME: This is a temporary layering violation while we move string code to WTF.
-// Landing the file moves in one patch, will follow on with patches to change the namespaces.
-namespace WebCore {
+namespace WTF {
class AtomicStringImpl : public StringImpl
{
@@ -35,4 +33,6 @@ public:
}
+using WTF::AtomicStringImpl;
+
#endif
diff --git a/JavaScriptCore/wtf/text/StringBuffer.h b/JavaScriptCore/wtf/text/StringBuffer.h
index 353a44a..c29dd79 100644
--- a/JavaScriptCore/wtf/text/StringBuffer.h
+++ b/JavaScriptCore/wtf/text/StringBuffer.h
@@ -33,7 +33,7 @@
#include <wtf/Noncopyable.h>
#include <wtf/unicode/Unicode.h>
-namespace WebCore {
+namespace WTF {
class StringBuffer : public Noncopyable {
public:
@@ -74,4 +74,6 @@ private:
}
+using WTF::StringBuffer;
+
#endif
diff --git a/JavaScriptCore/wtf/text/StringHash.h b/JavaScriptCore/wtf/text/StringHash.h
index b820004..8872fb3 100644
--- a/JavaScriptCore/wtf/text/StringHash.h
+++ b/JavaScriptCore/wtf/text/StringHash.h
@@ -24,13 +24,12 @@
#include "AtomicString.h"
#include "WTFString.h"
+#include <wtf/Forward.h>
#include <wtf/HashTraits.h>
#include <wtf/StringHashFunctions.h>
#include <wtf/unicode/Unicode.h>
-// FIXME: This is a temporary layering violation while we move string code to WTF.
-// Landing the file moves in one patch, will follow on with patches to change the namespaces.
-namespace WebCore {
+namespace WTF {
// The hash() functions on StringHash and CaseFoldingHash do not support
// null strings. get(), contains(), and add() on HashMap<String,..., StringHash>
@@ -253,16 +252,16 @@ namespace WebCore {
}
};
-}
-
-namespace WTF {
-
- template<> struct HashTraits<WebCore::String> : GenericHashTraits<WebCore::String> {
+ template<> struct HashTraits<String> : GenericHashTraits<String> {
static const bool emptyValueIsZero = true;
- static void constructDeletedValue(WebCore::String& slot) { new (&slot) WebCore::String(HashTableDeletedValue); }
- static bool isDeletedValue(const WebCore::String& slot) { return slot.isHashTableDeletedValue(); }
+ static void constructDeletedValue(String& slot) { new (&slot) String(HashTableDeletedValue); }
+ static bool isDeletedValue(const String& slot) { return slot.isHashTableDeletedValue(); }
};
}
+using WTF::StringHash;
+using WTF::CaseFoldingHash;
+using WTF::AlreadyHashed;
+
#endif
diff --git a/JavaScriptCore/wtf/text/StringImpl.cpp b/JavaScriptCore/wtf/text/StringImpl.cpp
index 698cab9..3669628 100644
--- a/JavaScriptCore/wtf/text/StringImpl.cpp
+++ b/JavaScriptCore/wtf/text/StringImpl.cpp
@@ -31,10 +31,9 @@
#include <wtf/StdLibExtras.h>
#include <wtf/WTFThreadData.h>
-using namespace WTF;
-using namespace Unicode;
+namespace WTF {
-namespace WebCore {
+using namespace Unicode;
static const unsigned minLengthToShare = 20;
@@ -535,12 +534,12 @@ int StringImpl::find(const char* chs, int index, bool caseSensitive)
int StringImpl::find(UChar c, int start)
{
- return WebCore::find(m_data, m_length, c, start);
+ return WTF::find(m_data, m_length, c, start);
}
int StringImpl::find(CharacterMatchFunctionPtr matchFunction, int start)
{
- return WebCore::find(m_data, m_length, matchFunction, start);
+ return WTF::find(m_data, m_length, matchFunction, start);
}
int StringImpl::find(StringImpl* str, int index, bool caseSensitive)
@@ -601,7 +600,7 @@ int StringImpl::find(StringImpl* str, int index, bool caseSensitive)
int StringImpl::reverseFind(UChar c, int index)
{
- return WebCore::reverseFind(m_data, m_length, c, index);
+ return WTF::reverseFind(m_data, m_length, c, index);
}
int StringImpl::reverseFind(StringImpl* str, int index, bool caseSensitive)
@@ -961,4 +960,4 @@ PassRefPtr<StringImpl> StringImpl::crossThreadString()
return threadsafeCopy();
}
-} // namespace WebCore
+} // namespace WTF
diff --git a/JavaScriptCore/wtf/text/StringImpl.h b/JavaScriptCore/wtf/text/StringImpl.h
index 244009f..6080474 100644
--- a/JavaScriptCore/wtf/text/StringImpl.h
+++ b/JavaScriptCore/wtf/text/StringImpl.h
@@ -26,6 +26,7 @@
#include <limits.h>
#include <wtf/ASCIICType.h>
#include <wtf/CrossThreadRefCounted.h>
+#include <wtf/Forward.h>
#include <wtf/OwnFastMallocPtr.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringHashFunctions.h>
@@ -44,21 +45,14 @@ typedef const struct __CFString * CFStringRef;
// FIXME: This is a temporary layering violation while we move string code to WTF.
// Landing the file moves in one patch, will follow on with patches to change the namespaces.
namespace JSC {
-
struct IdentifierCStringTranslator;
struct IdentifierUCharBufferTranslator;
-
}
-// FIXME: This is a temporary layering violation while we move string code to WTF.
-// Landing the file moves in one patch, will follow on with patches to change the namespaces.
-namespace WebCore {
-
-class StringBuffer;
+namespace WTF {
struct CStringTranslator;
struct HashAndCharactersTranslator;
-struct StringHash;
struct UCharBufferTranslator;
enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
@@ -70,9 +64,9 @@ typedef bool (*CharacterMatchFunctionPtr)(UChar);
class StringImpl : public StringImplBase {
friend struct JSC::IdentifierCStringTranslator;
friend struct JSC::IdentifierUCharBufferTranslator;
- friend struct CStringTranslator;
- friend struct HashAndCharactersTranslator;
- friend struct UCharBufferTranslator;
+ friend struct WTF::CStringTranslator;
+ friend struct WTF::HashAndCharactersTranslator;
+ friend struct WTF::UCharBufferTranslator;
friend class AtomicStringImpl;
private:
// Used to construct static strings, which have an special refCount that can never hit zero.
@@ -384,21 +378,23 @@ inline PassRefPtr<StringImpl> StringImpl::createStrippingNullCharacters(const UC
return StringImpl::createStrippingNullCharactersSlowCase(characters, length);
}
-}
-
-using WebCore::equal;
-
-namespace WTF {
+struct StringHash;
- // WebCore::StringHash is the default hash for StringImpl* and RefPtr<StringImpl>
- template<typename T> struct DefaultHash;
- template<> struct DefaultHash<WebCore::StringImpl*> {
- typedef WebCore::StringHash Hash;
- };
- template<> struct DefaultHash<RefPtr<WebCore::StringImpl> > {
- typedef WebCore::StringHash Hash;
- };
+// StringHash is the default hash for StringImpl* and RefPtr<StringImpl>
+template<typename T> struct DefaultHash;
+template<> struct DefaultHash<StringImpl*> {
+ typedef StringHash Hash;
+};
+template<> struct DefaultHash<RefPtr<StringImpl> > {
+ typedef StringHash Hash;
+};
}
+using WTF::StringImpl;
+using WTF::equal;
+using WTF::TextCaseSensitivity;
+using WTF::TextCaseSensitive;
+using WTF::TextCaseInsensitive;
+
#endif
diff --git a/JavaScriptCore/wtf/text/StringStatics.cpp b/JavaScriptCore/wtf/text/StringStatics.cpp
index 4a23a16..5654044 100644
--- a/JavaScriptCore/wtf/text/StringStatics.cpp
+++ b/JavaScriptCore/wtf/text/StringStatics.cpp
@@ -33,7 +33,7 @@
#include "StaticConstructors.h"
#include "StringImpl.h"
-namespace WebCore {
+namespace WTF {
StringImpl* StringImpl::empty()
{
diff --git a/JavaScriptCore/wtf/text/WTFString.cpp b/JavaScriptCore/wtf/text/WTFString.cpp
index 2d4417f..6c4de6e 100644
--- a/JavaScriptCore/wtf/text/WTFString.cpp
+++ b/JavaScriptCore/wtf/text/WTFString.cpp
@@ -32,10 +32,9 @@
#include <wtf/unicode/UTF8.h>
#include <wtf/unicode/Unicode.h>
-using namespace WTF;
-using namespace WTF::Unicode;
+namespace WTF {
-namespace WebCore {
+using namespace Unicode;
String::String(const UChar* str)
{
@@ -905,14 +904,14 @@ float charactersToFloat(const UChar* data, size_t length, bool* ok)
return static_cast<float>(charactersToDouble(data, length, ok));
}
-} // namespace WebCore
+} // namespace WTF
#ifndef NDEBUG
// For use in the debugger - leaks memory
-WebCore::String* string(const char*);
+String* string(const char*);
-WebCore::String* string(const char* s)
+String* string(const char* s)
{
- return new WebCore::String(s);
+ return new String(s);
}
#endif
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h
index 90d9a71..6af519c 100644
--- a/JavaScriptCore/wtf/text/WTFString.h
+++ b/JavaScriptCore/wtf/text/WTFString.h
@@ -51,16 +51,8 @@ class BString;
#endif
namespace WTF {
-class CString;
-}
-using WTF::CString;
-// FIXME: This is a temporary layering violation while we move string code to WTF.
-// Landing the file moves in one patch, will follow on with patches to change the namespaces.
-namespace WebCore {
-
-class SharedBuffer;
-struct StringHash;
+class CString;
// Declarations of string operations
@@ -417,16 +409,30 @@ inline void appendNumber(Vector<UChar>& vector, unsigned char number)
}
}
-} // namespace WebCore
-
-namespace WTF {
+struct StringHash;
- // StringHash is the default hash for String
- template<typename T> struct DefaultHash;
- template<> struct DefaultHash<WebCore::String> {
- typedef WebCore::StringHash Hash;
- };
+// StringHash is the default hash for String
+template<typename T> struct DefaultHash;
+template<> struct DefaultHash<String> {
+ typedef StringHash Hash;
+};
}
+using WTF::CString;
+using WTF::String;
+
+using WTF::isSpaceOrNewline;
+using WTF::find;
+using WTF::reverseFind;
+using WTF::append;
+using WTF::appendNumber;
+using WTF::equal;
+using WTF::equalIgnoringCase;
+using WTF::charactersAreAllASCII;
+using WTF::charactersToInt;
+using WTF::charactersToFloat;
+using WTF::charactersToDouble;
+using WTF::operator+;
+
#endif
diff --git a/JavaScriptCore/wtf/unicode/icu/CollatorICU.cpp b/JavaScriptCore/wtf/unicode/icu/CollatorICU.cpp
index 5112de5..805b114 100644
--- a/JavaScriptCore/wtf/unicode/icu/CollatorICU.cpp
+++ b/JavaScriptCore/wtf/unicode/icu/CollatorICU.cpp
@@ -61,7 +61,7 @@ PassOwnPtr<Collator> Collator::userDefault()
{
#if OS(DARWIN) && PLATFORM(CF)
// Mac OS X doesn't set UNIX locale to match user-selected one, so ICU default doesn't work.
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !OS(IPHONE_OS)
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !OS(IOS)
RetainPtr<CFLocaleRef> currentLocale(AdoptCF, CFLocaleCopyCurrent());
CFStringRef collationOrder = (CFStringRef)CFLocaleGetValue(currentLocale.get(), kCFLocaleCollatorIdentifier);
#else