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

Issue 9454012: Add type testing and casting support. (Closed)

Created:
8 years, 10 months ago by Kevin Millikin (Google)
Modified:
8 years, 10 months ago
Reviewers:
srdjan
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add type testing and casting support. Introduce a virtual tag() function to Instruction classes, use it to implement type testing and casting. Use type testing and casting to eliminate some virtual functions on the instruction classes. R=srdjan@google.com BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=4546

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+122 lines, -52 lines) Patch
M runtime/vm/flow_graph_builder.h View 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/flow_graph_builder.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M runtime/vm/intermediate_language.h View 5 chunks +108 lines, -39 lines 3 comments Download
M runtime/vm/intermediate_language.cc View 3 chunks +10 lines, -9 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
Kevin Millikin (Google)
I hope this isn't premature optimization. It seems nicer to get it in now when ...
8 years, 10 months ago (2012-02-23 13:17:53 UTC) #1
srdjan
8 years, 10 months ago (2012-02-23 16:50:26 UTC) #2
LGTM once addressing the comments and changing to IsXXX and AsXXX.

https://chromiumcodereview.appspot.com/9454012/diff/1/runtime/vm/intermediate...
File runtime/vm/intermediate_language.h (right):

https://chromiumcodereview.appspot.com/9454012/diff/1/runtime/vm/intermediate...
runtime/vm/intermediate_language.h:206: #undef DEFINE_TYPE_FUNCTIONS
I think the IsXXX and AsXXX are better. Typical use is:
a) test that something IsXXX
b) convert something with AsXXX

or

a) convert something with AsXXX and check if it is NULL.

The proposed design does not allow for second possibility. The first use
requires a virtual call for tag() anyway.
Yes I think eliminating virtual functions at this stage is premature
optimization. I think good design will set us well for future performance. Good
design would also include use of polymorphism instead of explicit type tests and
type conversion.

Sorry if I am sounding a little preachy here :-)

https://chromiumcodereview.appspot.com/9454012/diff/1/runtime/vm/intermediate...
runtime/vm/intermediate_language.h:252: intptr_t block_number_;
Optional: DISALLOW_yada_yada (here and below), but you ar right that it is not
needed since the superclass has a private one

https://chromiumcodereview.appspot.com/9454012/diff/1/runtime/vm/intermediate...
runtime/vm/intermediate_language.h:293: intptr_t block_number_;
Superclass has already field block_number_, remove it here and in constructor.

Powered by Google App Engine
This is Rietveld 408576698