This commit is contained in:
Phil Ringnalda 2015-01-04 15:21:51 -08:00
Родитель b092d51b09 415bfb6776
Коммит cd58416a73
47 изменённых файлов: 345 добавлений и 149 удалений

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

@ -1,4 +1,8 @@
{
"WeakMap.prototype.clear.length": true,
"WeakMap.prototype.delete.length": true,
"WeakMap.prototype.get.length": true,
"WeakMap.prototype.get: return undefined": true
"WeakMap.prototype.get: return undefined": true,
"WeakMap.prototype.has.length": true,
"WeakMap.prototype.set.length": true
}

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

@ -931,7 +931,7 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
// We allow multipart images to fail to initialize without cancelling the
// load because subsequent images might be fine; thus only single part
// images end up here.
this->Cancel(NS_ERROR_FAILURE);
this->Cancel(NS_IMAGELIB_ERROR_FAILURE);
return NS_BINDING_ABORTED;
}

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

@ -352,6 +352,7 @@ class GCRuntime
#ifdef JS_GC_ZEAL
const void *addressOfZealMode() { return &zealMode; }
void getZeal(uint8_t *zeal, uint32_t *frequency);
void setZeal(uint8_t zeal, uint32_t frequency);
bool parseAndSetZeal(const char *str);
void setNextScheduled(uint32_t count);

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

@ -41,7 +41,7 @@ function assertBuiltinFunction(o, name, arity) {
value: arity,
writable: false,
enumerable: false,
configurable: false,
configurable: true
});
}

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

@ -9332,9 +9332,9 @@ CodeGenerator::visitGetDOMProperty(LGetDOMProperty *ins)
}
void
CodeGenerator::visitGetDOMMember(LGetDOMMember *ins)
CodeGenerator::visitGetDOMMemberV(LGetDOMMemberV *ins)
{
// It's simple to duplicate visitLoadFixedSlotV here than it is to try to
// It's simpler to duplicate visitLoadFixedSlotV here than it is to try to
// use an LLoadFixedSlotV or some subclass of it for this case: that would
// require us to have MGetDOMMember inherit from MLoadFixedSlot, and then
// we'd have to duplicate a bunch of stuff we now get for free from
@ -9346,6 +9346,22 @@ CodeGenerator::visitGetDOMMember(LGetDOMMember *ins)
masm.loadValue(Address(object, NativeObject::getFixedSlotOffset(slot)), result);
}
void
CodeGenerator::visitGetDOMMemberT(LGetDOMMemberT *ins)
{
// It's simpler to duplicate visitLoadFixedSlotT here than it is to try to
// use an LLoadFixedSlotT or some subclass of it for this case: that would
// require us to have MGetDOMMember inherit from MLoadFixedSlot, and then
// we'd have to duplicate a bunch of stuff we now get for free from
// MGetDOMProperty.
Register object = ToRegister(ins->object());
size_t slot = ins->mir()->domMemberSlotIndex();
AnyRegister result = ToAnyRegister(ins->getDef(0));
MIRType type = ins->mir()->type();
masm.loadUnboxedValue(Address(object, NativeObject::getFixedSlotOffset(slot)), type, result);
}
void
CodeGenerator::visitSetDOMProperty(LSetDOMProperty *ins)
{

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

@ -305,7 +305,8 @@ class CodeGenerator : public CodeGeneratorSpecific
void visitCallInstanceOf(LCallInstanceOf *ins);
void visitProfilerStackOp(LProfilerStackOp *lir);
void visitGetDOMProperty(LGetDOMProperty *lir);
void visitGetDOMMember(LGetDOMMember *lir);
void visitGetDOMMemberV(LGetDOMMemberV *lir);
void visitGetDOMMemberT(LGetDOMMemberT *lir);
void visitSetDOMProperty(LSetDOMProperty *lir);
void visitCallDOMNative(LCallDOMNative *lir);
void visitCallGetIntrinsicValue(LCallGetIntrinsicValue *lir);

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

@ -1750,11 +1750,28 @@ class LGetDOMProperty : public LDOMPropertyInstructionHelper<BOX_PIECES, 0>
}
};
class LGetDOMMember : public LInstructionHelper<BOX_PIECES, 1, 0>
class LGetDOMMemberV : public LInstructionHelper<BOX_PIECES, 1, 0>
{
public:
LIR_HEADER(GetDOMMember);
explicit LGetDOMMember(const LAllocation &object) {
LIR_HEADER(GetDOMMemberV);
explicit LGetDOMMemberV(const LAllocation &object) {
setOperand(0, object);
}
const LAllocation *object() {
return getOperand(0);
}
MGetDOMMember *mir() const {
return mir_->toGetDOMMember();
}
};
class LGetDOMMemberT : public LInstructionHelper<1, 1, 0>
{
public:
LIR_HEADER(GetDOMMemberT);
explicit LGetDOMMemberT(const LAllocation &object) {
setOperand(0, object);
}

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

@ -316,7 +316,8 @@
_(InterruptCheckImplicit) \
_(ProfilerStackOp) \
_(GetDOMProperty) \
_(GetDOMMember) \
_(GetDOMMemberV) \
_(GetDOMMemberT) \
_(SetDOMProperty) \
_(CallDOMNative) \
_(IsCallable) \

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

@ -3824,9 +3824,19 @@ LIRGenerator::visitGetDOMMember(MGetDOMMember *ins)
// value can in fact change as a result of DOM setters and method calls.
MOZ_ASSERT(ins->domAliasSet() != JSJitInfo::AliasEverything,
"Member gets had better not alias the world");
LGetDOMMember *lir =
new(alloc()) LGetDOMMember(useRegisterAtStart(ins->object()));
defineBox(lir, ins);
MDefinition *obj = ins->object();
MOZ_ASSERT(obj->type() == MIRType_Object);
MIRType type = ins->type();
if (type == MIRType_Value) {
LGetDOMMemberV *lir = new(alloc()) LGetDOMMemberV(useRegisterAtStart(obj));
defineBox(lir, ins);
} else {
LGetDOMMemberT *lir = new(alloc()) LGetDOMMemberT(useRegisterForTypedLoad(obj, type));
define(lir, ins);
}
}
void

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

@ -1013,11 +1013,10 @@ MCallDOMNative::getAliasSet() const
{
const JSJitInfo *jitInfo = getJitInfo();
MOZ_ASSERT(jitInfo->aliasSet() != JSJitInfo::AliasNone);
// If we don't know anything about the types of our arguments, we have to
// assume that type-coercions can have side-effects, so we need to alias
// everything.
if (jitInfo->aliasSet() != JSJitInfo::AliasDOMSets || !jitInfo->isTypedMethodJitInfo())
if (jitInfo->aliasSet() == JSJitInfo::AliasEverything || !jitInfo->isTypedMethodJitInfo())
return AliasSet::Store(AliasSet::Any);
uint32_t argIndex = 0;
@ -1048,8 +1047,12 @@ MCallDOMNative::getAliasSet() const
}
}
// We checked all the args, and they check out. So we only
// alias DOM mutations.
// We checked all the args, and they check out. So we only alias DOM
// mutations or alias nothing, depending on the alias set in the jitinfo.
if (jitInfo->aliasSet() == JSJitInfo::AliasNone)
return AliasSet::None();
MOZ_ASSERT(jitInfo->aliasSet() == JSJitInfo::AliasDOMSets);
return AliasSet::Load(AliasSet::DOMProperty);
}

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

@ -3366,11 +3366,11 @@ class MCallDOMNative : public MCall
: MCall(target, numActualArgs, false)
{
// If our jitinfo is not marked movable, that means that our C++
// implementation is fallible or that we have no hope of ever doing the
// sort of argument analysis that would allow us to detemine that we're
// side-effect-free. In the latter case we wouldn't get DCEd no matter
// what, but for the former case we have to explicitly say that we can't
// be DCEd.
// implementation is fallible or that it never wants to be eliminated or
// coalesced or that we have no hope of ever doing the sort of argument
// analysis that would allow us to detemine that we're side-effect-free.
// In the latter case we wouldn't get DCEd no matter what, but for the
// former two cases we have to explicitly say that we can't be DCEd.
if (!getJitInfo()->isMovable)
setGuard();
}
@ -10644,6 +10644,7 @@ class MGetDOMMember : public MGetDOMProperty
explicit MGetDOMMember(const JSJitInfo *jitinfo)
: MGetDOMProperty(jitinfo)
{
setResultType(MIRTypeFromValueType(jitinfo->returnType()));
}
public:

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

@ -10,6 +10,10 @@
BEGIN_TEST(testGCHeapPostBarriers)
{
#ifdef JS_GC_ZEAL
AutoLeaveZeal nozeal(cx);
#endif /* JS_GC_ZEAL */
/* Sanity check - objects start in the nursery and then become tenured. */
JS_GC(cx->runtime());
JS::RootedObject obj(cx, NurseryObject());

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

@ -412,4 +412,28 @@ class TestJSPrincipals : public JSPrincipals
}
};
#ifdef JS_GC_ZEAL
/*
* Temporarily disable the GC zeal setting. This is only useful in tests that
* need very explicit GC behavior and should not be used elsewhere.
*/
class AutoLeaveZeal
{
JSContext *cx_;
uint8_t zeal_;
uint32_t frequency_;
public:
explicit AutoLeaveZeal(JSContext *cx) : cx_(cx) {
JS_GetGCZeal(cx_, &zeal_, &frequency_);
JS_SetGCZeal(cx_, 0, 0);
JS::PrepareForFullGC(JS_GetRuntime(cx_));
JS::ShrinkingGC(JS_GetRuntime(cx_), JS::gcreason::DEBUG_GC);
}
~AutoLeaveZeal() {
JS_SetGCZeal(cx_, zeal_, frequency_);
}
};
#endif /* JS_GC_ZEAL */
#endif /* jsapi_tests_tests_h */

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

@ -5725,6 +5725,12 @@ JS_AbortIfWrongThread(JSRuntime *rt)
}
#ifdef JS_GC_ZEAL
JS_PUBLIC_API(void)
JS_GetGCZeal(JSContext *cx, uint8_t *zeal, uint32_t *frequency)
{
cx->runtime()->gc.getZeal(zeal, frequency);
}
JS_PUBLIC_API(void)
JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency)
{

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

@ -5044,6 +5044,9 @@ JS_NewObjectForConstructor(JSContext *cx, const JSClass *clasp, const JS::CallAr
#ifdef JS_GC_ZEAL
#define JS_DEFAULT_ZEAL_FREQ 100
extern JS_PUBLIC_API(void)
JS_GetGCZeal(JSContext *cx, uint8_t *zeal, uint32_t *frequency);
extern JS_PUBLIC_API(void)
JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency);

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

@ -484,24 +484,41 @@ js::fun_resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
return true;
}
if (JSID_IS_ATOM(id, cx->names().length) || JSID_IS_ATOM(id, cx->names().name)) {
bool isLength = JSID_IS_ATOM(id, cx->names().length);
if (isLength || JSID_IS_ATOM(id, cx->names().name)) {
MOZ_ASSERT(!IsInternalFunctionObject(obj));
RootedValue v(cx);
if (JSID_IS_ATOM(id, cx->names().length)) {
uint32_t attrs;
if (isLength) {
// Since f.length is configurable, it could be resolved and then deleted:
// function f(x) {}
// assertEq(f.length, 1);
// delete f.length;
// Afterwards, asking for f.length again will cause this resolve
// hook to run again. Defining the property again the second
// time through would be a bug.
// assertEq(f.length, 0); // gets Function.prototype.length!
// We use the RESOLVED_LENGTH flag as a hack to prevent this bug.
if (fun->hasResolvedLength())
return true;
if (fun->isInterpretedLazy() && !fun->getOrCreateScript(cx))
return false;
uint16_t length = fun->hasScript() ? fun->nonLazyScript()->funLength() :
fun->nargs() - fun->hasRest();
v.setInt32(length);
attrs = JSPROP_READONLY;
} else {
v.setString(fun->atom() == nullptr ? cx->runtime()->emptyString : fun->atom());
attrs = JSPROP_READONLY | JSPROP_PERMANENT;
}
if (!DefineNativeProperty(cx, fun, id, v, nullptr, nullptr,
JSPROP_PERMANENT | JSPROP_READONLY)) {
if (!DefineNativeProperty(cx, fun, id, v, nullptr, nullptr, attrs))
return false;
}
if (isLength)
fun->setResolvedLength();
*resolvedp = true;
return true;

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

@ -49,6 +49,7 @@ class JSFunction : public js::NativeObject
ASMJS = 0x0800, /* function is an asm.js module or exported function */
INTERPRETED_LAZY = 0x1000, /* function is interpreted but doesn't have a script yet */
ARROW = 0x2000, /* ES6 '(args) => body' syntax */
RESOLVED_LENGTH = 0x4000, /* f.length has been resolved (see js::fun_resolve). */
/* Derived Flags values for convenience: */
NATIVE_FUN = 0,
@ -128,13 +129,13 @@ class JSFunction : public js::NativeObject
bool isSelfHostedBuiltin() const { return flags() & SELF_HOSTED; }
bool isSelfHostedConstructor() const { return flags() & SELF_HOSTED_CTOR; }
bool hasRest() const { return flags() & HAS_REST; }
bool isInterpretedLazy() const { return flags() & INTERPRETED_LAZY; }
bool hasScript() const { return flags() & INTERPRETED; }
bool isInterpretedLazy() const {
return flags() & INTERPRETED_LAZY;
}
bool hasScript() const {
return flags() & INTERPRETED;
}
// Arrow functions store their lexical |this| in the first extended slot.
bool isArrow() const { return flags() & ARROW; }
bool hasResolvedLength() const { return flags() & RESOLVED_LENGTH; }
bool hasJITCode() const {
if (!hasScript())
@ -143,9 +144,6 @@ class JSFunction : public js::NativeObject
return nonLazyScript()->hasBaselineScript() || nonLazyScript()->hasIonScript();
}
// Arrow functions store their lexical |this| in the first extended slot.
bool isArrow() const { return flags() & ARROW; }
/* Compound attributes: */
bool isBuiltin() const {
return (isNative() && !isAsmJSNative()) || isSelfHostedBuiltin();
@ -209,8 +207,16 @@ class JSFunction : public js::NativeObject
flags_ |= ARROW;
}
void setResolvedLength() {
flags_ |= RESOLVED_LENGTH;
}
JSAtom *atom() const { return hasGuessedAtom() ? nullptr : atom_.get(); }
js::PropertyName *name() const { return hasGuessedAtom() || !atom_ ? nullptr : atom_->asPropertyName(); }
js::PropertyName *name() const {
return hasGuessedAtom() || !atom_ ? nullptr : atom_->asPropertyName();
}
void initAtom(JSAtom *atom) { atom_.init(atom); }
JSAtom *displayAtom() const {

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

@ -1185,6 +1185,13 @@ GCRuntime::GCRuntime(JSRuntime *rt) :
#ifdef JS_GC_ZEAL
void
GCRuntime::getZeal(uint8_t *zeal, uint32_t *frequency)
{
*zeal = zealMode;
*frequency = zealFrequency;
}
const char *gc::ZealModeHelpText =
" Specifies how zealous the garbage collector should be. Values for level:\n"
" 0: Normal amount of collection\n"

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

@ -30,8 +30,6 @@ writeHeaderToLog( SECTION + " Array.prototype.join()");
var ARR_PROTOTYPE = Array.prototype;
new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length );
new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length );
new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") );
// case where array length is 0

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

@ -68,16 +68,6 @@ new TestCase( SECTION,
0,
Array.prototype.reverse.length );
new TestCase( SECTION,
"delete Array.prototype.reverse.length",
false,
delete Array.prototype.reverse.length );
new TestCase( SECTION,
"delete Array.prototype.reverse.length; Array.prototype.reverse.length",
0,
eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") );
// length of array is 0
new TestCase( SECTION,
"var A = new Array(); A.reverse(); A.length",

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

@ -64,8 +64,6 @@ writeHeaderToLog( SECTION + " Array.prototype.reverse()");
var ARR_PROTOTYPE = Array.prototype;
new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length );
new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length );
new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") );
// length of array is 0
new TestCase( SECTION,

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

@ -99,21 +99,6 @@ new TestCase( SECTION,
"var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS", "",
eval("var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS") );
new TestCase( SECTION,
"delete parseInt.length",
false,
delete parseInt.length );
new TestCase( SECTION,
"delete parseInt.length; parseInt.length",
2,
eval("delete parseInt.length; parseInt.length") );
new TestCase( SECTION,
"parseInt.length = null; parseInt.length",
2,
eval("parseInt.length = null; parseInt.length") );
new TestCase( SECTION,
"parseInt()",
NaN,

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

@ -54,8 +54,6 @@ writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length );
new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") );
new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length );
new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") );
new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") );
new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() );

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

@ -60,8 +60,6 @@ writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "escape.length", 1, escape.length );
new TestCase( SECTION, "escape.length = null; escape.length", 1, eval("escape.length = null; escape.length") );
new TestCase( SECTION, "delete escape.length", false, delete escape.length );
new TestCase( SECTION, "delete escape.length; escape.length", 1, eval("delete escape.length; escape.length") );
new TestCase( SECTION, "var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS", "", eval("var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS") );
new TestCase( SECTION, "escape()", "undefined", escape() );

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

@ -58,8 +58,6 @@ writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "unescape.length", 1, unescape.length );
new TestCase( SECTION, "unescape.length = null; unescape.length", 1, eval("unescape.length=null; unescape.length") );
new TestCase( SECTION, "delete unescape.length", false, delete unescape.length );
new TestCase( SECTION, "delete unescape.length; unescape.length", 1, eval("delete unescape.length; unescape.length") );
new TestCase( SECTION, "var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS") );
new TestCase( SECTION, "unescape()", "undefined", unescape() );

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

@ -27,8 +27,6 @@ writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "isNaN.length", 1, isNaN.length );
new TestCase( SECTION, "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS") );
new TestCase( SECTION, "isNaN.length = null; isNaN.length", 1, eval("isNaN.length=null; isNaN.length") );
new TestCase( SECTION, "delete isNaN.length", false, delete isNaN.length );
new TestCase( SECTION, "delete isNaN.length; isNaN.length", 1, eval("delete isNaN.length; isNaN.length") );
// new TestCase( SECTION, "isNaN.__proto__", Function.prototype, isNaN.__proto__ );

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

@ -27,8 +27,6 @@ writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "isFinite.length", 1, isFinite.length );
new TestCase( SECTION, "isFinite.length = null; isFinite.length", 1, eval("isFinite.length=null; isFinite.length") );
new TestCase( SECTION, "delete isFinite.length", false, delete isFinite.length );
new TestCase( SECTION, "delete isFinite.length; isFinite.length", 1, eval("delete isFinite.length; isFinite.length") );
new TestCase( SECTION, "var MYPROPS=''; for ( p in isFinite ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( p in isFinite ) { MYPROPS += p }; MYPROPS") );
new TestCase( SECTION, "isFinite()", false, isFinite() );

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

@ -52,8 +52,6 @@ var TITLE = "String.prototype.substring( start, end )";
writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length );
new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length );
new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") );
// test cases for when substring is called with no arguments.

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

@ -33,8 +33,6 @@ var TITLE = "String.prototype.toLowerCase()";
writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length );
new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length );
new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") );
// Basic Latin, Latin-1 Supplement, Latin Extended A
for ( var i = 0; i <= 0x017f; i++ ) {

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

@ -72,8 +72,6 @@ new TestCase( SECTION,
new TestCase( SECTION, "String.prototype.indexOf.length", 1, String.prototype.indexOf.length );
new TestCase( SECTION, "String.prototype.indexOf.length = null; String.prototype.indexOf.length", 1, eval("String.prototype.indexOf.length = null; String.prototype.indexOf.length") );
new TestCase( SECTION, "delete String.prototype.indexOf.length", false, delete String.prototype.indexOf.length );
new TestCase( SECTION, "delete String.prototype.indexOf.length; String.prototype.indexOf.length", 1, eval("delete String.prototype.indexOf.length; String.prototype.indexOf.length") );
new TestCase( SECTION,
"var s = new String(); s.indexOf()",

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

@ -53,8 +53,6 @@ writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "String.prototype.lastIndexOf.length", 1, String.prototype.lastIndexOf.length );
new TestCase( SECTION, "delete String.prototype.lastIndexOf.length", false, delete String.prototype.lastIndexOf.length );
new TestCase( SECTION, "delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length", 1, eval("delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length" ) );
new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('', 0)", LastIndexOf("","",0), eval("var s = new String(''); s.lastIndexOf('', 0)") );
new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('')", LastIndexOf("",""), eval("var s = new String(''); s.lastIndexOf('')") );

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

@ -39,8 +39,6 @@ var TITLE = "String.prototype.split";
writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length );
new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length );
new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") );
// test cases for when split is called with no arguments.

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

@ -42,8 +42,6 @@ var TITLE = "String.prototype.substring( start )";
writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length );
new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length );
new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") );
// test cases for when substring is called with no arguments.

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

@ -23,7 +23,6 @@ startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION, "eval.length", 1, eval.length );
new TestCase( SECTION, "delete eval.length", false, delete eval.length );
new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") );
new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") );
// new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ );

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

@ -212,14 +212,14 @@ var len1Desc =
assertEq(len1Desc.value, 3);
assertEq(len1Desc.writable, false);
assertEq(len1Desc.enumerable, false);
assertEq(len1Desc.configurable, false);
assertEq(len1Desc.configurable, true);
var len2Desc =
Object.getOwnPropertyDescriptor(function(a, b, c){}.bind(null, 2), "length");
assertEq(len2Desc.value, 2);
assertEq(len2Desc.writable, false);
assertEq(len2Desc.enumerable, false);
assertEq(len2Desc.configurable, false);
assertEq(len2Desc.configurable, true);
/*

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

@ -234,7 +234,7 @@ expected =
value: 0,
writable: false,
enumerable: false,
configurable: false
configurable: true
};
expectDescriptor(pd, expected);
@ -258,7 +258,7 @@ expected =
value: 1,
writable: false,
enumerable: false,
configurable: false
configurable: true
};
expectDescriptor(pd, expected);

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

@ -520,8 +520,6 @@ function mapTestDescriptors(filter)
var ALL_DESCRIPTORS = mapTestDescriptors(function(d) { return true; });
var VALID_DESCRIPTORS = mapTestDescriptors(isValidDescriptor);
var SKIP_FULL_FUNCTION_LENGTH_TESTS = true;
function TestRunner()
{
this._logLines = [];
@ -535,20 +533,11 @@ TestRunner.prototype =
var self = this;
function functionLengthTests()
{
if (SKIP_FULL_FUNCTION_LENGTH_TESTS)
{
print("Skipping full tests for redefining Function.length for now " +
"because we don't support redefinition of properties with " +
"native getter or setter...");
self._simpleFunctionLengthTests();
}
else
{
self._simpleFunctionLengthTests();
self._fullFunctionLengthTests(function() { }, 0);
self._fullFunctionLengthTests(function(one) { }, 1);
self._fullFunctionLengthTests(function(one, two) { }, 2);
}
self._fullFunctionLengthTests(() => Function("one", "/* body */"), 1);
self._fullFunctionLengthTests(() => function(one, two, three=null) { }, 2);
self._fullFunctionLengthTests(() => (one, two, ...etc) => 0, 2);
self._fullFunctionLengthTests(() => ({method(){}}.method), 0);
self._fullFunctionLengthTests(() => Object.getOwnPropertyDescriptor({set x(v){}}, "x").set, 1);
}
this._runTestSet(functionLengthTests, "Function length tests completed!");
@ -737,39 +726,15 @@ TestRunner.prototype =
if (errorCount > 0)
throw errorCount + " errors detected, FAIL";
},
_simpleFunctionLengthTests: function _simpleFunctionLengthTests(fun)
_fullFunctionLengthTests: function _fullFunctionLengthTests(funFactory, len)
{
print("Running simple Function.length tests now..");
print("Running Function.length (" + funFactory + ") tests now...");
function expectThrowTypeError(o, p, desc)
for (var i = 0, sz = VALID_DESCRIPTORS.length; i < sz; i++)
{
var err = "<none>", passed = false;
try
{
Object.defineProperty(o, p, desc);
}
catch (e)
{
err = e;
passed = e instanceof TypeError;
}
assertEq(passed, true, fun + " didn't throw TypeError when called: " + err);
var desc = VALID_DESCRIPTORS[i];
this._runSingleFunctionLengthTest(funFactory(), len, desc);
}
expectThrowTypeError(function a() { }, "length", { value: 1 });
expectThrowTypeError(function a() { }, "length", { enumerable: true });
expectThrowTypeError(function a() { }, "length", { configurable: true });
expectThrowTypeError(function a() { }, "length", { writable: true });
},
_fullFunctionLengthTests: function _fullFunctionLengthTests(fun)
{
var len = fun.length;
print("Running Function.length (" + len + ") tests now...");
var desc;
var gen = new DescriptorState();
while ((desc = gen.nextDescriptor()))
this._runSingleFunctionLengthTest(fun, len, desc);
},
_log: function _log(v)
{
@ -982,7 +947,7 @@ TestRunner.prototype =
{
value: len,
enumerable: false,
configurable: false,
configurable: true,
writable: false
});

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

@ -12,8 +12,5 @@ function fn() {
assertEq(testLenientAndStrict('var f = fn(); f.length = 1; f.length',
returns(3), raisesException(TypeError)),
true);
assertEq(testLenientAndStrict('var f = fn(); delete f.length',
returns(false), raisesException(TypeError)),
true);
reportCompare(true, true);

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

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

@ -0,0 +1,21 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/ */
// Deleting .length from a variety of builtin functions works as expected.
for (var fun of [Math.sin, Array.prototype.map, eval]) {
assertEq(delete fun.length, true);
assertEq(fun.hasOwnProperty("length"), false);
assertEq("length" in fun, true); // still inheriting Function.prototype.length
assertEq(fun.length, 0);
// The inherited property is nonwritable, so assigning still fails
// (silently, in sloppy mode).
fun.length = Math.hypot;
assertEq(fun.length, 0);
// It can be shadowed via defineProperty.
Object.defineProperty(fun, "length", {value: Math.hypot});
assertEq(fun.length, Math.hypot);
}
reportCompare(0, 0, 'ok');

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

@ -0,0 +1,86 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/ */
// Very simple initial test that the "length" property of a function is
// configurable. More thorough tests follow.
var f = function (a1, a2, a3, a4) {};
assertEq(delete f.length, true);
assertEq(f.hasOwnProperty("length"), false);
assertEq(f.length, 0); // inherited from Function.prototype.length
assertEq(delete Function.prototype.length, true);
assertEq(f.length, undefined);
// Now for the details.
//
// Many of these tests are poking at the "resolve hook" mechanism SM uses to
// lazily create this property, which is wonky and deserving of some extra
// skepticism.
// We've deleted Function.prototype.length. Check that the resolve hook does
// not resurrect it.
assertEq("length" in Function.prototype, false);
Function.prototype.length = 7;
assertEq(Function.prototype.length, 7);
delete Function.prototype.length;
assertEq(Function.prototype.length, undefined);
// OK, define Function.prototype.length back to its original state per spec, so
// the remaining tests can run in a more typical environment.
Object.defineProperty(Function.prototype, "length", {value: 0, configurable: true});
// Check the property descriptor of a function length property.
var g = function f(a1, a2, a3, a4, a5) {};
var desc = Object.getOwnPropertyDescriptor(g, "length");
assertEq(desc.configurable, true);
assertEq(desc.enumerable, false);
assertEq(desc.writable, false);
assertEq(desc.value, 5);
// After deleting the length property, assigning to f.length fails because
// Function.prototype.length is non-writable. In strict mode it would throw.
delete g.length;
g.length = 12;
assertEq(g.hasOwnProperty("length"), false);
assertEq(g.length, 0);
// After deleting both the length property and Function.prototype.length,
// assigning to f.length creates a new plain old data property.
delete Function.prototype.length;
g.length = 13;
var desc = Object.getOwnPropertyDescriptor(g, "length");
assertEq(desc.configurable, true);
assertEq(desc.enumerable, true);
assertEq(desc.writable, true);
assertEq(desc.value, 13);
// Deleting the .length of one instance of a FunctionDeclaration does not
// affect other instances.
function mkfun() {
function fun(a1, a2, a3, a4, a5) {}
return fun;
}
g = mkfun();
var h = mkfun();
delete h.length;
assertEq(g.length, 5);
assertEq(mkfun().length, 5);
// Object.defineProperty on a brand-new function is sufficient to cause the
// LENGTH_RESOLVED flag to be set.
g = mkfun();
Object.defineProperty(g, "length", {value: 0});
assertEq(delete g.length, true);
assertEq(g.hasOwnProperty("length"), false);
// Object.defineProperty on a brand-new function correctly merges new
// attributes with the builtin ones.
g = mkfun();
Object.defineProperty(g, "length", { value: 42 });
desc = Object.getOwnPropertyDescriptor(g, "length");
assertEq(desc.configurable, true);
assertEq(desc.enumerable, false);
assertEq(desc.writable, false);
assertEq(desc.value, 42);
reportCompare(0, 0, 'ok');

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

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

@ -4,6 +4,36 @@
skip-if(!this.hasOwnProperty("Intl")) include test262/intl402/jstests.list # Intl is not enabled in all builds
skip script ecma_6/String/normalize-generateddata-input.js # input data for other test
###################################################
# Test262 tests skipped due to SpiderMonkey fixes #
###################################################
# These tests assert that function.length is non-configurable. It was
# non-configurable in ES5, but ES6 changes this and we have implemented the
# newer standard (bug 911142).
skip script test262/intl402/ch13/13.1/13.1.1_L15.js
skip script test262/intl402/ch13/13.2/13.2.1_L15.js
skip script test262/intl402/ch13/13.3/13.3.1_L15.js
skip script test262/intl402/ch13/13.3/13.3.2_L15.js
skip script test262/intl402/ch13/13.3/13.3.3_L15.js
skip script test262/intl402/ch10/10.2/10.2.2_L15.js
skip script test262/intl402/ch10/10.3/10.3.2_1_a_L15.js
skip script test262/intl402/ch10/10.3/10.3.3_L15.js
skip script test262/intl402/ch10/10.3/10.3.2_L15.js
skip script test262/intl402/ch10/10.1/10.1_L15.js
skip script test262/intl402/ch11/11.2/11.2.2_L15.js
skip script test262/intl402/ch11/11.1/11.1_L15.js
skip script test262/intl402/ch11/11.3/11.3.3_L15.js
skip script test262/intl402/ch11/11.3/11.3.2_L15.js
skip script test262/intl402/ch11/11.3/11.3.2_1_a_L15.js
skip script test262/intl402/ch12/12.3/12.3.3_L15.js
skip script test262/intl402/ch12/12.3/12.3.2_L15.js
skip script test262/intl402/ch12/12.3/12.3.2_1_a_L15.js
skip script test262/intl402/ch12/12.1/12.1_L15.js
skip script test262/intl402/ch12/12.2/12.2.2_L15.js
skip script test262/ch13/13.2/13.2-15-1.js
skip script test262/ch11/11.4/11.4.1/11.4.1-5-a-28-s.js
##################################################
# Test262 tests skipped due to SpiderMonkey bugs #
##################################################

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

@ -1385,7 +1385,6 @@ Debugger::onTrap(JSContext *cx, MutableHandleValue vp)
if (!site || !site->hasBreakpoint(bp))
continue;
/*
* There are two reasons we have to check whether dbg is enabled and
* debugging scriptGlobal.
@ -1621,6 +1620,13 @@ Debugger::slowPathOnLogAllocationSite(JSContext *cx, HandleSavedFrame frame, int
return true;
}
bool
Debugger::isDebuggee(const JSCompartment *compartment) const
{
MOZ_ASSERT(compartment);
return compartment->isDebuggee() && debuggees.has(compartment->maybeGlobal());
}
bool
Debugger::appendAllocationSite(JSContext *cx, HandleSavedFrame frame, int64_t when)
{

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

@ -22,13 +22,13 @@
#include "vm/GlobalObject.h"
#include "vm/SavedStacks.h"
typedef enum JSTrapStatus {
enum JSTrapStatus {
JSTRAP_ERROR,
JSTRAP_CONTINUE,
JSTRAP_RETURN,
JSTRAP_THROW,
JSTRAP_LIMIT
} JSTrapStatus;
};
namespace js {
@ -234,10 +234,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
// Return true if the given compartment is a debuggee of this debugger,
// false otherwise.
bool isDebuggee(const JSCompartment *compartment) const {
MOZ_ASSERT(compartment);
return compartment->isDebuggee() && debuggees.has(compartment->maybeGlobal());
}
bool isDebuggee(const JSCompartment *compartment) const;
private:
HeapPtrNativeObject object; /* The Debugger object. Strong reference. */

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

@ -50,12 +50,26 @@ public:
// scenarios.
const static uint32_t kInitialRwin = 256 * 1024 * 1024;
// soft errors are errors that terminate a stream without terminating the
// connection. In general non-network errors are stream errors as well
// as network specific items like cancels.
bool SoftStreamError(nsresult code)
{
if (NS_SUCCEEDED(code)) {
return false;
}
// this could go either way, but because there are network instances of
// it being a hard error we should consider it hard.
if (code == NS_ERROR_FAILURE) {
return false;
}
if (NS_ERROR_GET_MODULE(code) != NS_ERROR_MODULE_NETWORK) {
return true;
}
// these are network specific soft errors
return (code == NS_BASE_STREAM_CLOSED || code == NS_BINDING_FAILED ||
code == NS_BINDING_ABORTED || code == NS_BINDING_REDIRECTED ||
code == NS_ERROR_INVALID_CONTENT_ENCODING ||

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

@ -1,8 +1,19 @@
[WeakMap.prototype-properties.html]
type: testharness
[WeakMap.prototype.clear.length]
expected: FAIL
[WeakMap.prototype.delete.length]
expected: FAIL
[WeakMap.prototype.get.length]
expected: FAIL
[WeakMap.prototype.get: return undefined]
expected: FAIL
[WeakMap.prototype.has.length]
expected: FAIL
[WeakMap.prototype.set.length]
expected: FAIL