Merge mozilla-central to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2016-04-16 11:23:40 +02:00
Родитель 27a66d7020 558930f4e9
Коммит 63dd433e61
6 изменённых файлов: 73 добавлений и 39 удалений

Просмотреть файл

@ -137,6 +137,8 @@ parseMessage(ZeroCopyInputStream& stream, uint32_t sizeOfMessage, MessageType& m
template<typename CharT, typename InternedStringSet>
struct GetOrInternStringMatcher
{
using ReturnType = const CharT*;
InternedStringSet& internedStrings;
explicit GetOrInternStringMatcher(InternedStringSet& strings) : internedStrings(strings) { }
@ -858,6 +860,8 @@ class TwoByteString : public Variant<JSAtom*, const char16_t*, JS::ubi::EdgeName
struct AsTwoByteStringMatcher
{
using ReturnType = TwoByteString;
TwoByteString match(JSAtom* atom) {
return TwoByteString(atom);
}
@ -869,12 +873,16 @@ class TwoByteString : public Variant<JSAtom*, const char16_t*, JS::ubi::EdgeName
struct IsNonNullMatcher
{
using ReturnType = bool;
template<typename T>
bool match(const T& t) { return t != nullptr; }
};
struct LengthMatcher
{
using ReturnType = size_t;
size_t match(JSAtom* atom) {
MOZ_ASSERT(atom);
JS::ubi::AtomOrTwoByteChars s(atom);
@ -894,6 +902,8 @@ class TwoByteString : public Variant<JSAtom*, const char16_t*, JS::ubi::EdgeName
struct CopyToBufferMatcher
{
using ReturnType = size_t;
RangedPtr<char16_t> destination;
size_t maxLength;
@ -975,6 +985,8 @@ struct TwoByteString::HashPolicy {
using Lookup = TwoByteString;
struct HashingMatcher {
using ReturnType = js::HashNumber;
js::HashNumber match(const JSAtom* atom) {
return js::DefaultHasher<const JSAtom*>::hash(atom);
}
@ -997,6 +1009,7 @@ struct TwoByteString::HashPolicy {
}
struct EqualityMatcher {
using ReturnType = bool;
const TwoByteString& rhs;
explicit EqualityMatcher(const TwoByteString& rhs) : rhs(rhs) { }

Просмотреть файл

@ -1938,6 +1938,8 @@ ScriptSource::chars(JSContext* cx, UncompressedSourceCache::AutoHoldEntry& holde
{
struct CharsMatcher
{
using ReturnType = const char16_t*;
JSContext* cx;
ScriptSource& ss;
UncompressedSourceCache::AutoHoldEntry& holder;
@ -1949,11 +1951,11 @@ ScriptSource::chars(JSContext* cx, UncompressedSourceCache::AutoHoldEntry& holde
, holder(holder)
{ }
const char16_t* match(Uncompressed& u) {
ReturnType match(Uncompressed& u) {
return u.chars;
}
const char16_t* match(Compressed& c) {
ReturnType match(Compressed& c) {
if (const char16_t* decompressed = cx->runtime()->uncompressedSourceCache.lookup(&ss, holder))
return decompressed;
@ -1982,16 +1984,18 @@ ScriptSource::chars(JSContext* cx, UncompressedSourceCache::AutoHoldEntry& holde
return decompressed;
}
const char16_t* match(Parent& p) {
ReturnType match(Parent& p) {
return p.parent->chars(cx, holder);
}
const char16_t* match(Missing&) {
ReturnType match(Missing&) {
MOZ_CRASH("ScriptSource::chars() on ScriptSource with SourceType = Missing");
return nullptr;
}
};
return data.match(CharsMatcher(cx, *this, holder));
CharsMatcher cm(cx, *this, holder);
return data.match(cm);
}
JSFlatString*
@ -2188,28 +2192,30 @@ ScriptSource::~ScriptSource()
{
struct DestroyMatcher
{
using ReturnType = void;
ScriptSource& ss;
explicit DestroyMatcher(ScriptSource& ss)
: ss(ss)
{ }
void match(Uncompressed& u) {
ReturnType match(Uncompressed& u) {
if (u.ownsChars)
js_free(const_cast<char16_t*>(u.chars));
}
void match(Compressed& c) {
ReturnType match(Compressed& c) {
if (ss.inCompressedSourceSet)
TlsPerThreadData.get()->runtimeFromMainThread()->compressedSourceSet.remove(&ss);
js_free(c.raw);
}
void match(Parent& p) {
ReturnType match(Parent& p) {
p.parent->decref();
}
void match(Missing&) {
ReturnType match(Missing&) {
// Nothing to do here.
}
};
@ -2217,7 +2223,8 @@ ScriptSource::~ScriptSource()
MOZ_ASSERT(refs == 0);
MOZ_ASSERT_IF(inCompressedSourceSet, data.is<Compressed>());
data.match(DestroyMatcher(*this));
DestroyMatcher dm(*this);
data.match(dm);
}
void
@ -2240,19 +2247,21 @@ ScriptSource::performXDR(XDRState<mode>* xdr)
{
struct CompressedLengthMatcher
{
size_t match(Uncompressed&) {
using ReturnType = size_t;
ReturnType match(Uncompressed&) {
return 0;
}
size_t match(Compressed& c) {
ReturnType match(Compressed& c) {
return c.nbytes;
}
size_t match(Parent& p) {
ReturnType match(Parent& p) {
return p.parent->data.match(*this);
}
size_t match(Missing&) {
ReturnType match(Missing&) {
MOZ_CRASH("Missing source data in ScriptSource::performXDR");
return 0;
}
@ -2260,19 +2269,21 @@ ScriptSource::performXDR(XDRState<mode>* xdr)
struct RawDataMatcher
{
void* match(Uncompressed& u) {
using ReturnType = void*;
ReturnType match(Uncompressed& u) {
return (void*) u.chars;
}
void* match(Compressed& c) {
ReturnType match(Compressed& c) {
return c.raw;
}
void* match(Parent& p) {
ReturnType match(Parent& p) {
return p.parent->data.match(*this);
}
void* match(Missing&) {
ReturnType match(Missing&) {
MOZ_CRASH("Missing source data in ScriptSource::performXDR");
return nullptr;
}
@ -2292,8 +2303,10 @@ ScriptSource::performXDR(XDRState<mode>* xdr)
return false;
uint32_t compressedLength;
if (mode == XDR_ENCODE)
compressedLength = data.match(CompressedLengthMatcher());
if (mode == XDR_ENCODE) {
CompressedLengthMatcher m;
compressedLength = data.match(m);
}
if (!xdr->codeUint32(&compressedLength))
return false;
@ -2321,7 +2334,8 @@ ScriptSource::performXDR(XDRState<mode>* xdr)
else
setSource((const char16_t*) p, length_);
} else {
void* p = data.match(RawDataMatcher());
RawDataMatcher rdm;
void* p = data.match(rdm);
if (!xdr->codeBytes(p, byteLen))
return false;
}

Просмотреть файл

@ -1560,6 +1560,8 @@ ConcreteStackFrame<SavedFrame>::constructSavedFrameStack(JSContext* cx,
// `JS::ubi::AtomOrTwoByteChars` string to a `JSAtom*`.
struct MOZ_STACK_CLASS AtomizingMatcher
{
using ReturnType = JSAtom*;
JSContext* cx;
size_t length;

Просмотреть файл

@ -55,6 +55,8 @@ using JS::ubi::TracerConcreteWithCompartment;
struct CopyToBufferMatcher
{
using ReturnType = size_t;
RangedPtr<char16_t> destination;
size_t maxLength;
@ -106,6 +108,8 @@ JS::ubi::AtomOrTwoByteChars::copyToBuffer(RangedPtr<char16_t> destination, size_
struct LengthMatcher
{
using ReturnType = size_t;
size_t
match(JSAtom* atom)
{

Просмотреть файл

@ -169,11 +169,10 @@ struct VariantImplementation<N, T> {
return aLhs.template as<T>() == aRhs.template as<T>();
}
template<typename Matcher, typename ConcreteVariant>
static auto
match(Matcher&& aMatcher, ConcreteVariant& aV)
-> decltype(aMatcher.match(aV.template as<T>()))
{
template<typename Matcher, typename ConcreteVariant,
typename ReturnType = typename RemoveReference<Matcher>::Type::ReturnType>
static ReturnType
match(Matcher&& aMatcher, ConcreteVariant& aV) {
return aMatcher.match(aV.template as<T>());
}
};
@ -227,10 +226,10 @@ struct VariantImplementation<N, T, Ts...>
}
}
template<typename Matcher, typename ConcreteVariant>
static auto
template<typename Matcher, typename ConcreteVariant,
typename ReturnType = typename RemoveReference<Matcher>::Type::ReturnType>
static ReturnType
match(Matcher&& aMatcher, ConcreteVariant& aV)
-> decltype(aMatcher.match(aV.template as<T>()))
{
if (aV.template is<T>()) {
return aMatcher.match(aV.template as<T>());
@ -244,7 +243,7 @@ struct VariantImplementation<N, T, Ts...>
// initialize return object of type <...> with an rvalue of type
// <...>" then that means that the Matcher::match(T&) overloads
// are returning different types. They must all return the same
// type.
// Matcher::ReturnType type.
return Next::match(aMatcher, aV);
}
}
@ -371,11 +370,11 @@ struct AsVariantTemporary
* // Good!
* struct FooMatcher
* {
* // The return type of all matchers must be idential.
* char* match(A& a) { ... }
* char* match(B& b) { ... }
* char* match(C& c) { ... }
* char* match(D& d) { ... } // Compile-time error to forget D!
* using ReturnType = char*;
* ReturnType match(A& a) { ... }
* ReturnType match(B& b) { ... }
* ReturnType match(C& c) { ... }
* ReturnType match(D& d) { ... } // Compile-time error to forget D!
* }
* char* foo(Variant<A, B, C, D>& v) {
* return v.match(FooMatcher());
@ -559,15 +558,15 @@ public:
/** Match on an immutable const reference. */
template<typename Matcher>
auto
match(Matcher&& aMatcher) const -> decltype(Impl::match(aMatcher, *this)) {
typename RemoveReference<Matcher>::Type::ReturnType
match(Matcher&& aMatcher) const {
return Impl::match(aMatcher, *this);
}
/** Match on a mutable non-const reference. */
template<typename Matcher>
auto
match(Matcher&& aMatcher) -> decltype(Impl::match(aMatcher, *this)) {
typename RemoveReference<Matcher>::Type::ReturnType
match(Matcher&& aMatcher) {
return Impl::match(aMatcher, *this);
}
};

Просмотреть файл

@ -129,6 +129,8 @@ struct Describer
static const char* medium;
static const char* big;
using ReturnType = const char*;
const char* match(const uint8_t&) { return little; }
const char* match(const uint32_t&) { return medium; }
const char* match(const uint64_t&) { return big; }