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

Issue 11360116: Pass closure object as first implicit argument to closure functions. (Closed)

Created:
8 years, 1 month ago by regis
Modified:
8 years, 1 month ago
Reviewers:
siva
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Pass closure object as first implicit argument to closure functions. Remove code passing captured receiver to native instance closures; instead, access captured receiver in context, as non-native functions do. Committed: https://code.google.com/p/dart/source/detail?r=14698

Patch Set 1 #

Total comments: 12

Patch Set 2 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+239 lines, -224 lines) Patch
M runtime/vm/ast.h View 1 1 chunk +7 lines, -18 lines 0 comments Download
M runtime/vm/ast_printer.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/code_generator.cc View 1 2 chunks +6 lines, -32 lines 0 comments Download
M runtime/vm/code_generator_test.cc View 1 3 chunks +6 lines, -10 lines 0 comments Download
M runtime/vm/code_patcher_ia32_test.cc View 1 1 chunk +3 lines, -6 lines 0 comments Download
M runtime/vm/code_patcher_x64_test.cc View 1 1 chunk +3 lines, -6 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 1 chunk +22 lines, -3 lines 0 comments Download
M runtime/vm/dart_entry.cc View 1 2 chunks +10 lines, -2 lines 0 comments Download
M runtime/vm/flow_graph_compiler_ia32.cc View 1 6 chunks +10 lines, -20 lines 0 comments Download
M runtime/vm/flow_graph_compiler_x64.cc View 1 6 chunks +11 lines, -22 lines 0 comments Download
M runtime/vm/flow_graph_inliner.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language.h View 1 2 chunks +2 lines, -10 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 1 chunk +3 lines, -5 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 1 chunk +3 lines, -7 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 1 chunk +3 lines, -7 lines 0 comments Download
M runtime/vm/native_arguments.h View 1 4 chunks +52 lines, -7 lines 0 comments Download
M runtime/vm/object.cc View 1 5 chunks +27 lines, -9 lines 0 comments Download
M runtime/vm/parser.cc View 1 6 chunks +36 lines, -29 lines 0 comments Download
M runtime/vm/stub_code_ia32.cc View 1 9 chunks +16 lines, -14 lines 0 comments Download
M runtime/vm/stub_code_x64.cc View 1 9 chunks +15 lines, -14 lines 0 comments Download
M runtime/vm/symbols.h View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
regis
8 years, 1 month ago (2012-11-06 23:55:35 UTC) #1
siva
lgtm with couple of questions 1. index value passed in to Dart_GetNativeArgument 2. count computation ...
8 years, 1 month ago (2012-11-07 18:56:32 UTC) #2
regis
8 years, 1 month ago (2012-11-08 18:08:30 UTC) #3
Thanks!

http://codereview.chromium.org/11360116/diff/1/runtime/vm/code_generator.cc
File runtime/vm/code_generator.cc (right):

http://codereview.chromium.org/11360116/diff/1/runtime/vm/code_generator.cc#n...
runtime/vm/code_generator.cc:1260: // Receiver parameter has already been
skipped by caller.
On 2012/11/07 18:56:32, siva wrote:
> We should probably add a comment here indicating why the closure needs to be
> passed as a the first argument

Done.

http://codereview.chromium.org/11360116/diff/1/runtime/vm/dart_api_impl.cc
File runtime/vm/dart_api_impl.cc (right):

http://codereview.chromium.org/11360116/diff/1/runtime/vm/dart_api_impl.cc#ne...
runtime/vm/dart_api_impl.cc:3942: index++;  // Hide closure object.
On 2012/11/07 18:56:32, siva wrote:
> This seems to suggest that if one passed in an index of -1
> to this function and the arguments are for a static implicit closure then we
> will not be reporting an error.
> 
> Maybe you should increment the index after the index check
> below?

Good catch! Incrementing the index after the check would require the upper bound
to be adjusted prior to the check. It is actually simpler to use
Dart_GetNativeArgumentCount here.

http://codereview.chromium.org/11360116/diff/1/runtime/vm/dart_api_impl.cc#ne...
runtime/vm/dart_api_impl.cc:3970: // argument count remains unchanged.
On 2012/11/07 18:56:32, siva wrote:
> This comment should appear outside the if statement right.

Done.

http://codereview.chromium.org/11360116/diff/1/runtime/vm/native_arguments.h
File runtime/vm/native_arguments.h (right):

http://codereview.chromium.org/11360116/diff/1/runtime/vm/native_arguments.h#...
runtime/vm/native_arguments.h:66: bool AreOfInstanceFunction() const {
On 2012/11/07 18:56:32, siva wrote:
> I find the name AreOfInstanceFunction() a bit hard to read
> maybe ToInstanceFunction().
> 
> You don't have to change this I am fine with either.

Done.

http://codereview.chromium.org/11360116/diff/1/runtime/vm/native_arguments.h#...
runtime/vm/native_arguments.h:102: count--;
On 2012/11/07 18:56:32, siva wrote:
> I am a little confused by this.
> If a function is static and has been implicitly closurised then the closure
> object should be hidden and the argument count becomes one less but the check
> above seems inverted.

Oops. I do not know where the ! is coming from. Good catch.

http://codereview.chromium.org/11360116/diff/1/runtime/vm/native_arguments.h#...
runtime/vm/native_arguments.h:136: int argc_tag_;  // Encodes argument count and
argument location.
On 2012/11/07 18:56:32, siva wrote:
> // Encodes argument count and argument location.
> 
> Should that be
> 
> // Encodes argument count and invoked native call type.

Done.

Powered by Google App Engine
This is Rietveld 408576698