Ignore:
Timestamp:
Apr 25, 2017, 5:57:59 PM (8 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r215476.
https://bugs.webkit.org/show_bug.cgi?id=171304

"It broke JSBench" (Requested by saamyjoon on #webkit).

Reverted changeset:

"[ES6]. Implement Annex B.3.3 function hoisting rules for
eval"
https://bugs.webkit.org/show_bug.cgi?id=163208
http://trac.webkit.org/changeset/215476

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r215720 r215779  
    10991099
    11001100    unsigned numVariables = eval->numVariables();
    1101     unsigned numTopLevelFunctionDecls = eval->numTopLevelFunctionDecls();
    1102     unsigned numFunctionHoistingCandidates = eval->numFunctionHoistingCandidates();
     1101    int numFunctions = eval->numberOfFunctionDecls();
    11031102
    11041103    JSScope* variableObject;
    1105     if ((numVariables || numTopLevelFunctionDecls) && eval->isStrictMode()) {
     1104    if ((numVariables || numFunctions) && eval->isStrictMode()) {
    11061105        scope = StrictEvalActivation::create(callFrame, scope);
    11071106        variableObject = scope;
     
    11341133
    11351134    // We can't declare a "var"/"function" that overwrites a global "let"/"const"/"class" in a sloppy-mode eval.
    1136     if (variableObject->isGlobalObject() && !eval->isStrictMode() && (numVariables || numTopLevelFunctionDecls)) {
     1135    if (variableObject->isGlobalObject() && !eval->isStrictMode() && (numVariables || numFunctions)) {
    11371136        JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalObject*>(variableObject)->globalLexicalEnvironment();
    11381137        for (unsigned i = 0; i < numVariables; ++i) {
     
    11441143        }
    11451144
    1146         for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) {
     1145        for (int i = 0; i < numFunctions; ++i) {
    11471146            FunctionExecutable* function = codeBlock->functionDecl(i);
    11481147            PropertySlot slot(globalLexicalEnvironment, PropertySlot::InternalMethodType::VMInquiry);
     
    11561155        variableObject->flattenDictionaryObject(vm);
    11571156
    1158     if (numVariables || numTopLevelFunctionDecls || numFunctionHoistingCandidates) {
     1157    if (numVariables || numFunctions) {
    11591158        BatchedTransitionOptimizer optimizer(vm, variableObject);
    11601159        if (variableObject->next() && !eval->isStrictMode())
     
    11731172            }
    11741173        }
    1175        
    1176         if (eval->isStrictMode()) {
    1177             for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) {
    1178                 FunctionExecutable* function = codeBlock->functionDecl(i);
    1179                 PutPropertySlot slot(variableObject);
    1180                 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
    1181             }
    1182         } else {
    1183             for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) {
    1184                 FunctionExecutable* function = codeBlock->functionDecl(i);
    1185                 JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, function->name());
    1186                 if (resolvedScope.isUndefined())
    1187                     return checkedReturn(throwSyntaxError(callFrame, throwScope, makeString("Can't create duplicate variable in eval: '", String(function->name().impl()), "'")));
    1188                 PutPropertySlot slot(variableObject);
    1189                 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
    1190                 RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
    1191             }
    1192 
    1193             for (unsigned i = 0; i < numFunctionHoistingCandidates; ++i) {
    1194                 const Identifier& ident = codeBlock->functionHoistingCandidate(i);
    1195                 JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, ident);
    1196                 if (!resolvedScope.isUndefined()) {
    1197                     if (!variableObject->hasProperty(callFrame, ident)) {
    1198                         PutPropertySlot slot(variableObject);
    1199                         variableObject->methodTable()->put(variableObject, callFrame, ident, jsUndefined(), slot);
    1200                         RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
    1201                     }
    1202                 }
    1203             }
     1174
     1175        for (int i = 0; i < numFunctions; ++i) {
     1176            FunctionExecutable* function = codeBlock->functionDecl(i);
     1177            PutPropertySlot slot(variableObject);
     1178            variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
     1179            RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
    12041180        }
    12051181    }
Note: See TracChangeset for help on using the changeset viewer.