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

Side by Side Diff: Source/bindings/scripts/v8_interface.py

Issue 611953003: Canvas2D Performance: fix the bottleneck of hasInstance during JS binding -- overloading (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update code accordingly (w/o redundant type check for overload resolution) Created 6 years, 2 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
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('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) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # coding=utf-8 2 # coding=utf-8
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 # • an interface type that V implements 746 # • an interface type that V implements
747 # (Unlike most of these tests, this can return multiple methods, since we 747 # (Unlike most of these tests, this can return multiple methods, since we
748 # test if it implements an interface. Thus we need a for loop, not a next.) 748 # test if it implements an interface. Thus we need a for loop, not a next.)
749 # (We distinguish wrapper types from built-in interface types.) 749 # (We distinguish wrapper types from built-in interface types.)
750 for idl_type, method in ((idl_type, method) 750 for idl_type, method in ((idl_type, method)
751 for idl_type, method in idl_types_methods 751 for idl_type, method in idl_types_methods
752 if idl_type.is_wrapper_type): 752 if idl_type.is_wrapper_type):
753 test = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())'.forma t(idl_type=idl_type.base_type, cpp_value=cpp_value) 753 test = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())'.forma t(idl_type=idl_type.base_type, cpp_value=cpp_value)
754 yield test, method 754 yield test, method
755 755
756 # all arguments here of wrapper type are checked by resolution (see above),
757 # they should not be check again for [TypeChecking=interface] methods during
758 # args checking. We mark resolution related arguments as type_checked_alread y
759 # to avoid redundant checking. However, if there are optional argument(s) in
760 # an overloading method, the method will have multiple callers. Resolution
761 # related argument may be not resolved in some callers in this situation.
762 # So, we just mark those resolution associated arguments whose method has
763 # no optional arguments, for safety.
764 for argument, method in arguments_methods:
765 argument['type_checked_already'] = (argument['is_wrapper_type'] and
766 method['number_of_required_arguments '] == method['number_of_arguments'])
767
756 # 8. Otherwise: if V is any kind of object except for a native Date object, 768 # 8. Otherwise: if V is any kind of object except for a native Date object,
757 # a native RegExp object, and there is an entry in S that has one of the 769 # a native RegExp object, and there is an entry in S that has one of the
758 # following types at position i of its type list, 770 # following types at position i of its type list,
759 # • an array type 771 # • an array type
760 # • a sequence type 772 # • a sequence type
761 # ... 773 # ...
762 # • a dictionary 774 # • a dictionary
763 # 775 #
764 # FIXME: 776 # FIXME:
765 # We don't strictly follow the algorithm here. The algorithm says "remove 777 # We don't strictly follow the algorithm here. The algorithm says "remove
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 # [ConstructorCallWith=Document] 915 # [ConstructorCallWith=Document]
904 has_extended_attribute_value(interface, 916 has_extended_attribute_value(interface,
905 'ConstructorCallWith', 'Document'), 917 'ConstructorCallWith', 'Document'),
906 'is_call_with_execution_context': 918 'is_call_with_execution_context':
907 # [ConstructorCallWith=ExecutionContext] 919 # [ConstructorCallWith=ExecutionContext]
908 has_extended_attribute_value(interface, 920 has_extended_attribute_value(interface,
909 'ConstructorCallWith', 'ExecutionContext'), 921 'ConstructorCallWith', 'ExecutionContext'),
910 'is_constructor': True, 922 'is_constructor': True,
911 'is_named_constructor': False, 923 'is_named_constructor': False,
912 'is_raises_exception': is_constructor_raises_exception, 924 'is_raises_exception': is_constructor_raises_exception,
925 'number_of_arguments': len(constructor.arguments),
913 'number_of_required_arguments': 926 'number_of_required_arguments':
914 number_of_required_arguments(constructor), 927 number_of_required_arguments(constructor),
915 } 928 }
916 929
917 930
918 # [NamedConstructor] 931 # [NamedConstructor]
919 def named_constructor_context(interface): 932 def named_constructor_context(interface):
920 extended_attributes = interface.extended_attributes 933 extended_attributes = interface.extended_attributes
921 if 'NamedConstructor' not in extended_attributes: 934 if 'NamedConstructor' not in extended_attributes:
922 return None 935 return None
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 deleter = next( 1146 deleter = next(
1134 method 1147 method
1135 for method in interface.operations 1148 for method in interface.operations
1136 if ('deleter' in method.specials and 1149 if ('deleter' in method.specials and
1137 len(method.arguments) == 1 and 1150 len(method.arguments) == 1 and
1138 str(method.arguments[0].idl_type) == 'DOMString')) 1151 str(method.arguments[0].idl_type) == 'DOMString'))
1139 except StopIteration: 1152 except StopIteration:
1140 return None 1153 return None
1141 1154
1142 return property_deleter(deleter) 1155 return property_deleter(deleter)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698