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

Side by Side Diff: lib/runtime/dart/_js_helper.js

Issue 1055923002: Don't call dinvoke on Object methods (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: modify test Created 5 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
OLDNEW
1 var _js_helper; 1 var _js_helper;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 class NoSideEffects extends core.Object { 4 class NoSideEffects extends core.Object {
5 NoSideEffects() { 5 NoSideEffects() {
6 } 6 }
7 } 7 }
8 class NoThrows extends core.Object { 8 class NoThrows extends core.Object {
9 NoThrows() { 9 NoThrows() {
10 } 10 }
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 function runtimeTypeToString(type, opts) { 957 function runtimeTypeToString(type, opts) {
958 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null; 958 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null;
959 if (type == null) { 959 if (type == null) {
960 return 'dynamic'; 960 return 'dynamic';
961 } else if (isJsArray(type)) { 961 } else if (isJsArray(type)) {
962 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable}); 962 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable});
963 } else if (isJsFunction(type)) { 963 } else if (isJsFunction(type)) {
964 return getConstructorName(type); 964 return getConstructorName(type);
965 } else if (typeof type == 'number') { 965 } else if (typeof type == 'number') {
966 if (onTypeVariable == null) { 966 if (onTypeVariable == null) {
967 return dart.as(dart.dinvoke(type, 'toString'), core.String); 967 return dart.as(type.toString(), core.String);
968 } else { 968 } else {
969 return onTypeVariable(dart.as(type, core.int)); 969 return onTypeVariable(dart.as(type, core.int));
970 } 970 }
971 } else { 971 } else {
972 return null; 972 return null;
973 } 973 }
974 } 974 }
975 // Function joinArguments: (dynamic, int, {onTypeVariable: (int) → String}) → String 975 // Function joinArguments: (dynamic, int, {onTypeVariable: (int) → String}) → String
976 function joinArguments(types, startIndex, opts) { 976 function joinArguments(types, startIndex, opts) {
977 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null; 977 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 if (!dart.equals(value, 0)) { 1361 if (!dart.equals(value, 0)) {
1362 return "" + value; 1362 return "" + value;
1363 } 1363 }
1364 } else if (dart.equals(true, value)) { 1364 } else if (dart.equals(true, value)) {
1365 return 'true'; 1365 return 'true';
1366 } else if (dart.equals(false, value)) { 1366 } else if (dart.equals(false, value)) {
1367 return 'false'; 1367 return 'false';
1368 } else if (value == null) { 1368 } else if (value == null) {
1369 return 'null'; 1369 return 'null';
1370 } 1370 }
1371 let res = dart.dinvoke(value, 'toString'); 1371 let res = value.toString();
1372 if (!(typeof res == 'string')) 1372 if (!(typeof res == 'string'))
1373 throw new core.ArgumentError(value); 1373 throw new core.ArgumentError(value);
1374 return dart.as(res, core.String); 1374 return dart.as(res, core.String);
1375 } 1375 }
1376 // Function createInvocationMirror: (String, dynamic, dynamic, dynamic, dynami c) → dynamic 1376 // Function createInvocationMirror: (String, dynamic, dynamic, dynamic, dynami c) → dynamic
1377 function createInvocationMirror(name, internalName, kind, arguments$, argument Names) { 1377 function createInvocationMirror(name, internalName, kind, arguments$, argument Names) {
1378 return new JSInvocationMirror(name, dart.as(internalName, core.String), dart .as(kind, core.int), dart.as(arguments$, core.List), dart.as(argumentNames, core .List)); 1378 return new JSInvocationMirror(name, dart.as(internalName, core.String), dart .as(kind, core.int), dart.as(arguments$, core.List), dart.as(argumentNames, core .List));
1379 } 1379 }
1380 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami c, dynamic) → dynamic 1380 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami c, dynamic) → dynamic
1381 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments $, argumentNames) { 1381 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments $, argumentNames) {
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 if ("defineProperty" in Object) { 2190 if ("defineProperty" in Object) {
2191 Object.defineProperty(wrapper, "message", {get: _foreign_helper.DART_CLOSU RE_TO_JS(toStringWrapper)}); 2191 Object.defineProperty(wrapper, "message", {get: _foreign_helper.DART_CLOSU RE_TO_JS(toStringWrapper)});
2192 wrapper.name = ""; 2192 wrapper.name = "";
2193 } else { 2193 } else {
2194 wrapper.toString = _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper); 2194 wrapper.toString = _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper);
2195 } 2195 }
2196 return wrapper; 2196 return wrapper;
2197 } 2197 }
2198 // Function toStringWrapper: () → dynamic 2198 // Function toStringWrapper: () → dynamic
2199 function toStringWrapper() { 2199 function toStringWrapper() {
2200 return dart.dinvoke(this.dartException, 'toString'); 2200 return this.dartException.toString();
2201 } 2201 }
2202 // Function throwExpression: (dynamic) → dynamic 2202 // Function throwExpression: (dynamic) → dynamic
2203 function throwExpression(ex) { 2203 function throwExpression(ex) {
2204 throw wrapException(ex); 2204 throw wrapException(ex);
2205 } 2205 }
2206 // Function makeLiteralListConst: (dynamic) → dynamic 2206 // Function makeLiteralListConst: (dynamic) → dynamic
2207 function makeLiteralListConst(list) { 2207 function makeLiteralListConst(list) {
2208 list.immutable$list = true; 2208 list.immutable$list = true;
2209 list.fixed$length = true; 2209 list.fixed$length = true;
2210 return list; 2210 return list;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 if (typeof this[_exception] === "object") { 2517 if (typeof this[_exception] === "object") {
2518 trace = dart.as(this[_exception].stack, core.String); 2518 trace = dart.as(this[_exception].stack, core.String);
2519 } 2519 }
2520 return this[_trace] = trace == null ? '' : trace; 2520 return this[_trace] = trace == null ? '' : trace;
2521 } 2521 }
2522 } 2522 }
2523 _StackTrace[dart.implements] = () => [core.StackTrace]; 2523 _StackTrace[dart.implements] = () => [core.StackTrace];
2524 // Function objectHashCode: (dynamic) → int 2524 // Function objectHashCode: (dynamic) → int
2525 function objectHashCode(object) { 2525 function objectHashCode(object) {
2526 if (dart.notNull(object == null) || typeof object != 'object') { 2526 if (dart.notNull(object == null) || typeof object != 'object') {
2527 return dart.as(dart.dload(object, 'hashCode'), core.int); 2527 return dart.as(object.hashCode, core.int);
2528 } else { 2528 } else {
2529 return Primitives.objectHashCode(object); 2529 return Primitives.objectHashCode(object);
2530 } 2530 }
2531 } 2531 }
2532 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic 2532 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic
2533 function fillLiteralMap(keyValuePairs, result) { 2533 function fillLiteralMap(keyValuePairs, result) {
2534 let index = 0; 2534 let index = 0;
2535 let length = getLength(keyValuePairs); 2535 let length = getLength(keyValuePairs);
2536 while (dart.notNull(index) < dart.notNull(length)) { 2536 while (dart.notNull(index) < dart.notNull(length)) {
2537 let key = getIndex(keyValuePairs, ((x$) => index = dart.notNull(x$) + 1, x $)(index)); 2537 let key = getIndex(keyValuePairs, ((x$) => index = dart.notNull(x$) + 1, x $)(index));
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 return true; 2840 return true;
2841 if (!dart.is(other, BoundClosure)) 2841 if (!dart.is(other, BoundClosure))
2842 return false; 2842 return false;
2843 return this[_self] === dart.dload(other, '_self') && this[_target] === dar t.dload(other, '_target') && this[_receiver] === dart.dload(other, '_receiver'); 2843 return this[_self] === dart.dload(other, '_self') && this[_target] === dar t.dload(other, '_target') && this[_receiver] === dart.dload(other, '_receiver');
2844 } 2844 }
2845 get hashCode() { 2845 get hashCode() {
2846 let receiverHashCode = null; 2846 let receiverHashCode = null;
2847 if (this[_receiver] == null) { 2847 if (this[_receiver] == null) {
2848 receiverHashCode = Primitives.objectHashCode(this[_self]); 2848 receiverHashCode = Primitives.objectHashCode(this[_self]);
2849 } else if (typeof this[_receiver] != 'object') { 2849 } else if (typeof this[_receiver] != 'object') {
2850 receiverHashCode = dart.as(dart.dload(this[_receiver], 'hashCode'), core .int); 2850 receiverHashCode = dart.as(this[_receiver].hashCode, core.int);
2851 } else { 2851 } else {
2852 receiverHashCode = Primitives.objectHashCode(this[_receiver]); 2852 receiverHashCode = Primitives.objectHashCode(this[_receiver]);
2853 } 2853 }
2854 return dart.notNull(receiverHashCode) ^ dart.notNull(Primitives.objectHash Code(this[_target])); 2854 return dart.notNull(receiverHashCode) ^ dart.notNull(Primitives.objectHash Code(this[_target]));
2855 } 2855 }
2856 static selfOf(closure) { 2856 static selfOf(closure) {
2857 return closure[_self]; 2857 return closure[_self];
2858 } 2858 }
2859 static targetOf(closure) { 2859 static targetOf(closure) {
2860 return closure[_target]; 2860 return closure[_target];
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 exports.UnimplementedNoSuchMethodError = UnimplementedNoSuchMethodError; 4002 exports.UnimplementedNoSuchMethodError = UnimplementedNoSuchMethodError;
4003 exports.random64 = random64; 4003 exports.random64 = random64;
4004 exports.jsonEncodeNative = jsonEncodeNative; 4004 exports.jsonEncodeNative = jsonEncodeNative;
4005 exports.getIsolateAffinityTag = getIsolateAffinityTag; 4005 exports.getIsolateAffinityTag = getIsolateAffinityTag;
4006 exports.loadDeferredLibrary = loadDeferredLibrary; 4006 exports.loadDeferredLibrary = loadDeferredLibrary;
4007 exports.MainError = MainError; 4007 exports.MainError = MainError;
4008 exports.missingMain = missingMain; 4008 exports.missingMain = missingMain;
4009 exports.badMain = badMain; 4009 exports.badMain = badMain;
4010 exports.mainHasTooManyParameters = mainHasTooManyParameters; 4010 exports.mainHasTooManyParameters = mainHasTooManyParameters;
4011 })(_js_helper || (_js_helper = {})); 4011 })(_js_helper || (_js_helper = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698