summaryrefslogtreecommitdiffstats
path: root/js/public
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-10 11:39:27 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-10 11:39:27 +0100
commit974a481d12bf430891725bd3662876358e57e11a (patch)
treecad011151456251fef2f1b8d02ef4b4e45fad61a /js/public
parent6bd66b1728eeddb058066edda740aaeb2ceaec23 (diff)
parent736d25cbec4541186ed46c935c117ce4d1c7f3bb (diff)
downloadUXP-974a481d12bf430891725bd3662876358e57e11a.tar
UXP-974a481d12bf430891725bd3662876358e57e11a.tar.gz
UXP-974a481d12bf430891725bd3662876358e57e11a.tar.lz
UXP-974a481d12bf430891725bd3662876358e57e11a.tar.xz
UXP-974a481d12bf430891725bd3662876358e57e11a.zip
Merge branch 'master' into js-modules
# Conflicts: # modules/libpref/init/all.js
Diffstat (limited to 'js/public')
-rw-r--r--js/public/CallArgs.h22
-rw-r--r--js/public/Class.h14
-rw-r--r--js/public/GCAPI.h8
-rw-r--r--js/public/HashTable.h46
-rw-r--r--js/public/LegacyIntTypes.h10
-rw-r--r--js/public/MemoryMetrics.h23
-rw-r--r--js/public/Proxy.h6
-rw-r--r--js/public/Utility.h2
-rw-r--r--js/public/Value.h7
9 files changed, 72 insertions, 66 deletions
diff --git a/js/public/CallArgs.h b/js/public/CallArgs.h
index a7774309a..aae7121ad 100644
--- a/js/public/CallArgs.h
+++ b/js/public/CallArgs.h
@@ -128,7 +128,10 @@ class MOZ_STACK_CLASS CallArgsBase : public WantUsedRval
protected:
Value* argv_;
unsigned argc_;
- bool constructing_;
+ bool constructing_:1;
+
+ // True if the caller does not use the return value.
+ bool ignoresReturnValue_:1;
public:
// CALLEE ACCESS
@@ -164,6 +167,10 @@ class MOZ_STACK_CLASS CallArgsBase : public WantUsedRval
return true;
}
+ bool ignoresReturnValue() const {
+ return ignoresReturnValue_;
+ }
+
MutableHandleValue newTarget() const {
MOZ_ASSERT(constructing_);
return MutableHandleValue::fromMarkedLocation(&this->argv_[argc_]);
@@ -280,14 +287,17 @@ class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase<detail::IncludeUsed
{
private:
friend CallArgs CallArgsFromVp(unsigned argc, Value* vp);
- friend CallArgs CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing);
+ friend CallArgs CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing,
+ bool ignoresReturnValue);
- static CallArgs create(unsigned argc, Value* argv, bool constructing) {
+ static CallArgs create(unsigned argc, Value* argv, bool constructing,
+ bool ignoresReturnValue = false) {
CallArgs args;
args.clearUsedRval();
args.argv_ = argv;
args.argc_ = argc;
args.constructing_ = constructing;
+ args.ignoresReturnValue_ = ignoresReturnValue;
#ifdef DEBUG
for (unsigned i = 0; i < argc; ++i)
MOZ_ASSERT_IF(argv[i].isGCThing(), !GCThingIsMarkedGray(GCCellPtr(argv[i])));
@@ -314,9 +324,11 @@ CallArgsFromVp(unsigned argc, Value* vp)
// eventually move it to an internal header. Embedders should use
// JS::CallArgsFromVp!
MOZ_ALWAYS_INLINE CallArgs
-CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing = false)
+CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing = false,
+ bool ignoresReturnValue = false)
{
- return CallArgs::create(stackSlots - constructing, sp - stackSlots, constructing);
+ return CallArgs::create(stackSlots - constructing, sp - stackSlots, constructing,
+ ignoresReturnValue);
}
} // namespace JS
diff --git a/js/public/Class.h b/js/public/Class.h
index 3b5023875..f7533654b 100644
--- a/js/public/Class.h
+++ b/js/public/Class.h
@@ -425,12 +425,6 @@ typedef bool
(* DeletePropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
JS::ObjectOpResult& result);
-typedef bool
-(* WatchOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable);
-
-typedef bool
-(* UnwatchOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id);
-
class JS_FRIEND_API(ElementAdder)
{
public:
@@ -670,8 +664,6 @@ struct ObjectOps
SetPropertyOp setProperty;
GetOwnPropertyOp getOwnPropertyDescriptor;
DeletePropertyOp deleteProperty;
- WatchOp watch;
- UnwatchOp unwatch;
GetElementsOp getElements;
JSNewEnumerateOp enumerate;
JSFunToStringOp funToString;
@@ -822,8 +814,8 @@ struct Class
* Objects of this class aren't native objects. They don't have Shapes that
* describe their properties and layout. Classes using this flag must
* provide their own property behavior, either by being proxy classes (do
- * this) or by overriding all the ObjectOps except getElements, watch and
- * unwatch (don't do this).
+ * this) or by overriding all the ObjectOps except getElements
+ * (don't do this).
*/
static const uint32_t NON_NATIVE = JSCLASS_INTERNAL_FLAG2;
@@ -900,8 +892,6 @@ struct Class
const { return oOps ? oOps->getOwnPropertyDescriptor
: nullptr; }
DeletePropertyOp getOpsDeleteProperty() const { return oOps ? oOps->deleteProperty : nullptr; }
- WatchOp getOpsWatch() const { return oOps ? oOps->watch : nullptr; }
- UnwatchOp getOpsUnwatch() const { return oOps ? oOps->unwatch : nullptr; }
GetElementsOp getOpsGetElements() const { return oOps ? oOps->getElements : nullptr; }
JSNewEnumerateOp getOpsEnumerate() const { return oOps ? oOps->enumerate : nullptr; }
JSFunToStringOp getOpsFunToString() const { return oOps ? oOps->funToString : nullptr; }
diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h
index 7a6675ca7..4ef2a8370 100644
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -119,14 +119,6 @@ enum Reason {
#undef MAKE_REASON
NO_REASON,
NUM_REASONS,
-
- /*
- * For telemetry, we want to keep a fixed max bucket size over time so we
- * don't have to switch histograms. 100 is conservative; as of this writing
- * there are 52. But the cost of extra buckets seems to be low while the
- * cost of switching histograms is high.
- */
- NUM_TELEMETRY_REASONS = 100
};
/**
diff --git a/js/public/HashTable.h b/js/public/HashTable.h
index 5d4c0665d..8a2493b55 100644
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -12,6 +12,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/Casting.h"
#include "mozilla/HashFunctions.h"
+#include "mozilla/MemoryChecking.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Move.h"
#include "mozilla/Opaque.h"
@@ -805,17 +806,22 @@ class HashTableEntry
void operator=(const HashTableEntry&) = delete;
~HashTableEntry() = delete;
+ void destroyStoredT() {
+ mem.addr()->~T();
+ MOZ_MAKE_MEM_UNDEFINED(mem.addr(), sizeof(*mem.addr()));
+ }
+
public:
// NB: HashTableEntry is treated as a POD: no constructor or destructor calls.
void destroyIfLive() {
if (isLive())
- mem.addr()->~T();
+ destroyStoredT();
}
void destroy() {
MOZ_ASSERT(isLive());
- mem.addr()->~T();
+ destroyStoredT();
}
void swap(HashTableEntry* other) {
@@ -835,10 +841,28 @@ class HashTableEntry
NonConstT& getMutable() { MOZ_ASSERT(isLive()); return *mem.addr(); }
bool isFree() const { return keyHash == sFreeKey; }
- void clearLive() { MOZ_ASSERT(isLive()); keyHash = sFreeKey; mem.addr()->~T(); }
- void clear() { if (isLive()) mem.addr()->~T(); keyHash = sFreeKey; }
+ void clearLive() {
+ MOZ_ASSERT(isLive());
+ keyHash = sFreeKey;
+ destroyStoredT();
+ }
+
+ void clear() {
+ if (isLive())
+ destroyStoredT();
+
+ MOZ_MAKE_MEM_UNDEFINED(this, sizeof(*this));
+ keyHash = sFreeKey;
+ }
+
bool isRemoved() const { return keyHash == sRemovedKey; }
- void removeLive() { MOZ_ASSERT(isLive()); keyHash = sRemovedKey; mem.addr()->~T(); }
+
+ void removeLive() {
+ MOZ_ASSERT(isLive());
+ keyHash = sRemovedKey;
+ destroyStoredT();
+ }
+
bool isLive() const { return isLiveHash(keyHash); }
void setCollision() { MOZ_ASSERT(isLive()); keyHash |= sCollisionBit; }
void unsetCollision() { keyHash &= ~sCollisionBit; }
@@ -1654,14 +1678,10 @@ class HashTable : private AllocPolicy
public:
void clear()
{
- if (mozilla::IsPod<Entry>::value) {
- memset(table, 0, sizeof(*table) * capacity());
- } else {
- uint32_t tableCapacity = capacity();
- Entry* end = table + tableCapacity;
- for (Entry* e = table; e < end; ++e)
- e->clear();
- }
+ Entry* end = table + capacity();
+ for (Entry* e = table; e < end; ++e)
+ e->clear();
+
removedCount = 0;
entryCount = 0;
#ifdef JS_DEBUG
diff --git a/js/public/LegacyIntTypes.h b/js/public/LegacyIntTypes.h
index 2c8498c89..cdfd98726 100644
--- a/js/public/LegacyIntTypes.h
+++ b/js/public/LegacyIntTypes.h
@@ -31,20 +31,10 @@ typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
-/*
- * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very
- * common header file) defines the types int8, int16, int32, and int64.
- * So we don't define these four types here to avoid conflicts in case
- * the code also includes sys/types.h.
- */
-#if defined(AIX) && defined(HAVE_SYS_INTTYPES_H)
-#include <sys/inttypes.h>
-#else
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
-#endif /* AIX && HAVE_SYS_INTTYPES_H */
typedef uint8_t JSUint8;
typedef uint16_t JSUint16;
diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h
index 9b5caa24b..dcc886217 100644
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -11,7 +11,6 @@
// at your own risk.
#include "mozilla/MemoryReporting.h"
-#include "mozilla/PodOperations.h"
#include "mozilla/TypeTraits.h"
#include <string.h>
@@ -37,7 +36,13 @@ struct TabSizes
Other
};
- TabSizes() { mozilla::PodZero(this); }
+ TabSizes()
+ : objects(0)
+ , strings(0)
+ , private_(0)
+ , other(0)
+ {
+ }
void add(Kind kind, size_t n) {
switch (kind) {
@@ -68,7 +73,7 @@ struct ServoSizes
Ignore
};
- ServoSizes() { mozilla::PodZero(this); }
+ ServoSizes() = default;
void add(Kind kind, size_t n) {
switch (kind) {
@@ -83,12 +88,12 @@ struct ServoSizes
}
}
- size_t gcHeapUsed;
- size_t gcHeapUnused;
- size_t gcHeapAdmin;
- size_t gcHeapDecommitted;
- size_t mallocHeap;
- size_t nonHeap;
+ size_t gcHeapUsed = 0;
+ size_t gcHeapUnused = 0;
+ size_t gcHeapAdmin = 0;
+ size_t gcHeapDecommitted = 0;
+ size_t mallocHeap = 0;
+ size_t nonHeap = 0;
};
} // namespace JS
diff --git a/js/public/Proxy.h b/js/public/Proxy.h
index 5acb91b26..f40772fb0 100644
--- a/js/public/Proxy.h
+++ b/js/public/Proxy.h
@@ -341,12 +341,6 @@ class JS_FRIEND_API(BaseProxyHandler)
virtual bool isCallable(JSObject* obj) const;
virtual bool isConstructor(JSObject* obj) const;
- // These two hooks must be overridden, or not overridden, in tandem -- no
- // overriding just one!
- virtual bool watch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
- JS::HandleObject callable) const;
- virtual bool unwatch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id) const;
-
virtual bool getElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end,
ElementAdder* adder) const;
diff --git a/js/public/Utility.h b/js/public/Utility.h
index 68de3004a..99712faa8 100644
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -391,7 +391,7 @@ js_delete_poison(const T* p)
{
if (p) {
p->~T();
- memset(const_cast<T*>(p), 0x3B, sizeof(T));
+ memset(static_cast<void*>(const_cast<T*>(p)), 0x3B, sizeof(T));
js_free(const_cast<T*>(p));
}
}
diff --git a/js/public/Value.h b/js/public/Value.h
index 01666ed4e..7c4f833e3 100644
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -567,8 +567,11 @@ class MOZ_NON_PARAM alignas(8) Value
}
bool isMagic(JSWhyMagic why) const {
- MOZ_ASSERT_IF(isMagic(), data.s.payload.why == why);
- return isMagic();
+ if (!isMagic()) {
+ return false;
+ }
+ MOZ_RELEASE_ASSERT(data.s.payload.why == why);
+ return true;
}
JS::TraceKind traceKind() const {