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

Side by Side Diff: pkg/compiler/lib/src/ssa/locals_handler.dart

Issue 3010473002: Adding JRecord and boxing mechanics.
Patch Set: .. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/kernel/env.dart ('k') | pkg/compiler/lib/src/universe/use.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 import '../elements/types.dart'; 9 import '../elements/types.dart';
10 import '../io/source_information.dart'; 10 import '../io/source_information.dart';
11 import '../js_backend/native_data.dart'; 11 import '../js_backend/native_data.dart';
12 import '../js_backend/interceptor_data.dart'; 12 import '../js_backend/interceptor_data.dart';
13 import '../js_model/closure.dart' show JBoxedField, JClosureField; 13 import '../js_model/closure.dart' show JRecord, JClosureField;
14 import '../tree/tree.dart' as ast; 14 import '../tree/tree.dart' as ast;
15 import '../types/types.dart'; 15 import '../types/types.dart';
16 import '../world.dart' show ClosedWorld; 16 import '../world.dart' show ClosedWorld;
17 17
18 import 'graph_builder.dart'; 18 import 'graph_builder.dart';
19 import 'nodes.dart'; 19 import 'nodes.dart';
20 import 'types.dart'; 20 import 'types.dart';
21 21
22 /// Keeps track of locals (including parameters and phis) when building. The 22 /// Keeps track of locals (including parameters and phis) when building. The
23 /// 'this' reference is treated as parameter and hence handled by this class, 23 /// 'this' reference is treated as parameter and hence handled by this class,
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } else if (isBoxed(local)) { 355 } else if (isBoxed(local)) {
356 FieldEntity redirect = redirectionMapping[local]; 356 FieldEntity redirect = redirectionMapping[local];
357 BoxLocal localBox; 357 BoxLocal localBox;
358 // In the function that declares the captured variable the box is 358 // In the function that declares the captured variable the box is
359 // accessed as direct local. Inside the nested closure the box is 359 // accessed as direct local. Inside the nested closure the box is
360 // accessed through a closure-field. 360 // accessed through a closure-field.
361 // Calling [readLocal] makes sure we generate the correct code to get 361 // Calling [readLocal] makes sure we generate the correct code to get
362 // the box. 362 // the box.
363 if (redirect is BoxFieldElement) { 363 if (redirect is BoxFieldElement) {
364 localBox = redirect.box; 364 localBox = redirect.box;
365 } else if (redirect is JBoxedField) { 365 } else if (redirect is JRecord) {
366 localBox = redirect.box; 366 localBox = redirect.box;
367 } 367 }
368 assert(localBox != null); 368 assert(localBox != null);
369 369
370 HInstruction box = readLocal(localBox); 370 HInstruction box = readLocal(localBox);
371 HInstruction lookup = 371 HInstruction lookup =
372 new HFieldGet(redirect, box, getTypeOfCapturedVariable(redirect)); 372 new HFieldGet(redirect, box, getTypeOfCapturedVariable(redirect));
373 builder.add(lookup); 373 builder.add(lookup);
374 return lookup..sourceInformation = sourceInformation; 374 return lookup..sourceInformation = sourceInformation;
375 } else { 375 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 assert(!isStoredInClosureField(local), 425 assert(!isStoredInClosureField(local),
426 "Local $local is stored in a closure field."); 426 "Local $local is stored in a closure field.");
427 if (isAccessedDirectly(local)) { 427 if (isAccessedDirectly(local)) {
428 directLocals[local] = value; 428 directLocals[local] = value;
429 } else if (isBoxed(local)) { 429 } else if (isBoxed(local)) {
430 FieldEntity redirect = redirectionMapping[local]; 430 FieldEntity redirect = redirectionMapping[local];
431 assert(redirect != null); 431 assert(redirect != null);
432 BoxLocal localBox; 432 BoxLocal localBox;
433 if (redirect is BoxFieldElement) { 433 if (redirect is BoxFieldElement) {
434 localBox = redirect.box; 434 localBox = redirect.box;
435 } else if (redirect is JBoxedField) { 435 } else if (redirect is JRecord) {
436 localBox = redirect.box; 436 localBox = redirect.box;
437 } 437 }
438 assert(localBox != null); 438 assert(localBox != null);
439 439
440 // The box itself could be captured, or be local. A local variable that 440 // The box itself could be captured, or be local. A local variable that
441 // is captured will be boxed, but the box itself will be a local. 441 // is captured will be boxed, but the box itself will be a local.
442 // Inside the closure the box is stored in a closure-field and cannot 442 // Inside the closure the box is stored in a closure-field and cannot
443 // be accessed directly. 443 // be accessed directly.
444 HInstruction box = readLocal(localBox); 444 HInstruction box = readLocal(localBox);
445 builder.add(new HFieldSet(redirect, box, value) 445 builder.add(new HFieldSet(redirect, box, value)
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 final MemberEntity memberContext; 693 final MemberEntity memberContext;
694 694
695 // Avoid slow Object.hashCode. 695 // Avoid slow Object.hashCode.
696 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); 696 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30);
697 static int _nextHashCode = 0; 697 static int _nextHashCode = 0;
698 698
699 SyntheticLocal(this.name, this.executableContext, this.memberContext); 699 SyntheticLocal(this.name, this.executableContext, this.memberContext);
700 700
701 toString() => 'SyntheticLocal($name)'; 701 toString() => 'SyntheticLocal($name)';
702 } 702 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/env.dart ('k') | pkg/compiler/lib/src/universe/use.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698