Commit 096e7e05 authored by aroben@apple.com's avatar aroben@apple.com

Roll out r46153, r46154, and r46155

        These changes were causing build failures and assertion failures on
        Windows.

JavaScriptCore:

        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * runtime/JSArray.cpp:
        * runtime/StringPrototype.cpp:
        * runtime/UString.cpp:
        * runtime/UString.h:
        * wtf/FastMalloc.cpp:
        * wtf/FastMalloc.h:
        * wtf/Platform.h:
        * wtf/PossiblyNull.h: Removed.

WebCore:

        * ForwardingHeaders/wtf/PossiblyNull.h: Removed.
        * platform/graphics/cg/ImageBufferCG.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@46180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7155963e
2009-07-21 Adam Roben <aroben@apple.com>
Roll out r46153, r46154, and r46155
These changes were causing build failures and assertion failures on
Windows.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/JSArray.cpp:
* runtime/StringPrototype.cpp:
* runtime/UString.cpp:
* runtime/UString.h:
* wtf/FastMalloc.cpp:
* wtf/FastMalloc.h:
* wtf/Platform.h:
* wtf/PossiblyNull.h: Removed.
2009-07-21 Roland Steiner <rolandsteiner@google.com>
Reviewed by David Levin.
......
......@@ -258,7 +258,7 @@ EXPORTS
?toUInt32@UString@JSC@@QBEIPA_N@Z
?toUInt32@UString@JSC@@QBEIPA_N_N@Z
?toUInt32SlowCase@JSC@@YAINAA_N@Z
?tryFastCalloc@WTF@@YA?AUTryMallocReturnValue@1@II@Z
?tryFastCalloc@WTF@@YAPAXII@Z
?tryLock@Mutex@WTF@@QAE_NXZ
?type@DebuggerCallFrame@JSC@@QBE?AW4Type@12@XZ
?unlock@JSLock@JSC@@SAX_N@Z
......
......@@ -258,7 +258,7 @@ EXPORTS
?toUInt32@UString@JSC@@QBEIPA_N@Z
?toUInt32@UString@JSC@@QBEIPA_N_N@Z
?toUInt32SlowCase@JSC@@YAINAA_N@Z
?tryFastCalloc@WTF@@YA?AUTryMallocReturnValue@1@II@Z
?tryFastCalloc@WTF@@YAPAXII@Z
?tryLock@Mutex@WTF@@QAE_NXZ
?type@DebuggerCallFrame@JSC@@QBE?AW4Type@12@XZ
?unlock@JSLock@JSC@@SAX_N@Z
......
......@@ -201,7 +201,6 @@
A7A1F7AC0F252B3C00E184E2 /* ByteArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A1F7AA0F252B3C00E184E2 /* ByteArray.cpp */; };
A7A1F7AD0F252B3C00E184E2 /* ByteArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A1F7AB0F252B3C00E184E2 /* ByteArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */; };
A7D649AA1015224E009B2E1B /* PossiblyNull.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D649A91015224E009B2E1B /* PossiblyNull.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7E2EA6B0FB460CF00601F06 /* LiteralParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A7E2EA690FB460CF00601F06 /* LiteralParser.h */; };
A7E2EA6C0FB460CF00601F06 /* LiteralParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E2EA6A0FB460CF00601F06 /* LiteralParser.cpp */; };
A7F9935F0FD7325100A0B2D0 /* JSONObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A7F9935D0FD7325100A0B2D0 /* JSONObject.h */; };
......@@ -742,7 +741,6 @@
A7A1F7AB0F252B3C00E184E2 /* ByteArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteArray.h; sourceTree = "<group>"; };
A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutableAllocator.h; sourceTree = "<group>"; };
A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocator.cpp; sourceTree = "<group>"; };
A7D649A91015224E009B2E1B /* PossiblyNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PossiblyNull.h; sourceTree = "<group>"; };
A7E2EA690FB460CF00601F06 /* LiteralParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiteralParser.h; sourceTree = "<group>"; };
A7E2EA6A0FB460CF00601F06 /* LiteralParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralParser.cpp; sourceTree = "<group>"; };
A7E42C180E3938830065A544 /* JSStaticScopeObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStaticScopeObject.h; sourceTree = "<group>"; };
......@@ -1229,7 +1227,6 @@
44DD48520FAEA85000D6B4EB /* PassOwnPtr.h */,
6580F795094070560082C219 /* PassRefPtr.h */,
65D6D87E09B5A32E0002E4D7 /* Platform.h */,
A7D649A91015224E009B2E1B /* PossiblyNull.h */,
0B1F921B0F17502D0036468E /* PtrAndFlags.h */,
088FA5B90EF76D4300578E6F /* RandomNumber.cpp */,
088FA5BA0EF76D4300578E6F /* RandomNumber.h */,
......@@ -1878,7 +1875,6 @@
1429DAE00ED2645B00B89619 /* WRECGenerator.h in Headers */,
1429DABF0ED263E700B89619 /* WRECParser.h in Headers */,
9688CB160ED12B4E001D649F /* X86Assembler.h in Headers */,
A7D649AA1015224E009B2E1B /* PossiblyNull.h in Headers */,
86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
86D3B2C510156BDE002865E7 /* AssemblerBufferWithConstantPool.h in Headers */,
86D3B2C610156BDE002865E7 /* MacroAssemblerARM.h in Headers */,
......
......@@ -343,7 +343,8 @@ NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue valu
}
}
if (!tryFastRealloc(storage, storageSize(newVectorLength)).getValue(storage)) {
storage = static_cast<ArrayStorage*>(tryFastRealloc(storage, storageSize(newVectorLength)));
if (!storage) {
throwOutOfMemoryError(exec);
return;
}
......@@ -461,7 +462,8 @@ bool JSArray::increaseVectorLength(unsigned newLength)
ASSERT(newLength <= MAX_STORAGE_VECTOR_INDEX);
unsigned newVectorLength = increasedVectorLength(newLength);
if (!tryFastRealloc(storage, storageSize(newVectorLength)).getValue(storage))
storage = static_cast<ArrayStorage*>(tryFastRealloc(storage, storageSize(newVectorLength)));
if (!storage)
return false;
Heap::heap(this)->reportExtraMemoryCost(storageSize(newVectorLength) - storageSize(vectorLength));
......
......@@ -821,8 +821,8 @@ JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValu
if (a0.getUInt32(smallInteger) && smallInteger <= 9) {
unsigned stringSize = s.size();
unsigned bufferSize = 22 + stringSize;
UChar* buffer;
if (!tryFastMalloc(bufferSize * sizeof(UChar)).getValue(buffer))
UChar* buffer = static_cast<UChar*>(tryFastMalloc(bufferSize * sizeof(UChar)));
if (!buffer)
return jsUndefined();
buffer[0] = '<';
buffer[1] = 'f';
......@@ -869,8 +869,8 @@ JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec, JSObject*, JSValue th
unsigned linkTextSize = linkText.size();
unsigned stringSize = s.size();
unsigned bufferSize = 15 + linkTextSize + stringSize;
UChar* buffer;
if (!tryFastMalloc(bufferSize * sizeof(UChar)).getValue(buffer))
UChar* buffer = static_cast<UChar*>(tryFastMalloc(bufferSize * sizeof(UChar)));
if (!buffer)
return jsUndefined();
buffer[0] = '<';
buffer[1] = 'a';
......
......@@ -68,20 +68,20 @@ static const int minLengthToShare = 10;
static inline size_t overflowIndicator() { return std::numeric_limits<size_t>::max(); }
static inline size_t maxUChars() { return std::numeric_limits<size_t>::max() / sizeof(UChar); }
static inline PossiblyNull<UChar*> allocChars(size_t length)
static inline UChar* allocChars(size_t length)
{
ASSERT(length);
if (length > maxUChars())
return 0;
return tryFastMalloc(sizeof(UChar) * length);
return static_cast<UChar*>(tryFastMalloc(sizeof(UChar) * length));
}
static inline PossiblyNull<UChar*> reallocChars(UChar* buffer, size_t length)
static inline UChar* reallocChars(UChar* buffer, size_t length)
{
ASSERT(length);
if (length > maxUChars())
return 0;
return tryFastRealloc(buffer, sizeof(UChar) * length);
return static_cast<UChar*>(tryFastRealloc(buffer, sizeof(UChar) * length));
}
static inline void copyChars(UChar* destination, const UChar* source, unsigned numCharacters)
......@@ -480,7 +480,8 @@ static inline bool expandCapacity(UString::Rep* rep, int requiredLength)
if (requiredLength > base->capacity) {
size_t newCapacity = expandedSize(requiredLength, base->preCapacity);
UChar* oldBuf = base->buf;
if (!reallocChars(base->buf, newCapacity).getValue(base->buf)) {
base->buf = reallocChars(base->buf, newCapacity);
if (!base->buf) {
base->buf = oldBuf;
return false;
}
......@@ -511,7 +512,8 @@ bool UString::Rep::reserveCapacity(int capacity)
size_t newCapacity = expandedSize(capacity, base->preCapacity);
UChar* oldBuf = base->buf;
if (!reallocChars(base->buf, newCapacity).getValue(base->buf)) {
base->buf = reallocChars(base->buf, newCapacity);
if (!base->buf) {
base->buf = oldBuf;
return false;
}
......@@ -538,8 +540,8 @@ void UString::expandPreCapacity(int requiredPreCap)
size_t newCapacity = expandedSize(requiredPreCap, base->capacity);
int delta = newCapacity - base->capacity - base->preCapacity;
UChar* newBuf;
if (!allocChars(newCapacity).getValue(newBuf)) {
UChar* newBuf = allocChars(newCapacity);
if (!newBuf) {
makeNull();
return;
}
......@@ -564,8 +566,8 @@ static PassRefPtr<UString::Rep> createRep(const char* c)
return &UString::Rep::empty();
size_t length = strlen(c);
UChar* d;
if (!allocChars(length).getValue(d))
UChar* d = allocChars(length);
if (!d)
return &UString::Rep::null();
else {
for (size_t i = 0; i < length; i++)
......@@ -654,8 +656,8 @@ static ALWAYS_INLINE PassRefPtr<UString::Rep> concatenate(PassRefPtr<UString::Re
} else {
// This is shared in some way that prevents us from modifying base, so we must make a whole new string.
size_t newCapacity = expandedSize(length, 0);
UChar* d;
if (!allocChars(newCapacity).getValue(d))
UChar* d = allocChars(newCapacity);
if (!d)
rep = &UString::Rep::null();
else {
copyChars(d, rep->data(), thisSize);
......@@ -710,8 +712,8 @@ static ALWAYS_INLINE PassRefPtr<UString::Rep> concatenate(PassRefPtr<UString::Re
} else {
// This is shared in some way that prevents us from modifying base, so we must make a whole new string.
size_t newCapacity = expandedSize(length, 0);
UChar* d;
if (!allocChars(newCapacity).getValue(d))
UChar* d = allocChars(newCapacity);
if (!d)
rep = &UString::Rep::null();
else {
copyChars(d, rep->data(), thisSize);
......@@ -798,8 +800,8 @@ PassRefPtr<UString::Rep> concatenate(UString::Rep* a, UString::Rep* b)
// a does not qualify for append, and b does not qualify for prepend, gotta make a whole new string
size_t newCapacity = expandedSize(length, 0);
UChar* d;
if (!allocChars(newCapacity).getValue(d))
UChar* d = allocChars(newCapacity);
if (!d)
return 0;
copyChars(d, a->data(), aSize);
copyChars(d + aSize, b->data(), bSize);
......@@ -1074,8 +1076,8 @@ UString UString::spliceSubstringsWithSeparators(const Range* substringRanges, in
if (totalLength == 0)
return "";
UChar* buffer;
if (!allocChars(totalLength).getValue(buffer))
UChar* buffer = allocChars(totalLength);
if (!buffer)
return null();
int maxCount = max(rangeCount, separatorCount);
......@@ -1103,8 +1105,8 @@ UString UString::replaceRange(int rangeStart, int rangeLength, const UString& re
if (totalLength == 0)
return "";
UChar* buffer;
if (!allocChars(totalLength).getValue(buffer))
UChar* buffer = allocChars(totalLength);
if (!buffer)
return null();
copyChars(buffer, data(), rangeStart);
......@@ -1151,8 +1153,8 @@ UString& UString::append(const UString &t)
} else {
// This is shared in some way that prevents us from modifying base, so we must make a whole new string.
size_t newCapacity = expandedSize(length, 0);
UChar* d;
if (!allocChars(newCapacity).getValue(d))
UChar* d = allocChars(newCapacity);
if (!d)
makeNull();
else {
copyChars(d, data(), thisSize);
......@@ -1204,8 +1206,8 @@ UString& UString::append(UChar c)
if (length == 0) {
// this is empty - must make a new m_rep because we don't want to pollute the shared empty one
size_t newCapacity = expandedSize(1, 0);
UChar* d;
if (!allocChars(newCapacity).getValue(d))
UChar* d = allocChars(newCapacity);
if (!d)
makeNull();
else {
d[0] = c;
......@@ -1232,8 +1234,8 @@ UString& UString::append(UChar c)
} else {
// This is shared in some way that prevents us from modifying base, so we must make a whole new string.
size_t newCapacity = expandedSize(length + 1, 0);
UChar* d;
if (!allocChars(newCapacity).getValue(d))
UChar* d = allocChars(newCapacity);
if (!d)
makeNull();
else {
copyChars(d, data(), length);
......@@ -1311,7 +1313,8 @@ UString& UString::operator=(const char* c)
m_rep->_hash = 0;
m_rep->len = l;
} else {
if (!allocChars(l).getValue(d)) {
d = allocChars(l);
if (!d) {
makeNull();
return *this;
}
......
......@@ -91,8 +91,7 @@ namespace JSC {
{
// Guard against integer overflow
if (size < (std::numeric_limits<size_t>::max() / sizeof(UChar))) {
void * buf = 0;
if (tryFastMalloc(size * sizeof(UChar)).getValue(buf))
if (void * buf = tryFastMalloc(size * sizeof(UChar)))
return adoptRef(new BaseString(static_cast<UChar*>(buf), 0, size));
}
return adoptRef(new BaseString(0, 0, 0));
......
......@@ -172,10 +172,10 @@ void* fastZeroedMalloc(size_t n)
return result;
}
TryMallocReturnValue tryFastZeroedMalloc(size_t n)
void* tryFastZeroedMalloc(size_t n)
{
void* result;
if (!tryFastMalloc(n).getValue(result))
void* result = tryFastMalloc(n);
if (!result)
return 0;
memset(result, 0, n);
return result;
......@@ -194,7 +194,7 @@ TryMallocReturnValue tryFastZeroedMalloc(size_t n)
namespace WTF {
TryMallocReturnValue tryFastMalloc(size_t n)
void* tryFastMalloc(size_t n)
{
ASSERT(!isForbidden());
......@@ -230,7 +230,7 @@ void* fastMalloc(size_t n)
return result;
}
TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size)
void* tryFastCalloc(size_t n_elements, size_t element_size)
{
ASSERT(!isForbidden());
......@@ -285,7 +285,7 @@ void fastFree(void* p)
#endif
}
TryMallocReturnValue tryFastRealloc(void* p, size_t n)
void* tryFastRealloc(void* p, size_t n)
{
ASSERT(!isForbidden());
......@@ -3387,7 +3387,7 @@ void* fastMalloc(size_t size)
return malloc<true>(size);
}
TryMallocReturnValue tryFastMalloc(size_t size)
void* tryFastMalloc(size_t size)
{
return malloc<false>(size);
}
......@@ -3448,7 +3448,7 @@ void* fastCalloc(size_t n, size_t elem_size)
return calloc<true>(n, elem_size);
}
TryMallocReturnValue tryFastCalloc(size_t n, size_t elem_size)
void* tryFastCalloc(size_t n, size_t elem_size)
{
return calloc<false>(n, elem_size);
}
......@@ -3512,7 +3512,7 @@ void* fastRealloc(void* old_ptr, size_t new_size)
return realloc<true>(old_ptr, new_size);
}
TryMallocReturnValue tryFastRealloc(void* old_ptr, size_t new_size)
void* tryFastRealloc(void* old_ptr, size_t new_size)
{
return realloc<false>(old_ptr, new_size);
}
......
......@@ -22,7 +22,6 @@
#define WTF_FastMalloc_h
#include "Platform.h"
#include "PossiblyNull.h"
#include <stdlib.h>
#include <new>
......@@ -34,37 +33,11 @@ namespace WTF {
void* fastCalloc(size_t n_elements, size_t element_size);
void* fastRealloc(void* p, size_t n);
struct TryMallocReturnValue {
TryMallocReturnValue(void* data)
: m_data(data)
{
}
~TryMallocReturnValue() { ASSERT(!m_data); }
template <typename T> bool getValue(T& data) WARN_UNUSED_RETURN;
template <typename T> operator PossiblyNull<T>()
{
T value;
getValue(value);
return PossiblyNull<T>(value);
}
private:
void* m_data;
};
template <typename T> bool TryMallocReturnValue::getValue(T& data) {
union u { void* data; T target; } res;
res.data = m_data;
data = res.target;
bool returnValue = !!m_data;
m_data = 0;
return returnValue;
}
// These functions return NULL if an allocation fails.
TryMallocReturnValue tryFastMalloc(size_t n);
TryMallocReturnValue tryFastZeroedMalloc(size_t n);
TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size);
TryMallocReturnValue tryFastRealloc(void* p, size_t n);
void* tryFastMalloc(size_t n);
void* tryFastZeroedMalloc(size_t n);
void* tryFastCalloc(size_t n_elements, size_t element_size);
void* tryFastRealloc(void* p, size_t n);
void fastFree(void* p);
......
......@@ -675,10 +675,4 @@
#define WTF_USE_ACCELERATED_COMPOSITING 1
#endif
#if COMPILER(GCC)
#define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result))
#else
#define WARN_UNUSED_RETURN
#endif
#endif /* WTF_Platform_h */
/*
* Copyright (C) 2009 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 PossiblyNull_h
#define PossiblyNull_h
#include "Assertions.h"
namespace WTF {
template <typename T> struct PossiblyNull {
PossiblyNull(T data)
: m_data(data)
{
}
~PossiblyNull() { ASSERT(!m_data); }
bool getValue(T& out) WARN_UNUSED_RETURN;
private:
T m_data;
};
template <typename T> bool PossiblyNull<T>::getValue(T& out)
{
out = m_data;
bool result = !!m_data;
m_data = 0;
return result;
}
}
#endif
2009-07-21 Adam Roben <aroben@apple.com>
Roll out r46153, r46154, and r46155
These changes were causing build failures and assertion failures on
Windows.
* ForwardingHeaders/wtf/PossiblyNull.h: Removed.
* platform/graphics/cg/ImageBufferCG.cpp:
2009-07-21 Jian Li <jianli@chromium.org>
Reviewed by Eric Seidel.
......
#ifndef WebCore_FWD_PossiblyNull_h
#define WebCore_FWD_PossiblyNull_h
#include <JavaScriptCore/PossiblyNull.h>
#endif
......@@ -64,9 +64,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
bytesPerRow *= 4;
}
if (!tryFastCalloc(size.height(), bytesPerRow).getValue(m_data.m_data))
return;
m_data.m_data = tryFastCalloc(size.height(), bytesPerRow);
ASSERT((reinterpret_cast<size_t>(m_data.m_data) & 2) == 0);
CGColorSpaceRef colorSpace = grayScale ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment