|
|
Created:
4 years, 3 months ago by Dan Ehrenberg Modified:
4 years, 3 months ago CC:
neis, v8-reviews_googlegroups.com, Toon Verwaest Target Ref:
refs/pending/heads/master Project:
v8 Visibility:
Public. |
DescriptionFilter out synthetic variables from with scopes
This patch ensures that variables like .new_target aren't overwritable
using with scopes. It does this by ensuring that scope analysis does
not consider with scopes (or eval scopes) for such 'synthetic variables',
similarly to how the 'this' variable was already handled.
The patch also adds a DCHECK for the dynamic parallel to this case,
replacing a previous unreachable path for a particular instance.
BUG=v8:5405
Committed: https://crrev.com/dcd61b90207adc8cc068c2b86c9f5a9d4e54999f
Cr-Commit-Position: refs/heads/master@{#39567}
Patch Set 1 #Patch Set 2 : formatting #Patch Set 3 : Test against the raw_name, not the name #Patch Set 4 : Fix whitespace #
Total comments: 4
Patch Set 5 : Minimal fix #Messages
Total messages: 32 (22 generated)
The CQ bit was checked by littledan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by littledan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_presubmit on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/24390)
The CQ bit was checked by littledan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_presubmit on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/24396)
The CQ bit was checked by littledan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
littledan@chromium.org changed reviewers: + adamk@chromium.org
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux_dbg_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_dbg_ng/builds/13003) v8_linux_dbg_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_dbg_ng_triggered/b...)
https://codereview.chromium.org/2353623002/diff/60001/src/ast/scopeinfo.cc File src/ast/scopeinfo.cc (right): https://codereview.chromium.org/2353623002/diff/60001/src/ast/scopeinfo.cc#ne... src/ast/scopeinfo.cc:621: bool Scope::VariableIsSynthetic(const AstRawString* name) { Yikes, I think this should be in scopes.cc. If you want to have them in the same file, they should be in the same class, in which case I think putting them both in Scope makes sense (as public static methods). https://codereview.chromium.org/2353623002/diff/60001/src/contexts.cc File src/contexts.cc (right): https://codereview.chromium.org/2353623002/diff/60001/src/contexts.cc#newcode233 src/contexts.cc:233: DCHECK(!ScopeInfo::VariableIsSynthetic(*name)); Looks like this is failing?
verwaest@chromium.org changed reviewers: + verwaest@chromium.org
https://codereview.chromium.org/2353623002/diff/60001/src/ast/scopes.cc File src/ast/scopes.cc (right): https://codereview.chromium.org/2353623002/diff/60001/src/ast/scopes.cc#newco... src/ast/scopes.cc:1451: if (Scope::VariableIsSynthetic(var->raw_name())) return var; I'd be much in favor of having specialized scope resolution for those variables, done on-the-fly when dealing with those specific vars. This just slows down scope resolution for al other vars unnecessarily.
https://codereview.chromium.org/2353623002/diff/60001/src/ast/scopes.cc File src/ast/scopes.cc (right): https://codereview.chromium.org/2353623002/diff/60001/src/ast/scopes.cc#newco... src/ast/scopes.cc:1451: if (Scope::VariableIsSynthetic(var->raw_name())) return var; On 2016/09/19 at 20:01:50, Toon Verwaest wrote: > I'd be much in favor of having specialized scope resolution for those variables, done on-the-fly when dealing with those specific vars. This just slows down scope resolution for al other vars unnecessarily. I looked into some ways to mitigate the performance regression here in a more limited way, without a separate scope resolution mechanism, but it seems like it would result in at least reading another flag/having a conditional per variable at some point or other. What if we backed out this portion of the patch, as it hurts performance without being what we want for the long-term structure, but left in the context part as a quick, hopefully temporary fix for the new.target case? The context code change shouldn't hurt performance much (I don't think we should care about with getting slightly slower). For the promise case, I'm working on switching that to directly using temporaries at https://codereview.chromium.org/2359513002 , but new.target is a little tougher because it is captured by arrow functions.
What do you think of this minimal fix for new.target while a better solution is developed for a more static mechanism for scoping synthetic variables? I don't think it should have significant performance effects (with scopes are already slow, with unscopables, etc).
The CQ bit was checked by littledan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
FWIW this minimal fix lgtm; Toon, thoughts?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Lgtm thanks. Surprised to see this handled there as it should never happen.
The CQ bit was checked by littledan@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #5 (id:80001)
Message was sent while issue was closed.
Description was changed from ========== Filter out synthetic variables from with scopes This patch ensures that variables like .new_target aren't overwritable using with scopes. It does this by ensuring that scope analysis does not consider with scopes (or eval scopes) for such 'synthetic variables', similarly to how the 'this' variable was already handled. The patch also adds a DCHECK for the dynamic parallel to this case, replacing a previous unreachable path for a particular instance. BUG=v8:5405 ========== to ========== Filter out synthetic variables from with scopes This patch ensures that variables like .new_target aren't overwritable using with scopes. It does this by ensuring that scope analysis does not consider with scopes (or eval scopes) for such 'synthetic variables', similarly to how the 'this' variable was already handled. The patch also adds a DCHECK for the dynamic parallel to this case, replacing a previous unreachable path for a particular instance. BUG=v8:5405 Committed: https://crrev.com/dcd61b90207adc8cc068c2b86c9f5a9d4e54999f Cr-Commit-Position: refs/heads/master@{#39567} ==========
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/dcd61b90207adc8cc068c2b86c9f5a9d4e54999f Cr-Commit-Position: refs/heads/master@{#39567} |