OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 | 15 |
16 class AstNumberingVisitor FINAL : public AstVisitor { | 16 class AstNumberingVisitor FINAL : public AstVisitor { |
17 public: | 17 public: |
18 explicit AstNumberingVisitor(Zone* zone) | 18 explicit AstNumberingVisitor(Zone* zone) |
19 : AstVisitor(), | 19 : AstVisitor(), |
20 next_id_(BailoutId::FirstUsable().ToInt()), | 20 next_id_(BailoutId::FirstUsable().ToInt()), |
21 dont_crankshaft_reason_(kNoReason), | 21 dont_optimize_reason_(kNoReason) { |
22 dont_turbofan_reason_(kNoReason) { | |
23 InitializeAstVisitor(zone); | 22 InitializeAstVisitor(zone); |
24 } | 23 } |
25 | 24 |
26 bool Renumber(FunctionLiteral* node); | 25 bool Renumber(FunctionLiteral* node); |
27 | 26 |
28 private: | 27 private: |
29 // AST node visitor interface. | 28 // AST node visitor interface. |
30 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; | 29 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; |
31 AST_NODE_LIST(DEFINE_VISIT) | 30 AST_NODE_LIST(DEFINE_VISIT) |
32 #undef DEFINE_VISIT | 31 #undef DEFINE_VISIT |
33 | 32 |
34 bool Finish(FunctionLiteral* node); | 33 bool Finish(FunctionLiteral* node); |
35 | 34 |
36 void VisitStatements(ZoneList<Statement*>* statements) OVERRIDE; | 35 void VisitStatements(ZoneList<Statement*>* statements) OVERRIDE; |
37 void VisitDeclarations(ZoneList<Declaration*>* declarations) OVERRIDE; | 36 void VisitDeclarations(ZoneList<Declaration*>* declarations) OVERRIDE; |
38 void VisitArguments(ZoneList<Expression*>* arguments); | 37 void VisitArguments(ZoneList<Expression*>* arguments); |
39 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); | 38 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
40 | 39 |
41 int ReserveIdRange(int n) { | 40 int ReserveIdRange(int n) { |
42 int tmp = next_id_; | 41 int tmp = next_id_; |
43 next_id_ += n; | 42 next_id_ += n; |
44 return tmp; | 43 return tmp; |
45 } | 44 } |
46 | 45 |
47 void IncrementNodeCount() { properties_.add_node_count(1); } | 46 void IncrementNodeCount() { properties_.add_node_count(1); } |
48 void DisableCrankshaft(BailoutReason reason) { | |
49 dont_crankshaft_reason_ = reason; | |
50 DisableSelfOptimization(); | |
51 } | |
52 // TODO(turbofan): Remove the dont_turbofan_reason once no nodes are | |
53 // DisableTurbofan. That set of nodes must be kept in sync with | |
54 // Pipeline::GenerateCode. | |
55 void DisableTurbofan(BailoutReason reason) { | |
56 dont_crankshaft_reason_ = reason; | |
57 dont_turbofan_reason_ = reason; | |
58 DisableSelfOptimization(); | |
59 } | |
60 void DisableSelfOptimization() { | 47 void DisableSelfOptimization() { |
61 properties_.flags()->Add(kDontSelfOptimize); | 48 properties_.flags()->Add(kDontSelfOptimize); |
62 } | 49 } |
| 50 void DisableOptimization(BailoutReason reason) { |
| 51 dont_optimize_reason_ = reason; |
| 52 DisableSelfOptimization(); |
| 53 } |
63 void DisableCaching(BailoutReason reason) { | 54 void DisableCaching(BailoutReason reason) { |
64 dont_crankshaft_reason_ = reason; | 55 dont_optimize_reason_ = reason; |
65 DisableSelfOptimization(); | 56 DisableSelfOptimization(); |
66 properties_.flags()->Add(kDontCache); | 57 properties_.flags()->Add(kDontCache); |
67 } | 58 } |
68 | 59 |
69 template <typename Node> | 60 template <typename Node> |
70 void ReserveFeedbackSlots(Node* node) { | 61 void ReserveFeedbackSlots(Node* node) { |
71 FeedbackVectorRequirements reqs = | 62 FeedbackVectorRequirements reqs = |
72 node->ComputeFeedbackRequirements(isolate()); | 63 node->ComputeFeedbackRequirements(isolate()); |
73 if (reqs.slots() > 0) { | 64 if (reqs.slots() > 0) { |
74 node->SetFirstFeedbackSlot(FeedbackVectorSlot(properties_.slots())); | 65 node->SetFirstFeedbackSlot(FeedbackVectorSlot(properties_.slots())); |
75 properties_.increase_slots(reqs.slots()); | 66 properties_.increase_slots(reqs.slots()); |
76 } | 67 } |
77 if (reqs.ic_slots() > 0) { | 68 if (reqs.ic_slots() > 0) { |
78 int ic_slots = properties_.ic_slots(); | 69 int ic_slots = properties_.ic_slots(); |
79 node->SetFirstFeedbackICSlot(FeedbackVectorICSlot(ic_slots)); | 70 node->SetFirstFeedbackICSlot(FeedbackVectorICSlot(ic_slots)); |
80 properties_.increase_ic_slots(reqs.ic_slots()); | 71 properties_.increase_ic_slots(reqs.ic_slots()); |
81 if (FLAG_vector_ics) { | 72 if (FLAG_vector_ics) { |
82 for (int i = 0; i < reqs.ic_slots(); i++) { | 73 for (int i = 0; i < reqs.ic_slots(); i++) { |
83 properties_.SetKind(ic_slots + i, node->FeedbackICSlotKind(i)); | 74 properties_.SetKind(ic_slots + i, node->FeedbackICSlotKind(i)); |
84 } | 75 } |
85 } | 76 } |
86 } | 77 } |
87 } | 78 } |
88 | 79 |
89 BailoutReason dont_optimize_reason() const { | 80 BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; } |
90 return (dont_turbofan_reason_ != kNoReason) ? dont_turbofan_reason_ | |
91 : dont_crankshaft_reason_; | |
92 } | |
93 | 81 |
94 int next_id_; | 82 int next_id_; |
95 AstProperties properties_; | 83 AstProperties properties_; |
96 BailoutReason dont_crankshaft_reason_; | 84 BailoutReason dont_optimize_reason_; |
97 BailoutReason dont_turbofan_reason_; | |
98 | 85 |
99 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 86 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
100 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); | 87 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); |
101 }; | 88 }; |
102 | 89 |
103 | 90 |
104 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { | 91 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { |
105 IncrementNodeCount(); | 92 IncrementNodeCount(); |
106 VisitVariableProxy(node->proxy()); | 93 VisitVariableProxy(node->proxy()); |
107 } | 94 } |
108 | 95 |
109 | 96 |
110 void AstNumberingVisitor::VisitExportDeclaration(ExportDeclaration* node) { | 97 void AstNumberingVisitor::VisitExportDeclaration(ExportDeclaration* node) { |
111 IncrementNodeCount(); | 98 IncrementNodeCount(); |
112 DisableCrankshaft(kExportDeclaration); | 99 DisableOptimization(kExportDeclaration); |
113 VisitVariableProxy(node->proxy()); | 100 VisitVariableProxy(node->proxy()); |
114 } | 101 } |
115 | 102 |
116 | 103 |
117 void AstNumberingVisitor::VisitModuleUrl(ModuleUrl* node) { | 104 void AstNumberingVisitor::VisitModuleUrl(ModuleUrl* node) { |
118 IncrementNodeCount(); | 105 IncrementNodeCount(); |
119 DisableCrankshaft(kModuleUrl); | 106 DisableOptimization(kModuleUrl); |
120 } | 107 } |
121 | 108 |
122 | 109 |
123 void AstNumberingVisitor::VisitEmptyStatement(EmptyStatement* node) { | 110 void AstNumberingVisitor::VisitEmptyStatement(EmptyStatement* node) { |
124 IncrementNodeCount(); | 111 IncrementNodeCount(); |
125 } | 112 } |
126 | 113 |
127 | 114 |
128 void AstNumberingVisitor::VisitContinueStatement(ContinueStatement* node) { | 115 void AstNumberingVisitor::VisitContinueStatement(ContinueStatement* node) { |
129 IncrementNodeCount(); | 116 IncrementNodeCount(); |
130 } | 117 } |
131 | 118 |
132 | 119 |
133 void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) { | 120 void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) { |
134 IncrementNodeCount(); | 121 IncrementNodeCount(); |
135 } | 122 } |
136 | 123 |
137 | 124 |
138 void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) { | 125 void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) { |
139 IncrementNodeCount(); | 126 IncrementNodeCount(); |
140 DisableCrankshaft(kDebuggerStatement); | 127 DisableOptimization(kDebuggerStatement); |
141 node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids())); | 128 node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids())); |
142 } | 129 } |
143 | 130 |
144 | 131 |
145 void AstNumberingVisitor::VisitNativeFunctionLiteral( | 132 void AstNumberingVisitor::VisitNativeFunctionLiteral( |
146 NativeFunctionLiteral* node) { | 133 NativeFunctionLiteral* node) { |
147 IncrementNodeCount(); | 134 IncrementNodeCount(); |
148 DisableCrankshaft(kNativeFunctionLiteral); | 135 DisableOptimization(kNativeFunctionLiteral); |
149 node->set_base_id(ReserveIdRange(NativeFunctionLiteral::num_ids())); | 136 node->set_base_id(ReserveIdRange(NativeFunctionLiteral::num_ids())); |
150 } | 137 } |
151 | 138 |
152 | 139 |
153 void AstNumberingVisitor::VisitLiteral(Literal* node) { | 140 void AstNumberingVisitor::VisitLiteral(Literal* node) { |
154 IncrementNodeCount(); | 141 IncrementNodeCount(); |
155 node->set_base_id(ReserveIdRange(Literal::num_ids())); | 142 node->set_base_id(ReserveIdRange(Literal::num_ids())); |
156 } | 143 } |
157 | 144 |
158 | 145 |
159 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { | 146 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { |
160 IncrementNodeCount(); | 147 IncrementNodeCount(); |
161 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); | 148 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); |
162 } | 149 } |
163 | 150 |
164 | 151 |
165 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { | 152 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { |
166 IncrementNodeCount(); | 153 IncrementNodeCount(); |
167 if (node->var()->IsLookupSlot()) { | 154 if (node->var()->IsLookupSlot()) { |
168 DisableCrankshaft(kReferenceToAVariableWhichRequiresDynamicLookup); | 155 DisableOptimization(kReferenceToAVariableWhichRequiresDynamicLookup); |
169 } | 156 } |
170 ReserveFeedbackSlots(node); | 157 ReserveFeedbackSlots(node); |
171 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); | 158 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); |
172 } | 159 } |
173 | 160 |
174 | 161 |
175 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { | 162 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { |
176 IncrementNodeCount(); | 163 IncrementNodeCount(); |
177 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); | 164 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); |
178 } | 165 } |
179 | 166 |
180 | 167 |
181 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { | 168 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { |
182 IncrementNodeCount(); | 169 IncrementNodeCount(); |
183 DisableTurbofan(kSuperReference); | 170 DisableOptimization(kSuperReference); |
184 ReserveFeedbackSlots(node); | 171 ReserveFeedbackSlots(node); |
185 node->set_base_id(ReserveIdRange(SuperReference::num_ids())); | 172 node->set_base_id(ReserveIdRange(SuperReference::num_ids())); |
186 Visit(node->this_var()); | 173 Visit(node->this_var()); |
187 } | 174 } |
188 | 175 |
189 | 176 |
190 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { | 177 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { |
191 IncrementNodeCount(); | 178 IncrementNodeCount(); |
192 DisableCrankshaft(kModuleDeclaration); | 179 DisableOptimization(kModuleDeclaration); |
193 VisitVariableProxy(node->proxy()); | 180 VisitVariableProxy(node->proxy()); |
194 Visit(node->module()); | 181 Visit(node->module()); |
195 } | 182 } |
196 | 183 |
197 | 184 |
198 void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) { | 185 void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) { |
199 IncrementNodeCount(); | 186 IncrementNodeCount(); |
200 DisableCrankshaft(kImportDeclaration); | 187 DisableOptimization(kImportDeclaration); |
201 VisitVariableProxy(node->proxy()); | 188 VisitVariableProxy(node->proxy()); |
202 Visit(node->module()); | 189 Visit(node->module()); |
203 } | 190 } |
204 | 191 |
205 | 192 |
206 void AstNumberingVisitor::VisitModuleVariable(ModuleVariable* node) { | 193 void AstNumberingVisitor::VisitModuleVariable(ModuleVariable* node) { |
207 IncrementNodeCount(); | 194 IncrementNodeCount(); |
208 DisableCrankshaft(kModuleVariable); | 195 DisableOptimization(kModuleVariable); |
209 Visit(node->proxy()); | 196 Visit(node->proxy()); |
210 } | 197 } |
211 | 198 |
212 | 199 |
213 void AstNumberingVisitor::VisitModulePath(ModulePath* node) { | 200 void AstNumberingVisitor::VisitModulePath(ModulePath* node) { |
214 IncrementNodeCount(); | 201 IncrementNodeCount(); |
215 DisableCrankshaft(kModulePath); | 202 DisableOptimization(kModulePath); |
216 Visit(node->module()); | 203 Visit(node->module()); |
217 } | 204 } |
218 | 205 |
219 | 206 |
220 void AstNumberingVisitor::VisitModuleStatement(ModuleStatement* node) { | 207 void AstNumberingVisitor::VisitModuleStatement(ModuleStatement* node) { |
221 IncrementNodeCount(); | 208 IncrementNodeCount(); |
222 DisableCrankshaft(kModuleStatement); | 209 DisableOptimization(kModuleStatement); |
223 Visit(node->body()); | 210 Visit(node->body()); |
224 } | 211 } |
225 | 212 |
226 | 213 |
227 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { | 214 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { |
228 IncrementNodeCount(); | 215 IncrementNodeCount(); |
229 Visit(node->expression()); | 216 Visit(node->expression()); |
230 } | 217 } |
231 | 218 |
232 | 219 |
233 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { | 220 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { |
234 IncrementNodeCount(); | 221 IncrementNodeCount(); |
235 Visit(node->expression()); | 222 Visit(node->expression()); |
236 } | 223 } |
237 | 224 |
238 | 225 |
239 void AstNumberingVisitor::VisitYield(Yield* node) { | 226 void AstNumberingVisitor::VisitYield(Yield* node) { |
240 IncrementNodeCount(); | 227 IncrementNodeCount(); |
241 DisableCrankshaft(kYield); | 228 DisableOptimization(kYield); |
242 ReserveFeedbackSlots(node); | 229 ReserveFeedbackSlots(node); |
243 node->set_base_id(ReserveIdRange(Yield::num_ids())); | 230 node->set_base_id(ReserveIdRange(Yield::num_ids())); |
244 Visit(node->generator_object()); | 231 Visit(node->generator_object()); |
245 Visit(node->expression()); | 232 Visit(node->expression()); |
246 } | 233 } |
247 | 234 |
248 | 235 |
249 void AstNumberingVisitor::VisitThrow(Throw* node) { | 236 void AstNumberingVisitor::VisitThrow(Throw* node) { |
250 IncrementNodeCount(); | 237 IncrementNodeCount(); |
251 node->set_base_id(ReserveIdRange(Throw::num_ids())); | 238 node->set_base_id(ReserveIdRange(Throw::num_ids())); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 DisableCaching(kModuleLiteral); | 274 DisableCaching(kModuleLiteral); |
288 VisitBlock(node->body()); | 275 VisitBlock(node->body()); |
289 } | 276 } |
290 | 277 |
291 | 278 |
292 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { | 279 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { |
293 IncrementNodeCount(); | 280 IncrementNodeCount(); |
294 ReserveFeedbackSlots(node); | 281 ReserveFeedbackSlots(node); |
295 if (node->is_jsruntime()) { | 282 if (node->is_jsruntime()) { |
296 // Don't try to optimize JS runtime calls because we bailout on them. | 283 // Don't try to optimize JS runtime calls because we bailout on them. |
297 DisableCrankshaft(kCallToAJavaScriptRuntimeFunction); | 284 DisableOptimization(kCallToAJavaScriptRuntimeFunction); |
298 } | 285 } |
299 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); | 286 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); |
300 VisitArguments(node->arguments()); | 287 VisitArguments(node->arguments()); |
301 } | 288 } |
302 | 289 |
303 | 290 |
304 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { | 291 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { |
305 IncrementNodeCount(); | 292 IncrementNodeCount(); |
306 DisableCrankshaft(kWithStatement); | 293 DisableOptimization(kWithStatement); |
307 Visit(node->expression()); | 294 Visit(node->expression()); |
308 Visit(node->statement()); | 295 Visit(node->statement()); |
309 } | 296 } |
310 | 297 |
311 | 298 |
312 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { | 299 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { |
313 IncrementNodeCount(); | 300 IncrementNodeCount(); |
314 DisableSelfOptimization(); | 301 DisableSelfOptimization(); |
315 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); | 302 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); |
316 Visit(node->body()); | 303 Visit(node->body()); |
317 Visit(node->cond()); | 304 Visit(node->cond()); |
318 } | 305 } |
319 | 306 |
320 | 307 |
321 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { | 308 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { |
322 IncrementNodeCount(); | 309 IncrementNodeCount(); |
323 DisableSelfOptimization(); | 310 DisableSelfOptimization(); |
324 node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); | 311 node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); |
325 Visit(node->cond()); | 312 Visit(node->cond()); |
326 Visit(node->body()); | 313 Visit(node->body()); |
327 } | 314 } |
328 | 315 |
329 | 316 |
330 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { | 317 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { |
331 IncrementNodeCount(); | 318 IncrementNodeCount(); |
332 DisableTurbofan(kTryCatchStatement); | 319 DisableOptimization(kTryCatchStatement); |
333 Visit(node->try_block()); | 320 Visit(node->try_block()); |
334 Visit(node->catch_block()); | 321 Visit(node->catch_block()); |
335 } | 322 } |
336 | 323 |
337 | 324 |
338 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { | 325 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { |
339 IncrementNodeCount(); | 326 IncrementNodeCount(); |
340 DisableTurbofan(kTryFinallyStatement); | 327 DisableOptimization(kTryFinallyStatement); |
341 Visit(node->try_block()); | 328 Visit(node->try_block()); |
342 Visit(node->finally_block()); | 329 Visit(node->finally_block()); |
343 } | 330 } |
344 | 331 |
345 | 332 |
346 void AstNumberingVisitor::VisitProperty(Property* node) { | 333 void AstNumberingVisitor::VisitProperty(Property* node) { |
347 IncrementNodeCount(); | 334 IncrementNodeCount(); |
348 ReserveFeedbackSlots(node); | 335 ReserveFeedbackSlots(node); |
349 node->set_base_id(ReserveIdRange(Property::num_ids())); | 336 node->set_base_id(ReserveIdRange(Property::num_ids())); |
350 Visit(node->key()); | 337 Visit(node->key()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 ReserveFeedbackSlots(node); | 370 ReserveFeedbackSlots(node); |
384 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); | 371 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); |
385 Visit(node->each()); | 372 Visit(node->each()); |
386 Visit(node->enumerable()); | 373 Visit(node->enumerable()); |
387 Visit(node->body()); | 374 Visit(node->body()); |
388 } | 375 } |
389 | 376 |
390 | 377 |
391 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { | 378 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { |
392 IncrementNodeCount(); | 379 IncrementNodeCount(); |
393 DisableCrankshaft(kForOfStatement); | 380 DisableOptimization(kForOfStatement); |
394 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); | 381 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); |
395 Visit(node->assign_iterator()); | 382 Visit(node->assign_iterator()); |
396 Visit(node->next_result()); | 383 Visit(node->next_result()); |
397 Visit(node->result_done()); | 384 Visit(node->result_done()); |
398 Visit(node->assign_each()); | 385 Visit(node->assign_each()); |
399 Visit(node->body()); | 386 Visit(node->body()); |
400 } | 387 } |
401 | 388 |
402 | 389 |
403 void AstNumberingVisitor::VisitConditional(Conditional* node) { | 390 void AstNumberingVisitor::VisitConditional(Conditional* node) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 node->set_base_id(ReserveIdRange(ForStatement::num_ids())); | 432 node->set_base_id(ReserveIdRange(ForStatement::num_ids())); |
446 if (node->init() != NULL) Visit(node->init()); | 433 if (node->init() != NULL) Visit(node->init()); |
447 if (node->cond() != NULL) Visit(node->cond()); | 434 if (node->cond() != NULL) Visit(node->cond()); |
448 if (node->next() != NULL) Visit(node->next()); | 435 if (node->next() != NULL) Visit(node->next()); |
449 Visit(node->body()); | 436 Visit(node->body()); |
450 } | 437 } |
451 | 438 |
452 | 439 |
453 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { | 440 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { |
454 IncrementNodeCount(); | 441 IncrementNodeCount(); |
455 DisableCrankshaft(kClassLiteral); | 442 DisableOptimization(kClassLiteral); |
456 node->set_base_id(ReserveIdRange(ClassLiteral::num_ids())); | 443 node->set_base_id(ReserveIdRange(ClassLiteral::num_ids())); |
457 if (node->extends()) Visit(node->extends()); | 444 if (node->extends()) Visit(node->extends()); |
458 if (node->constructor()) Visit(node->constructor()); | 445 if (node->constructor()) Visit(node->constructor()); |
459 if (node->class_variable_proxy()) { | 446 if (node->class_variable_proxy()) { |
460 VisitVariableProxy(node->class_variable_proxy()); | 447 VisitVariableProxy(node->class_variable_proxy()); |
461 } | 448 } |
462 for (int i = 0; i < node->properties()->length(); i++) { | 449 for (int i = 0; i < node->properties()->length(); i++) { |
463 VisitObjectLiteralProperty(node->properties()->at(i)); | 450 VisitObjectLiteralProperty(node->properties()->at(i)); |
464 } | 451 } |
465 } | 452 } |
466 | 453 |
467 | 454 |
468 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { | 455 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { |
469 IncrementNodeCount(); | 456 IncrementNodeCount(); |
470 node->set_base_id(ReserveIdRange(ObjectLiteral::num_ids())); | 457 node->set_base_id(ReserveIdRange(ObjectLiteral::num_ids())); |
471 for (int i = 0; i < node->properties()->length(); i++) { | 458 for (int i = 0; i < node->properties()->length(); i++) { |
472 VisitObjectLiteralProperty(node->properties()->at(i)); | 459 VisitObjectLiteralProperty(node->properties()->at(i)); |
473 } | 460 } |
474 } | 461 } |
475 | 462 |
476 | 463 |
477 void AstNumberingVisitor::VisitObjectLiteralProperty( | 464 void AstNumberingVisitor::VisitObjectLiteralProperty( |
478 ObjectLiteralProperty* node) { | 465 ObjectLiteralProperty* node) { |
479 if (node->is_computed_name()) DisableTurbofan(kComputedPropertyName); | 466 if (node->is_computed_name()) DisableOptimization(kComputedPropertyName); |
480 Visit(node->key()); | 467 Visit(node->key()); |
481 Visit(node->value()); | 468 Visit(node->value()); |
482 } | 469 } |
483 | 470 |
484 | 471 |
485 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) { | 472 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) { |
486 IncrementNodeCount(); | 473 IncrementNodeCount(); |
487 node->set_base_id(ReserveIdRange(node->num_ids())); | 474 node->set_base_id(ReserveIdRange(node->num_ids())); |
488 for (int i = 0; i < node->values()->length(); i++) { | 475 for (int i = 0; i < node->values()->length(); i++) { |
489 Visit(node->values()->at(i)); | 476 Visit(node->values()->at(i)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 node->set_dont_optimize_reason(dont_optimize_reason()); | 532 node->set_dont_optimize_reason(dont_optimize_reason()); |
546 return !HasStackOverflow(); | 533 return !HasStackOverflow(); |
547 } | 534 } |
548 | 535 |
549 | 536 |
550 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { | 537 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { |
551 Scope* scope = node->scope(); | 538 Scope* scope = node->scope(); |
552 | 539 |
553 if (scope->HasIllegalRedeclaration()) { | 540 if (scope->HasIllegalRedeclaration()) { |
554 scope->VisitIllegalRedeclaration(this); | 541 scope->VisitIllegalRedeclaration(this); |
555 DisableCrankshaft(kFunctionWithIllegalRedeclaration); | 542 DisableOptimization(kFunctionWithIllegalRedeclaration); |
556 return Finish(node); | 543 return Finish(node); |
557 } | 544 } |
558 if (scope->calls_eval()) DisableCrankshaft(kFunctionCallsEval); | 545 if (scope->calls_eval()) DisableOptimization(kFunctionCallsEval); |
559 if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) { | 546 if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) { |
560 DisableCrankshaft(kContextAllocatedArguments); | 547 DisableOptimization(kContextAllocatedArguments); |
561 } | 548 } |
562 | 549 |
563 VisitDeclarations(scope->declarations()); | 550 VisitDeclarations(scope->declarations()); |
564 if (scope->is_function_scope() && scope->function() != NULL) { | 551 if (scope->is_function_scope() && scope->function() != NULL) { |
565 // Visit the name of the named function expression. | 552 // Visit the name of the named function expression. |
566 Visit(scope->function()); | 553 Visit(scope->function()); |
567 } | 554 } |
568 VisitStatements(node->body()); | 555 VisitStatements(node->body()); |
569 | 556 |
570 return Finish(node); | 557 return Finish(node); |
571 } | 558 } |
572 | 559 |
573 | 560 |
574 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { | 561 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { |
575 AstNumberingVisitor visitor(zone); | 562 AstNumberingVisitor visitor(zone); |
576 return visitor.Renumber(function); | 563 return visitor.Renumber(function); |
577 } | 564 } |
578 } | 565 } |
579 } // namespace v8::internal | 566 } // namespace v8::internal |
OLD | NEW |