Ignore:
Timestamp:
Feb 25, 2016, 4:15:58 PM (9 years ago)
Author:
[email protected]
Message:

[ES6] for...in iteration doesn't comply with the specification
https://bugs.webkit.org/show_bug.cgi?id=154665

Reviewed by Michael Saboff.

If you read ForIn/OfHeadEvaluation inside the spec:
https://tc39.github.io/ecma262/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind
It calls EnumerateObjectProperties(obj) to get a set of properties
to enumerate over (it models this "set" as en ES6 generator function).
EnumerateObjectProperties is defined in section 13.7.5.15:
https://tc39.github.io/ecma262/#sec-enumerate-object-properties
The implementation calls Reflect.getOwnPropertyDescriptor(.) on the
properties it sees. We must do the same by modeling the operation as
a GetOwnProperty instead of a HasProperty internal method call.

  • jit/JITOperations.cpp:
  • jit/JITOperations.h:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/JSObject.cpp:

(JSC::JSObject::hasProperty):
(JSC::JSObject::hasPropertyGeneric):

  • runtime/JSObject.h:
  • tests/stress/proxy-get-own-property.js:

(assert):
(let.handler.getOwnPropertyDescriptor):
(i.set assert):

Location:
trunk/Source/JavaScriptCore/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r196868 r197144  
    603603    pc[4].u.arrayProfile->observeStructure(base->structure(vm));
    604604    ASSERT(property.isUInt32());
    605     RETURN(jsBoolean(base->hasProperty(exec, property.asUInt32())));
     605    RETURN(jsBoolean(base->hasPropertyGeneric(exec, property.asUInt32(), PropertySlot::InternalMethodType::GetOwnProperty)));
    606606}
    607607
     
    615615    if (base->structure(vm)->id() == enumerator->cachedStructureID())
    616616        RETURN(jsBoolean(true));
    617     RETURN(jsBoolean(base->hasProperty(exec, asString(property.asCell())->toIdentifier(exec))));
     617    RETURN(jsBoolean(base->hasPropertyGeneric(exec, asString(property.asCell())->toIdentifier(exec), PropertySlot::InternalMethodType::GetOwnProperty)));
    618618}
    619619
     
    625625    bool result;
    626626    if (property.isString())
    627         result = base->hasProperty(exec, asString(property.asCell())->toIdentifier(exec));
     627        result = base->hasPropertyGeneric(exec, asString(property.asCell())->toIdentifier(exec), PropertySlot::InternalMethodType::GetOwnProperty);
    628628    else {
    629629        ASSERT(property.isUInt32());
    630         result = base->hasProperty(exec, property.asUInt32());
     630        result = base->hasPropertyGeneric(exec, property.asUInt32(), PropertySlot::InternalMethodType::GetOwnProperty);
    631631    }
    632632    RETURN(jsBoolean(result));
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r197136 r197144  
    12811281bool JSObject::hasProperty(ExecState* exec, PropertyName propertyName) const
    12821282{
    1283     PropertySlot slot(this, PropertySlot::InternalMethodType::HasProperty);
     1283    return hasPropertyGeneric(exec, propertyName, PropertySlot::InternalMethodType::HasProperty);
     1284}
     1285
     1286bool JSObject::hasProperty(ExecState* exec, unsigned propertyName) const
     1287{
     1288    return hasPropertyGeneric(exec, propertyName, PropertySlot::InternalMethodType::HasProperty);
     1289}
     1290
     1291bool JSObject::hasPropertyGeneric(ExecState* exec, PropertyName propertyName, PropertySlot::InternalMethodType internalMethodType) const
     1292{
     1293    PropertySlot slot(this, internalMethodType);
    12841294    return const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
    12851295}
    12861296
    1287 bool JSObject::hasProperty(ExecState* exec, unsigned propertyName) const
    1288 {
    1289     PropertySlot slot(this, PropertySlot::InternalMethodType::HasProperty);
     1297bool JSObject::hasPropertyGeneric(ExecState* exec, unsigned propertyName, PropertySlot::InternalMethodType internalMethodType) const
     1298{
     1299    PropertySlot slot(this, internalMethodType);
    12901300    return const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
    12911301}
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r197136 r197144  
    479479    JS_EXPORT_PRIVATE bool hasProperty(ExecState*, PropertyName) const;
    480480    JS_EXPORT_PRIVATE bool hasProperty(ExecState*, unsigned propertyName) const;
     481    bool hasPropertyGeneric(ExecState*, PropertyName, PropertySlot::InternalMethodType) const;
     482    bool hasPropertyGeneric(ExecState*, unsigned propertyName, PropertySlot::InternalMethodType) const;
    481483    bool hasOwnProperty(ExecState*, PropertyName) const;
    482484    bool hasOwnProperty(ExecState*, unsigned) const;
Note: See TracChangeset for help on using the changeset viewer.