Skip to content

Conversation

@dilijev
Copy link
Contributor

@dilijev dilijev commented Feb 7, 2018

Replaces #4639

Several tests and test baselines needed to be updated to reflect the change in behavior. This change improves caller/arguments behavior without regressing any previous Chakra behavior. Chakra still differs from the spec and other engines on some aspects of caller/arguments.

See: https://tc39.github.io/ecma262/#sec-forbidden-extensions

Fixes #249
Fixes OS#14101048


Test262 results strictly improved.

Using test262 commit tc39/test262@03da228:

Previously 44130 passed, now 44138 passed out of 57102. (Duplicates below are strict and non-strict versions of the tests.)

+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js

@dilijev dilijev changed the title OS#14101048: gh-249: built-in functions should not have caller/arguments (and related fixes) OS#14101048: Fixes #249: built-in functions should not have caller/arguments (and related fixes) Feb 7, 2018
this->IsGeneratorFunction() ||
this->IsBoundFunction() ||
this->IsStrictMode()
this->IsStrictMode() ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this should also check to see if the function is a method, right? Seems like https://tc39.github.io/ecma262/#sec-forbidden-extensions implies this. This is a little complicated, though, because FunctionInfo doesn't have an IsMethod helper. To plumb the flag, you could pull it out of PnFnc::IsMethod in ByteCodeGenerator::StartBindFunction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this->functionInfo->IsClassMethod() up at the top of this clause captures that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's true since kFunctionIsClassMember and kFunctionIsMethod are different flags on PnFnc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. In any case the behavior seems to be correct (per comparison other engines on test/es6/ES6RestrictedProperties.js). Will look into this in the future.


In reply to: 166775893 [](ancestors = 166775893)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I thought I saw a comment in one of the test files that said object-literal methods had different behavior on spidermonkey / v8.

Copy link
Contributor

@boingoing boingoing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍
I'd like to address handling methods correctly as well but that can be handled in a different issue as far as I'm concerned.

this->IsGeneratorFunction() ||
this->IsBoundFunction() ||
this->IsStrictMode()
this->IsStrictMode() ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this->functionInfo->IsClassMethod() up at the top of this clause captures that.


bool RuntimeFunction::Is(Var func)
{
return JavascriptFunction::Is(func) && !JavascriptFunction::UnsafeFromVar(func)->GetFunctionInfo()->HasBody();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@curtisman does this look right?

For reference, ScriptFunction is defined similarly (without negating HasBody()):

    bool ScriptFunction::Is(Var func)
    {
        return JavascriptFunction::Is(func) && JavascriptFunction::UnsafeFromVar(func)->GetFunctionInfo()->HasBody();
    }

@dilijev
Copy link
Contributor Author

dilijev commented Feb 7, 2018

Updated the description with test262 results. /cc @bterlson

var p2 = Object.getOwnPropertyDescriptor(obj, 'arguments');
assert.isFalse(p2.enumerable, "Function.prototype function has 'arguments' own property which is not enumerable");
assert.isFalse(p2.configurable, "Function.prototype function has 'arguments' own property which is not configurable");
assert.isTrue(p2.configurable, "Function.prototype function has 'arguments' own property which is is configurable");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is [](start = 110, length = 3)

whoops, typo

@dilijev
Copy link
Contributor Author

dilijev commented Feb 8, 2018

@dilijev dilijev force-pushed the func-restricted-props branch from b40e157 to 6a2e42d Compare February 8, 2018 01:13
@dilijev dilijev changed the base branch from master to release/1.8 February 8, 2018 01:22
@dilijev
Copy link
Contributor Author

dilijev commented Feb 8, 2018

@boingoing

Oh I thought I saw a comment in one of the test files that said object-literal methods had different behavior on spidermonkey / v8.

Yes, that's right. I didn't realize we would call those object member function "methods". Getting that check right would fix that divergent behavior. But I think that can be outside the scope of this fix (which fixes the bug, no regressions).

Copy link
Contributor

@curtisman curtisman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@akroshg akroshg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@chakrabot chakrabot merged commit 6a2e42d into chakra-core:release/1.8 Feb 8, 2018
chakrabot pushed a commit that referenced this pull request Feb 8, 2018
…ould not have caller/arguments (and related fixes)

Merge pull request #4651 from dilijev:func-restricted-props

Replaces #4639

Several tests and test baselines needed to be updated to reflect the change in behavior. This change improves caller/arguments behavior without regressing any previous Chakra behavior. Chakra still differs from the spec and other engines on some aspects of caller/arguments.

See: https://tc39.github.io/ecma262/#sec-forbidden-extensions

Fixes #249
Fixes OS#14101048

---

Test262 results strictly improved.

Using test262 commit tc39/test262@03da228:

Previously 44130 passed, now 44138 passed out of 57102. (Duplicates below are strict and non-strict versions of the tests.)

```
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js
```
chakrabot pushed a commit that referenced this pull request Feb 8, 2018
…nctions should not have caller/arguments (and related fixes)

Merge pull request #4651 from dilijev:func-restricted-props

Replaces #4639

Several tests and test baselines needed to be updated to reflect the change in behavior. This change improves caller/arguments behavior without regressing any previous Chakra behavior. Chakra still differs from the spec and other engines on some aspects of caller/arguments.

See: https://tc39.github.io/ecma262/#sec-forbidden-extensions

Fixes #249
Fixes OS#14101048

---

Test262 results strictly improved.

Using test262 commit tc39/test262@03da228:

Previously 44130 passed, now 44138 passed out of 57102. (Duplicates below are strict and non-strict versions of the tests.)

```
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js
```
chakrabot pushed a commit that referenced this pull request Feb 8, 2018
… built-in functions should not have caller/arguments (and related fixes)

Merge pull request #4651 from dilijev:func-restricted-props

Replaces #4639

Several tests and test baselines needed to be updated to reflect the change in behavior. This change improves caller/arguments behavior without regressing any previous Chakra behavior. Chakra still differs from the spec and other engines on some aspects of caller/arguments.

See: https://tc39.github.io/ecma262/#sec-forbidden-extensions

Fixes #249
Fixes OS#14101048

---

Test262 results strictly improved.

Using test262 commit tc39/test262@03da228:

Previously 44130 passed, now 44138 passed out of 57102. (Duplicates below are strict and non-strict versions of the tests.)

```
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/Function/prototype/restricted-property-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-arguments.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js
+PASS e:/dd/test262/test262/test/built-ins/ThrowTypeError/forbidden-caller.js
```
@dilijev dilijev deleted the func-restricted-props branch February 8, 2018 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants