| 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/ast/ast-numbering.h" | 5 #include "src/ast/ast-numbering.h" |
| 6 | 6 |
| 7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool Renumber(FunctionLiteral* node); | 32 bool Renumber(FunctionLiteral* node); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 // AST node visitor interface. | 35 // AST node visitor interface. |
| 36 #define DEFINE_VISIT(type) void Visit##type(type* node); | 36 #define DEFINE_VISIT(type) void Visit##type(type* node); |
| 37 AST_NODE_LIST(DEFINE_VISIT) | 37 AST_NODE_LIST(DEFINE_VISIT) |
| 38 #undef DEFINE_VISIT | 38 #undef DEFINE_VISIT |
| 39 | 39 |
| 40 void VisitVariableProxy(VariableProxy* node, TypeofMode typeof_mode); |
| 40 void VisitVariableProxyReference(VariableProxy* node); | 41 void VisitVariableProxyReference(VariableProxy* node); |
| 41 void VisitPropertyReference(Property* node); | 42 void VisitPropertyReference(Property* node); |
| 42 void VisitReference(Expression* expr); | 43 void VisitReference(Expression* expr); |
| 43 | 44 |
| 44 void VisitStatementsAndDeclarations(Block* node); | 45 void VisitStatementsAndDeclarations(Block* node); |
| 45 void VisitStatements(ZoneList<Statement*>* statements); | 46 void VisitStatements(ZoneList<Statement*>* statements); |
| 46 void VisitDeclarations(Declaration::List* declarations); | 47 void VisitDeclarations(Declaration::List* declarations); |
| 47 void VisitArguments(ZoneList<Expression*>* arguments); | 48 void VisitArguments(ZoneList<Expression*>* arguments); |
| 48 void VisitLiteralProperty(LiteralProperty* property); | 49 void VisitLiteralProperty(LiteralProperty* property); |
| 49 | 50 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 break; | 181 break; |
| 181 case VariableLocation::MODULE: | 182 case VariableLocation::MODULE: |
| 182 DisableFullCodegenAndCrankshaft(kReferenceToModuleVariable); | 183 DisableFullCodegenAndCrankshaft(kReferenceToModuleVariable); |
| 183 break; | 184 break; |
| 184 default: | 185 default: |
| 185 break; | 186 break; |
| 186 } | 187 } |
| 187 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); | 188 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); |
| 188 } | 189 } |
| 189 | 190 |
| 191 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node, |
| 192 TypeofMode typeof_mode) { |
| 193 VisitVariableProxyReference(node); |
| 194 node->AssignFeedbackVectorSlots(properties_.get_spec(), typeof_mode, |
| 195 &slot_cache_); |
| 196 } |
| 190 | 197 |
| 191 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { | 198 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { |
| 192 VisitVariableProxyReference(node); | 199 VisitVariableProxy(node, NOT_INSIDE_TYPEOF); |
| 193 ReserveFeedbackSlots(node); | |
| 194 } | 200 } |
| 195 | 201 |
| 196 | 202 |
| 197 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { | 203 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { |
| 198 IncrementNodeCount(); | 204 IncrementNodeCount(); |
| 199 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); | 205 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); |
| 200 } | 206 } |
| 201 | 207 |
| 202 | 208 |
| 203 void AstNumberingVisitor::VisitSuperPropertyReference( | 209 void AstNumberingVisitor::VisitSuperPropertyReference( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 void AstNumberingVisitor::VisitThrow(Throw* node) { | 251 void AstNumberingVisitor::VisitThrow(Throw* node) { |
| 246 IncrementNodeCount(); | 252 IncrementNodeCount(); |
| 247 node->set_base_id(ReserveIdRange(Throw::num_ids())); | 253 node->set_base_id(ReserveIdRange(Throw::num_ids())); |
| 248 Visit(node->exception()); | 254 Visit(node->exception()); |
| 249 } | 255 } |
| 250 | 256 |
| 251 | 257 |
| 252 void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) { | 258 void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) { |
| 253 IncrementNodeCount(); | 259 IncrementNodeCount(); |
| 254 node->set_base_id(ReserveIdRange(UnaryOperation::num_ids())); | 260 node->set_base_id(ReserveIdRange(UnaryOperation::num_ids())); |
| 255 Visit(node->expression()); | 261 if ((node->op() == Token::TYPEOF) && node->expression()->IsVariableProxy()) { |
| 262 VariableProxy* proxy = node->expression()->AsVariableProxy(); |
| 263 VisitVariableProxy(proxy, INSIDE_TYPEOF); |
| 264 } else { |
| 265 Visit(node->expression()); |
| 266 } |
| 256 } | 267 } |
| 257 | 268 |
| 258 | 269 |
| 259 void AstNumberingVisitor::VisitCountOperation(CountOperation* node) { | 270 void AstNumberingVisitor::VisitCountOperation(CountOperation* node) { |
| 260 IncrementNodeCount(); | 271 IncrementNodeCount(); |
| 261 node->set_base_id(ReserveIdRange(CountOperation::num_ids())); | 272 node->set_base_id(ReserveIdRange(CountOperation::num_ids())); |
| 262 Visit(node->expression()); | 273 Visit(node->expression()); |
| 263 ReserveFeedbackSlots(node); | 274 ReserveFeedbackSlots(node); |
| 264 } | 275 } |
| 265 | 276 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 Compiler::EagerInnerFunctionLiterals* eager_literals) { | 713 Compiler::EagerInnerFunctionLiterals* eager_literals) { |
| 703 DisallowHeapAllocation no_allocation; | 714 DisallowHeapAllocation no_allocation; |
| 704 DisallowHandleAllocation no_handles; | 715 DisallowHandleAllocation no_handles; |
| 705 DisallowHandleDereference no_deref; | 716 DisallowHandleDereference no_deref; |
| 706 | 717 |
| 707 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); | 718 AstNumberingVisitor visitor(stack_limit, zone, eager_literals); |
| 708 return visitor.Renumber(function); | 719 return visitor.Renumber(function); |
| 709 } | 720 } |
| 710 } // namespace internal | 721 } // namespace internal |
| 711 } // namespace v8 | 722 } // namespace v8 |
| OLD | NEW |