OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart2js.js_emitter.lazy_emitter.model_emitter; | 5 library dart2js.js_emitter.lazy_emitter.model_emitter; |
6 | 6 |
7 import 'package:js_runtime/shared/embedded_names.dart' | 7 import 'package:js_runtime/shared/embedded_names.dart' |
8 show | 8 show |
9 CREATE_NEW_ISOLATE, | 9 CREATE_NEW_ISOLATE, |
10 DEFERRED_LIBRARY_URIS, | 10 DEFERRED_LIBRARY_URIS, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 'deferredInitializer': emitDeferredInitializerGlobal(program.loadMap), | 203 'deferredInitializer': emitDeferredInitializerGlobal(program.loadMap), |
204 'holders': emitHolders(program.holders), | 204 'holders': emitHolders(program.holders), |
205 'tearOff': buildTearOffCode(backend), | 205 'tearOff': buildTearOffCode(backend), |
206 'parseFunctionDescriptor': | 206 'parseFunctionDescriptor': |
207 js.js.statement(parseFunctionDescriptorBoilerplate, { | 207 js.js.statement(parseFunctionDescriptorBoilerplate, { |
208 'argumentCount': js.string(namer.requiredParameterField), | 208 'argumentCount': js.string(namer.requiredParameterField), |
209 'defaultArgumentValues': js.string(namer.defaultValuesField), | 209 'defaultArgumentValues': js.string(namer.defaultValuesField), |
210 'callName': js.string(namer.callNameField) | 210 'callName': js.string(namer.callNameField) |
211 }), | 211 }), |
212 'cyclicThrow': backend.emitter | 212 'cyclicThrow': backend.emitter |
213 .staticFunctionAccess(backend.helpers.cyclicThrowHelper), | 213 .staticFunctionAccess(backend.commonElements.cyclicThrowHelper), |
214 'outputContainsConstantList': program.outputContainsConstantList, | 214 'outputContainsConstantList': program.outputContainsConstantList, |
215 'embeddedGlobals': emitEmbeddedGlobals(program), | 215 'embeddedGlobals': emitEmbeddedGlobals(program), |
216 'readMetadataTypeFunction': readMetadataTypeFunction, | 216 'readMetadataTypeFunction': readMetadataTypeFunction, |
217 'staticNonFinals': | 217 'staticNonFinals': |
218 emitStaticNonFinalFields(fragment.staticNonFinalFields), | 218 emitStaticNonFinalFields(fragment.staticNonFinalFields), |
219 'operatorIsPrefix': js.string(namer.operatorIsPrefix), | 219 'operatorIsPrefix': js.string(namer.operatorIsPrefix), |
220 'callName': js.string(namer.callNameField), | 220 'callName': js.string(namer.callNameField), |
221 'argumentCount': js.string(namer.requiredParameterField), | 221 'argumentCount': js.string(namer.requiredParameterField), |
222 'defaultArgumentValues': js.string(namer.defaultValuesField), | 222 'defaultArgumentValues': js.string(namer.defaultValuesField), |
223 'eagerClasses': emitEagerClassInitializations(fragment.libraries), | 223 'eagerClasses': emitEagerClassInitializations(fragment.libraries), |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 // arguments to the static: `foo(foo(499))`; | 1018 // arguments to the static: `foo(foo(499))`; |
1019 return holder[name].apply(this, arguments); | 1019 return holder[name].apply(this, arguments); |
1020 } | 1020 } |
1021 var method = compile(name, descriptor); | 1021 var method = compile(name, descriptor); |
1022 holder[name] = method; | 1022 holder[name] = method; |
1023 descriptor = null; // GC the descriptor. | 1023 descriptor = null; // GC the descriptor. |
1024 return method.apply(this, arguments); | 1024 return method.apply(this, arguments); |
1025 }; | 1025 }; |
1026 } else { | 1026 } else { |
1027 // Parse the tear off information and generate compile handlers. | 1027 // Parse the tear off information and generate compile handlers. |
1028 // TODO(herhut): Share parser with instance methods. | 1028 // TODO(herhut): Share parser with instance methods. |
1029 function compileAllStubs(typesOffset) { | 1029 function compileAllStubs(typesOffset) { |
1030 var funs; | 1030 var funs; |
1031 var fun = compile(name, descriptor[0]); | 1031 var fun = compile(name, descriptor[0]); |
1032 fun[#callName] = descriptor[1]; | 1032 fun[#callName] = descriptor[1]; |
1033 holder[name] = fun; | 1033 holder[name] = fun; |
1034 funs = [fun]; | 1034 funs = [fun]; |
1035 // We iterate in blocks of 3 but have to stop before we reach the | 1035 // We iterate in blocks of 3 but have to stop before we reach the |
1036 // (optional) two trailing items. To accomplish this, we only iterate | 1036 // (optional) two trailing items. To accomplish this, we only iterate |
1037 // until we reach length - 2. | 1037 // until we reach length - 2. |
1038 for (var pos = 4; pos < descriptor.length - 2; pos += 3) { | 1038 for (var pos = 4; pos < descriptor.length - 2; pos += 3) { |
1039 var stubName = descriptor[pos]; | 1039 var stubName = descriptor[pos]; |
1040 fun = compile(stubName, descriptor[pos + 2]); | 1040 fun = compile(stubName, descriptor[pos + 2]); |
1041 fun[#callName] = descriptor[pos + 1]; | 1041 fun[#callName] = descriptor[pos + 1]; |
1042 holder[stubName] = fun; | 1042 holder[stubName] = fun; |
1043 funs.push(fun); | 1043 funs.push(fun); |
1044 } | 1044 } |
1045 if (descriptor[2] != null) { // tear-off name. | 1045 if (descriptor[2] != null) { // tear-off name. |
1046 // functions, reflectionInfo, isStatic, name, isIntercepted. | 1046 // functions, reflectionInfo, isStatic, name, isIntercepted. |
1047 var reflectionInfo = descriptor[3]; | 1047 var reflectionInfo = descriptor[3]; |
1048 if (typeof reflectionInfo == "number") { | 1048 if (typeof reflectionInfo == "number") { |
1049 reflectionInfo = reflectionInfo + typesOffset; | 1049 reflectionInfo = reflectionInfo + typesOffset; |
1050 } | 1050 } |
1051 holder[descriptor[2]] = | 1051 holder[descriptor[2]] = |
1052 tearOff(funs, reflectionInfo, true, name, false); | 1052 tearOff(funs, reflectionInfo, true, name, false); |
1053 } | 1053 } |
1054 if (pos < descriptor.length) { | 1054 if (pos < descriptor.length) { |
1055 fun[#argumentCount] = descriptor[pos]; | 1055 fun[#argumentCount] = descriptor[pos]; |
1056 fun[#defaultArgumentValues] = descriptor[pos + 1]; | 1056 fun[#defaultArgumentValues] = descriptor[pos + 1]; |
1057 } | 1057 } |
1058 } | 1058 } |
1059 | 1059 |
1060 function setupCompileAllAndDelegateStub(name, typesOffset) { | 1060 function setupCompileAllAndDelegateStub(name, typesOffset) { |
1061 holder[name] = function() { | 1061 holder[name] = function() { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 #eagerClasses; | 1268 #eagerClasses; |
1269 | 1269 |
1270 var end = Date.now(); | 1270 var end = Date.now(); |
1271 // print('Setup: ' + (end - start) + ' ms.'); | 1271 // print('Setup: ' + (end - start) + ' ms.'); |
1272 | 1272 |
1273 #invokeMain; // Start main. | 1273 #invokeMain; // Start main. |
1274 | 1274 |
1275 })(Date.now(), #code) | 1275 })(Date.now(), #code) |
1276 }"""; | 1276 }"""; |
1277 } | 1277 } |
OLD | NEW |