Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Issue 2989493002: Simplify and fix implicit closure check, speed up Closure_equals (Closed)

Created:
3 years, 5 months ago by alexmarkov
Modified:
3 years, 5 months ago
Reviewers:
zra, siva
CC:
reviews_dartlang.org, turnidge, rmacnak, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Simplify and fix implicit closure check, speed up Closure_equals This CL introduces a new Function kind, kImplicitClosureFunction, in order to simplify check for implicit closures and make it more efficient. This CL also fixes Function::IsImplicitStaticClosureFunction(RawFunction*) to correctly handle implicit closures created from static native functions. Closes #30203. As the result of a faster check for implicit closures and slight refactoring of Closure_equals, micro-benchmark exercising Closure_equals speeds up from 9618ms to 6700ms for implicit closures case and insignificantly for other cases. R=zra@google.com Committed: https://github.com/dart-lang/sdk/commit/44e8da3ecd23de5fdd022d6de0d2ec895cc37beb

Patch Set 1 #

Total comments: 8

Patch Set 2 : Review fixes #

Total comments: 2

Patch Set 3 : Avoid overloaded NewClosureFunction #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+170 lines, -75 lines) Patch
M runtime/lib/function.cc View 1 chunk +22 lines, -25 lines 4 comments Download
M runtime/observatory/lib/src/elements/function_view.dart View 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/observatory/lib/src/models/objects/function.dart View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/observatory/lib/src/service/object.dart View 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/kernel_binary_flowgraph.cc View 2 chunks +2 lines, -0 lines 0 comments Download
M runtime/vm/object.h View 1 2 6 chunks +23 lines, -4 lines 0 comments Download
M runtime/vm/object.cc View 1 2 8 chunks +44 lines, -42 lines 0 comments Download
M runtime/vm/parser.cc View 1 chunk +3 lines, -4 lines 0 comments Download
M runtime/vm/raw_object.h View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/source_report.cc View 1 chunk +1 line, -0 lines 0 comments Download
A tests/isolate/message4_test.dart View 1 1 chunk +69 lines, -0 lines 0 comments Download

Messages

Total messages: 12 (2 generated)
alexmarkov
3 years, 5 months ago (2017-07-21 19:20:14 UTC) #2
zra
https://codereview.chromium.org/2989493002/diff/1/runtime/vm/object.cc File runtime/vm/object.cc (right): https://codereview.chromium.org/2989493002/diff/1/runtime/vm/object.cc#newcode5993 runtime/vm/object.cc:5993: RawFunction::Kind k = kind(); const https://codereview.chromium.org/2989493002/diff/1/runtime/vm/object.cc#newcode6674 runtime/vm/object.cc:6674: RawFunction* Function::NewClosureFunction(const ...
3 years, 5 months ago (2017-07-21 19:54:16 UTC) #3
alexmarkov
https://codereview.chromium.org/2989493002/diff/1/runtime/vm/object.cc File runtime/vm/object.cc (right): https://codereview.chromium.org/2989493002/diff/1/runtime/vm/object.cc#newcode5993 runtime/vm/object.cc:5993: RawFunction::Kind k = kind(); On 2017/07/21 19:54:16, zra wrote: ...
3 years, 5 months ago (2017-07-21 20:51:42 UTC) #4
zra
lgtm w/ helper function rename. https://codereview.chromium.org/2989493002/diff/20001/runtime/vm/object.h File runtime/vm/object.h (right): https://codereview.chromium.org/2989493002/diff/20001/runtime/vm/object.h#newcode2888 runtime/vm/object.h:2888: static RawFunction* NewClosureFunction(RawFunction::Kind kind, ...
3 years, 5 months ago (2017-07-21 20:58:09 UTC) #5
alexmarkov
https://codereview.chromium.org/2989493002/diff/20001/runtime/vm/object.h File runtime/vm/object.h (right): https://codereview.chromium.org/2989493002/diff/20001/runtime/vm/object.h#newcode2888 runtime/vm/object.h:2888: static RawFunction* NewClosureFunction(RawFunction::Kind kind, On 2017/07/21 20:58:09, zra wrote: ...
3 years, 5 months ago (2017-07-21 21:16:08 UTC) #6
alexmarkov
Committed patchset #3 (id:40001) manually as 44e8da3ecd23de5fdd022d6de0d2ec895cc37beb (presubmit successful).
3 years, 5 months ago (2017-07-21 21:27:02 UTC) #8
siva
DBC https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc File runtime/lib/function.cc (right): https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc#newcode45 runtime/lib/function.cc:45: const Function& func_a = Function::Handle(zone, receiver.function()); It probably ...
3 years, 5 months ago (2017-07-21 21:47:17 UTC) #9
alexmarkov
https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc File runtime/lib/function.cc (right): https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc#newcode45 runtime/lib/function.cc:45: const Function& func_a = Function::Handle(zone, receiver.function()); On 2017/07/21 21:47:17, ...
3 years, 5 months ago (2017-07-21 22:02:43 UTC) #10
siva
https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc File runtime/lib/function.cc (right): https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc#newcode45 runtime/lib/function.cc:45: const Function& func_a = Function::Handle(zone, receiver.function()); On 2017/07/21 22:02:43, ...
3 years, 5 months ago (2017-07-21 22:51:25 UTC) #11
alexmarkov
3 years, 5 months ago (2017-07-24 16:11:47 UTC) #12
Message was sent while issue was closed.
https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc
File runtime/lib/function.cc (right):

https://codereview.chromium.org/2989493002/diff/40001/runtime/lib/function.cc...
runtime/lib/function.cc:45: const Function& func_a = Function::Handle(zone,
receiver.function());
On 2017/07/21 22:51:24, siva wrote:
> On 2017/07/21 22:02:43, alexmarkov wrote:
> > On 2017/07/21 21:47:17, siva wrote:
> > > It probably makes sense to avoid creation of this handle
> > > if other.IsClosure() is false.
> > > The old code was doing that.
> > 
> > My gut feeling tells me that comparing a closure with non-closure is more
rare
> > than comparing 2 closures. By moving IsClosure() check after
> > IsImplicitClosureFunction() I optimized cases of explicit and implicit
static
> > closures (identity comparison is sufficient for them).
> > 
> > Do you think my assumption is wrong and comparison of closure with
non-closure
> > happens more frequently than comparison of 2 closures?
> 
> Not sure depends on the program being run, you should be able to figure that
out
> by running some flutter programs (posse, gallery etc.). 
> 
> other.IsClosure() is a very cheap function anyway (a virtual call)

Reverted to the earlier testing other.IsClosure(), in the next review
(https://codereview.chromium.org/2987703002/).

Powered by Google App Engine
This is Rietveld 408576698