Skip to content

Commit

Permalink
Merge mozilla-central and inbound
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Morley committed May 1, 2014
2 parents a1d3ea4 + b4d126f commit be6c4cd
Show file tree
Hide file tree
Showing 39 changed files with 1,639 additions and 517 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ function test() {
{
info("disk storage contains " + num + " entries");
},
onCacheEntryInfo: function(entry)
onCacheEntryInfo: function(uri)
{
info(entry.key);
is(entry.key.contains(filename), false, "web content present in disk cache");
var urispec = uri.asciiSpec;
info(urispec);
is(urispec.contains(filename), false, "web content present in disk cache");
},
onCacheEntryVisitCompleted: function()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ function getStorageEntryCount(device, goon) {
entryCount: 0,
onCacheStorageInfo: function (aEntryCount, aConsumption) {
},
onCacheEntryInfo: function(entry)
onCacheEntryInfo: function(uri)
{
info(device + ":" + entry.key + "\n");
if (entry.key.match(/^http:\/\/example.org\//))
var urispec = uri.asciiSpec;
info(device + ":" + urispec + "\n");
if (urispec.match(/^http:\/\/example.org\//))
++this.entryCount;
},
onCacheEntryVisitCompleted: function()
Expand Down
7 changes: 4 additions & 3 deletions browser/devtools/styleeditor/test/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ function checkDiskCacheFor(host, done)
{
info("disk storage contains " + num + " entries");
},
onCacheEntryInfo: function(entry)
onCacheEntryInfo: function(uri)
{
info(entry.key);
foundPrivateData |= entry.key.contains(host);
var urispec = uri.asciiSpec;
info(urispec);
foundPrivateData |= urispec.contains(host);
},
onCacheEntryVisitCompleted: function()
{
Expand Down
9 changes: 9 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -5887,6 +5887,15 @@ if test "$MOZ_GAMEPAD"; then
MOZ_GAMEPAD_BACKEND=cocoa
;;
WINNT)
case "$MOZ_WINSDK_MAXVER" in
# We support building with the Windows 7 SDK otherwise, but
# Gamepad support requires the Windows 8 SDK for some HID headers.
0x0601*)
AC_MSG_ERROR([The Windows 8 SDK or newer is required to build Gamepad support. Please install a newer Windows SDK or reconfigure with --disable-gamepad to disable gamepad support.])
;;
*)
;;
esac
MOZ_GAMEPAD_BACKEND=windows
;;
Linux)
Expand Down
4 changes: 2 additions & 2 deletions content/canvas/src/CanvasRenderingContext2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,8 @@ CanvasRenderingContext2D::CheckSizeForSkiaGL(IntSize size) {
}
}

int32_t threshold = gDefaultScale > 0 ? ceil(gDefaultScale * gScreenPixels)
: gScreenPixels;
double scale = gDefaultScale > 0 ? gDefaultScale : 1.0;
int32_t threshold = ceil(scale * scale * gScreenPixels);

// screen size acts as max threshold
return threshold < 0 || (size.width * size.height) <= threshold;
Expand Down
8 changes: 8 additions & 0 deletions js/src/jit-test/tests/basic/bug1003161.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

function foo(a, b) {
function bar() {
return b;
}
return arguments[0] + arguments[1] + bar();
}
foo(1, 2);
42 changes: 39 additions & 3 deletions js/src/jit/IonAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,21 +2371,25 @@ jit::AnalyzeNewScriptProperties(JSContext *cx, JSFunction *fun,
}

static bool
ArgumentsUseCanBeLazy(JSContext *cx, JSScript *script, MInstruction *ins, size_t index)
ArgumentsUseCanBeLazy(JSContext *cx, JSScript *script, MInstruction *ins, size_t index,
bool *argumentsContentsObserved)
{
// We can read the frame's arguments directly for f.apply(x, arguments).
if (ins->isCall()) {
if (*ins->toCall()->resumePoint()->pc() == JSOP_FUNAPPLY &&
ins->toCall()->numActualArgs() == 2 &&
index == MCall::IndexOfArgument(1))
{
*argumentsContentsObserved = true;
return true;
}
}

// arguments[i] can read fp->canonicalActualArg(i) directly.
if (ins->isCallGetElement() && index == 0)
if (ins->isCallGetElement() && index == 0) {
*argumentsContentsObserved = true;
return true;
}

// arguments.length length can read fp->numActualArgs() directly.
if (ins->isCallGetProperty() && index == 0 && ins->toCallGetProperty()->name() == cx->names().length)
Expand All @@ -2408,6 +2412,26 @@ jit::AnalyzeArgumentsUsage(JSContext *cx, JSScript *scriptArg)
// and also simplifies handling of early returns.
script->setNeedsArgsObj(true);

// Always construct arguments objects when in debug mode and for generator
// scripts (generators can be suspended when speculation fails).
//
// FIXME: Don't build arguments for ES6 generator expressions.
if (cx->compartment()->debugMode() || script->isGenerator())
return true;

// If the script has dynamic name accesses which could reach 'arguments',
// the parser will already have checked to ensure there are no explicit
// uses of 'arguments' in the function. If there are such uses, the script
// will be marked as definitely needing an arguments object.
//
// New accesses on 'arguments' can occur through 'eval' or the debugger
// statement. In the former case, we will dynamically detect the use and
// mark the arguments optimization as having failed.
if (script->bindingsAccessedDynamically()) {
script->setNeedsArgsObj(false);
return true;
}

if (!jit::IsIonEnabled(cx) || !script->compileAndGo())
return true;

Expand Down Expand Up @@ -2470,17 +2494,29 @@ jit::AnalyzeArgumentsUsage(JSContext *cx, JSScript *scriptArg)

MDefinition *argumentsValue = graph.begin()->getSlot(info.argsObjSlot());

bool argumentsContentsObserved = false;

for (MUseDefIterator uses(argumentsValue); uses; uses++) {
MDefinition *use = uses.def();

// Don't track |arguments| through assignments to phis.
if (!use->isInstruction())
return true;

if (!ArgumentsUseCanBeLazy(cx, script, use->toInstruction(), uses.index()))
if (!ArgumentsUseCanBeLazy(cx, script, use->toInstruction(), uses.index(),
&argumentsContentsObserved))
{
return true;
}
}

// If a script explicitly accesses the contents of 'arguments', and has
// formals which may be stored as part of a call object, don't use lazy
// arguments. The compiler can then assume that accesses through
// arguments[i] will be on unaliased variables.
if (script->funHasAnyAliasedFormal() && argumentsContentsObserved)
return true;

script->setNeedsArgsObj(false);
return true;
}
13 changes: 12 additions & 1 deletion netwerk/cache2/AppCacheStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,18 @@ NS_IMETHODIMP AppCacheStorage::AsyncVisitStorage(nsICacheStorageVisitor* aVisito

LOG(("AppCacheStorage::AsyncVisitStorage [this=%p, cb=%p]", this, aVisitor));

return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv;

nsCOMPtr<nsICacheService> serv =
do_GetService(NS_CACHESERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);

nsRefPtr<_OldVisitCallbackWrapper> cb = new _OldVisitCallbackWrapper(
"offline", aVisitor, aVisitEntries, LoadInfo());
rv = serv->VisitEntries(cb);
NS_ENSURE_SUCCESS(rv, rv);

return NS_OK;
}

} // net
Expand Down
9 changes: 8 additions & 1 deletion netwerk/cache2/CacheEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,13 @@ NS_IMETHODIMP CacheEntry::SetMetaDataElement(const char * aKey, const char * aVa
return mFile->SetElement(aKey, aValue);
}

NS_IMETHODIMP CacheEntry::VisitMetaData(nsICacheEntryMetaDataVisitor *aVisitor)
{
NS_ENSURE_SUCCESS(mFileStatus, NS_ERROR_NOT_AVAILABLE);

return mFile->VisitMetaData(aVisitor);
}

NS_IMETHODIMP CacheEntry::MetaDataReady()
{
mozilla::MutexAutoLock lock(mLock);
Expand Down Expand Up @@ -1467,7 +1474,7 @@ void CacheEntry::BackgroundOp(uint32_t aOperations, bool aForceAsync)
#endif

// Half-life is dynamic, in seconds.
static double half_life = CacheObserver::HalfLifeSeconds();
static double half_life = CacheObserver::HalfLifeSeconds();
// Must convert from seconds to milliseconds since PR_Now() gives usecs.
static double const decay = (M_LN2 / half_life) / static_cast<double>(PR_USEC_PER_SEC);

Expand Down
11 changes: 11 additions & 0 deletions netwerk/cache2/CacheFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,17 @@ CacheFile::SetElement(const char *aKey, const char *aValue)
return mMetadata->SetElement(aKey, aValue);
}

nsresult
CacheFile::VisitMetaData(nsICacheEntryMetaDataVisitor *aVisitor)
{
CacheFileAutoLock lock(this);
MOZ_ASSERT(mMetadata);
MOZ_ASSERT(mReady);
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);

return mMetadata->Visit(aVisitor);
}

nsresult
CacheFile::ElementsSize(uint32_t *_retval)
{
Expand Down
2 changes: 2 additions & 0 deletions netwerk/cache2/CacheFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

class nsIInputStream;
class nsIOutputStream;
class nsICacheEntryMetaDataVisitor;

namespace mozilla {
namespace net {
Expand Down Expand Up @@ -85,6 +86,7 @@ class CacheFile : public CacheFileChunkListener
// metadata forwarders
nsresult GetElement(const char *aKey, char **_retval);
nsresult SetElement(const char *aKey, const char *aValue);
nsresult VisitMetaData(nsICacheEntryMetaDataVisitor *aVisitor);
nsresult ElementsSize(uint32_t *_retval);
nsresult SetExpirationTime(uint32_t aExpirationTime);
nsresult GetExpirationTime(uint32_t *_retval);
Expand Down
88 changes: 88 additions & 0 deletions netwerk/cache2/CacheFileIOManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "nsISimpleEnumerator.h"
#include "nsIDirectoryEnumerator.h"
#include "nsIObserverService.h"
#include "nsICacheStorageVisitor.h"
#include "nsISizeOf.h"
#include "mozilla/Telemetry.h"
#include "mozilla/DebugOnly.h"
Expand All @@ -28,6 +29,7 @@
#include "private/pprio.h"
#include "mozilla/VisualEventTracer.h"
#include "mozilla/Preferences.h"
#include "nsNetUtil.h"

// include files for ftruncate (or equivalent)
#if defined(XP_UNIX)
Expand Down Expand Up @@ -2212,6 +2214,92 @@ void CacheFileIOManager::GetCacheDirectory(nsIFile** result)
file.forget(result);
}

// static
nsresult
CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash,
CacheStorageService::EntryInfoCallback *aCallback)
{
MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());

nsresult rv;

nsRefPtr<CacheFileIOManager> ioMan = gInstance;
if (!ioMan) {
return NS_ERROR_NOT_INITIALIZED;
}

nsAutoCString enhanceId;
nsAutoCString uriSpec;

nsRefPtr<CacheFileHandle> handle;
ioMan->mHandles.GetHandle(aHash, false, getter_AddRefs(handle));
if (handle) {
nsRefPtr<nsILoadContextInfo> info =
CacheFileUtils::ParseKey(handle->Key(), &enhanceId, &uriSpec);

MOZ_ASSERT(info);
if (!info) {
return NS_OK; // ignore
}

nsRefPtr<CacheStorageService> service = CacheStorageService::Self();
if (!service) {
return NS_ERROR_NOT_INITIALIZED;
}

// Invokes OnCacheEntryInfo when an existing entry is found
if (service->GetCacheEntryInfo(info, enhanceId, uriSpec, aCallback)) {
return NS_OK;
}

// When we are here, there is no existing entry and we need
// to synchrnously load metadata from a disk file.
}

// Locate the actual file
nsCOMPtr<nsIFile> file;
ioMan->GetFile(aHash, getter_AddRefs(file));

// Read metadata from the file synchronously
nsRefPtr<CacheFileMetadata> metadata = new CacheFileMetadata();
rv = metadata->SyncReadMetadata(file);
if (NS_FAILED(rv)) {
return NS_OK;
}

// Now get the context + enhance id + URL from the key.
nsAutoCString key;
metadata->GetKey(key);

nsRefPtr<nsILoadContextInfo> info =
CacheFileUtils::ParseKey(key, &enhanceId, &uriSpec);
MOZ_ASSERT(info);
if (!info) {
return NS_OK;
}

// Pick all data to pass to the callback.
int64_t dataSize = metadata->Offset();
uint32_t fetchCount;
if (NS_FAILED(metadata->GetFetchCount(&fetchCount))) {
fetchCount = 0;
}
uint32_t expirationTime;
if (NS_FAILED(metadata->GetExpirationTime(&expirationTime))) {
expirationTime = 0;
}
uint32_t lastModified;
if (NS_FAILED(metadata->GetLastModified(&lastModified))) {
lastModified = 0;
}

// Call directly on the callback.
aCallback->OnEntryInfo(uriSpec, enhanceId, dataSize, fetchCount,
lastModified, expirationTime);

return NS_OK;
}

static nsresult
TruncFile(PRFileDesc *aFD, uint32_t aEOF)
{
Expand Down
9 changes: 9 additions & 0 deletions netwerk/cache2/CacheFileIOManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define CacheFileIOManager__h__

#include "CacheIOThread.h"
#include "CacheStorageService.h"
#include "nsIEventTarget.h"
#include "nsITimer.h"
#include "nsCOMPtr.h"
Expand All @@ -22,6 +23,7 @@ class nsIFile;
class nsITimer;
class nsIDirectoryEnumerator;
class nsILoadContextInfo;
class nsICacheStorageVisitor;

namespace mozilla {
namespace net {
Expand Down Expand Up @@ -278,6 +280,13 @@ class CacheFileIOManager : public nsITimerCallback

static void GetCacheDirectory(nsIFile** result);

// Calls synchronously OnEntryInfo for an entry with the given hash.
// Tries to find an existing entry in the service hashtables first, if not
// found, loads synchronously from disk file.
// Callable on the IO thread only.
static nsresult GetEntryInfo(const SHA1Sum::Hash *aHash,
CacheStorageService::EntryInfoCallback *aCallback);

// Memory reporting
static size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
static size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
Expand Down
Loading

0 comments on commit be6c4cd

Please sign in to comment.