mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-29 10:08:38 +00:00
Merge remote-tracking branch 'origin/master' into media-works
This commit is contained in:
@@ -3157,8 +3157,8 @@ bool
|
||||
nsGlobalWindow::DialogsAreBeingAbused()
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
NS_ASSERTION(GetScriptableTop() &&
|
||||
GetScriptableTop()->GetCurrentInnerWindowInternal() == this,
|
||||
NS_ASSERTION(GetScriptableTopInternal() &&
|
||||
GetScriptableTopInternal()->GetCurrentInnerWindowInternal() == this,
|
||||
"DialogsAreBeingAbused called with invalid window");
|
||||
|
||||
if (mLastDialogQuitTime.IsNull() ||
|
||||
|
||||
@@ -252,7 +252,7 @@ CollectWindowReports(nsGlobalWindow *aWindow,
|
||||
nsCOMPtr<nsIURI> location;
|
||||
if (aWindow->GetOuterWindow()) {
|
||||
// Our window should have a null top iff it has a null docshell.
|
||||
MOZ_ASSERT(!!aWindow->GetTop() == !!aWindow->GetDocShell());
|
||||
MOZ_ASSERT(!!aWindow->GetTopInternal() == !!aWindow->GetDocShell());
|
||||
top = aWindow->GetTopInternal();
|
||||
if (top) {
|
||||
location = GetWindowURI(top);
|
||||
|
||||
@@ -127,7 +127,7 @@ nsWEBPDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
||||
PostHasTransparency();
|
||||
|
||||
if (!mImageData) {
|
||||
MOZ_ASSERT(haveSize, "Didn't fetch metadata?");
|
||||
MOZ_ASSERT(HasSize(), "Didn't fetch metadata?");
|
||||
nsresult rv_ = AllocateBasicFrame();
|
||||
if (NS_FAILED(rv_)) {
|
||||
return;
|
||||
|
||||
@@ -685,6 +685,7 @@ function ArrayValuesAt(n) {
|
||||
function ArrayValues() {
|
||||
return CreateArrayIterator(this, ITEM_KIND_VALUE);
|
||||
}
|
||||
_SetCanonicalName(ArrayValues, "values");
|
||||
|
||||
function ArrayEntries() {
|
||||
return CreateArrayIterator(this, ITEM_KIND_KEY_AND_VALUE);
|
||||
|
||||
@@ -88,6 +88,7 @@ function LegacyGeneratorNext(val) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
_SetCanonicalName(LegacyGeneratorNext, "next");
|
||||
|
||||
function LegacyGeneratorThrow(val) {
|
||||
if (!IsObject(this) || !IsLegacyGeneratorObject(this))
|
||||
|
||||
+29
-6
@@ -81,7 +81,7 @@ internalIntlRegExps.currencyDigitsRE = null;
|
||||
function getUnicodeLocaleExtensionSequenceRE() {
|
||||
return internalIntlRegExps.unicodeLocaleExtensionSequenceRE ||
|
||||
(internalIntlRegExps.unicodeLocaleExtensionSequenceRE =
|
||||
regexp_construct_no_statics("-u(-[a-z0-9]{2,8})+"));
|
||||
regexp_construct_no_statics("-u(?:-[a-z0-9]{2,8})+"));
|
||||
}
|
||||
|
||||
|
||||
@@ -89,15 +89,38 @@ function getUnicodeLocaleExtensionSequenceRE() {
|
||||
* Removes Unicode locale extension sequences from the given language tag.
|
||||
*/
|
||||
function removeUnicodeExtensions(locale) {
|
||||
// Don't use std_String_replace directly with a regular expression,
|
||||
// as that would set RegExp statics.
|
||||
// A wholly-privateuse locale has no extension sequences.
|
||||
if (callFunction(std_String_startsWith, locale, "x-"))
|
||||
return locale;
|
||||
|
||||
// Otherwise, split on "-x-" marking the start of any privateuse component.
|
||||
// Replace Unicode locale extension sequences in the left half, and return
|
||||
// the concatenation.
|
||||
var pos = callFunction(std_String_indexOf, locale, "-x-");
|
||||
if (pos < 0)
|
||||
pos = locale.length;
|
||||
|
||||
var left = callFunction(std_String_substring, locale, 0, pos);
|
||||
var right = callFunction(std_String_substring, locale, pos);
|
||||
|
||||
var extensions;
|
||||
var unicodeLocaleExtensionSequenceRE = getUnicodeLocaleExtensionSequenceRE();
|
||||
while ((extensions = regexp_exec_no_statics(unicodeLocaleExtensionSequenceRE, locale)) !== null) {
|
||||
locale = callFunction(std_String_replace, locale, extensions[0], "");
|
||||
while ((extensions = regexp_exec_no_statics(unicodeLocaleExtensionSequenceRE, left)) !== null) {
|
||||
left = callFunction(std_String_replace, left, extensions[0], "");
|
||||
unicodeLocaleExtensionSequenceRE.lastIndex = 0;
|
||||
}
|
||||
return locale;
|
||||
|
||||
var combined = left + right;
|
||||
assert(IsStructurallyValidLanguageTag(combined), "recombination produced an invalid language tag");
|
||||
assert(function() {
|
||||
var uindex = callFunction(std_String_indexOf, combined, "-u-");
|
||||
if (uindex < 0)
|
||||
return true;
|
||||
var xindex = callFunction(std_String_indexOf, combined, "-x-");
|
||||
return xindex > 0 && xindex < uindex;
|
||||
}(), "recombination failed to remove all Unicode locale extension sequences");
|
||||
|
||||
return combined;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -91,3 +91,4 @@ function MapSpecies() {
|
||||
// Step 1.
|
||||
return this;
|
||||
}
|
||||
_SetCanonicalName(MapSpecies, "get [Symbol.species]");
|
||||
|
||||
@@ -36,6 +36,7 @@ function RegExpFlagsGetter() {
|
||||
// Step 19.
|
||||
return result;
|
||||
}
|
||||
_SetCanonicalName(RegExpFlagsGetter, "get flags");
|
||||
|
||||
// ES6 draft rc1 21.2.5.14.
|
||||
function RegExpToString()
|
||||
@@ -54,3 +55,4 @@ function RegExpToString()
|
||||
// Step 7.
|
||||
return '/' + pattern + '/' + flags;
|
||||
}
|
||||
_SetCanonicalName(RegExpToString, "toString");
|
||||
|
||||
@@ -30,6 +30,15 @@
|
||||
#define ATTR_NONCONFIGURABLE 0x10
|
||||
#define ATTR_NONWRITABLE 0x20
|
||||
|
||||
// The extended slot in which the self-hosted name for self-hosted builtins is
|
||||
// stored.
|
||||
#define LAZY_FUNCTION_NAME_SLOT 0
|
||||
|
||||
// The extended slot which contains a boolean value that indicates whether
|
||||
// that the canonical name of the self-hosted builtins is set in self-hosted
|
||||
// global. This slot is used only in debug build.
|
||||
#define HAS_SELFHOSTED_CANONICAL_NAME_SLOT 0
|
||||
|
||||
// Stores the private WeakMap slot used for WeakSets
|
||||
#define WEAKSET_MAP_SLOT 0
|
||||
|
||||
|
||||
@@ -38,3 +38,4 @@ function SetSpecies() {
|
||||
// Step 1.
|
||||
return this;
|
||||
}
|
||||
_SetCanonicalName(SetSpecies, "get [Symbol.species]");
|
||||
|
||||
@@ -948,6 +948,7 @@ function TypedArrayValues() {
|
||||
// Step 7.
|
||||
return CreateArrayIterator(O, ITEM_KIND_VALUE);
|
||||
}
|
||||
_SetCanonicalName(TypedArrayValues, "values");
|
||||
|
||||
// Proposed for ES7:
|
||||
// https://github.com/tc39/Array.prototype.includes/blob/7c023c19a0/spec.md
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "jstypes.h"
|
||||
|
||||
#include "asmjs/AsmJSValidate.h"
|
||||
#include "builtin/SelfHostingDefines.h"
|
||||
#include "frontend/BytecodeCompiler.h"
|
||||
#include "frontend/FoldConstants.h"
|
||||
#include "frontend/ParseMaps.h"
|
||||
@@ -1278,6 +1279,9 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||
|
||||
gc::AllocKind allocKind = gc::AllocKind::FUNCTION;
|
||||
JSFunction::Flags flags;
|
||||
#ifdef DEBUG
|
||||
bool isGlobalSelfHostedBuiltin = false;
|
||||
#endif
|
||||
switch (kind) {
|
||||
case Expression:
|
||||
flags = JSFunction::INTERPRETED_LAMBDA;
|
||||
@@ -1308,6 +1312,12 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||
allocKind = gc::AllocKind::FUNCTION_EXTENDED;
|
||||
break;
|
||||
default:
|
||||
#ifdef DEBUG
|
||||
if (options().selfHostingMode && !pc->sc->isFunctionBox()) {
|
||||
isGlobalSelfHostedBuiltin = true;
|
||||
allocKind = gc::AllocKind::FUNCTION_EXTENDED;
|
||||
}
|
||||
#endif
|
||||
flags = JSFunction::INTERPRETED_NORMAL;
|
||||
break;
|
||||
}
|
||||
@@ -1316,8 +1326,13 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||
allocKind, TenuredObject);
|
||||
if (!fun)
|
||||
return nullptr;
|
||||
if (options().selfHostingMode)
|
||||
if (options().selfHostingMode) {
|
||||
fun->setIsSelfHostedBuiltin();
|
||||
#ifdef DEBUG
|
||||
if (isGlobalSelfHostedBuiltin)
|
||||
fun->setExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT, BooleanValue(false));
|
||||
#endif
|
||||
}
|
||||
return fun;
|
||||
}
|
||||
|
||||
|
||||
@@ -174,8 +174,8 @@ IsOwnedByOtherRuntime(JSTracer* trc, T thing)
|
||||
{
|
||||
bool other = thing->runtimeFromAnyThread() != trc->runtime();
|
||||
MOZ_ASSERT_IF(other,
|
||||
ThingIsPermanentAtom(thing) ||
|
||||
thing->runtimeFromAnyThread()->isSelfHostingZone(thing->zoneFromAnyThread()));
|
||||
ThingIsPermanentAtomOrWellKnownSymbol(thing) ||
|
||||
thing->zoneFromAnyThread()->isSelfHostingZone());
|
||||
return other;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ JitcodeGlobalEntry::IonEntry::callStackAtAddr(JSRuntime* rt, void* ptr,
|
||||
uint32_t maxResults) const
|
||||
{
|
||||
MOZ_ASSERT(maxResults >= 1);
|
||||
MOZ_ASSERT(regionIdx < regionTable()->numRegions());
|
||||
|
||||
uint32_t ptrOffset;
|
||||
JitcodeRegionEntry region = RegionAtAddr(*this, ptr, &ptrOffset);
|
||||
|
||||
|
||||
@@ -6394,7 +6394,6 @@ class LPostWriteBarrierO : public LInstructionHelper<0, 2, 1>
|
||||
return getOperand(0);
|
||||
}
|
||||
const LAllocation* value() {
|
||||
MOZ_ASSERT(valueOp == 1);
|
||||
return getOperand(1);
|
||||
}
|
||||
const LDefinition* temp() {
|
||||
|
||||
+1
-1
@@ -3762,7 +3762,7 @@ bool
|
||||
js::ArrayInfo(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
RootedBobject obj(cx);
|
||||
RootedObject obj(cx);
|
||||
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
HandleValue arg = args[i];
|
||||
|
||||
+2
-4
@@ -1535,7 +1535,7 @@ JSFunction::createScriptForLazilyInterpretedFunction(JSContext* cx, HandleFuncti
|
||||
|
||||
/* Lazily cloned self-hosted script. */
|
||||
MOZ_ASSERT(fun->isSelfHostedBuiltin());
|
||||
RootedAtom funAtom(cx, &fun->getExtendedSlot(0).toString()->asAtom());
|
||||
RootedAtom funAtom(cx, &fun->getExtendedSlot(LAZY_FUNCTION_NAME_SLOT).toString()->asAtom());
|
||||
if (!funAtom)
|
||||
return false;
|
||||
Rooted<PropertyName*> funName(cx, funAtom->asPropertyName());
|
||||
@@ -1581,7 +1581,7 @@ JSFunction::maybeRelazify(JSRuntime* rt)
|
||||
} else {
|
||||
MOZ_ASSERT(isSelfHostedBuiltin());
|
||||
MOZ_ASSERT(isExtended());
|
||||
MOZ_ASSERT(getExtendedSlot(0).toString()->isAtom());
|
||||
MOZ_ASSERT(getExtendedSlot(LAZY_FUNCTION_NAME_SLOT).toString()->isAtom());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2187,8 +2187,6 @@ NewFunctionClone(JSContext* cx, HandleFunction fun, NewObjectKind newKind,
|
||||
return nullptr;
|
||||
RootedFunction clone(cx, &cloneobj->as<JSFunction>());
|
||||
|
||||
MOZ_ASSERT(useSameScript || !fun->isInterpretedLazy());
|
||||
|
||||
uint16_t flags = fun->flags() & ~JSFunction::EXTENDED;
|
||||
if (allocKind == AllocKind::FUNCTION_EXTENDED)
|
||||
flags |= JSFunction::EXTENDED;
|
||||
|
||||
+1
-1
@@ -3329,7 +3329,7 @@ JSObject::dump()
|
||||
if (obj->isNative()) {
|
||||
fprintf(stderr, "properties:\n");
|
||||
Vector<Shape*, 8, SystemAllocPolicy> props;
|
||||
for (Shape::Range<NoGC> r(obj->as<NativeObject>().lastProperty()); !r.empty(); r.popFront())
|
||||
for (Shape::Range<NoGC> r(obj->as<NativeObject>().lastProperty()); !r.empty(); r.popFront()) {
|
||||
if (!props.append(&r.front())) {
|
||||
fprintf(stderr, "(OOM while appending properties)\n");
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// |reftest| skip-if(!this.hasOwnProperty("Intl"))
|
||||
|
||||
/* 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/. */
|
||||
|
||||
// Locale processing is supposed to internally remove any Unicode extension
|
||||
// sequences in the locale. Test that various weird testcases invoking
|
||||
// algorithmic edge cases don't assert or throw exceptions.
|
||||
|
||||
var weirdCases =
|
||||
[
|
||||
"x-u-foo",
|
||||
"en-x-u-foo",
|
||||
"en-a-bar-x-u-foo",
|
||||
"en-x-u-foo-a-bar",
|
||||
"en-a-bar-u-baz-x-u-foo",
|
||||
];
|
||||
|
||||
for (var locale of weirdCases)
|
||||
Intl.NumberFormat(locale).format(5);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
@@ -1258,7 +1258,7 @@ class ByAllocationStack : public CountType {
|
||||
|
||||
#ifdef DEBUG
|
||||
// Check that nothing rehashes our table while we hold pointers into it.
|
||||
uint32_t generation = count.table.generation();
|
||||
Generation generation = count.table.generation();
|
||||
#endif
|
||||
|
||||
// Build a vector of pointers to entries; sort by total; and then use
|
||||
|
||||
@@ -641,16 +641,37 @@ GlobalObject::getSelfHostedFunction(JSContext* cx, Handle<GlobalObject*> global,
|
||||
HandlePropertyName selfHostedName, HandleAtom name,
|
||||
unsigned nargs, MutableHandleValue funVal)
|
||||
{
|
||||
if (GlobalObject::maybeGetIntrinsicValue(cx, global, selfHostedName, funVal))
|
||||
return true;
|
||||
if (GlobalObject::maybeGetIntrinsicValue(cx, global, selfHostedName, funVal)) {
|
||||
RootedFunction fun(cx, &funVal.toObject().as<JSFunction>());
|
||||
if (fun->atom() == name)
|
||||
return true;
|
||||
|
||||
JSFunction* fun =
|
||||
NewScriptedFunction(cx, nargs, JSFunction::INTERPRETED_LAZY,
|
||||
name, gc::AllocKind::FUNCTION_EXTENDED, SingletonObject);
|
||||
if (!fun)
|
||||
if (fun->atom() == selfHostedName) {
|
||||
// This function was initially cloned because it was called by
|
||||
// other self-hosted code, so the clone kept its self-hosted name,
|
||||
// instead of getting the name it's intended to have in content
|
||||
// compartments. This can happen when a lazy builtin is initialized
|
||||
// after self-hosted code for another builtin used the same
|
||||
// function. In that case, we need to change the function's name,
|
||||
// which is ok because it can't have been exposed to content
|
||||
// before.
|
||||
fun->initAtom(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// The function might be installed multiple times on the same or
|
||||
// different builtins, under different property names, so its name
|
||||
// might be neither "selfHostedName" nor "name". In that case, its
|
||||
// canonical name must've been set using the `_SetCanonicalName`
|
||||
// intrinsic.
|
||||
cx->runtime()->assertSelfHostedFunctionHasCanonicalName(cx, selfHostedName);
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedFunction fun(cx);
|
||||
if (!cx->runtime()->createLazySelfHostedFunctionClone(cx, selfHostedName, name, nargs, &fun))
|
||||
return false;
|
||||
fun->setIsSelfHostedBuiltin();
|
||||
fun->setExtendedSlot(0, StringValue(selfHostedName));
|
||||
funVal.setObject(*fun);
|
||||
|
||||
return GlobalObject::addIntrinsicValue(cx, global, selfHostedName, funVal);
|
||||
|
||||
@@ -918,6 +918,10 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
static js::GlobalObject*
|
||||
createSelfHostingGlobal(JSContext* cx);
|
||||
|
||||
bool getUnclonedSelfHostedValue(JSContext* cx, js::HandlePropertyName name,
|
||||
js::MutableHandleValue vp);
|
||||
JSFunction* getUnclonedSelfHostedFunction(JSContext* cx, js::HandlePropertyName name);
|
||||
|
||||
/* Space for interpreter frames. */
|
||||
js::InterpreterStack interpreterStack_;
|
||||
|
||||
@@ -949,10 +953,14 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
}
|
||||
bool isSelfHostingCompartment(JSCompartment* comp) const;
|
||||
bool isSelfHostingZone(const JS::Zone* zone) const;
|
||||
bool createLazySelfHostedFunctionClone(JSContext* cx, js::HandlePropertyName selfHostedName,
|
||||
js::HandleAtom name, unsigned nargs,
|
||||
js::MutableHandleFunction fun);
|
||||
bool cloneSelfHostedFunctionScript(JSContext* cx, js::Handle<js::PropertyName*> name,
|
||||
js::Handle<JSFunction*> targetFun);
|
||||
bool cloneSelfHostedValue(JSContext* cx, js::Handle<js::PropertyName*> name,
|
||||
js::MutableHandleValue vp);
|
||||
void assertSelfHostedFunctionHasCanonicalName(JSContext* cx, js::HandlePropertyName name);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Locale information
|
||||
|
||||
+62
-10
@@ -14,6 +14,7 @@
|
||||
#include "jscompartment.h"
|
||||
#include "jsdate.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsfun.h"
|
||||
#include "jshashutil.h"
|
||||
#include "jsweakmap.h"
|
||||
#include "jswrapper.h"
|
||||
@@ -1836,8 +1837,10 @@ CloneObject(JSContext* cx, HandleNativeObject selfHostedObject)
|
||||
/* newStaticScope = */ nullptr, kind);
|
||||
// To be able to re-lazify the cloned function, its name in the
|
||||
// self-hosting compartment has to be stored on the clone.
|
||||
if (clone && hasName)
|
||||
clone->as<JSFunction>().setExtendedSlot(0, StringValue(selfHostedFunction->atom()));
|
||||
if (clone && hasName) {
|
||||
clone->as<JSFunction>().setExtendedSlot(LAZY_FUNCTION_NAME_SLOT,
|
||||
StringValue(selfHostedFunction->atom()));
|
||||
}
|
||||
} else if (selfHostedObject->is<RegExpObject>()) {
|
||||
RegExpObject& reobj = selfHostedObject->as<RegExpObject>();
|
||||
RootedAtom source(cx, reobj.getSource());
|
||||
@@ -1904,16 +1907,37 @@ CloneValue(JSContext* cx, HandleValue selfHostedValue, MutableHandleValue vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
JSRuntime::createLazySelfHostedFunctionClone(JSContext* cx, HandlePropertyName selfHostedName,
|
||||
HandleAtom name, unsigned nargs,
|
||||
MutableHandleFunction fun)
|
||||
{
|
||||
RootedAtom funName(cx, name);
|
||||
JSFunction* selfHostedFun = getUnclonedSelfHostedFunction(cx, selfHostedName);
|
||||
if (!selfHostedFun)
|
||||
return false;
|
||||
|
||||
if (selfHostedFun->atom() != selfHostedName) {
|
||||
MOZ_ASSERT(selfHostedFun->getExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT).toBoolean());
|
||||
funName = selfHostedFun->atom();
|
||||
}
|
||||
|
||||
fun.set(NewScriptedFunction(cx, nargs, JSFunction::INTERPRETED_LAZY,
|
||||
funName, gc::AllocKind::FUNCTION_EXTENDED, SingletonObject));
|
||||
if (!fun)
|
||||
return false;
|
||||
fun->setIsSelfHostedBuiltin();
|
||||
fun->setExtendedSlot(LAZY_FUNCTION_NAME_SLOT, StringValue(selfHostedName));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name,
|
||||
HandleFunction targetFun)
|
||||
{
|
||||
RootedId id(cx, NameToId(name));
|
||||
RootedValue funVal(cx);
|
||||
if (!GetUnclonedValue(cx, HandleNativeObject::fromMarkedLocation(&selfHostingGlobal_), id, &funVal))
|
||||
RootedFunction sourceFun(cx, getUnclonedSelfHostedFunction(cx, name));
|
||||
if (!sourceFun)
|
||||
return false;
|
||||
|
||||
RootedFunction sourceFun(cx, &funVal.toObject().as<JSFunction>());
|
||||
// JSFunction::generatorKind can't handle lazy self-hosted functions, so we make sure there
|
||||
// aren't any.
|
||||
MOZ_ASSERT(!sourceFun->isGenerator());
|
||||
@@ -1931,11 +1955,28 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name,
|
||||
}
|
||||
|
||||
bool
|
||||
JSRuntime::cloneSelfHostedValue(JSContext* cx, HandlePropertyName name, MutableHandleValue vp)
|
||||
JSRuntime::getUnclonedSelfHostedValue(JSContext* cx, HandlePropertyName name,
|
||||
MutableHandleValue vp)
|
||||
{
|
||||
RootedId id(cx, NameToId(name));
|
||||
return GetUnclonedValue(cx, HandleNativeObject::fromMarkedLocation(&selfHostingGlobal_), id, vp);
|
||||
}
|
||||
|
||||
JSFunction*
|
||||
JSRuntime::getUnclonedSelfHostedFunction(JSContext* cx, HandlePropertyName name)
|
||||
{
|
||||
RootedValue selfHostedValue(cx);
|
||||
if (!GetUnclonedValue(cx, HandleNativeObject::fromMarkedLocation(&selfHostingGlobal_), id, &selfHostedValue))
|
||||
if (!getUnclonedSelfHostedValue(cx, name, &selfHostedValue))
|
||||
return nullptr;
|
||||
|
||||
return &selfHostedValue.toObject().as<JSFunction>();
|
||||
}
|
||||
|
||||
bool
|
||||
JSRuntime::cloneSelfHostedValue(JSContext* cx, HandlePropertyName name, MutableHandleValue vp)
|
||||
{
|
||||
RootedValue selfHostedValue(cx);
|
||||
if (!getUnclonedSelfHostedValue(cx, name, &selfHostedValue))
|
||||
return false;
|
||||
|
||||
/*
|
||||
@@ -1951,6 +1992,16 @@ JSRuntime::cloneSelfHostedValue(JSContext* cx, HandlePropertyName name, MutableH
|
||||
return CloneValue(cx, selfHostedValue, vp);
|
||||
}
|
||||
|
||||
void
|
||||
JSRuntime::assertSelfHostedFunctionHasCanonicalName(JSContext* cx, HandlePropertyName name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
JSFunction* selfHostedFun = getUnclonedSelfHostedFunction(cx, name);
|
||||
MOZ_ASSERT(selfHostedFun);
|
||||
MOZ_ASSERT(selfHostedFun->getExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT).toBoolean());
|
||||
#endif
|
||||
}
|
||||
|
||||
JSFunction*
|
||||
js::SelfHostedFunction(JSContext* cx, HandlePropertyName propName)
|
||||
{
|
||||
@@ -1966,7 +2017,8 @@ js::SelfHostedFunction(JSContext* cx, HandlePropertyName propName)
|
||||
bool
|
||||
js::IsSelfHostedFunctionWithName(JSFunction* fun, JSAtom* name)
|
||||
{
|
||||
return fun->isSelfHostedBuiltin() && fun->getExtendedSlot(0).toString() == name;
|
||||
return fun->isSelfHostedBuiltin() &&
|
||||
fun->getExtendedSlot(LAZY_FUNCTION_NAME_SLOT).toString() == name;
|
||||
}
|
||||
|
||||
static_assert(JSString::MAX_LENGTH <= INT32_MAX,
|
||||
|
||||
@@ -3520,10 +3520,6 @@ XPCJSRuntime::DebugDump(int16_t depth)
|
||||
XPC_LOG_INDENT();
|
||||
XPC_LOG_ALWAYS(("mJSRuntime @ %x", Runtime()));
|
||||
|
||||
XPC_LOG_ALWAYS(("mWrappedJSToReleaseArray @ %x with %d wrappers(s)",
|
||||
&mWrappedJSToReleaseArray,
|
||||
mWrappedJSToReleaseArray.Length()));
|
||||
|
||||
int cxCount = 0;
|
||||
JSContext* iter = nullptr;
|
||||
while (JS_ContextIterator(Runtime(), &iter))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 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/. */
|
||||
|
||||
#include "JSObjectHolder.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(mozilla::JSObjectHolder, nsISupports)
|
||||
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 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_JSObjectHolder_h
|
||||
#define mozilla_JSObjectHolder_h
|
||||
|
||||
#include "js/RootingAPI.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// This class is useful when something on one thread needs to keep alive
|
||||
// a JS Object from another thread. If they are both on the same thread, the
|
||||
// owning class should instead be made a cycle collected SCRIPT_HOLDER class.
|
||||
// This object should only be AddRefed and Released on the same thread as
|
||||
// mJSObject.
|
||||
//
|
||||
// Note that this keeps alive the JS object until it goes away, so be sure not to
|
||||
// create cycles that keep alive the holder.
|
||||
//
|
||||
// JSObjectHolder is ISupports to make it usable with NS_ReleaseOnMainThread.
|
||||
class JSObjectHolder final : public nsISupports
|
||||
{
|
||||
public:
|
||||
JSObjectHolder(JSContext* aCx, JSObject* aObject) : mJSObject(aCx, aObject) {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
JSObject* GetJSObject() { return mJSObject; }
|
||||
|
||||
private:
|
||||
~JSObjectHolder() {}
|
||||
|
||||
JS::PersistentRooted<JSObject*> mJSObject;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_JSObjectHolder_h
|
||||
@@ -76,6 +76,7 @@ EXPORTS.mozilla += [
|
||||
'DeferredFinalize.h',
|
||||
'ErrorNames.h',
|
||||
'HoldDropJSObjects.h',
|
||||
'JSObjectHolder.h',
|
||||
'LinuxUtils.h',
|
||||
'nsMemoryInfoDumper.h',
|
||||
'StaticMutex.h',
|
||||
@@ -99,6 +100,7 @@ UNIFIED_SOURCES += [
|
||||
'DeferredFinalize.cpp',
|
||||
'ErrorNames.cpp',
|
||||
'HoldDropJSObjects.cpp',
|
||||
'JSObjectHolder.cpp',
|
||||
'nsConsoleMessage.cpp',
|
||||
'nsConsoleService.cpp',
|
||||
'nsCycleCollector.cpp',
|
||||
|
||||
Reference in New Issue
Block a user