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

Issue 12334070: Support runtime check of function types. (Closed)

Created:
7 years, 10 months ago by Johnni Winther
Modified:
7 years, 4 months ago
Reviewers:
karlklose, ahe
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Support runtime check of function types. New scheme for checking function subtyping: 1) Generate an $isX predicate on objects that are statically known subtypes of a given function type 2) Generate a signature encoding the whole function type on objects when a runtime check is needed. A check succeeds if either 1) or 2) is true. If too many predicates are needed a signature is generated instead, and if a signature is needed, no predicates are generated. Maximum number of predicates is currently determined by the magic constant MAX_FUNCTION_TYPE_PREDICATES in emitter.dart. R=karlklose@google.com Committed: https://code.google.com/p/dart/source/detail?r=24286 Committed: https://code.google.com/p/dart/source/detail?r=24309

Patch Set 1 : Register dependency #

Total comments: 30

Patch Set 2 : Register methods that need rti #

Patch Set 3 : Use signature as fallback when too many predicates are needed. #

Patch Set 4 : New check encoding #

Total comments: 68

Patch Set 5 : Rebased #

Patch Set 6 : Handle function types in checked mode. #

Total comments: 4

Patch Set 7 : Ensure generation of isX and asX for function types. #

Patch Set 8 : Ensure handling of static and bound closures. #

Patch Set 9 : Rebased #

Patch Set 10 : Fix status files #

Total comments: 140

Patch Set 11 : Rebased #

Patch Set 12 : Updated cf. comments. #

Total comments: 6

Patch Set 13 : Rebased + comments addressed. #

Patch Set 14 : Fix bugs. #

Patch Set 15 : Minor fix #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+3351 lines, -357 lines) Patch
M pkg/pkg.status View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/closure.dart View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +35 lines, -20 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/compile_time_constants.dart View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/compiler.dart View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +20 lines, -2 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/dart_types.dart View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +37 lines, -2 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/enqueue.dart View 1 2 3 4 5 6 7 8 9 10 11 7 chunks +33 lines, -7 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/backend.dart View 1 2 3 4 5 6 7 8 9 10 11 12 chunks +276 lines, -68 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 21 chunks +205 lines, -45 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/namer.dart View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +103 lines, -2 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart View 1 2 3 4 5 6 7 8 9 10 11 12 16 chunks +207 lines, -27 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/resolution/members.dart View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +7 lines, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/builder.dart View 1 2 3 4 5 6 7 8 9 10 11 12 20 chunks +128 lines, -16 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/codegen.dart View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +8 lines, -44 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/nodes.dart View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +28 lines, -5 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/optimize.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +8 lines, -2 lines 0 comments Download
sdk/lib/_internal/compiler/implementation/tree/nodes.dart View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +5 lines, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/universe/universe.dart View 1 2 3 4 5 6 7 8 3 chunks +27 lines, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/util/link.dart View 1 2 3 4 1 chunk +6 lines, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/util/link_implementation.dart View 1 2 3 4 1 chunk +3 lines, -3 lines 0 comments Download
M sdk/lib/_internal/lib/foreign_helper.dart View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +44 lines, -0 lines 3 comments Download
M sdk/lib/_internal/lib/js_helper.dart View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +11 lines, -1 line 0 comments Download
M sdk/lib/_internal/lib/js_rti.dart View 1 2 3 4 5 6 7 8 9 10 11 12 7 chunks +280 lines, -22 lines 0 comments Download
M tests/co19/co19-dart2js.status View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +3 lines, -3 lines 0 comments Download
M tests/compiler/dart2js/mock_compiler.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +13 lines, -1 line 0 comments Download
M tests/compiler/dart2js/subtype_test.dart View 1 2 3 4 5 6 3 chunks +9 lines, -0 lines 0 comments Download
M tests/compiler/dart2js/type_representation_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 4 chunks +28 lines, -15 lines 0 comments Download
M tests/html/html.status View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +3 lines, -0 lines 0 comments Download
A tests/language/function_subtype0_test.dart View 1 2 3 4 5 6 1 chunk +87 lines, -0 lines 0 comments Download
A tests/language/function_subtype1_test.dart View 1 2 3 4 5 6 1 chunk +74 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure0_test.dart View 1 2 3 4 1 chunk +40 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure1_test.dart View 1 2 3 4 1 chunk +53 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure2_test.dart View 1 2 3 4 1 chunk +40 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure3_test.dart View 1 2 3 4 1 chunk +36 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure4_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +38 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure5_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +42 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure6_test.dart View 1 2 3 4 1 chunk +43 lines, -0 lines 0 comments Download
A tests/language/function_subtype_bound_closure7_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +33 lines, -0 lines 0 comments Download
A tests/language/function_subtype_call0_test.dart View 1 2 3 4 1 chunk +42 lines, -0 lines 0 comments Download
A tests/language/function_subtype_call1_test.dart View 1 2 3 4 1 chunk +53 lines, -0 lines 0 comments Download
A tests/language/function_subtype_call2_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +60 lines, -0 lines 0 comments Download
A tests/language/function_subtype_cast0_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +20 lines, -0 lines 0 comments Download
tests/language/function_subtype_cast1_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +32 lines, -0 lines 0 comments Download
A tests/language/function_subtype_cast2_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +30 lines, -0 lines 0 comments Download
A tests/language/function_subtype_cast3_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +33 lines, -0 lines 0 comments Download
A tests/language/function_subtype_checked0_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +79 lines, -0 lines 0 comments Download
A + tests/language/function_subtype_closure0_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +15 lines, -11 lines 0 comments Download
A + tests/language/function_subtype_closure1_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +14 lines, -11 lines 0 comments Download
A tests/language/function_subtype_factory0_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +27 lines, -0 lines 0 comments Download
A tests/language/function_subtype_factory1_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +35 lines, -0 lines 0 comments Download
A tests/language/function_subtype_inline0_test.dart View 1 2 3 4 5 6 1 chunk +41 lines, -0 lines 0 comments Download
A tests/language/function_subtype_inline1_test.dart View 1 2 3 4 5 6 1 chunk +39 lines, -0 lines 0 comments Download
A tests/language/function_subtype_local0_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +34 lines, -0 lines 0 comments Download
A tests/language/function_subtype_local1_test.dart View 1 2 3 4 1 chunk +48 lines, -0 lines 0 comments Download
A tests/language/function_subtype_local2_test.dart View 1 2 3 4 1 chunk +40 lines, -0 lines 0 comments Download
A tests/language/function_subtype_local3_test.dart View 1 2 3 4 1 chunk +36 lines, -0 lines 0 comments Download
A tests/language/function_subtype_local4_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +39 lines, -0 lines 0 comments Download
A tests/language/function_subtype_local5_test.dart View 1 2 3 4 1 chunk +42 lines, -0 lines 0 comments Download
A tests/language/function_subtype_named1_test.dart View 1 2 3 4 5 6 1 chunk +69 lines, -0 lines 0 comments Download
A tests/language/function_subtype_named2_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +56 lines, -0 lines 0 comments Download
A tests/language/function_subtype_not0_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +20 lines, -0 lines 0 comments Download
tests/language/function_subtype_not1_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +32 lines, -0 lines 0 comments Download
A tests/language/function_subtype_not2_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +26 lines, -0 lines 0 comments Download
tests/language/function_subtype_not3_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +29 lines, -0 lines 0 comments Download
A tests/language/function_subtype_null.dart View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +17 lines, -0 lines 0 comments Download
A tests/language/function_subtype_optional1_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +71 lines, -0 lines 0 comments Download
A tests/language/function_subtype_optional2_test.dart View 1 2 3 4 5 6 1 chunk +60 lines, -0 lines 0 comments Download
A tests/language/function_subtype_setter0_test.dart View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +40 lines, -0 lines 0 comments Download
A tests/language/function_subtype_top_level0_test.dart View 1 2 3 4 1 chunk +34 lines, -0 lines 0 comments Download
tests/language/function_subtype_top_level1_test.dart View 1 2 3 4 1 chunk +42 lines, -0 lines 0 comments Download
A tests/language/function_subtype_typearg0_test.dart View 1 2 3 4 5 1 chunk +29 lines, -0 lines 0 comments Download
A + tests/language/function_subtype_typearg1_test.dart View 1 2 3 4 5 6 1 chunk +9 lines, -8 lines 0 comments Download
A + tests/language/function_subtype_typearg2_test.dart View 1 2 3 4 5 6 1 chunk +9 lines, -8 lines 0 comments Download
A + tests/language/function_subtype_typearg3_test.dart View 1 2 3 4 5 6 1 chunk +11 lines, -7 lines 0 comments Download
A + tests/language/function_subtype_typearg4_test.dart View 1 2 3 4 5 6 1 chunk +11 lines, -7 lines 0 comments Download
M tests/language/language_dart2js.status View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +3 lines, -12 lines 0 comments Download
M tests/lib/lib.status View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +3 lines, -3 lines 0 comments Download
M tests/standalone/standalone.status View 1 2 3 4 5 6 7 8 9 10 13 14 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
Johnni Winther
Hi Karl, Take a look at this implementation. Is uses the same overall strategy of ...
7 years, 10 months ago (2013-02-26 15:48:36 UTC) #1
Johnni Winther
PTAL
7 years, 9 months ago (2013-03-13 08:53:12 UTC) #2
ngeoffray
Thank you for all the tests! https://codereview.chromium.org/12334070/diff/35001/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart File sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (right): https://codereview.chromium.org/12334070/diff/35001/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart#newcode1513 sdk/lib/_internal/compiler/implementation/lib/js_helper.dart:1513: var targetSignature = ...
7 years, 9 months ago (2013-03-13 09:30:46 UTC) #3
karlklose
I'll wait with the full review until you upload the next version we talked about. ...
7 years, 9 months ago (2013-03-13 10:33:34 UTC) #4
Johnni Winther
New scheme for checking subtypes. PTAL https://codereview.chromium.org/12334070/diff/35001/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart File sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (right): https://codereview.chromium.org/12334070/diff/35001/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart#newcode1513 sdk/lib/_internal/compiler/implementation/lib/js_helper.dart:1513: var targetSignature = ...
7 years, 9 months ago (2013-03-22 07:30:24 UTC) #5
karlklose
LGTM. https://codereview.chromium.org/12334070/diff/59001/sdk/lib/_internal/compiler/implementation/closure.dart File sdk/lib/_internal/compiler/implementation/closure.dart (right): https://codereview.chromium.org/12334070/diff/59001/sdk/lib/_internal/compiler/implementation/closure.dart#newcode437 sdk/lib/_internal/compiler/implementation/closure.dart:437: if (operatorString == 'is' || operatorString == 'as') ...
7 years, 9 months ago (2013-03-22 13:17:46 UTC) #6
Johnni Winther
PTAL https://codereview.chromium.org/12334070/diff/59001/sdk/lib/_internal/compiler/implementation/closure.dart File sdk/lib/_internal/compiler/implementation/closure.dart (right): https://codereview.chromium.org/12334070/diff/59001/sdk/lib/_internal/compiler/implementation/closure.dart#newcode437 sdk/lib/_internal/compiler/implementation/closure.dart:437: if (operatorString == 'is' || operatorString == 'as') ...
7 years, 6 months ago (2013-06-12 14:39:10 UTC) #7
karlklose
Comments so far. https://codereview.chromium.org/12334070/diff/86001/sdk/lib/_internal/compiler/implementation/compiler.dart File sdk/lib/_internal/compiler/implementation/compiler.dart (right): https://codereview.chromium.org/12334070/diff/86001/sdk/lib/_internal/compiler/implementation/compiler.dart#newcode132 sdk/lib/_internal/compiler/implementation/compiler.dart:132: bool needsRti(ClassElement cls); Should we rename ...
7 years, 6 months ago (2013-06-19 14:37:05 UTC) #8
karlklose
Final comments on the implementation. Looking at the tests now. https://codereview.chromium.org/12334070/diff/127063/sdk/lib/_internal/compiler/implementation/closure.dart File sdk/lib/_internal/compiler/implementation/closure.dart (right): https://codereview.chromium.org/12334070/diff/127063/sdk/lib/_internal/compiler/implementation/closure.dart#newcode528 ...
7 years, 6 months ago (2013-06-20 07:32:55 UTC) #9
karlklose
Comments on the tests. https://codereview.chromium.org/12334070/diff/127063/tests/language/function_subtype_bound_closure0_test.dart File tests/language/function_subtype_bound_closure0_test.dart (right): https://codereview.chromium.org/12334070/diff/127063/tests/language/function_subtype_bound_closure0_test.dart#newcode10 tests/language/function_subtype_bound_closure0_test.dart:10: typedef int Foo(bool a, [String ...
7 years, 6 months ago (2013-06-20 13:11:04 UTC) #10
Johnni Winther
https://codereview.chromium.org/12334070/diff/35001/sdk/lib/_internal/compiler/implementation/ssa/builder.dart File sdk/lib/_internal/compiler/implementation/ssa/builder.dart (right): https://codereview.chromium.org/12334070/diff/35001/sdk/lib/_internal/compiler/implementation/ssa/builder.dart#newcode2688 sdk/lib/_internal/compiler/implementation/ssa/builder.dart:2688: compiler.enqueuer.codegen.registerIsCheck(type, work.resolutionTree); On 2013/03/13 09:30:46, ngeoffray wrote: > Add ...
7 years, 6 months ago (2013-06-21 12:19:14 UTC) #11
karlklose
LGTM. https://codereview.chromium.org/12334070/diff/111003/tests/language/function_subtype_bound_closure4_test.dart File tests/language/function_subtype_bound_closure4_test.dart (right): https://codereview.chromium.org/12334070/diff/111003/tests/language/function_subtype_bound_closure4_test.dart#newcode32 tests/language/function_subtype_bound_closure4_test.dart:32: class D<S,T> extends C<T> {} Add a space ...
7 years, 6 months ago (2013-06-21 12:48:41 UTC) #12
Johnni Winther
https://codereview.chromium.org/12334070/diff/111003/tests/language/function_subtype_bound_closure4_test.dart File tests/language/function_subtype_bound_closure4_test.dart (right): https://codereview.chromium.org/12334070/diff/111003/tests/language/function_subtype_bound_closure4_test.dart#newcode32 tests/language/function_subtype_bound_closure4_test.dart:32: class D<S,T> extends C<T> {} On 2013/06/21 12:48:41, karlklose ...
7 years, 6 months ago (2013-06-21 13:32:21 UTC) #13
Johnni Winther
Committed patchset #13 manually as r24286 (presubmit successful).
7 years, 6 months ago (2013-06-21 13:37:33 UTC) #14
Johnni Winther
Committed patchset #15 manually as r24309 (presubmit successful).
7 years, 6 months ago (2013-06-24 07:00:32 UTC) #15
ahe
https://codereview.chromium.org/12334070/diff/170001/sdk/lib/_internal/lib/foreign_helper.dart File sdk/lib/_internal/lib/foreign_helper.dart (right): https://codereview.chromium.org/12334070/diff/170001/sdk/lib/_internal/lib/foreign_helper.dart#newcode217 sdk/lib/_internal/lib/foreign_helper.dart:217: JS_GLOBAL_OBJECT() {} How is this different from JS_CURRENT_ISOLATE?
7 years, 4 months ago (2013-08-07 21:50:12 UTC) #16
Johnni Winther
https://codereview.chromium.org/12334070/diff/170001/sdk/lib/_internal/lib/foreign_helper.dart File sdk/lib/_internal/lib/foreign_helper.dart (right): https://codereview.chromium.org/12334070/diff/170001/sdk/lib/_internal/lib/foreign_helper.dart#newcode217 sdk/lib/_internal/lib/foreign_helper.dart:217: JS_GLOBAL_OBJECT() {} On 2013/08/07 21:50:12, ahe wrote: > How ...
7 years, 4 months ago (2013-08-08 05:44:36 UTC) #17
ahe
7 years, 4 months ago (2013-08-21 12:42:14 UTC) #18
Message was sent while issue was closed.
https://codereview.chromium.org/12334070/diff/170001/sdk/lib/_internal/lib/fo...
File sdk/lib/_internal/lib/foreign_helper.dart (right):

https://codereview.chromium.org/12334070/diff/170001/sdk/lib/_internal/lib/fo...
sdk/lib/_internal/lib/foreign_helper.dart:217: JS_GLOBAL_OBJECT() {}
On 2013/08/08 05:44:37, Johnni Winther wrote:
> On 2013/08/07 21:50:12, ahe wrote:
> > How is this different from JS_CURRENT_ISOLATE?
> 
> Depending on the use of isolates, JS_CURRENT_ISOLATE might not be the $ object
> (= JS_GLOBAL_OBJECT).

I'm talking about JS_CURRENT_ISOLATE. Are you talking about
JS_CURRENT_ISOLATE_CONTEXT?

Powered by Google App Engine
This is Rietveld 408576698