mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-27 04:08:36 +00:00
202db2bd0f
- pointer style (34e9d556e) - Bug 1175466 - Allocate arguments objects in the nursery. r=terrence (14e7d019d) - Bug 1175511 - Use template objects for arguments object allocation. r=bhackett (09c43e10e) - Bug 1169250 - Zero-initialize all function object members r=jandem (55e6c44d7) - Bug 987514, part 3 - Make every global have a (usually empty) Reflect object; rename JS_InitReflect -> JS_InitReflectParse. r=Waldo. (f7beebe35) - Bug 987514, part 4 - Implement most of the standard Reflect methods. r=Waldo. (0ee01d6da) - Bug 1160665 - Use the same implementation for both internal and external barriers; r=jonco (5291b100f) - Bug 1175511 - Use template objects for arguments object allocation. r=bhackett (980240980) - Bug 1170182 - Remove dead functions from js/src. r=jorendorff (2f6130fa2) - Bug 1167468: Assert that JSObjects and their metadata are always in the same compartment. r=fitzgen (dc780d455) - Bug 1172138 - Call PR_LogInit before profiler_init. r=froydnj (bd23dafce) - re-add WebM NesteggReporter (b22381367) - Bug 1159507 - make allocation times consistent with timeline; r=fitzgen,mccr8 (3a9c8e3dc) - Bug 1174906 - Add a mozilla::Variant<T1, T2, ...> template class; r=Waldo (7c12bcf74) - Bug 1068988 - Part 1: Add byte size to the allocation log; r=shu (4cbbbd8db) - Bug 1068988 - Part 2: Add a test for byte sizes in the allocations log; r=shu (aa7d187db) - Bug 1068988 - Part 3: Document the size property in the allocations log; r=shu (fa774e0bd) - Bug 1068988 - Part 4: Fix object-pending-metadata root marking; r=shu (89961c6ee) - Bug 1155211: Part 3.1 - Update tests for extractLane; r=h4writer (e8d0da406) - Bug 1155211: Part 3.2 - Remove lanes getters; r=nbp (840230594) - Bug 1155211: Part 3.3 - New tests; r=h4writer (9e8a8a456) - Bug 1174850 - Remove the explicitly relocatable store buffers; r=jonco (02bc4962b) - Bug 1165843 - Don't fire the pre-barrier in HeapPtr destructor r=terrence (d6277ed50) - pointer style (5c58f858d) - Bug 1175642 - Fix the interface that RelocatablePtr uses to interact with the StoreBuffer; r=jonco (30c4c1b47) - Bug 1165054 - Add API to clear postbarrier callbacks and use it when CPOW tables are destroyed r=terrence (e8d62c559) - Bug 1131285 - Propagate checkTypeSet flag correctly, r=jandem. (2baae056d) - re-shufflemethods due to bad patching (5bb9a0ae5) - Bug 977805 followup - Fix some issues with IonCache::reset reprotection. r=luke (11bcad882) - Bug 1180854 - Record and expose Ion IC stub optimization info to Jit Coach. r=shu (fa00fd728) - Bug 1179264 - Only assert markedness of sampled scripts in JitcodeMap during finalization. (r=terrence) (e9639d963) - Bug 1173764 - Enable LAllocation/LUse serialization in optimized builds. r=bhackett (a10398167) - Bug 1173764 - Disable JitSpew argument computation in optimizied builds. r=bhackett (54d0f0b5e) - cleanup spaces and pointer style (d79dba082) - Bug 1175761 - Avoid using types in the nursery during optimization tracking, r=shu. (739174bd3) - Bug 1176511 - Minor GC when tracking types as a better bandaid. (r=terrence) (3913d0b0d) - Bug 1182730 - Mark the JitcodeGlobalTable unconditionally when minor collecting. (r=terrence) (86ace1dcd) - Bug 1182730 - Followup: only mark the JitcodeGlobalMap when profiling is on. (r=djvj) (be105dff4) - Bug 1187512 - Fix accumulated unified bustage in SpiderMonkey; r=jonco (8a663452f) - Bug 1155211: Rename bitselect into selectBits; r=nbp (b644a0731) - Bug 1155211: Remove selectBits on Float types; r=nbp (588ffbc3e) - Bug 1175494 - comprehensive atomics tests for asm.js. r=luke (1ef4b9c1d) - Bug 1141986 - Atomics.exchange on integer elements -- asm.js parts. r=bbouvier (d7eeba2b4) - Bug 1183308 - Fix ARM64 bustage from Bug 1141986. r=efaust (8915a33ac) - real part of previous partial Bug 1038839 - Use type information for alias analysis. r=jandem (98f3ac4f9) - Bug 1148375 - Ignore unhandled Elements. r=jandem (a74a4954e) - Bug 1180990 - Add checks for nursery objects when building MIR. r=jandem (55117882e) - Bug 1180049 - Add OOM check in MNewArray constructor. r=bhackett (95dca3f7d) - Bug 1186271: IonMonkey: Honor truncated flag during folding of binary operations, r=nbp (34d66ad0b) - Bug 1173869: IonMonkey - Cleanup of some dead code in MBinaryArithInstruction::infer, r=jandem (4d42ac15a) - Bug 1193112: IonMonkey - Let the float32 optimization work with Float32, r=bbouvier (fae4514b6)
225 lines
7.1 KiB
C++
225 lines
7.1 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
* vim: set ts=8 sw=4 et tw=80:
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_jsipc_JavaScriptShared_h__
|
|
#define mozilla_jsipc_JavaScriptShared_h__
|
|
|
|
#include "mozilla/dom/DOMTypes.h"
|
|
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
|
#include "mozilla/jsipc/PJavaScript.h"
|
|
#include "nsJSUtils.h"
|
|
|
|
namespace mozilla {
|
|
namespace jsipc {
|
|
|
|
class ObjectId {
|
|
public:
|
|
// Use 47 bits at most, to be safe, since jsval privates are encoded as
|
|
// doubles. See bug 1065811 comment 12 for an explanation.
|
|
static const size_t SERIAL_NUMBER_BITS = 47;
|
|
static const size_t FLAG_BITS = 1;
|
|
static const uint64_t SERIAL_NUMBER_MAX = (uint64_t(1) << SERIAL_NUMBER_BITS) - 1;
|
|
|
|
explicit ObjectId(uint64_t serialNumber, bool hasXrayWaiver)
|
|
: serialNumber_(serialNumber), hasXrayWaiver_(hasXrayWaiver)
|
|
{
|
|
if (MOZ_UNLIKELY(serialNumber == 0 || serialNumber > SERIAL_NUMBER_MAX))
|
|
MOZ_CRASH("Bad CPOW Id");
|
|
}
|
|
|
|
bool operator==(const ObjectId& other) const {
|
|
bool equal = serialNumber() == other.serialNumber();
|
|
MOZ_ASSERT_IF(equal, hasXrayWaiver() == other.hasXrayWaiver());
|
|
return equal;
|
|
}
|
|
|
|
bool isNull() { return !serialNumber_; }
|
|
|
|
uint64_t serialNumber() const { return serialNumber_; }
|
|
bool hasXrayWaiver() const { return hasXrayWaiver_; }
|
|
uint64_t serialize() const {
|
|
MOZ_ASSERT(serialNumber(), "Don't send a null ObjectId over IPC");
|
|
return uint64_t((serialNumber() << FLAG_BITS) | ((hasXrayWaiver() ? 1 : 0) << 0));
|
|
}
|
|
|
|
static ObjectId nullId() { return ObjectId(); }
|
|
static ObjectId deserialize(uint64_t data) {
|
|
return ObjectId(data >> FLAG_BITS, data & 1);
|
|
}
|
|
|
|
private:
|
|
ObjectId() : serialNumber_(0), hasXrayWaiver_(false) {}
|
|
|
|
uint64_t serialNumber_ : SERIAL_NUMBER_BITS;
|
|
bool hasXrayWaiver_ : 1;
|
|
};
|
|
|
|
class JavaScriptShared;
|
|
|
|
// DefaultHasher<T> requires that T coerce to an integral type. We could make
|
|
// ObjectId do that, but doing so would weaken our type invariants, so we just
|
|
// reimplement it manually.
|
|
struct ObjectIdHasher
|
|
{
|
|
typedef ObjectId Lookup;
|
|
static js::HashNumber hash(const Lookup& l) {
|
|
return l.serialize();
|
|
}
|
|
static bool match(const ObjectId& k, const ObjectId& l) {
|
|
return k == l;
|
|
}
|
|
static void rekey(ObjectId& k, const ObjectId& newKey) {
|
|
k = newKey;
|
|
}
|
|
};
|
|
|
|
// Map ids -> JSObjects
|
|
class IdToObjectMap
|
|
{
|
|
typedef js::HashMap<ObjectId, JS::Heap<JSObject*>, ObjectIdHasher, js::SystemAllocPolicy> Table;
|
|
|
|
public:
|
|
IdToObjectMap();
|
|
|
|
bool init();
|
|
void trace(JSTracer* trc);
|
|
void sweep();
|
|
|
|
bool add(ObjectId id, JSObject* obj);
|
|
JSObject* find(ObjectId id);
|
|
void remove(ObjectId id);
|
|
|
|
void clear();
|
|
bool empty() const;
|
|
|
|
private:
|
|
Table table_;
|
|
};
|
|
|
|
// Map JSObjects -> ids
|
|
class ObjectToIdMap
|
|
{
|
|
typedef js::PointerHasher<JSObject*, 3> Hasher;
|
|
typedef js::HashMap<JSObject*, ObjectId, Hasher, js::SystemAllocPolicy> Table;
|
|
|
|
public:
|
|
ObjectToIdMap(JSRuntime* rt);
|
|
~ObjectToIdMap();
|
|
|
|
bool init();
|
|
void trace(JSTracer* trc);
|
|
void sweep();
|
|
|
|
bool add(JSContext* cx, JSObject* obj, ObjectId id);
|
|
ObjectId find(JSObject* obj);
|
|
void remove(JSObject* obj);
|
|
void clear();
|
|
|
|
private:
|
|
static void keyMarkCallback(JSTracer* trc, JSObject* key, void* data);
|
|
|
|
JSRuntime* rt_;
|
|
Table table_;
|
|
};
|
|
|
|
class Logging;
|
|
|
|
class JavaScriptShared : public CPOWManager
|
|
{
|
|
public:
|
|
explicit JavaScriptShared(JSRuntime* rt);
|
|
virtual ~JavaScriptShared();
|
|
|
|
bool init();
|
|
|
|
void decref();
|
|
void incref();
|
|
|
|
bool Unwrap(JSContext* cx, const InfallibleTArray<CpowEntry>& aCpows, JS::MutableHandleObject objp);
|
|
bool Wrap(JSContext* cx, JS::HandleObject aObj, InfallibleTArray<CpowEntry>* outCpows);
|
|
|
|
protected:
|
|
bool toVariant(JSContext* cx, JS::HandleValue from, JSVariant* to);
|
|
bool fromVariant(JSContext* cx, const JSVariant& from, JS::MutableHandleValue to);
|
|
|
|
bool toJSIDVariant(JSContext* cx, JS::HandleId from, JSIDVariant* to);
|
|
bool fromJSIDVariant(JSContext* cx, const JSIDVariant& from, JS::MutableHandleId to);
|
|
|
|
bool toSymbolVariant(JSContext* cx, JS::Symbol* sym, SymbolVariant* symVarp);
|
|
JS::Symbol* fromSymbolVariant(JSContext* cx, SymbolVariant symVar);
|
|
|
|
bool fromDescriptor(JSContext* cx, JS::Handle<JSPropertyDescriptor> desc,
|
|
PPropertyDescriptor* out);
|
|
bool toDescriptor(JSContext* cx, const PPropertyDescriptor& in,
|
|
JS::MutableHandle<JSPropertyDescriptor> out);
|
|
|
|
bool toObjectOrNullVariant(JSContext* cx, JSObject* obj, ObjectOrNullVariant* objVarp);
|
|
JSObject* fromObjectOrNullVariant(JSContext* cx, ObjectOrNullVariant objVar);
|
|
|
|
bool convertIdToGeckoString(JSContext* cx, JS::HandleId id, nsString* to);
|
|
bool convertGeckoStringToId(JSContext* cx, const nsString& from, JS::MutableHandleId id);
|
|
|
|
virtual bool toObjectVariant(JSContext* cx, JSObject* obj, ObjectVariant* objVarp) = 0;
|
|
virtual JSObject* fromObjectVariant(JSContext* cx, ObjectVariant objVar) = 0;
|
|
|
|
static void ConvertID(const nsID& from, JSIID* to);
|
|
static void ConvertID(const JSIID& from, nsID* to);
|
|
|
|
JSObject* findCPOWById(const ObjectId& objId) {
|
|
return cpows_.find(objId);
|
|
}
|
|
JSObject* findObjectById(JSContext* cx, const ObjectId& objId);
|
|
|
|
static bool LoggingEnabled() { return sLoggingEnabled; }
|
|
static bool StackLoggingEnabled() { return sStackLoggingEnabled; }
|
|
|
|
friend class Logging;
|
|
|
|
virtual bool isParent() = 0;
|
|
|
|
virtual JSObject* scopeForTargetObjects() = 0;
|
|
|
|
protected:
|
|
JSRuntime* rt_;
|
|
uintptr_t refcount_;
|
|
|
|
IdToObjectMap objects_;
|
|
IdToObjectMap cpows_;
|
|
|
|
uint64_t nextSerialNumber_;
|
|
|
|
// CPOW references can be weak, and any object we store in a map may be
|
|
// GCed (at which point the CPOW will report itself "dead" to the owner).
|
|
// This means that we don't want to store any js::Wrappers in the CPOW map,
|
|
// because CPOW will die if the wrapper is GCed, even if the underlying
|
|
// object is still alive.
|
|
//
|
|
// This presents a tricky situation for Xray waivers, since they're normally
|
|
// represented as a special same-compartment wrapper. We have to strip them
|
|
// off before putting them in the id-to-object and object-to-id maps, so we
|
|
// need a way of distinguishing them at lookup-time.
|
|
//
|
|
// For the id-to-object map, we encode waiver-or-not information into the id
|
|
// itself, which lets us do the right thing when accessing the object.
|
|
//
|
|
// For the object-to-id map, we just keep two maps, one for each type.
|
|
ObjectToIdMap unwaivedObjectIds_;
|
|
ObjectToIdMap waivedObjectIds_;
|
|
ObjectToIdMap& objectIdMap(bool waiver) {
|
|
return waiver ? waivedObjectIds_ : unwaivedObjectIds_;
|
|
}
|
|
|
|
static bool sLoggingInitialized;
|
|
static bool sLoggingEnabled;
|
|
static bool sStackLoggingEnabled;
|
|
};
|
|
|
|
} // namespace jsipc
|
|
} // namespace mozilla
|
|
|
|
#endif
|