| 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/scopes.h" | 9 #include "src/scopes.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 void IncrementNodeCount() { properties_.add_node_count(1); } | 47 void IncrementNodeCount() { properties_.add_node_count(1); } |
| 48 void DisableSelfOptimization() { | 48 void DisableSelfOptimization() { |
| 49 properties_.flags()->Add(kDontSelfOptimize); | 49 properties_.flags()->Add(kDontSelfOptimize); |
| 50 } | 50 } |
| 51 void DisableOptimization(BailoutReason reason) { | 51 void DisableOptimization(BailoutReason reason) { |
| 52 dont_optimize_reason_ = reason; | 52 dont_optimize_reason_ = reason; |
| 53 DisableSelfOptimization(); | 53 DisableSelfOptimization(); |
| 54 } | 54 } |
| 55 void DisableCrankshaft(BailoutReason reason) { |
| 56 if (FLAG_turbo_shipping) { |
| 57 return properties_.flags()->Add(kDontCrankshaft); |
| 58 } |
| 59 dont_optimize_reason_ = reason; |
| 60 DisableSelfOptimization(); |
| 61 } |
| 55 void DisableCaching(BailoutReason reason) { | 62 void DisableCaching(BailoutReason reason) { |
| 56 dont_optimize_reason_ = reason; | 63 dont_optimize_reason_ = reason; |
| 57 DisableSelfOptimization(); | 64 DisableSelfOptimization(); |
| 58 properties_.flags()->Add(kDontCache); | 65 properties_.flags()->Add(kDontCache); |
| 59 } | 66 } |
| 60 | 67 |
| 61 template <typename Node> | 68 template <typename Node> |
| 62 void ReserveFeedbackSlots(Node* node) { | 69 void ReserveFeedbackSlots(Node* node) { |
| 63 FeedbackVectorRequirements reqs = | 70 FeedbackVectorRequirements reqs = |
| 64 node->ComputeFeedbackRequirements(isolate(), &ic_slot_cache_); | 71 node->ComputeFeedbackRequirements(isolate(), &ic_slot_cache_); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 148 |
| 142 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { | 149 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { |
| 143 IncrementNodeCount(); | 150 IncrementNodeCount(); |
| 144 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); | 151 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); |
| 145 } | 152 } |
| 146 | 153 |
| 147 | 154 |
| 148 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { | 155 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { |
| 149 IncrementNodeCount(); | 156 IncrementNodeCount(); |
| 150 if (node->var()->IsLookupSlot()) { | 157 if (node->var()->IsLookupSlot()) { |
| 151 DisableOptimization(kReferenceToAVariableWhichRequiresDynamicLookup); | 158 DisableCrankshaft(kReferenceToAVariableWhichRequiresDynamicLookup); |
| 152 } | 159 } |
| 153 ReserveFeedbackSlots(node); | 160 ReserveFeedbackSlots(node); |
| 154 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); | 161 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); |
| 155 } | 162 } |
| 156 | 163 |
| 157 | 164 |
| 158 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { | 165 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { |
| 159 IncrementNodeCount(); | 166 IncrementNodeCount(); |
| 160 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); | 167 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); |
| 161 } | 168 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Don't try to optimize JS runtime calls because we bailout on them. | 249 // Don't try to optimize JS runtime calls because we bailout on them. |
| 243 DisableOptimization(kCallToAJavaScriptRuntimeFunction); | 250 DisableOptimization(kCallToAJavaScriptRuntimeFunction); |
| 244 } | 251 } |
| 245 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); | 252 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); |
| 246 VisitArguments(node->arguments()); | 253 VisitArguments(node->arguments()); |
| 247 } | 254 } |
| 248 | 255 |
| 249 | 256 |
| 250 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { | 257 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { |
| 251 IncrementNodeCount(); | 258 IncrementNodeCount(); |
| 252 DisableOptimization(kWithStatement); | 259 DisableCrankshaft(kWithStatement); |
| 253 node->set_base_id(ReserveIdRange(WithStatement::num_ids())); | 260 node->set_base_id(ReserveIdRange(WithStatement::num_ids())); |
| 254 Visit(node->expression()); | 261 Visit(node->expression()); |
| 255 Visit(node->statement()); | 262 Visit(node->statement()); |
| 256 } | 263 } |
| 257 | 264 |
| 258 | 265 |
| 259 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { | 266 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { |
| 260 IncrementNodeCount(); | 267 IncrementNodeCount(); |
| 261 DisableSelfOptimization(); | 268 DisableSelfOptimization(); |
| 262 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); | 269 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 ReserveFeedbackSlots(node); | 344 ReserveFeedbackSlots(node); |
| 338 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); | 345 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); |
| 339 Visit(node->each()); | 346 Visit(node->each()); |
| 340 Visit(node->enumerable()); | 347 Visit(node->enumerable()); |
| 341 Visit(node->body()); | 348 Visit(node->body()); |
| 342 } | 349 } |
| 343 | 350 |
| 344 | 351 |
| 345 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { | 352 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { |
| 346 IncrementNodeCount(); | 353 IncrementNodeCount(); |
| 347 DisableOptimization(kForOfStatement); | 354 DisableCrankshaft(kForOfStatement); |
| 348 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); | 355 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); |
| 349 Visit(node->assign_iterator()); | 356 Visit(node->assign_iterator()); |
| 350 Visit(node->next_result()); | 357 Visit(node->next_result()); |
| 351 Visit(node->result_done()); | 358 Visit(node->result_done()); |
| 352 Visit(node->assign_each()); | 359 Visit(node->assign_each()); |
| 353 Visit(node->body()); | 360 Visit(node->body()); |
| 354 } | 361 } |
| 355 | 362 |
| 356 | 363 |
| 357 void AstNumberingVisitor::VisitConditional(Conditional* node) { | 364 void AstNumberingVisitor::VisitConditional(Conditional* node) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { | 511 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { |
| 505 Scope* scope = node->scope(); | 512 Scope* scope = node->scope(); |
| 506 | 513 |
| 507 if (scope->HasIllegalRedeclaration()) { | 514 if (scope->HasIllegalRedeclaration()) { |
| 508 scope->VisitIllegalRedeclaration(this); | 515 scope->VisitIllegalRedeclaration(this); |
| 509 DisableOptimization(kFunctionWithIllegalRedeclaration); | 516 DisableOptimization(kFunctionWithIllegalRedeclaration); |
| 510 return Finish(node); | 517 return Finish(node); |
| 511 } | 518 } |
| 512 if (scope->calls_eval()) DisableOptimization(kFunctionCallsEval); | 519 if (scope->calls_eval()) DisableOptimization(kFunctionCallsEval); |
| 513 if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) { | 520 if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) { |
| 514 DisableOptimization(kContextAllocatedArguments); | 521 DisableCrankshaft(kContextAllocatedArguments); |
| 515 } | 522 } |
| 516 | 523 |
| 517 VisitDeclarations(scope->declarations()); | 524 VisitDeclarations(scope->declarations()); |
| 518 if (scope->is_function_scope() && scope->function() != NULL) { | 525 if (scope->is_function_scope() && scope->function() != NULL) { |
| 519 // Visit the name of the named function expression. | 526 // Visit the name of the named function expression. |
| 520 Visit(scope->function()); | 527 Visit(scope->function()); |
| 521 } | 528 } |
| 522 VisitStatements(node->body()); | 529 VisitStatements(node->body()); |
| 523 | 530 |
| 524 return Finish(node); | 531 return Finish(node); |
| 525 } | 532 } |
| 526 | 533 |
| 527 | 534 |
| 528 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 535 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, |
| 529 FunctionLiteral* function) { | 536 FunctionLiteral* function) { |
| 530 AstNumberingVisitor visitor(isolate, zone); | 537 AstNumberingVisitor visitor(isolate, zone); |
| 531 return visitor.Renumber(function); | 538 return visitor.Renumber(function); |
| 532 } | 539 } |
| 533 } | 540 } |
| 534 } // namespace v8::internal | 541 } // namespace v8::internal |
| OLD | NEW |