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

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
32 String methodName;
33 Namer namer = compiler.namer;
34 if (element.kind == ElementKind.FUNCTION) {
35 FunctionParameters parameters = element.computeParameters(compiler);
36 methodName = namer.instanceMethodName(
37 element.getLibrary(), element.name, parameters.parameterCount);
38 } else if (element.kind == ElementKind.GETTER) {
39 methodName = namer.getterName(element.getLibrary(), element.name);
40 } else if (element.kind == ElementKind.SETTER) {
41 methodName = namer.setterName(element.getLibrary(), element.name);
42 } else {
43 compiler.internalError('unexpected kind: "${element.kind}"',
44 element: element);
45 }
46 StringBuffer buffer = new StringBuffer();
47 native.generateMethodWithPrototypeCheck(
floitsch 2012/04/16 17:59:47 create native.generateMethodWithPrototypeCheckForE
ngeoffray 2012/04/17 08:04:18 Done.
48 compiler, buffer, methodName, '${codegen.buffer}', parameters);
49 code = buffer.toString();
50 } else {
51 code = codegen.buffer.toString();
52 }
53 return 'function($parameters) {\n$code}';
19 }); 54 });
20 } 55 }
21 56
22 String generateBailoutMethod(WorkItem work, HGraph graph) { 57 String generateBailoutMethod(WorkItem work, HGraph graph) {
23 return measure(() { 58 return measure(() {
24 compiler.tracer.traceGraph("codegen-bailout", graph); 59 compiler.tracer.traceGraph("codegen-bailout", graph);
25 new SsaBailoutPropagator(compiler).visitGraph(graph); 60 new SsaBailoutPropagator(compiler).visitGraph(graph);
26 61
27 Map<Element, String> parameterNames = getParameterNames(work); 62 Map<Element, String> parameterNames = getParameterNames(work);
28 String parameters = Strings.join(parameterNames.getValues(), ', '); 63 String parameters = Strings.join(parameterNames.getValues(), ', ');
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 startBailoutSwitch(); 1917 startBailoutSwitch();
1883 } 1918 }
1884 } 1919 }
1885 1920
1886 void endElse(HIf node) { 1921 void endElse(HIf node) {
1887 if (node.elseBlock.hasGuards()) { 1922 if (node.elseBlock.hasGuards()) {
1888 endBailoutSwitch(); 1923 endBailoutSwitch();
1889 } 1924 }
1890 } 1925 }
1891 } 1926 }
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