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

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

Issue 896763003: dart2js: emit noSuchMethod stubs in the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgot to save. Created 5 years, 10 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/nsm_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) 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.program_builder; 5 library dart2js.js_emitter.program_builder;
6 6
7 import 'js_emitter.dart' show computeMixinClass; 7 import 'js_emitter.dart' show computeMixinClass;
8 import 'model.dart'; 8 import 'model.dart';
9 9
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 /// HACK for Incremental Compilation. 283 /// HACK for Incremental Compilation.
284 /// 284 ///
285 /// Returns a class that contains the fields of a class. 285 /// Returns a class that contains the fields of a class.
286 Class buildFieldsHackForIncrementalCompilation(ClassElement element) { 286 Class buildFieldsHackForIncrementalCompilation(ClassElement element) {
287 assert(_compiler.hasIncrementalSupport); 287 assert(_compiler.hasIncrementalSupport);
288 288
289 List<Field> instanceFields = _buildFields(element, false); 289 List<Field> instanceFields = _buildFields(element, false);
290 String name = namer.getNameOfClass(element); 290 String name = namer.getNameOfClass(element);
291 291
292 return new Class( 292 return new Class(
293 element, name, null, [], instanceFields, [], [], [], null, 293 element, name, null, [], instanceFields, [], [], [], [], null,
294 isDirectlyInstantiated: true, 294 isDirectlyInstantiated: true,
295 onlyForRti: false, 295 onlyForRti: false,
296 isNative: element.isNative); 296 isNative: element.isNative);
297 } 297 }
298 298
299 Class _buildClass(ClassElement element) { 299 Class _buildClass(ClassElement element) {
300 bool onlyForRti = _task.typeTestRegistry.rtiNeededClasses.contains(element); 300 bool onlyForRti = _task.typeTestRegistry.rtiNeededClasses.contains(element);
301 301
302 List<Method> methods = []; 302 List<Method> methods = [];
303 List<StubMethod> callStubs = <StubMethod>[]; 303 List<StubMethod> callStubs = <StubMethod>[];
304 304
305 ClassStubGenerator classStubGenerator =
306 new ClassStubGenerator(_compiler, namer, backend);
307
305 void visitMember(ClassElement enclosing, Element member) { 308 void visitMember(ClassElement enclosing, Element member) {
306 assert(invariant(element, member.isDeclaration)); 309 assert(invariant(element, member.isDeclaration));
307 assert(invariant(element, element == enclosing)); 310 assert(invariant(element, element == enclosing));
308 311
309 if (Elements.isNonAbstractInstanceMember(member)) { 312 if (Elements.isNonAbstractInstanceMember(member)) {
310 js.Expression code = backend.generatedCode[member]; 313 js.Expression code = backend.generatedCode[member];
311 // TODO(herhut): Remove once _buildMethod can no longer return null. 314 // TODO(herhut): Remove once _buildMethod can no longer return null.
312 Method method = _buildMethod(member); 315 Method method = _buildMethod(member);
313 if (method != null) methods.add(method); 316 if (method != null) methods.add(method);
314 } 317 }
315 if (member.isGetter || member.isField) { 318 if (member.isGetter || member.isField) {
316 Set<Selector> selectors = 319 Set<Selector> selectors =
317 _compiler.codegenWorld.invokedNames[member.name]; 320 _compiler.codegenWorld.invokedNames[member.name];
318 if (selectors != null && !selectors.isEmpty) { 321 if (selectors != null && !selectors.isEmpty) {
319 ClassStubGenerator generator = 322
320 new ClassStubGenerator(_compiler, namer, backend);
321 Map<String, js.Expression> callStubsForMember = 323 Map<String, js.Expression> callStubsForMember =
322 generator.generateCallStubsForGetter(member, selectors); 324 classStubGenerator.generateCallStubsForGetter(member, selectors);
323 callStubsForMember.forEach((String name, js.Expression code) { 325 callStubsForMember.forEach((String name, js.Expression code) {
324 callStubs.add(_buildStubMethod(name, code, element: member)); 326 callStubs.add(_buildStubMethod(name, code, element: member));
325 }); 327 });
326 } 328 }
327 } 329 }
328 } 330 }
329 331
332 List<StubMethod> noSuchMethodStubs = <StubMethod>[];
333 if (element == _compiler.objectClass) {
334 Map<String, Selector> selectors =
335 classStubGenerator.computeSelectorsForNsmHandlers();
336 selectors.forEach((String name, Selector selector) {
337 noSuchMethodStubs
338 .add(classStubGenerator.generateStubForNoSuchMethod(name,
339 selector));
340 });
341 }
342
330 ClassElement implementation = element.implementation; 343 ClassElement implementation = element.implementation;
331 344
332 // MixinApplications run through the members of their mixin. Here, we are 345 // MixinApplications run through the members of their mixin. Here, we are
333 // only interested in direct members. 346 // only interested in direct members.
334 if (!onlyForRti && !element.isMixinApplication) { 347 if (!onlyForRti && !element.isMixinApplication) {
335 implementation.forEachMember(visitMember, includeBackendMembers: true); 348 implementation.forEachMember(visitMember, includeBackendMembers: true);
336 } 349 }
337 350
338 List<Field> instanceFields = 351 List<Field> instanceFields =
339 onlyForRti ? const <Field>[] : _buildFields(element, false); 352 onlyForRti ? const <Field>[] : _buildFields(element, false);
(...skipping 30 matching lines...) Expand all
370 callStubs, 383 callStubs,
371 isChecks, 384 isChecks,
372 typeTests.functionTypeIndex, 385 typeTests.functionTypeIndex,
373 isDirectlyInstantiated: isInstantiated, 386 isDirectlyInstantiated: isInstantiated,
374 onlyForRti: onlyForRti); 387 onlyForRti: onlyForRti);
375 } else { 388 } else {
376 result = new Class(element, 389 result = new Class(element,
377 name, holder, methods, instanceFields, 390 name, holder, methods, instanceFields,
378 staticFieldsForReflection, 391 staticFieldsForReflection,
379 callStubs, 392 callStubs,
393 noSuchMethodStubs,
380 isChecks, 394 isChecks,
381 typeTests.functionTypeIndex, 395 typeTests.functionTypeIndex,
382 isDirectlyInstantiated: isInstantiated, 396 isDirectlyInstantiated: isInstantiated,
383 onlyForRti: onlyForRti, 397 onlyForRti: onlyForRti,
384 isNative: element.isNative); 398 isNative: element.isNative);
385 } 399 }
386 _classes[element] = result; 400 _classes[element] = result;
387 return result; 401 return result;
388 } 402 }
389 403
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 _registry.registerConstant(outputUnit, constantValue); 634 _registry.registerConstant(outputUnit, constantValue);
621 assert(!_constants.containsKey(constantValue)); 635 assert(!_constants.containsKey(constantValue));
622 String name = namer.constantName(constantValue); 636 String name = namer.constantName(constantValue);
623 String constantObject = namer.globalObjectForConstant(constantValue); 637 String constantObject = namer.globalObjectForConstant(constantValue);
624 Holder holder = _registry.registerHolder(constantObject); 638 Holder holder = _registry.registerHolder(constantObject);
625 Constant constant = new Constant(name, holder, constantValue); 639 Constant constant = new Constant(name, holder, constantValue);
626 _constants[constantValue] = constant; 640 _constants[constantValue] = constant;
627 } 641 }
628 } 642 }
629 } 643 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698