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

Issue 10827288: - Support for patching of class methods and fields. (Closed)

Created:
8 years, 4 months ago by Ivan Posva
Modified:
8 years, 4 months ago
Reviewers:
hausner, siva
CC:
reviews_dartlang.org, Anders Johnsen, Mads Ager (google)
Visibility:
Public.

Description

- Support for patching of class methods and fields. Committed: https://code.google.com/p/dart/source/detail?r=10616

Patch Set 1 #

Patch Set 2 : #

Total comments: 1

Patch Set 3 : #

Total comments: 13
Unified diffs Side-by-side diffs Delta from patch set Stats (+361 lines, -97 lines) Patch
M runtime/lib/isolate.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/vm/class_finalizer.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/code_generator.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 4 chunks +22 lines, -2 lines 0 comments Download
M runtime/vm/debugger.cc View 1 6 chunks +7 lines, -10 lines 0 comments Download
M runtime/vm/exceptions.cc View 1 1 chunk +1 line, -2 lines 0 comments Download
M runtime/vm/flow_graph_builder.cc View 1 5 chunks +5 lines, -5 lines 0 comments Download
M runtime/vm/il_printer.cc View 1 3 chunks +3 lines, -4 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M runtime/vm/intrinsifier.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/object.h View 1 6 chunks +30 lines, -5 lines 0 comments Download
M runtime/vm/object.cc View 1 21 chunks +133 lines, -25 lines 7 comments Download
M runtime/vm/object_test.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M runtime/vm/parser.cc View 1 2 25 chunks +67 lines, -28 lines 6 comments Download
M runtime/vm/raw_object.h View 1 3 chunks +17 lines, -1 line 0 comments Download
M runtime/vm/raw_object.cc View 1 1 chunk +7 lines, -0 lines 0 comments Download
M runtime/vm/raw_object_snapshot.cc View 1 1 chunk +46 lines, -0 lines 0 comments Download
M runtime/vm/snapshot.h View 1 3 chunks +3 lines, -0 lines 0 comments Download
M runtime/vm/snapshot.cc View 1 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Ivan Posva
8 years, 4 months ago (2012-08-14 00:13:07 UTC) #1
Ivan Posva
TBR=asiva,hausner
8 years, 4 months ago (2012-08-14 00:37:31 UTC) #2
Ivan Posva
https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.cc File runtime/vm/object.cc (right): https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.cc#newcode1491 runtime/vm/object.cc:1491: OS::PrintErr("patch_script: %s\n", str.ToCString()); Debug print removed...
8 years, 4 months ago (2012-08-14 01:21:49 UTC) #3
hausner
I cannot LGTM this. I have two concerns: the runtime overhead of function::Owner(), with is ...
8 years, 4 months ago (2012-08-14 18:25:06 UTC) #4
siva
https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.cc File runtime/vm/object.cc (right): https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.cc#newcode1504 runtime/vm/object.cc:1504: const Array& new_functions = Array::Handle(Array::New(patch_len + orig_len)); I think ...
8 years, 4 months ago (2012-08-15 00:16:03 UTC) #5
Ivan Posva
8 years, 4 months ago (2012-08-15 06:50:39 UTC) #6
https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.cc
File runtime/vm/object.cc (right):

https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.c...
runtime/vm/object.cc:1504: const Array& new_functions =
Array::Handle(Array::New(patch_len + orig_len));
On 2012/08/15 00:16:04, asiva wrote:
> I think you should add a comment here that currently all patched functions are
> prepended to the functions list and
> maybe a TODO that this list will be changed to override the function in the
> original list or append new functions if any.

I attempted to address the second part of your suggestion in the TODO on line
1501. I guess I failed. I will try to come up with a better wording in a
different CL unless I do implement the correct behaviour first.

https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.c...
runtime/vm/object.cc:1520: patch_len = patch_fields.Length();
On 2012/08/15 00:16:04, asiva wrote:
> why not call the array handle variables orig_list, patch_list and new_list.
You
> could then resuse them between the function and field loop.
ditto

https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/object.c...
runtime/vm/object.cc:4352: const Object& obj =
Object::Handle(raw_ptr()->owner_);
On 2012/08/14 18:25:06, hausner wrote:
> It would be nice if you could avoid this extra handle allocation (with implied
> thread local storage lookup) for such a common operation, especially since
it's
> caused by this very uncommon corner case.

I have seen 0% impact by this change on performance. It is just not called
enough when running the VM.

https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/parser.cc
File runtime/vm/parser.cc (right):

https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/parser.c...
runtime/vm/parser.cc:2963: class_name.ToCString());
On 2012/08/15 00:16:04, asiva wrote:
> I suppose it is an error to have multiple patch classes also right similar to
> regular classes? i.e:
> 
> class A { .....} seen
> patch class A { .... } seen
> patch class A { ..... } this would be an error.

Currently this error cannot be identified as I am not adding the patch class to
the library and thus I have no means of finding this error condition. I should
get to this when addressing the better error checking when merging the member
definitions in ApplyPatch.

https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/parser.c...
runtime/vm/parser.cc:2975: }
On 2012/08/15 00:16:04, asiva wrote:
> There seems to be a duplication of this is already defined check, it was done
> above in the if (!is_patch && ..) statement.

Merge-conflict resolution error. Thanks for noticing, fixing...

https://chromiumcodereview.appspot.com/10827288/diff/8004/runtime/vm/parser.c...
runtime/vm/parser.cc:3025: // Do not install implicit constructors.
On 2012/08/14 18:25:06, hausner wrote:
> Why? 

If a patch class does not patch a constructor, it should not be adding an
implicit constructor. I will split the CheckConstructors into two:
AddImplicitConstructor and CheckConstructors to not conflate the two things.

Powered by Google App Engine
This is Rietveld 408576698