| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_AST_H_ | 28 #ifndef V8_AST_H_ |
| 29 #define V8_AST_H_ | 29 #define V8_AST_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "execution.h" | 32 #include "execution.h" |
| 33 #include "factory.h" | 33 #include "factory.h" |
| 34 #include "jsregexp.h" | 34 #include "jsregexp.h" |
| 35 #include "runtime.h" | 35 #include "runtime.h" |
| 36 #include "small-pointer-list.h" |
| 36 #include "token.h" | 37 #include "token.h" |
| 37 #include "variables.h" | 38 #include "variables.h" |
| 38 | 39 |
| 39 namespace v8 { | 40 namespace v8 { |
| 40 namespace internal { | 41 namespace internal { |
| 41 | 42 |
| 42 // The abstract syntax tree is an intermediate, light-weight | 43 // The abstract syntax tree is an intermediate, light-weight |
| 43 // representation of the parsed JavaScript code suitable for | 44 // representation of the parsed JavaScript code suitable for |
| 44 // compilation to native code. | 45 // compilation to native code. |
| 45 | 46 |
| 46 // Nodes are allocated in a separate zone, which allows faster | 47 // Nodes are allocated in a separate zone, which allows faster |
| 47 // allocation and constant-time deallocation of the entire syntax | 48 // allocation and constant-time deallocation of the entire syntax |
| 48 // tree. | 49 // tree. |
| 49 | 50 |
| 50 | 51 |
| 51 // ---------------------------------------------------------------------------- | 52 // ---------------------------------------------------------------------------- |
| 52 // Nodes of the abstract syntax tree. Only concrete classes are | 53 // Nodes of the abstract syntax tree. Only concrete classes are |
| 53 // enumerated here. | 54 // enumerated here. |
| 54 | 55 |
| 55 #define STATEMENT_NODE_LIST(V) \ | 56 #define STATEMENT_NODE_LIST(V) \ |
| 56 V(Block) \ | 57 V(Block) \ |
| 57 V(ExpressionStatement) \ | 58 V(ExpressionStatement) \ |
| 58 V(EmptyStatement) \ | 59 V(EmptyStatement) \ |
| 59 V(IfStatement) \ | 60 V(IfStatement) \ |
| 60 V(ContinueStatement) \ | 61 V(ContinueStatement) \ |
| 61 V(BreakStatement) \ | 62 V(BreakStatement) \ |
| 62 V(ReturnStatement) \ | 63 V(ReturnStatement) \ |
| 63 V(EnterWithContextStatement) \ | 64 V(WithStatement) \ |
| 64 V(ExitContextStatement) \ | 65 V(ExitContextStatement) \ |
| 65 V(SwitchStatement) \ | 66 V(SwitchStatement) \ |
| 66 V(DoWhileStatement) \ | 67 V(DoWhileStatement) \ |
| 67 V(WhileStatement) \ | 68 V(WhileStatement) \ |
| 68 V(ForStatement) \ | 69 V(ForStatement) \ |
| 69 V(ForInStatement) \ | 70 V(ForInStatement) \ |
| 70 V(TryCatchStatement) \ | 71 V(TryCatchStatement) \ |
| 71 V(TryFinallyStatement) \ | 72 V(TryFinallyStatement) \ |
| 72 V(DebuggerStatement) | 73 V(DebuggerStatement) |
| 73 | 74 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 201 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
| 201 | 202 |
| 202 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 203 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
| 203 int statement_pos() const { return statement_pos_; } | 204 int statement_pos() const { return statement_pos_; } |
| 204 | 205 |
| 205 private: | 206 private: |
| 206 int statement_pos_; | 207 int statement_pos_; |
| 207 }; | 208 }; |
| 208 | 209 |
| 209 | 210 |
| 211 class SmallMapList { |
| 212 public: |
| 213 SmallMapList() {} |
| 214 explicit SmallMapList(int capacity) : list_(capacity) {} |
| 215 |
| 216 void Reserve(int capacity) { list_.Reserve(capacity); } |
| 217 void Clear() { list_.Clear(); } |
| 218 |
| 219 bool is_empty() const { return list_.is_empty(); } |
| 220 int length() const { return list_.length(); } |
| 221 |
| 222 void Add(Handle<Map> handle) { |
| 223 list_.Add(handle.location()); |
| 224 } |
| 225 |
| 226 Handle<Map> at(int i) const { |
| 227 return Handle<Map>(list_.at(i)); |
| 228 } |
| 229 |
| 230 Handle<Map> first() const { return at(0); } |
| 231 Handle<Map> last() const { return at(length() - 1); } |
| 232 |
| 233 private: |
| 234 // The list stores pointers to Map*, that is Map**, so it's GC safe. |
| 235 SmallPointerList<Map*> list_; |
| 236 |
| 237 DISALLOW_COPY_AND_ASSIGN(SmallMapList); |
| 238 }; |
| 239 |
| 240 |
| 210 class Expression: public AstNode { | 241 class Expression: public AstNode { |
| 211 public: | 242 public: |
| 212 enum Context { | 243 enum Context { |
| 213 // Not assigned a context yet, or else will not be visited during | 244 // Not assigned a context yet, or else will not be visited during |
| 214 // code generation. | 245 // code generation. |
| 215 kUninitialized, | 246 kUninitialized, |
| 216 // Evaluated for its side effects. | 247 // Evaluated for its side effects. |
| 217 kEffect, | 248 kEffect, |
| 218 // Evaluated for its value (and side effects). | 249 // Evaluated for its value (and side effects). |
| 219 kValue, | 250 kValue, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 289 |
| 259 // Type feedback information for assignments and properties. | 290 // Type feedback information for assignments and properties. |
| 260 virtual bool IsMonomorphic() { | 291 virtual bool IsMonomorphic() { |
| 261 UNREACHABLE(); | 292 UNREACHABLE(); |
| 262 return false; | 293 return false; |
| 263 } | 294 } |
| 264 virtual bool IsArrayLength() { | 295 virtual bool IsArrayLength() { |
| 265 UNREACHABLE(); | 296 UNREACHABLE(); |
| 266 return false; | 297 return false; |
| 267 } | 298 } |
| 268 virtual ZoneMapList* GetReceiverTypes() { | 299 virtual SmallMapList* GetReceiverTypes() { |
| 269 UNREACHABLE(); | 300 UNREACHABLE(); |
| 270 return NULL; | 301 return NULL; |
| 271 } | 302 } |
| 272 virtual Handle<Map> GetMonomorphicReceiverType() { | 303 Handle<Map> GetMonomorphicReceiverType() { |
| 273 UNREACHABLE(); | 304 ASSERT(IsMonomorphic()); |
| 274 return Handle<Map>(); | 305 SmallMapList* types = GetReceiverTypes(); |
| 306 ASSERT(types != NULL && types->length() == 1); |
| 307 return types->at(0); |
| 275 } | 308 } |
| 276 | 309 |
| 277 unsigned id() const { return id_; } | 310 unsigned id() const { return id_; } |
| 278 unsigned test_id() const { return test_id_; } | 311 unsigned test_id() const { return test_id_; } |
| 279 | 312 |
| 280 private: | 313 private: |
| 281 unsigned id_; | 314 unsigned id_; |
| 282 unsigned test_id_; | 315 unsigned test_id_; |
| 283 }; | 316 }; |
| 284 | 317 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 return statements_[0]->StatementAsCountOperation(); | 385 return statements_[0]->StatementAsCountOperation(); |
| 353 } | 386 } |
| 354 | 387 |
| 355 virtual bool IsInlineable() const; | 388 virtual bool IsInlineable() const; |
| 356 | 389 |
| 357 void AddStatement(Statement* statement) { statements_.Add(statement); } | 390 void AddStatement(Statement* statement) { statements_.Add(statement); } |
| 358 | 391 |
| 359 ZoneList<Statement*>* statements() { return &statements_; } | 392 ZoneList<Statement*>* statements() { return &statements_; } |
| 360 bool is_initializer_block() const { return is_initializer_block_; } | 393 bool is_initializer_block() const { return is_initializer_block_; } |
| 361 | 394 |
| 395 Scope* block_scope() const { return block_scope_; } |
| 396 void set_block_scope(Scope* block_scope) { block_scope_ = block_scope; } |
| 397 |
| 362 private: | 398 private: |
| 363 ZoneList<Statement*> statements_; | 399 ZoneList<Statement*> statements_; |
| 364 bool is_initializer_block_; | 400 bool is_initializer_block_; |
| 401 Scope* block_scope_; |
| 365 }; | 402 }; |
| 366 | 403 |
| 367 | 404 |
| 368 class Declaration: public AstNode { | 405 class Declaration: public AstNode { |
| 369 public: | 406 public: |
| 370 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) | 407 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) |
| 371 : proxy_(proxy), | 408 : proxy_(proxy), |
| 372 mode_(mode), | 409 mode_(mode), |
| 373 fun_(fun) { | 410 fun_(fun) { |
| 374 ASSERT(mode == Variable::VAR || mode == Variable::CONST); | 411 ASSERT(mode == Variable::VAR || |
| 412 mode == Variable::CONST || |
| 413 mode == Variable::LET); |
| 375 // At the moment there are no "const functions"'s in JavaScript... | 414 // At the moment there are no "const functions"'s in JavaScript... |
| 376 ASSERT(fun == NULL || mode == Variable::VAR); | 415 ASSERT(fun == NULL || mode == Variable::VAR || mode == Variable::LET); |
| 377 } | 416 } |
| 378 | 417 |
| 379 DECLARE_NODE_TYPE(Declaration) | 418 DECLARE_NODE_TYPE(Declaration) |
| 380 | 419 |
| 381 VariableProxy* proxy() const { return proxy_; } | 420 VariableProxy* proxy() const { return proxy_; } |
| 382 Variable::Mode mode() const { return mode_; } | 421 Variable::Mode mode() const { return mode_; } |
| 383 FunctionLiteral* fun() const { return fun_; } // may be NULL | 422 FunctionLiteral* fun() const { return fun_; } // may be NULL |
| 384 virtual bool IsInlineable() const; | 423 virtual bool IsInlineable() const; |
| 385 | 424 |
| 386 private: | 425 private: |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 DECLARE_NODE_TYPE(ReturnStatement) | 659 DECLARE_NODE_TYPE(ReturnStatement) |
| 621 | 660 |
| 622 Expression* expression() const { return expression_; } | 661 Expression* expression() const { return expression_; } |
| 623 virtual bool IsInlineable() const; | 662 virtual bool IsInlineable() const; |
| 624 | 663 |
| 625 private: | 664 private: |
| 626 Expression* expression_; | 665 Expression* expression_; |
| 627 }; | 666 }; |
| 628 | 667 |
| 629 | 668 |
| 630 class EnterWithContextStatement: public Statement { | 669 class WithStatement: public Statement { |
| 631 public: | 670 public: |
| 632 explicit EnterWithContextStatement(Expression* expression) | 671 WithStatement(Expression* expression, Statement* statement) |
| 633 : expression_(expression) { } | 672 : expression_(expression), statement_(statement) { } |
| 634 | 673 |
| 635 DECLARE_NODE_TYPE(EnterWithContextStatement) | 674 DECLARE_NODE_TYPE(WithStatement) |
| 636 | 675 |
| 637 Expression* expression() const { return expression_; } | 676 Expression* expression() const { return expression_; } |
| 677 Statement* statement() const { return statement_; } |
| 638 | 678 |
| 639 virtual bool IsInlineable() const; | 679 virtual bool IsInlineable() const; |
| 640 | 680 |
| 641 private: | 681 private: |
| 642 Expression* expression_; | 682 Expression* expression_; |
| 683 Statement* statement_; |
| 643 }; | 684 }; |
| 644 | 685 |
| 645 | 686 |
| 646 class ExitContextStatement: public Statement { | 687 class ExitContextStatement: public Statement { |
| 647 public: | 688 public: |
| 648 virtual bool IsInlineable() const; | 689 virtual bool IsInlineable() const; |
| 649 | 690 |
| 650 DECLARE_NODE_TYPE(ExitContextStatement) | 691 DECLARE_NODE_TYPE(ExitContextStatement) |
| 651 }; | 692 }; |
| 652 | 693 |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 Property(Isolate* isolate, | 1239 Property(Isolate* isolate, |
| 1199 Expression* obj, | 1240 Expression* obj, |
| 1200 Expression* key, | 1241 Expression* key, |
| 1201 int pos, | 1242 int pos, |
| 1202 Type type = NORMAL) | 1243 Type type = NORMAL) |
| 1203 : Expression(isolate), | 1244 : Expression(isolate), |
| 1204 obj_(obj), | 1245 obj_(obj), |
| 1205 key_(key), | 1246 key_(key), |
| 1206 pos_(pos), | 1247 pos_(pos), |
| 1207 type_(type), | 1248 type_(type), |
| 1208 receiver_types_(NULL), | |
| 1209 is_monomorphic_(false), | 1249 is_monomorphic_(false), |
| 1210 is_array_length_(false), | 1250 is_array_length_(false), |
| 1211 is_string_length_(false), | 1251 is_string_length_(false), |
| 1212 is_string_access_(false), | 1252 is_string_access_(false), |
| 1213 is_function_prototype_(false) { } | 1253 is_function_prototype_(false) { } |
| 1214 | 1254 |
| 1215 DECLARE_NODE_TYPE(Property) | 1255 DECLARE_NODE_TYPE(Property) |
| 1216 | 1256 |
| 1217 virtual bool IsValidLeftHandSide() { return true; } | 1257 virtual bool IsValidLeftHandSide() { return true; } |
| 1218 virtual bool IsInlineable() const; | 1258 virtual bool IsInlineable() const; |
| 1219 | 1259 |
| 1220 Expression* obj() const { return obj_; } | 1260 Expression* obj() const { return obj_; } |
| 1221 Expression* key() const { return key_; } | 1261 Expression* key() const { return key_; } |
| 1222 virtual int position() const { return pos_; } | 1262 virtual int position() const { return pos_; } |
| 1223 bool is_synthetic() const { return type_ == SYNTHETIC; } | 1263 bool is_synthetic() const { return type_ == SYNTHETIC; } |
| 1224 | 1264 |
| 1225 bool IsStringLength() const { return is_string_length_; } | 1265 bool IsStringLength() const { return is_string_length_; } |
| 1226 bool IsStringAccess() const { return is_string_access_; } | 1266 bool IsStringAccess() const { return is_string_access_; } |
| 1227 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1267 bool IsFunctionPrototype() const { return is_function_prototype_; } |
| 1228 | 1268 |
| 1229 // Type feedback information. | 1269 // Type feedback information. |
| 1230 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1270 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1231 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1271 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1232 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1272 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 1233 virtual bool IsArrayLength() { return is_array_length_; } | 1273 virtual bool IsArrayLength() { return is_array_length_; } |
| 1234 virtual Handle<Map> GetMonomorphicReceiverType() { | |
| 1235 return monomorphic_receiver_type_; | |
| 1236 } | |
| 1237 | 1274 |
| 1238 private: | 1275 private: |
| 1239 Expression* obj_; | 1276 Expression* obj_; |
| 1240 Expression* key_; | 1277 Expression* key_; |
| 1241 int pos_; | 1278 int pos_; |
| 1242 Type type_; | 1279 Type type_; |
| 1243 | 1280 |
| 1244 ZoneMapList* receiver_types_; | 1281 SmallMapList receiver_types_; |
| 1245 bool is_monomorphic_ : 1; | 1282 bool is_monomorphic_ : 1; |
| 1246 bool is_array_length_ : 1; | 1283 bool is_array_length_ : 1; |
| 1247 bool is_string_length_ : 1; | 1284 bool is_string_length_ : 1; |
| 1248 bool is_string_access_ : 1; | 1285 bool is_string_access_ : 1; |
| 1249 bool is_function_prototype_ : 1; | 1286 bool is_function_prototype_ : 1; |
| 1250 Handle<Map> monomorphic_receiver_type_; | |
| 1251 }; | 1287 }; |
| 1252 | 1288 |
| 1253 | 1289 |
| 1254 class Call: public Expression { | 1290 class Call: public Expression { |
| 1255 public: | 1291 public: |
| 1256 Call(Isolate* isolate, | 1292 Call(Isolate* isolate, |
| 1257 Expression* expression, | 1293 Expression* expression, |
| 1258 ZoneList<Expression*>* arguments, | 1294 ZoneList<Expression*>* arguments, |
| 1259 int pos) | 1295 int pos) |
| 1260 : Expression(isolate), | 1296 : Expression(isolate), |
| 1261 expression_(expression), | 1297 expression_(expression), |
| 1262 arguments_(arguments), | 1298 arguments_(arguments), |
| 1263 pos_(pos), | 1299 pos_(pos), |
| 1264 is_monomorphic_(false), | 1300 is_monomorphic_(false), |
| 1265 check_type_(RECEIVER_MAP_CHECK), | 1301 check_type_(RECEIVER_MAP_CHECK), |
| 1266 receiver_types_(NULL), | |
| 1267 return_id_(GetNextId(isolate)) { | 1302 return_id_(GetNextId(isolate)) { |
| 1268 } | 1303 } |
| 1269 | 1304 |
| 1270 DECLARE_NODE_TYPE(Call) | 1305 DECLARE_NODE_TYPE(Call) |
| 1271 | 1306 |
| 1272 virtual bool IsInlineable() const; | 1307 virtual bool IsInlineable() const; |
| 1273 | 1308 |
| 1274 Expression* expression() const { return expression_; } | 1309 Expression* expression() const { return expression_; } |
| 1275 ZoneList<Expression*>* arguments() const { return arguments_; } | 1310 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1276 virtual int position() const { return pos_; } | 1311 virtual int position() const { return pos_; } |
| 1277 | 1312 |
| 1278 void RecordTypeFeedback(TypeFeedbackOracle* oracle, | 1313 void RecordTypeFeedback(TypeFeedbackOracle* oracle, |
| 1279 CallKind call_kind); | 1314 CallKind call_kind); |
| 1280 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1315 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 1281 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1316 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1282 CheckType check_type() const { return check_type_; } | 1317 CheckType check_type() const { return check_type_; } |
| 1283 Handle<JSFunction> target() { return target_; } | 1318 Handle<JSFunction> target() { return target_; } |
| 1284 Handle<JSObject> holder() { return holder_; } | 1319 Handle<JSObject> holder() { return holder_; } |
| 1285 Handle<JSGlobalPropertyCell> cell() { return cell_; } | 1320 Handle<JSGlobalPropertyCell> cell() { return cell_; } |
| 1286 | 1321 |
| 1287 bool ComputeTarget(Handle<Map> type, Handle<String> name); | 1322 bool ComputeTarget(Handle<Map> type, Handle<String> name); |
| 1288 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup); | 1323 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup); |
| 1289 | 1324 |
| 1290 // Bailout support. | 1325 // Bailout support. |
| 1291 int ReturnId() const { return return_id_; } | 1326 int ReturnId() const { return return_id_; } |
| 1292 | 1327 |
| 1293 #ifdef DEBUG | 1328 #ifdef DEBUG |
| 1294 // Used to assert that the FullCodeGenerator records the return site. | 1329 // Used to assert that the FullCodeGenerator records the return site. |
| 1295 bool return_is_recorded_; | 1330 bool return_is_recorded_; |
| 1296 #endif | 1331 #endif |
| 1297 | 1332 |
| 1298 private: | 1333 private: |
| 1299 Expression* expression_; | 1334 Expression* expression_; |
| 1300 ZoneList<Expression*>* arguments_; | 1335 ZoneList<Expression*>* arguments_; |
| 1301 int pos_; | 1336 int pos_; |
| 1302 | 1337 |
| 1303 bool is_monomorphic_; | 1338 bool is_monomorphic_; |
| 1304 CheckType check_type_; | 1339 CheckType check_type_; |
| 1305 ZoneMapList* receiver_types_; | 1340 SmallMapList receiver_types_; |
| 1306 Handle<JSFunction> target_; | 1341 Handle<JSFunction> target_; |
| 1307 Handle<JSObject> holder_; | 1342 Handle<JSObject> holder_; |
| 1308 Handle<JSGlobalPropertyCell> cell_; | 1343 Handle<JSGlobalPropertyCell> cell_; |
| 1309 | 1344 |
| 1310 int return_id_; | 1345 int return_id_; |
| 1311 }; | 1346 }; |
| 1312 | 1347 |
| 1313 | 1348 |
| 1314 class AstSentinels { | 1349 class AstSentinels { |
| 1315 public: | 1350 public: |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 Token::Value op, | 1505 Token::Value op, |
| 1471 bool is_prefix, | 1506 bool is_prefix, |
| 1472 Expression* expr, | 1507 Expression* expr, |
| 1473 int pos) | 1508 int pos) |
| 1474 : Expression(isolate), | 1509 : Expression(isolate), |
| 1475 op_(op), | 1510 op_(op), |
| 1476 is_prefix_(is_prefix), | 1511 is_prefix_(is_prefix), |
| 1477 expression_(expr), | 1512 expression_(expr), |
| 1478 pos_(pos), | 1513 pos_(pos), |
| 1479 assignment_id_(GetNextId(isolate)), | 1514 assignment_id_(GetNextId(isolate)), |
| 1480 count_id_(GetNextId(isolate)), | 1515 count_id_(GetNextId(isolate)) {} |
| 1481 receiver_types_(NULL) { } | |
| 1482 | 1516 |
| 1483 DECLARE_NODE_TYPE(CountOperation) | 1517 DECLARE_NODE_TYPE(CountOperation) |
| 1484 | 1518 |
| 1485 bool is_prefix() const { return is_prefix_; } | 1519 bool is_prefix() const { return is_prefix_; } |
| 1486 bool is_postfix() const { return !is_prefix_; } | 1520 bool is_postfix() const { return !is_prefix_; } |
| 1487 | 1521 |
| 1488 Token::Value op() const { return op_; } | 1522 Token::Value op() const { return op_; } |
| 1489 Token::Value binary_op() { | 1523 Token::Value binary_op() { |
| 1490 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 1524 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
| 1491 } | 1525 } |
| 1492 | 1526 |
| 1493 Expression* expression() const { return expression_; } | 1527 Expression* expression() const { return expression_; } |
| 1494 virtual int position() const { return pos_; } | 1528 virtual int position() const { return pos_; } |
| 1495 | 1529 |
| 1496 virtual void MarkAsStatement() { is_prefix_ = true; } | 1530 virtual void MarkAsStatement() { is_prefix_ = true; } |
| 1497 | 1531 |
| 1498 virtual bool IsInlineable() const; | 1532 virtual bool IsInlineable() const; |
| 1499 | 1533 |
| 1500 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1534 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1501 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1535 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1502 virtual Handle<Map> GetMonomorphicReceiverType() { | 1536 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 1503 return monomorphic_receiver_type_; | |
| 1504 } | |
| 1505 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | |
| 1506 | 1537 |
| 1507 // Bailout support. | 1538 // Bailout support. |
| 1508 int AssignmentId() const { return assignment_id_; } | 1539 int AssignmentId() const { return assignment_id_; } |
| 1509 int CountId() const { return count_id_; } | 1540 int CountId() const { return count_id_; } |
| 1510 | 1541 |
| 1511 private: | 1542 private: |
| 1512 Token::Value op_; | 1543 Token::Value op_; |
| 1513 bool is_prefix_; | 1544 bool is_prefix_; |
| 1514 bool is_monomorphic_; | 1545 bool is_monomorphic_; |
| 1515 Expression* expression_; | 1546 Expression* expression_; |
| 1516 int pos_; | 1547 int pos_; |
| 1517 int assignment_id_; | 1548 int assignment_id_; |
| 1518 int count_id_; | 1549 int count_id_; |
| 1519 Handle<Map> monomorphic_receiver_type_; | 1550 SmallMapList receiver_types_; |
| 1520 ZoneMapList* receiver_types_; | |
| 1521 }; | 1551 }; |
| 1522 | 1552 |
| 1523 | 1553 |
| 1524 class CompareOperation: public Expression { | 1554 class CompareOperation: public Expression { |
| 1525 public: | 1555 public: |
| 1526 CompareOperation(Isolate* isolate, | 1556 CompareOperation(Isolate* isolate, |
| 1527 Token::Value op, | 1557 Token::Value op, |
| 1528 Expression* left, | 1558 Expression* left, |
| 1529 Expression* right, | 1559 Expression* right, |
| 1530 int pos) | 1560 int pos) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 // ending of these blocks to allow for optimizations of initialization | 1688 // ending of these blocks to allow for optimizations of initialization |
| 1659 // blocks. | 1689 // blocks. |
| 1660 bool starts_initialization_block() { return block_start_; } | 1690 bool starts_initialization_block() { return block_start_; } |
| 1661 bool ends_initialization_block() { return block_end_; } | 1691 bool ends_initialization_block() { return block_end_; } |
| 1662 void mark_block_start() { block_start_ = true; } | 1692 void mark_block_start() { block_start_ = true; } |
| 1663 void mark_block_end() { block_end_ = true; } | 1693 void mark_block_end() { block_end_ = true; } |
| 1664 | 1694 |
| 1665 // Type feedback information. | 1695 // Type feedback information. |
| 1666 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1696 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1667 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1697 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1668 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1698 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 1669 virtual Handle<Map> GetMonomorphicReceiverType() { | |
| 1670 return monomorphic_receiver_type_; | |
| 1671 } | |
| 1672 | 1699 |
| 1673 // Bailout support. | 1700 // Bailout support. |
| 1674 int CompoundLoadId() const { return compound_load_id_; } | 1701 int CompoundLoadId() const { return compound_load_id_; } |
| 1675 int AssignmentId() const { return assignment_id_; } | 1702 int AssignmentId() const { return assignment_id_; } |
| 1676 | 1703 |
| 1677 private: | 1704 private: |
| 1678 Token::Value op_; | 1705 Token::Value op_; |
| 1679 Expression* target_; | 1706 Expression* target_; |
| 1680 Expression* value_; | 1707 Expression* value_; |
| 1681 int pos_; | 1708 int pos_; |
| 1682 BinaryOperation* binary_operation_; | 1709 BinaryOperation* binary_operation_; |
| 1683 int compound_load_id_; | 1710 int compound_load_id_; |
| 1684 int assignment_id_; | 1711 int assignment_id_; |
| 1685 | 1712 |
| 1686 bool block_start_; | 1713 bool block_start_; |
| 1687 bool block_end_; | 1714 bool block_end_; |
| 1688 | 1715 |
| 1689 bool is_monomorphic_; | 1716 bool is_monomorphic_; |
| 1690 ZoneMapList* receiver_types_; | 1717 SmallMapList receiver_types_; |
| 1691 Handle<Map> monomorphic_receiver_type_; | |
| 1692 }; | 1718 }; |
| 1693 | 1719 |
| 1694 | 1720 |
| 1695 class Throw: public Expression { | 1721 class Throw: public Expression { |
| 1696 public: | 1722 public: |
| 1697 Throw(Isolate* isolate, Expression* exception, int pos) | 1723 Throw(Isolate* isolate, Expression* exception, int pos) |
| 1698 : Expression(isolate), exception_(exception), pos_(pos) {} | 1724 : Expression(isolate), exception_(exception), pos_(pos) {} |
| 1699 | 1725 |
| 1700 DECLARE_NODE_TYPE(Throw) | 1726 DECLARE_NODE_TYPE(Throw) |
| 1701 | 1727 |
| 1702 Expression* exception() const { return exception_; } | 1728 Expression* exception() const { return exception_; } |
| 1703 virtual int position() const { return pos_; } | 1729 virtual int position() const { return pos_; } |
| 1704 virtual bool IsInlineable() const; | 1730 virtual bool IsInlineable() const; |
| 1705 | 1731 |
| 1706 private: | 1732 private: |
| 1707 Expression* exception_; | 1733 Expression* exception_; |
| 1708 int pos_; | 1734 int pos_; |
| 1709 }; | 1735 }; |
| 1710 | 1736 |
| 1711 | 1737 |
| 1712 class FunctionLiteral: public Expression { | 1738 class FunctionLiteral: public Expression { |
| 1713 public: | 1739 public: |
| 1740 enum Type { |
| 1741 ANONYMOUS_EXPRESSION, |
| 1742 NAMED_EXPRESSION, |
| 1743 DECLARATION |
| 1744 }; |
| 1745 |
| 1714 FunctionLiteral(Isolate* isolate, | 1746 FunctionLiteral(Isolate* isolate, |
| 1715 Handle<String> name, | 1747 Handle<String> name, |
| 1716 Scope* scope, | 1748 Scope* scope, |
| 1717 ZoneList<Statement*>* body, | 1749 ZoneList<Statement*>* body, |
| 1718 int materialized_literal_count, | 1750 int materialized_literal_count, |
| 1719 int expected_property_count, | 1751 int expected_property_count, |
| 1720 bool has_only_simple_this_property_assignments, | 1752 bool has_only_simple_this_property_assignments, |
| 1721 Handle<FixedArray> this_property_assignments, | 1753 Handle<FixedArray> this_property_assignments, |
| 1722 int num_parameters, | 1754 int num_parameters, |
| 1723 int start_position, | 1755 int start_position, |
| 1724 int end_position, | 1756 int end_position, |
| 1725 bool is_expression, | 1757 Type type, |
| 1726 bool has_duplicate_parameters) | 1758 bool has_duplicate_parameters) |
| 1727 : Expression(isolate), | 1759 : Expression(isolate), |
| 1728 name_(name), | 1760 name_(name), |
| 1729 scope_(scope), | 1761 scope_(scope), |
| 1730 body_(body), | 1762 body_(body), |
| 1731 materialized_literal_count_(materialized_literal_count), | 1763 materialized_literal_count_(materialized_literal_count), |
| 1732 expected_property_count_(expected_property_count), | 1764 expected_property_count_(expected_property_count), |
| 1733 has_only_simple_this_property_assignments_( | 1765 has_only_simple_this_property_assignments_( |
| 1734 has_only_simple_this_property_assignments), | 1766 has_only_simple_this_property_assignments), |
| 1735 this_property_assignments_(this_property_assignments), | 1767 this_property_assignments_(this_property_assignments), |
| 1736 num_parameters_(num_parameters), | 1768 num_parameters_(num_parameters), |
| 1737 start_position_(start_position), | 1769 start_position_(start_position), |
| 1738 end_position_(end_position), | 1770 end_position_(end_position), |
| 1739 function_token_position_(RelocInfo::kNoPosition), | 1771 function_token_position_(RelocInfo::kNoPosition), |
| 1740 inferred_name_(HEAP->empty_string()), | 1772 inferred_name_(HEAP->empty_string()), |
| 1741 is_expression_(is_expression), | 1773 is_expression_(type != DECLARATION), |
| 1774 is_anonymous_(type == ANONYMOUS_EXPRESSION), |
| 1742 pretenure_(false), | 1775 pretenure_(false), |
| 1743 has_duplicate_parameters_(has_duplicate_parameters) { | 1776 has_duplicate_parameters_(has_duplicate_parameters) { |
| 1744 } | 1777 } |
| 1745 | 1778 |
| 1746 DECLARE_NODE_TYPE(FunctionLiteral) | 1779 DECLARE_NODE_TYPE(FunctionLiteral) |
| 1747 | 1780 |
| 1748 Handle<String> name() const { return name_; } | 1781 Handle<String> name() const { return name_; } |
| 1749 Scope* scope() const { return scope_; } | 1782 Scope* scope() const { return scope_; } |
| 1750 ZoneList<Statement*>* body() const { return body_; } | 1783 ZoneList<Statement*>* body() const { return body_; } |
| 1751 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1784 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1752 int function_token_position() const { return function_token_position_; } | 1785 int function_token_position() const { return function_token_position_; } |
| 1753 int start_position() const { return start_position_; } | 1786 int start_position() const { return start_position_; } |
| 1754 int end_position() const { return end_position_; } | 1787 int end_position() const { return end_position_; } |
| 1755 bool is_expression() const { return is_expression_; } | 1788 bool is_expression() const { return is_expression_; } |
| 1789 bool is_anonymous() const { return is_anonymous_; } |
| 1756 bool strict_mode() const; | 1790 bool strict_mode() const; |
| 1757 | 1791 |
| 1758 int materialized_literal_count() { return materialized_literal_count_; } | 1792 int materialized_literal_count() { return materialized_literal_count_; } |
| 1759 int expected_property_count() { return expected_property_count_; } | 1793 int expected_property_count() { return expected_property_count_; } |
| 1760 bool has_only_simple_this_property_assignments() { | 1794 bool has_only_simple_this_property_assignments() { |
| 1761 return has_only_simple_this_property_assignments_; | 1795 return has_only_simple_this_property_assignments_; |
| 1762 } | 1796 } |
| 1763 Handle<FixedArray> this_property_assignments() { | 1797 Handle<FixedArray> this_property_assignments() { |
| 1764 return this_property_assignments_; | 1798 return this_property_assignments_; |
| 1765 } | 1799 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1790 int materialized_literal_count_; | 1824 int materialized_literal_count_; |
| 1791 int expected_property_count_; | 1825 int expected_property_count_; |
| 1792 bool has_only_simple_this_property_assignments_; | 1826 bool has_only_simple_this_property_assignments_; |
| 1793 Handle<FixedArray> this_property_assignments_; | 1827 Handle<FixedArray> this_property_assignments_; |
| 1794 int num_parameters_; | 1828 int num_parameters_; |
| 1795 int start_position_; | 1829 int start_position_; |
| 1796 int end_position_; | 1830 int end_position_; |
| 1797 int function_token_position_; | 1831 int function_token_position_; |
| 1798 Handle<String> inferred_name_; | 1832 Handle<String> inferred_name_; |
| 1799 bool is_expression_; | 1833 bool is_expression_; |
| 1834 bool is_anonymous_; |
| 1800 bool pretenure_; | 1835 bool pretenure_; |
| 1801 bool has_duplicate_parameters_; | 1836 bool has_duplicate_parameters_; |
| 1802 }; | 1837 }; |
| 1803 | 1838 |
| 1804 | 1839 |
| 1805 class SharedFunctionInfoLiteral: public Expression { | 1840 class SharedFunctionInfoLiteral: public Expression { |
| 1806 public: | 1841 public: |
| 1807 SharedFunctionInfoLiteral( | 1842 SharedFunctionInfoLiteral( |
| 1808 Isolate* isolate, | 1843 Isolate* isolate, |
| 1809 Handle<SharedFunctionInfo> shared_function_info) | 1844 Handle<SharedFunctionInfo> shared_function_info) |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2227 | 2262 |
| 2228 private: | 2263 private: |
| 2229 Isolate* isolate_; | 2264 Isolate* isolate_; |
| 2230 bool stack_overflow_; | 2265 bool stack_overflow_; |
| 2231 }; | 2266 }; |
| 2232 | 2267 |
| 2233 | 2268 |
| 2234 } } // namespace v8::internal | 2269 } } // namespace v8::internal |
| 2235 | 2270 |
| 2236 #endif // V8_AST_H_ | 2271 #endif // V8_AST_H_ |
| OLD | NEW |