mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Backout changeset e931fb581aee (Bug 673473) due to trace malloc regression on OSX.
This commit is contained in:
parent
94181da50c
commit
8f4398e1d0
@ -242,7 +242,10 @@ private:
|
||||
class CreateIndexHelper : public AsyncConnectionHelper
|
||||
{
|
||||
public:
|
||||
CreateIndexHelper(IDBTransaction* aTransaction, IDBIndex* aIndex);
|
||||
CreateIndexHelper(IDBTransaction* aTransaction,
|
||||
IDBIndex* aIndex)
|
||||
: AsyncConnectionHelper(aTransaction, nsnull), mIndex(aIndex)
|
||||
{ }
|
||||
|
||||
nsresult DoDatabaseWork(mozIStorageConnection* aConnection);
|
||||
|
||||
@ -265,17 +268,10 @@ public:
|
||||
private:
|
||||
nsresult InsertDataFromObjectStore(mozIStorageConnection* aConnection);
|
||||
|
||||
static void DestroyTLSEntry(void* aPtr);
|
||||
|
||||
static PRUintn sTLSIndex;
|
||||
|
||||
// In-params.
|
||||
nsRefPtr<IDBIndex> mIndex;
|
||||
};
|
||||
|
||||
static const PRUintn BAD_TLS_INDEX = (PRUint32)-1;
|
||||
PRUintn CreateIndexHelper::sTLSIndex = BAD_TLS_INDEX;
|
||||
|
||||
class DeleteIndexHelper : public AsyncConnectionHelper
|
||||
{
|
||||
public:
|
||||
@ -595,7 +591,7 @@ nsresult
|
||||
IDBObjectStore::GetKeyPathValueFromStructuredData(const PRUint8* aData,
|
||||
PRUint32 aDataLength,
|
||||
const nsAString& aKeyPath,
|
||||
JSContext* aCx,
|
||||
JSContext** aCx,
|
||||
Key& aValue)
|
||||
{
|
||||
NS_ASSERTION(aData, "Null pointer!");
|
||||
@ -603,10 +599,18 @@ IDBObjectStore::GetKeyPathValueFromStructuredData(const PRUint8* aData,
|
||||
NS_ASSERTION(!aKeyPath.IsEmpty(), "Empty keyPath!");
|
||||
NS_ASSERTION(aCx, "Null pointer!");
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
nsresult rv;
|
||||
|
||||
if (!*aCx) {
|
||||
rv = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(aCx);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
}
|
||||
JSContext*& cx = *aCx;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
jsval clone;
|
||||
if (!JS_ReadStructuredClone(aCx, reinterpret_cast<const uint64*>(aData),
|
||||
if (!JS_ReadStructuredClone(cx, reinterpret_cast<const uint64*>(aData),
|
||||
aDataLength, JS_STRUCTURED_CLONE_VERSION,
|
||||
&clone, NULL, NULL)) {
|
||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
||||
@ -625,10 +629,10 @@ IDBObjectStore::GetKeyPathValueFromStructuredData(const PRUint8* aData,
|
||||
const size_t keyPathLen = aKeyPath.Length();
|
||||
|
||||
jsval keyVal;
|
||||
JSBool ok = JS_GetUCProperty(aCx, obj, keyPathChars, keyPathLen, &keyVal);
|
||||
JSBool ok = JS_GetUCProperty(cx, obj, keyPathChars, keyPathLen, &keyVal);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
nsresult rv = GetKeyFromJSVal(keyVal, aCx, aValue);
|
||||
rv = GetKeyFromJSVal(keyVal, *aCx, aValue);
|
||||
if (NS_FAILED(rv)) {
|
||||
// If the object doesn't have a value that we can use for our index then we
|
||||
// leave it unset.
|
||||
@ -2200,87 +2204,6 @@ OpenCursorHelper::GetSuccessResult(JSContext* aCx,
|
||||
return WrapNative(aCx, cursor, aVal);
|
||||
}
|
||||
|
||||
class ThreadLocalJSRuntime
|
||||
{
|
||||
JSRuntime* mRuntime;
|
||||
JSContext* mContext;
|
||||
JSObject* mGlobal;
|
||||
|
||||
static JSClass sGlobalClass;
|
||||
static const unsigned sRuntimeHeapSize = 64 * 1024; // should be enough for anyone
|
||||
|
||||
ThreadLocalJSRuntime() : mRuntime(NULL), mContext(NULL), mGlobal(NULL) {}
|
||||
|
||||
nsresult Init()
|
||||
{
|
||||
mRuntime = JS_NewRuntime(sRuntimeHeapSize);
|
||||
NS_ENSURE_TRUE(mRuntime, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mContext = JS_NewContext(mRuntime, 0);
|
||||
NS_ENSURE_TRUE(mContext, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JSAutoRequest ar(mContext);
|
||||
|
||||
mGlobal = JS_NewCompartmentAndGlobalObject(mContext, &sGlobalClass, NULL);
|
||||
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS_SetGlobalObject(mContext, mGlobal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
public:
|
||||
static ThreadLocalJSRuntime *Create()
|
||||
{
|
||||
ThreadLocalJSRuntime *entry = new ThreadLocalJSRuntime();
|
||||
NS_ENSURE_TRUE(entry, nsnull);
|
||||
|
||||
if (NS_FAILED(entry->Init())) {
|
||||
delete entry;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
JSContext *Context() const
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
~ThreadLocalJSRuntime()
|
||||
{
|
||||
if (mContext) {
|
||||
JS_DestroyContext(mContext);
|
||||
}
|
||||
|
||||
if (mRuntime) {
|
||||
JS_DestroyRuntime(mRuntime);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
JSClass ThreadLocalJSRuntime::sGlobalClass = {
|
||||
"IndexedDBTransactionThreadGlobal",
|
||||
JSCLASS_GLOBAL_FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
CreateIndexHelper::CreateIndexHelper(IDBTransaction* aTransaction,
|
||||
IDBIndex* aIndex)
|
||||
: AsyncConnectionHelper(aTransaction, nsnull), mIndex(aIndex)
|
||||
{
|
||||
if (sTLSIndex == BAD_TLS_INDEX) {
|
||||
PR_NewThreadPrivateIndex(&sTLSIndex, DestroyTLSEntry);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CreateIndexHelper::DestroyTLSEntry(void* aPtr)
|
||||
{
|
||||
delete reinterpret_cast<ThreadLocalJSRuntime *>(aPtr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CreateIndexHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||
{
|
||||
@ -2411,22 +2334,11 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection)
|
||||
rv = stmt->GetSharedBlob(1, &dataLength, &data);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
NS_ENSURE_TRUE(sTLSIndex != BAD_TLS_INDEX, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
ThreadLocalJSRuntime* tlsEntry =
|
||||
reinterpret_cast<ThreadLocalJSRuntime*>(PR_GetThreadPrivate(sTLSIndex));
|
||||
|
||||
if (!tlsEntry) {
|
||||
tlsEntry = ThreadLocalJSRuntime::Create();
|
||||
NS_ENSURE_TRUE(tlsEntry, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
PR_SetThreadPrivate(sTLSIndex, tlsEntry);
|
||||
}
|
||||
|
||||
Key key;
|
||||
JSContext* cx = nsnull;
|
||||
rv = IDBObjectStore::GetKeyPathValueFromStructuredData(data, dataLength,
|
||||
mIndex->KeyPath(),
|
||||
tlsEntry->Context(), key);
|
||||
&cx, key);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (key.IsUnset()) {
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
GetKeyPathValueFromStructuredData(const PRUint8* aData,
|
||||
PRUint32 aDataLength,
|
||||
const nsAString& aKeyPath,
|
||||
JSContext* aCx,
|
||||
JSContext** aCx,
|
||||
Key& aValue);
|
||||
|
||||
static nsresult
|
||||
|
Loading…
Reference in New Issue
Block a user