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

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

Issue 2497313003: Fix HTypeConversion.checkedInput (Closed)
Patch Set: Add some comments Created 4 years, 1 month 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 | « no previous file | pkg/compiler/lib/src/ssa/builder_kernel.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) 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 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 assert(result.isValid()); 293 assert(result.isValid());
294 return result; 294 return result;
295 } 295 }
296 296
297 void addWithPosition(HInstruction instruction, ast.Node node) { 297 void addWithPosition(HInstruction instruction, ast.Node node) {
298 add(attachPosition(instruction, node)); 298 add(attachPosition(instruction, node));
299 } 299 }
300 300
301 HTypeConversion buildFunctionTypeConversion( 301 HTypeConversion buildFunctionTypeConversion(
302 HInstruction original, DartType type, int kind) { 302 HInstruction original, DartType type, int kind) {
303 String name = 303 HInstruction reifiedType = buildFunctionType(type);
304 kind == HTypeConversion.CAST_TYPE_CHECK ? '_asCheck' : '_assertCheck'; 304 return new HTypeConversion.viaMethodOnType(
305 305 type, kind, original.instructionType, reifiedType, original);
306 List<HInstruction> arguments = <HInstruction>[
307 buildFunctionType(type),
308 original
309 ];
310 pushInvokeDynamic(
311 null,
312 new Selector.call(
313 new Name(name, helpers.jsHelperLibrary), CallStructure.ONE_ARG),
314 null,
315 arguments);
316
317 return new HTypeConversion(type, kind, original.instructionType, pop());
318 } 306 }
319 307
320 /** 308 /**
321 * Returns a complete argument list for a call of [function]. 309 * Returns a complete argument list for a call of [function].
322 */ 310 */
323 List<HInstruction> completeSendArgumentsList( 311 List<HInstruction> completeSendArgumentsList(
324 FunctionElement function, 312 FunctionElement function,
325 Selector selector, 313 Selector selector,
326 List<HInstruction> providedArguments, 314 List<HInstruction> providedArguments,
327 ast.Node currentNode) { 315 ast.Node currentNode) {
(...skipping 3135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 !backend.isJsInterop(constructor)) { 3451 !backend.isJsInterop(constructor)) {
3464 // Native class generative constructors take a pre-constructed object. 3452 // Native class generative constructors take a pre-constructed object.
3465 inputs.add(graph.addConstantNull(compiler)); 3453 inputs.add(graph.addConstantNull(compiler));
3466 } 3454 }
3467 inputs.addAll(makeStaticArgumentList( 3455 inputs.addAll(makeStaticArgumentList(
3468 callStructure, send.arguments, constructorImplementation)); 3456 callStructure, send.arguments, constructorImplementation));
3469 3457
3470 TypeMask elementType = computeType(constructor); 3458 TypeMask elementType = computeType(constructor);
3471 if (isFixedListConstructorCall) { 3459 if (isFixedListConstructorCall) {
3472 if (!inputs[0].isNumber(compiler)) { 3460 if (!inputs[0].isNumber(compiler)) {
3473 HTypeConversion conversion = new HTypeConversion( 3461 HTypeConversion conversion = new HTypeConversion(null,
3474 null, 3462 HTypeConversion.ARGUMENT_TYPE_CHECK, backend.numType, inputs[0]);
3475 HTypeConversion.ARGUMENT_TYPE_CHECK,
3476 backend.numType,
3477 inputs[0],
3478 null);
3479 add(conversion); 3463 add(conversion);
3480 inputs[0] = conversion; 3464 inputs[0] = conversion;
3481 } 3465 }
3482 js.Template code = js.js.parseForeignJS('new Array(#)'); 3466 js.Template code = js.js.parseForeignJS('new Array(#)');
3483 var behavior = new native.NativeBehavior(); 3467 var behavior = new native.NativeBehavior();
3484 behavior.typesReturned.add(expectedType); 3468 behavior.typesReturned.add(expectedType);
3485 // The allocation can throw only if the given length is a double or 3469 // The allocation can throw only if the given length is a double or
3486 // outside the unsigned 32 bit range. 3470 // outside the unsigned 32 bit range.
3487 // TODO(sra): Array allocation should be an instruction so that canThrow 3471 // TODO(sra): Array allocation should be an instruction so that canThrow
3488 // can depend on a length type discovered in optimization. 3472 // can depend on a length type discovered in optimization.
(...skipping 3297 matching lines...) Expand 10 before | Expand all | Expand 10 after
6786 this.oldReturnLocal, 6770 this.oldReturnLocal,
6787 this.oldReturnType, 6771 this.oldReturnType,
6788 this.oldResolvedAst, 6772 this.oldResolvedAst,
6789 this.oldStack, 6773 this.oldStack,
6790 this.oldLocalsHandler, 6774 this.oldLocalsHandler,
6791 this.inTryStatement, 6775 this.inTryStatement,
6792 this.allFunctionsCalledOnce, 6776 this.allFunctionsCalledOnce,
6793 this.oldElementInferenceResults) 6777 this.oldElementInferenceResults)
6794 : super(function); 6778 : super(function);
6795 } 6779 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/builder_kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698