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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart

Issue 834133002: dart2js OldEmitter: Small cleanups in output. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added check for using Function.apply. Created 5 years, 11 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 | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 // TODO(ahe): Share these with js_helper.dart. 7 // TODO(ahe): Share these with js_helper.dart.
8 const FUNCTION_INDEX = 0; 8 const FUNCTION_INDEX = 0;
9 const NAME_INDEX = 1; 9 const NAME_INDEX = 1;
10 const CALL_NAME_INDEX = 2; 10 const CALL_NAME_INDEX = 2;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 var isAccessor = (requiredParameterInfo & 1) === 1; 227 var isAccessor = (requiredParameterInfo & 1) === 1;
228 var isSetter = requiredParameterInfo === 3; 228 var isSetter = requiredParameterInfo === 3;
229 var isGetter = requiredParameterInfo === 1; 229 var isGetter = requiredParameterInfo === 1;
230 var optionalParameterInfo = ${readInt("array", "1")}; 230 var optionalParameterInfo = ${readInt("array", "1")};
231 var optionalParameterCount = optionalParameterInfo >> 1; 231 var optionalParameterCount = optionalParameterInfo >> 1;
232 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1; 232 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1;
233 var isIntercepted = 233 var isIntercepted =
234 requiredParameterCount + optionalParameterCount != funcs[0].length; 234 requiredParameterCount + optionalParameterCount != funcs[0].length;
235 var functionTypeIndex = ${readFunctionType("array", "2")}; 235 var functionTypeIndex = ${readFunctionType("array", "2")};
236 var unmangledNameIndex = $unmangledNameIndex; 236 var unmangledNameIndex = $unmangledNameIndex;
237 var isReflectable = array.length > unmangledNameIndex;
238 237
239 if (getterStubName) { 238 if (getterStubName) {
240 f = tearOff(funcs, array, isStatic, name, isIntercepted); 239 f = tearOff(funcs, array, isStatic, name, isIntercepted);
241 descriptor[name].\$getter = f; 240 descriptor[name].\$getter = f;
242 f.\$getterStub = true; 241 f.\$getterStub = true;
243 // Used to create an isolate using spawnFunction. 242 // Used to create an isolate using spawnFunction.
244 if (isStatic) #globalFunctions[name] = f; 243 if (isStatic) #globalFunctions[name] = f;
245 originalDescriptor[getterStubName] = descriptor[getterStubName] = f; 244 originalDescriptor[getterStubName] = descriptor[getterStubName] = f;
246 funcs.push(f); 245 funcs.push(f);
247 if (getterStubName) functions.push(getterStubName); 246 if (getterStubName) functions.push(getterStubName);
248 f.\$stubName = getterStubName; 247 f.\$stubName = getterStubName;
249 f.\$callName = null; 248 f.\$callName = null;
250 if (isIntercepted) #interceptedNames[getterStubName] = true; 249 if (isIntercepted) #interceptedNames[getterStubName] = true;
251 } 250 }
252 if (isReflectable) { 251
253 for (var i = 0; i < funcs.length; i++) { 252 if (#usesMangledNames) {
254 funcs[i].$reflectableField = 1; 253 var isReflectable = array.length > unmangledNameIndex;
255 funcs[i].$reflectionInfoField = array; 254 if (isReflectable) {
255 for (var i = 0; i < funcs.length; i++) {
256 funcs[i].$reflectableField = 1;
257 funcs[i].$reflectionInfoField = array;
258 }
259 var mangledNames = isStatic ? #mangledGlobalNames : #mangledNames;
260 var unmangledName = ${readString("array", "unmangledNameIndex")};
261 // The function is either a getter, a setter, or a method.
262 // If it is a method, it might also have a tear-off closure.
263 // The unmangledName is the same as the getter-name.
264 var reflectionName = unmangledName;
265 if (getterStubName) mangledNames[getterStubName] = reflectionName;
266 if (isSetter) {
267 reflectionName += "=";
268 } else if (!isGetter) {
269 reflectionName += ":" + requiredParameterCount +
270 ":" + optionalParameterCount;
271 }
272 mangledNames[name] = reflectionName;
273 funcs[0].$reflectionNameField = reflectionName;
274 funcs[0].$metadataIndexField = unmangledNameIndex + 1;
275 if (optionalParameterCount) descriptor[unmangledName + "*"] = funcs[0];
256 } 276 }
257 var mangledNames = isStatic ? #mangledGlobalNames : #mangledNames;
258 var unmangledName = ${readString("array", "unmangledNameIndex")};
259 // The function is either a getter, a setter, or a method.
260 // If it is a method, it might also have a tear-off closure.
261 // The unmangledName is the same as the getter-name.
262 var reflectionName = unmangledName;
263 if (getterStubName) mangledNames[getterStubName] = reflectionName;
264 if (isSetter) {
265 reflectionName += "=";
266 } else if (!isGetter) {
267 reflectionName += ":" + requiredParameterCount +
268 ":" + optionalParameterCount;
269 }
270 mangledNames[name] = reflectionName;
271 funcs[0].$reflectionNameField = reflectionName;
272 funcs[0].$metadataIndexField = unmangledNameIndex + 1;
273 if (optionalParameterCount) descriptor[unmangledName + "*"] = funcs[0];
274 } 277 }
275 } 278 }
276 ''', {'globalFunctions' : globalFunctionsAccess, 279 ''', {'globalFunctions' : globalFunctionsAccess,
277 'interceptedNames': interceptedNamesAccess, 280 'interceptedNames': interceptedNamesAccess,
281 'usesMangledNames':
282 compiler.mirrorsLibrary != null || compiler.enabledFunctionApply,
278 'mangledGlobalNames': mangledGlobalNamesAccess, 283 'mangledGlobalNames': mangledGlobalNamesAccess,
279 'mangledNames': mangledNamesAccess}); 284 'mangledNames': mangledNamesAccess});
280 285
281 List<jsAst.Statement> tearOffCode = buildTearOffCode(backend); 286 List<jsAst.Statement> tearOffCode = buildTearOffCode(backend);
282 287
283 jsAst.Statement init = js.statement('''{ 288 jsAst.Statement init = js.statement('''{
284 var functionCounter = 0; 289 var functionCounter = 0;
285 if (!#libraries) #libraries = []; 290 if (!#libraries) #libraries = [];
286 if (!#mangledNames) #mangledNames = map(); 291 if (!#mangledNames) #mangledNames = map();
287 if (!#mangledGlobalNames) #mangledGlobalNames = map(); 292 if (!#mangledGlobalNames) #mangledGlobalNames = map();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 (function() { 567 (function() {
563 var result = $array[$index]; 568 var result = $array[$index];
564 if ($check) { 569 if ($check) {
565 throw new Error( 570 throw new Error(
566 name + ": expected value of type \'$type\' at index " + ($index) + 571 name + ": expected value of type \'$type\' at index " + ($index) +
567 " but got " + (typeof result)); 572 " but got " + (typeof result));
568 } 573 }
569 return result; 574 return result;
570 })()'''; 575 })()''';
571 } 576 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698