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

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10386086: RFC: Start refactoring to provide more than a single backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 9
10 String buildJavaScriptFunction(FunctionElement element, 10 String buildJavaScriptFunction(FunctionElement element,
(...skipping 27 matching lines...) Expand all
38 String parameters = Strings.join(parameterNames.getValues(), ', '); 38 String parameters = Strings.join(parameterNames.getValues(), ', ');
39 SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator( 39 SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator(
40 compiler, work, parameters, parameterNames); 40 compiler, work, parameters, parameterNames);
41 codegen.visitGraph(graph); 41 codegen.visitGraph(graph);
42 42
43 FunctionElement element = work.element; 43 FunctionElement element = work.element;
44 String code; 44 String code;
45 if (element.isInstanceMember() 45 if (element.isInstanceMember()
46 && element.enclosingElement.isClass() 46 && element.enclosingElement.isClass()
47 && element.enclosingElement.isNative() 47 && element.enclosingElement.isNative()
48 && native.isOverriddenMethod(element, 48 && native.isOverriddenMethod(
49 element.enclosingElement, 49 element, element.enclosingElement,
50 compiler.emitter.nativeEmitter)) { 50 compiler.backend.emitter.nativeEmitter)) {
51 // Record that this method is overridden. In case of optional 51 // Record that this method is overridden. In case of optional
52 // arguments, the emitter will generate stubs to handle them, 52 // arguments, the emitter will generate stubs to handle them,
53 // and needs to know if the method is overridden. 53 // and needs to know if the method is overridden.
54 compiler.emitter.nativeEmitter.overriddenMethods.add(element); 54 compiler.backend.emitter.nativeEmitter.overriddenMethods.add(element);
55 StringBuffer buffer = new StringBuffer(); 55 StringBuffer buffer = new StringBuffer();
56 native.generateMethodWithPrototypeCheckForElement( 56 native.generateMethodWithPrototypeCheckForElement(
57 compiler, buffer, element, '${codegen.buffer}', parameters); 57 compiler, buffer, element, '${codegen.buffer}', parameters);
58 code = buffer.toString(); 58 code = buffer.toString();
59 } else { 59 } else {
60 code = codegen.buffer.toString(); 60 code = codegen.buffer.toString();
61 } 61 }
62 return buildJavaScriptFunction(element, parameters, code); 62 return buildJavaScriptFunction(element, parameters, code);
63 }); 63 });
64 } 64 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 phiEquivalence = new Equivalence<HPhi>(), 200 phiEquivalence = new Equivalence<HPhi>(),
201 unsignedShiftPrecedences = JSPrecedence.binary['>>>'] { 201 unsignedShiftPrecedences = JSPrecedence.binary['>>>'] {
202 202
203 for (final name in parameterNames.getValues()) { 203 for (final name in parameterNames.getValues()) {
204 prefixes[name] = 0; 204 prefixes[name] = 0;
205 } 205 }
206 206
207 // Create a namespace for temporaries. 207 // Create a namespace for temporaries.
208 prefixes[TEMPORARY_PREFIX] = 0; 208 prefixes[TEMPORARY_PREFIX] = 0;
209 209
210 Interceptors interceptors = compiler.builder.interceptors; 210 Interceptors interceptors = compiler.backend.builder.interceptors;
211 equalsNullElement = interceptors.getEqualsNullInterceptor(); 211 equalsNullElement = interceptors.getEqualsNullInterceptor();
212 boolifiedEqualsNullElement = 212 boolifiedEqualsNullElement =
213 interceptors.getBoolifiedVersionOf(equalsNullElement); 213 interceptors.getBoolifiedVersionOf(equalsNullElement);
214 } 214 }
215 215
216 abstract visitTypeGuard(HTypeGuard node); 216 abstract visitTypeGuard(HTypeGuard node);
217 217
218 abstract beginGraph(HGraph graph); 218 abstract beginGraph(HGraph graph);
219 abstract endGraph(HGraph graph); 219 abstract endGraph(HGraph graph);
220 220
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); 2036 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE);
2037 checkObject(input, '==='); 2037 checkObject(input, '===');
2038 buffer.add(" && "); 2038 buffer.add(" && ");
2039 checkType(input, element); 2039 checkType(input, element);
2040 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); 2040 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE);
2041 endExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); 2041 endExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE);
2042 } 2042 }
2043 2043
2044 void checkType(HInstruction input, Element element) { 2044 void checkType(HInstruction input, Element element) {
2045 bool requiresNativeIsCheck = 2045 bool requiresNativeIsCheck =
2046 compiler.emitter.nativeEmitter.requiresNativeIsCheck(element); 2046 compiler.backend.emitter.nativeEmitter.requiresNativeIsCheck(element);
2047 if (!requiresNativeIsCheck) buffer.add('!!'); 2047 if (!requiresNativeIsCheck) buffer.add('!!');
2048 use(input, JSPrecedence.MEMBER_PRECEDENCE); 2048 use(input, JSPrecedence.MEMBER_PRECEDENCE);
2049 buffer.add('.'); 2049 buffer.add('.');
2050 buffer.add(compiler.namer.operatorIs(element)); 2050 buffer.add(compiler.namer.operatorIs(element));
2051 if (requiresNativeIsCheck) buffer.add('()'); 2051 if (requiresNativeIsCheck) buffer.add('()');
2052 } 2052 }
2053 2053
2054 void handleStringSupertypeCheck(HInstruction input, Element element) { 2054 void handleStringSupertypeCheck(HInstruction input, Element element) {
2055 // Make sure List and String don't share supertypes, otherwise we 2055 // Make sure List and String don't share supertypes, otherwise we
2056 // would need to check for List too. 2056 // would need to check for List too.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 } 2156 }
2157 } 2157 }
2158 2158
2159 void visitTypeConversion(HTypeConversion node) { 2159 void visitTypeConversion(HTypeConversion node) {
2160 if (node.checked) { 2160 if (node.checked) {
2161 Element element = node.type.computeType(compiler).element; 2161 Element element = node.type.computeType(compiler).element;
2162 compiler.registerIsCheck(element); 2162 compiler.registerIsCheck(element);
2163 SourceString helper; 2163 SourceString helper;
2164 String additionalArgument; 2164 String additionalArgument;
2165 bool nativeCheck = 2165 bool nativeCheck =
2166 compiler.emitter.nativeEmitter.requiresNativeIsCheck(element); 2166 compiler.backend.emitter.nativeEmitter.requiresNativeIsCheck(element);
2167 beginExpression(JSPrecedence.CALL_PRECEDENCE); 2167 beginExpression(JSPrecedence.CALL_PRECEDENCE);
2168 2168
2169 if (element == compiler.stringClass) { 2169 if (element == compiler.stringClass) {
2170 helper = const SourceString('stringTypeCheck'); 2170 helper = const SourceString('stringTypeCheck');
2171 } else if (element == compiler.doubleClass) { 2171 } else if (element == compiler.doubleClass) {
2172 helper = const SourceString('doubleTypeCheck'); 2172 helper = const SourceString('doubleTypeCheck');
2173 } else if (element == compiler.numClass) { 2173 } else if (element == compiler.numClass) {
2174 helper = const SourceString('numTypeCheck'); 2174 helper = const SourceString('numTypeCheck');
2175 } else if (element == compiler.boolClass) { 2175 } else if (element == compiler.boolClass) {
2176 helper = const SourceString('boolTypeCheck'); 2176 helper = const SourceString('boolTypeCheck');
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 startBailoutSwitch(); 2610 startBailoutSwitch();
2611 } 2611 }
2612 } 2612 }
2613 2613
2614 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2614 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2615 if (labeledBlockInfo.body.start.hasGuards()) { 2615 if (labeledBlockInfo.body.start.hasGuards()) {
2616 endBailoutSwitch(); 2616 endBailoutSwitch();
2617 } 2617 }
2618 } 2618 }
2619 } 2619 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698