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

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

Issue 10092012: Fix issue 2358: dart methods on native classes must also check if the current prototype has the met… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « lib/compiler/implementation/native_handler.dart ('k') | no next file » | 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) 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 generateMethod(WorkItem work, HGraph graph) { 10 String generateMethod(WorkItem work, HGraph graph) {
11 return measure(() { 11 return measure(() {
12 compiler.tracer.traceGraph("codegen", graph); 12 compiler.tracer.traceGraph("codegen", graph);
13 Map<Element, String> parameterNames = getParameterNames(work); 13 Map<Element, String> parameterNames = getParameterNames(work);
14 String parameters = Strings.join(parameterNames.getValues(), ', '); 14 String parameters = Strings.join(parameterNames.getValues(), ', ');
15 SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator( 15 SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator(
16 compiler, work, parameters, parameterNames); 16 compiler, work, parameters, parameterNames);
17 codegen.visitGraph(graph); 17 codegen.visitGraph(graph);
18 return 'function($parameters) {\n${codegen.buffer}}'; 18
19 FunctionElement element = work.element;
20 String code;
21 if (element.isInstanceMember()
22 && element.enclosingElement.isClass()
23 && element.enclosingElement.isNative()
24 && native.isOverriddenMethod(element,
25 element.enclosingElement,
26 compiler.emitter.nativeEmitter)) {
27 // Record that this method is overridden. In case of optional
28 // arguments, the emitter will generate stubs to handle them,
29 // and needs to know if the method is overridden.
30 compiler.emitter.nativeEmitter.overriddenMethods.add(element);
31 StringBuffer buffer = new StringBuffer();
32 native.generateMethodWithPrototypeCheckForElement(
33 compiler, buffer, element, '${codegen.buffer}', parameters);
34 code = buffer.toString();
35 } else {
36 code = codegen.buffer.toString();
37 }
38 return 'function($parameters) {\n$code}';
19 }); 39 });
20 } 40 }
21 41
22 String generateBailoutMethod(WorkItem work, HGraph graph) { 42 String generateBailoutMethod(WorkItem work, HGraph graph) {
23 return measure(() { 43 return measure(() {
24 compiler.tracer.traceGraph("codegen-bailout", graph); 44 compiler.tracer.traceGraph("codegen-bailout", graph);
25 new SsaBailoutPropagator(compiler).visitGraph(graph); 45 new SsaBailoutPropagator(compiler).visitGraph(graph);
26 46
27 Map<Element, String> parameterNames = getParameterNames(work); 47 Map<Element, String> parameterNames = getParameterNames(work);
28 String parameters = Strings.join(parameterNames.getValues(), ', '); 48 String parameters = Strings.join(parameterNames.getValues(), ', ');
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 startBailoutSwitch(); 1905 startBailoutSwitch();
1886 } 1906 }
1887 } 1907 }
1888 1908
1889 void endElse(HIf node) { 1909 void endElse(HIf node) {
1890 if (node.elseBlock.hasGuards()) { 1910 if (node.elseBlock.hasGuards()) {
1891 endBailoutSwitch(); 1911 endBailoutSwitch();
1892 } 1912 }
1893 } 1913 }
1894 } 1914 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/native_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698