-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathCodeGeneratorWeights.swift
More file actions
197 lines (187 loc) · 9.41 KB
/
CodeGeneratorWeights.swift
File metadata and controls
197 lines (187 loc) · 9.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/// Default weights for the builtin code generators.
public let codeGeneratorWeights = [
// Value generators. These are used to bootstrap code
// generation and therefore control the types of variables
// available at the start of code generation.
"IntegerGenerator": 20,
"RegExpGenerator": 5,
"BigIntGenerator": 10,
"FloatGenerator": 10,
"StringGenerator": 10,
"BooleanGenerator": 2,
"UndefinedGenerator": 1,
"NullGenerator": 1,
"NamedVariableGenerator": 10,
"ArrayGenerator": 10,
"FloatArrayGenerator": 10,
"IntArrayGenerator": 10,
"TypedArrayGenerator": 20,
"BuiltinObjectInstanceGenerator": 10,
"ObjectBuilderFunctionGenerator": 10,
"ObjectConstructorGenerator": 10,
"ClassDefinitionGenerator": 20,
"TrivialFunctionGenerator": 10,
// Regular code generators.
"ThisGenerator": 3,
"ArgumentsAccessGenerator": 3,
"FunctionWithArgumentsAccessGenerator": 2,
"BuiltinGenerator": 10,
"BuiltinOverwriteGenerator": 3,
"LoadNewTargetGenerator": 3,
"DisposableVariableGenerator": 5,
"AsyncDisposableVariableGenerator": 5,
"ObjectLiteralGenerator": 10,
// The following generators determine how frequently different
// types of fields are generated in object literals.
"ObjectLiteralPropertyGenerator": 20,
"ObjectLiteralElementGenerator": 5,
"ObjectLiteralComputedPropertyGenerator": 5,
"ObjectLiteralCopyPropertiesGenerator": 5,
"ObjectLiteralPrototypeGenerator": 5,
"ObjectLiteralMethodGenerator": 5,
"ObjectLiteralComputedMethodGenerator": 3,
"ObjectLiteralGetterGenerator": 3,
"ObjectLiteralSetterGenerator": 3,
// The following generators determine how frequently different
// types of fields are generated in class definitions.
"ClassConstructorGenerator": 10, // Will only run if no constructor exists yet
"ClassInstancePropertyGenerator": 5,
"ClassInstanceElementGenerator": 5,
"ClassInstanceComputedPropertyGenerator": 5,
"ClassInstanceMethodGenerator": 10,
"ClassInstanceGetterGenerator": 3,
"ClassInstanceSetterGenerator": 3,
"ClassStaticPropertyGenerator": 3,
"ClassStaticElementGenerator": 3,
"ClassStaticComputedPropertyGenerator": 3,
"ClassStaticInitializerGenerator": 3,
"ClassStaticMethodGenerator": 5,
"ClassStaticGetterGenerator": 2,
"ClassStaticSetterGenerator": 2,
"ClassPrivateInstancePropertyGenerator": 5,
"ClassPrivateInstanceMethodGenerator": 5,
"ClassPrivateStaticPropertyGenerator": 5,
"ClassPrivateStaticMethodGenerator": 5,
"ObjectWithSpreadGenerator": 2,
"ArrayWithSpreadGenerator": 2,
"TemplateStringGenerator": 1,
"StringNormalizeGenerator": 1,
"PlainFunctionGenerator": 15,
"ArrowFunctionGenerator": 3,
"GeneratorFunctionGenerator": 3,
"AsyncFunctionGenerator": 3,
"AsyncArrowFunctionGenerator": 1,
"AsyncGeneratorFunctionGenerator": 1,
"ConstructorGenerator": 5,
"SubroutineReturnGenerator": 3,
"YieldGenerator": 5,
"YieldEachGenerator": 5,
"AwaitGenerator": 2,
"PropertyRetrievalGenerator": 20,
"PropertyAssignmentGenerator": 20,
"PropertyUpdateGenerator": 10,
"PropertyRemovalGenerator": 5,
"PropertyConfigurationGenerator": 10,
"ElementRetrievalGenerator": 20,
"ElementAssignmentGenerator": 20,
"ElementUpdateGenerator": 7,
"ElementRemovalGenerator": 5,
"ElementConfigurationGenerator": 10,
"TypeTestGenerator": 5,
"InstanceOfGenerator": 5,
"InGenerator": 3,
"ComputedPropertyRetrievalGenerator": 20,
"ComputedPropertyAssignmentGenerator": 20,
"ComputedPropertyUpdateGenerator": 7,
"ComputedPropertyRemovalGenerator": 5,
"ComputedPropertyConfigurationGenerator": 10,
"FunctionCallGenerator": 30,
"FunctionCallWithSpreadGenerator": 3,
"ConstructorCallGenerator": 20,
"ConstructorCallWithSpreadGenerator": 3,
"MethodCallGenerator": 30,
"MethodCallWithSpreadGenerator": 3,
"ComputedMethodCallGenerator": 10,
"ComputedMethodCallWithSpreadGenerator": 3,
"UnaryOperationGenerator": 10,
"BinaryOperationGenerator": 40,
"TernaryOperationGenerator": 5,
"ReassignmentGenerator": 40,
"UpdateGenerator": 20,
"DupGenerator": 2,
"DestructArrayGenerator": 5,
"DestructArrayAndReassignGenerator": 5,
"DestructObjectGenerator": 5,
"DestructObjectAndReassignGenerator": 5,
"WithStatementGenerator": 3,
"ComparisonGenerator": 10,
"SuperMethodCallGenerator": 20,
// These will only be used inside class methods, and only if private properties were previously declared in that class.
"PrivatePropertyRetrievalGenerator": 30,
"PrivatePropertyAssignmentGenerator": 30,
"PrivatePropertyUpdateGenerator": 15,
"PrivateMethodCallGenerator": 20,
// These will only be used inside class- or object literal methods.
"SuperPropertyRetrievalGenerator": 20,
"SuperPropertyAssignmentGenerator": 20,
"ComputedSuperPropertyRetrievalGenerator": 20,
"ComputedSuperPropertyAssignmentGenerator": 20,
"SuperPropertyUpdateGenerator": 10,
"IfElseGenerator": 10,
"CompareWithIfElseGenerator": 15,
"SwitchBlockGenerator": 5,
"SwitchDefaultCaseGenerator": 3,
"SwitchCaseGenerator": 5,
"WhileLoopGenerator": 15,
"DoWhileLoopGenerator": 15,
"SimpleForLoopGenerator": 10,
"ComplexForLoopGenerator": 10,
"ForInLoopGenerator": 10,
"ForOfLoopGenerator": 10,
"ForOfWithDestructLoopGenerator": 3,
"RepeatLoopGenerator": 10,
"SwitchCaseBreakGenerator": 5,
"LoopBreakGenerator": 5,
"ContinueGenerator": 5,
"TryCatchGenerator": 5,
"ThrowGenerator": 1,
"BlockStatementGenerator": 1,
// Special generators
"WellKnownPropertyLoadGenerator": 5,
"WellKnownPropertyStoreGenerator": 5,
"PrototypeAccessGenerator": 10,
"PrototypeOverwriteGenerator": 10,
"CallbackPropertyGenerator": 10,
"MethodCallWithDifferentThisGenerator": 5,
"WeirdClassGenerator": 10,
"ProxyGenerator": 10,
"LengthChangeGenerator": 5,
"ElementKindChangeGenerator": 5,
"PromiseGenerator": 3,
"EvalGenerator": 3,
"NumberComputationGenerator": 40,
"ImitationGenerator": 30,
"ResizableArrayBufferGenerator": 5,
"GrowableSharedArrayBufferGenerator": 5,
"FastToSlowPropertiesGenerator": 10,
"IteratorGenerator": 5,
"ConstructWithDifferentNewTargetGenerator": 5,
"ObjectHierarchyGenerator": 10,
"ApiConstructorCallGenerator": 15,
"ApiMethodCallGenerator": 15,
"ApiFunctionCallGenerator": 15,
"VoidGenerator": 1,
]