-
Notifications
You must be signed in to change notification settings - Fork 1.2k
OS#14101048: Fixes #249: built-in functions should not have caller/arguments (and related fixes) #4651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS#14101048: Fixes #249: built-in functions should not have caller/arguments (and related fixes) #4651
Conversation
| this->IsGeneratorFunction() || | ||
| this->IsBoundFunction() || | ||
| this->IsStrictMode() | ||
| this->IsStrictMode() || |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
boingoing
left a comment
There was a problem hiding this 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() || |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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();
}
|
Updated the description with test262 results. /cc @bterlson |
test/es6/ES6RestrictedProperties.js
Outdated
| 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"); |
There was a problem hiding this comment.
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
…e caller/arguments (and related fixes) See: https://tc39.github.io/ecma262/#sec-forbidden-extensions Fixes chakra-core#249 Fixes OS#14101048
b40e157 to
6a2e42d
Compare
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). |
curtisman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
akroshg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
…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 ```
…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 ```
… 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 ```
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.)