Bug 1019181 - Don't use JSPROP_PERMANENT for JSOP_DEFCONST (r=jorendorff)

This commit is contained in:
Bill McCloskey 2014-06-21 11:54:36 -07:00
parent 21b58e5735
commit 53f07d07b2
4 changed files with 11 additions and 7 deletions

View File

@ -2195,10 +2195,10 @@ BaselineCompiler::emit_JSOP_DEFVAR()
frame.syncStack(0);
unsigned attrs = JSPROP_ENUMERATE;
if (!script->isForEval())
attrs |= JSPROP_PERMANENT;
if (JSOp(*pc) == JSOP_DEFCONST)
attrs |= JSPROP_READONLY;
else if (!script->isForEval())
attrs |= JSPROP_PERMANENT;
JS_ASSERT(attrs <= UINT32_MAX);
masm.loadPtr(frame.addressOfScopeChain(), R0.scratchReg());

View File

@ -9733,9 +9733,12 @@ IonBuilder::jsop_defvar(uint32_t index)
PropertyName *name = script()->getName(index);
// Bake in attrs.
unsigned attrs = JSPROP_ENUMERATE | JSPROP_PERMANENT;
unsigned attrs = JSPROP_ENUMERATE;
if (JSOp(*pc) == JSOP_DEFCONST)
attrs |= JSPROP_READONLY;
else
attrs |= JSPROP_PERMANENT;
JS_ASSERT(!script()->isForEval());
// Pass the ScopeChain.
JS_ASSERT(analysis().usesScopeChain());

View File

@ -2910,10 +2910,10 @@ CASE(JSOP_DEFVAR)
{
/* ES5 10.5 step 8 (with subsequent errata). */
unsigned attrs = JSPROP_ENUMERATE;
if (!REGS.fp()->isEvalFrame())
attrs |= JSPROP_PERMANENT;
if (*REGS.pc == JSOP_DEFCONST)
attrs |= JSPROP_READONLY;
else if (!REGS.fp()->isEvalFrame())
attrs |= JSPROP_PERMANENT;
/* Step 8b. */
RootedObject &obj = rootObject0;

View File

@ -1138,8 +1138,9 @@
macro(JSOP_DEFFUN, 127,"deffun", NULL, 5, 0, 0, JOF_OBJECT) \
/*
* Defines the new binding on the frame's current variables-object (the
* scope object on the scope chain designated to receive new variables)
* with 'READONLY' attribute.
* scope object on the scope chain designated to receive new variables) with
* 'READONLY' attribute. The binding is *not* JSPROP_PERMANENT. See bug
* 1019181 for the reason.
*
* This is used for global scripts and also in some cases for function
* scripts where use of dynamic scoping inhibits optimization.