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

Issue 8393015: Add additional runtime type checks.

Created:
9 years, 2 months ago by jat
Modified:
9 years, 1 month ago
Reviewers:
John Lenz, fabiomfv
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add additional runtime type checks.

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+100 lines, -26 lines) Patch
M compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java View 12 chunks +65 lines, -9 lines 4 comments Download
M compiler/java/com/google/dart/compiler/backend/js/RuntimeTypeInjector.java View 8 chunks +33 lines, -15 lines 2 comments Download
M compiler/java/com/google/dart/compiler/type/Types.java View 1 chunk +1 line, -1 line 0 comments Download
M tests/language/src/TypeDartcTest.dart View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 4 (0 generated)
jat
9 years, 2 months ago (2011-10-25 20:36:00 UTC) #1
jat
In addition to adding bool type checks, this fixes http://code.google.com/p/dart/issues/detail?id=6
9 years, 2 months ago (2011-10-25 20:39:28 UTC) #2
fabiomfv
LGTM. few comments (inline). could run benchmarks in optimized to double check none of the ...
9 years, 1 month ago (2011-10-26 14:43:25 UTC) #3
jat
9 years, 1 month ago (2011-10-31 20:16:14 UTC) #4
http://codereview.chromium.org/8393015/diff/1/compiler/java/com/google/dart/c...
File
compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
(right):

http://codereview.chromium.org/8393015/diff/1/compiler/java/com/google/dart/c...
compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java:1674:
JsExpression expr = rtt.addTypeCheck(getCurrentClass(), jsParam, paramType,
null, param);
On 2011/10/26 14:43:25, fabiomfv wrote:
> assuming this change is basically refactoring?

No, this is what actually fixes issue 6.  The problem is that the parameter's
type node has the return type of a function type, but if I go through the symbol
first I get the correct type.  This is another example of what I have mentioned
before, where type is stored in several places and it isn't clear which one is
the right one to use (or even which one will actually be populated in which
circumstances).

http://codereview.chromium.org/8393015/diff/1/compiler/java/com/google/dart/c...
compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java:2284:
case NOT:
On 2011/10/26 14:43:25, fabiomfv wrote:
> we probably dont need NOT since we dont call getRequiredType() from visit
> unaryexpr.

Done.

http://codereview.chromium.org/8393015/diff/1/compiler/java/com/google/dart/c...
File compiler/java/com/google/dart/compiler/backend/js/RuntimeTypeInjector.java
(right):

http://codereview.chromium.org/8393015/diff/1/compiler/java/com/google/dart/c...
compiler/java/com/google/dart/compiler/backend/js/RuntimeTypeInjector.java:944:
// TODO: do we need a more detailed RTT than just a generic function?
On 2011/10/26 14:43:25, fabiomfv wrote:
> I wonder if we should use the generic function. what will happen when one has
> 'String f()' and pass 'int g()' for instance?

Currently, it won't be caught.

However, adding more detailed RTT will be a lot of work which realistically
isn't going to happen at this point.  Still, it is better to catch passing a
non-function when a function is expected and vice-versa.

Powered by Google App Engine
This is Rietveld 408576698