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

Issue 11413184: Create specialized versions of getInterceptor. (Closed)

Created:
8 years ago by ngeoffray
Modified:
8 years ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Create specialized versions of getInterceptor. Committed: https://code.google.com/p/dart/source/detail?r=15398

Patch Set 1 : #

Total comments: 17

Patch Set 2 : #

Messages

Total messages: 3 (0 generated)
ngeoffray
8 years ago (2012-11-27 12:04:10 UTC) #1
ahe
LGTM https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right): https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart#newcode684 sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:684: final Map<String, Collection<ClassElement>> specializedGetInterceptors; What is the key? ...
8 years ago (2012-11-27 14:29:45 UTC) #2
ngeoffray
8 years ago (2012-11-27 15:50:54 UTC) #3
Thanks Peter.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right):

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:684: final
Map<String, Collection<ClassElement>> specializedGetInterceptors;
On 2012/11/27 14:29:45, ahe wrote:
> What is the key?

It's in the comment above: the name of the specialized method.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:753: return
<ClassElement>[jsStringClass, jsArrayClass, jsIntClass,
On 2012/11/27 14:29:45, ahe wrote:
> I suggest you create this list in initializeInterceptorElements.  Like what I
> did in CL 11421060.  This way you increase the chance that this list is in
sync
> with what is constructed in initializeInterceptorElements.

Done.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:806:
specializedGetInterceptors.putIfAbsent(name, () {
On 2012/11/27 14:29:45, ahe wrote:
> I don't understand why you do this.  Why shouldn't you unconditionally store
the
> complete list?

Because I did not want to call getListOfInterceptedClasses multiple times. As
discussed, I added a TODO to implement the set of intercepted classes with a
bitset.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
File sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (right):

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart:1688: void
emitTypeCheck(ClassElement cls, CodeBuffer buffer) {
On 2012/11/27 14:29:45, ahe wrote:
> This is not really emitting a type check, which would be what you emit in
> checked mode for:
> 
> int x = foo(); // Here is a type check that foo returns an int.

I renamed the method emitInterceptorCheck.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart:1691: String
then = 'return ${namer.isolateAccess(cls)}.prototype;';
On 2012/11/27 14:29:45, ahe wrote:
> Weird variable name.  How about interceptorObject?

Done.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart:1693:
buffer.add("if (typeof receiver == 'boolean') $then");
On 2012/11/27 14:29:45, ahe wrote:
> This pattern really hurts my eyes :-)
> 
> How about:
> 
> buffer.add("if (typeof receiver == 'boolean') return ");
> buffer.add(namer.isolateAccess(cls));
> buffer.add('.prototype');
> 
> Notice that the last two lines can be shared at the end of this method.  So
you
> don't need the "then" variable.

Done.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart:1714: void
emitGetInterceptors(CodeBuffer buffer) {
On 2012/11/27 14:29:45, ahe wrote:
> How about "emitGetInterceptorMethods"?

Done.

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
File sdk/lib/_internal/compiler/implementation/lib/interceptors.dart (right):

https://codereview.chromium.org/11413184/diff/4001/sdk/lib/_internal/compiler...
sdk/lib/_internal/compiler/implementation/lib/interceptors.dart:26: Function
getInterceptor;
On 2012/11/27 14:29:45, ahe wrote:
> I suggest using this pattern instead:
> 
> getInterceptor(object) {
>   // This is a magic method: the compiler does ...
> }

Done.

Powered by Google App Engine
This is Rietveld 408576698