OLD | NEW |
---|---|
1 // Copyright 2010 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 // Evaluated for its side effects. | 215 // Evaluated for its side effects. |
216 kEffect, | 216 kEffect, |
217 // Evaluated for its value (and side effects). | 217 // Evaluated for its value (and side effects). |
218 kValue, | 218 kValue, |
219 // Evaluated for control flow (and side effects). | 219 // Evaluated for control flow (and side effects). |
220 kTest | 220 kTest |
221 }; | 221 }; |
222 | 222 |
223 Expression() : bitfields_(0) {} | 223 Expression() : bitfields_(0) {} |
224 | 224 |
225 virtual int position() const { | |
226 UNREACHABLE(); | |
227 return 0; | |
228 } | |
229 | |
225 virtual Expression* AsExpression() { return this; } | 230 virtual Expression* AsExpression() { return this; } |
226 | 231 |
227 virtual bool IsTrivial() { return false; } | 232 virtual bool IsTrivial() { return false; } |
228 virtual bool IsValidLeftHandSide() { return false; } | 233 virtual bool IsValidLeftHandSide() { return false; } |
229 | 234 |
230 // Helpers for ToBoolean conversion. | 235 // Helpers for ToBoolean conversion. |
231 virtual bool ToBooleanIsTrue() { return false; } | 236 virtual bool ToBooleanIsTrue() { return false; } |
232 virtual bool ToBooleanIsFalse() { return false; } | 237 virtual bool ToBooleanIsFalse() { return false; } |
233 | 238 |
234 // Symbols that cannot be parsed as array indices are considered property | 239 // Symbols that cannot be parsed as array indices are considered property |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 } | 316 } |
312 | 317 |
313 // How many bitwise logical or shift operators are used in this expression? | 318 // How many bitwise logical or shift operators are used in this expression? |
314 int num_bit_ops() { return NumBitOpsField::decode(bitfields_); } | 319 int num_bit_ops() { return NumBitOpsField::decode(bitfields_); } |
315 void set_num_bit_ops(int num_bit_ops) { | 320 void set_num_bit_ops(int num_bit_ops) { |
316 bitfields_ &= ~NumBitOpsField::mask(); | 321 bitfields_ &= ~NumBitOpsField::mask(); |
317 num_bit_ops = Min(num_bit_ops, kMaxNumBitOps); | 322 num_bit_ops = Min(num_bit_ops, kMaxNumBitOps); |
318 bitfields_ |= NumBitOpsField::encode(num_bit_ops); | 323 bitfields_ |= NumBitOpsField::encode(num_bit_ops); |
319 } | 324 } |
320 | 325 |
326 ExternalArrayType external_array_type() const { | |
327 return ExternalArrayTypeField::decode(bitfields_); | |
328 } | |
329 void set_external_array_type(ExternalArrayType array_type) { | |
330 bitfields_ &= ~ExternalArrayTypeField::mask(); | |
331 bitfields_ |= ExternalArrayTypeField::encode(array_type); | |
332 } | |
333 | |
321 private: | 334 private: |
322 static const int kMaxNumBitOps = (1 << 5) - 1; | 335 static const int kMaxNumBitOps = (1 << 5) - 1; |
323 | 336 |
324 uint32_t bitfields_; | 337 uint32_t bitfields_; |
325 StaticType type_; | 338 StaticType type_; |
326 | 339 |
327 // Using template BitField<type, start, size>. | 340 // Using template BitField<type, start, size>. |
328 class SideEffectFreeField : public BitField<bool, 0, 1> {}; | 341 class SideEffectFreeField : public BitField<bool, 0, 1> {}; |
329 class NoNegativeZeroField : public BitField<bool, 1, 1> {}; | 342 class NoNegativeZeroField : public BitField<bool, 1, 1> {}; |
330 class ToInt32Field : public BitField<bool, 2, 1> {}; | 343 class ToInt32Field : public BitField<bool, 2, 1> {}; |
331 class NumBitOpsField : public BitField<int, 3, 5> {}; | 344 class NumBitOpsField : public BitField<int, 3, 5> {}; |
332 class LoopConditionField: public BitField<bool, 8, 1> {}; | 345 class LoopConditionField: public BitField<bool, 8, 1> {}; |
346 class ExternalArrayTypeField: public BitField<ExternalArrayType, 9, 4> {}; | |
333 }; | 347 }; |
334 | 348 |
335 | 349 |
336 /** | 350 /** |
337 * A sentinel used during pre parsing that represents some expression | 351 * A sentinel used during pre parsing that represents some expression |
338 * that is a valid left hand side without having to actually build | 352 * that is a valid left hand side without having to actually build |
339 * the expression. | 353 * the expression. |
340 */ | 354 */ |
341 class ValidLeftHandSideSentinel: public Expression { | 355 class ValidLeftHandSideSentinel: public Expression { |
342 public: | 356 public: |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); | 703 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); |
690 | 704 |
691 bool is_default() const { return label_ == NULL; } | 705 bool is_default() const { return label_ == NULL; } |
692 Expression* label() const { | 706 Expression* label() const { |
693 CHECK(!is_default()); | 707 CHECK(!is_default()); |
694 return label_; | 708 return label_; |
695 } | 709 } |
696 JumpTarget* body_target() { return &body_target_; } | 710 JumpTarget* body_target() { return &body_target_; } |
697 ZoneList<Statement*>* statements() const { return statements_; } | 711 ZoneList<Statement*>* statements() const { return statements_; } |
698 | 712 |
699 int position() { return position_; } | 713 int position() const { return position_; } |
Mads Ager (chromium)
2011/04/06 16:45:15
Repeat the virtual keyword all the way down for vi
| |
700 void set_position(int pos) { position_ = pos; } | 714 void set_position(int pos) { position_ = pos; } |
701 | 715 |
702 int EntryId() { return entry_id_; } | 716 int EntryId() { return entry_id_; } |
703 | 717 |
704 // Type feedback information. | 718 // Type feedback information. |
705 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 719 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
706 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } | 720 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } |
707 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } | 721 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } |
708 | 722 |
709 private: | 723 private: |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1248 bool IsStringAccess() const { return is_string_access_; } | 1262 bool IsStringAccess() const { return is_string_access_; } |
1249 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1263 bool IsFunctionPrototype() const { return is_function_prototype_; } |
1250 | 1264 |
1251 // Marks that this is actually an argument rewritten to a keyed property | 1265 // Marks that this is actually an argument rewritten to a keyed property |
1252 // accessing the argument through the arguments shadow object. | 1266 // accessing the argument through the arguments shadow object. |
1253 void set_is_arguments_access(bool is_arguments_access) { | 1267 void set_is_arguments_access(bool is_arguments_access) { |
1254 is_arguments_access_ = is_arguments_access; | 1268 is_arguments_access_ = is_arguments_access; |
1255 } | 1269 } |
1256 bool is_arguments_access() const { return is_arguments_access_; } | 1270 bool is_arguments_access() const { return is_arguments_access_; } |
1257 | 1271 |
1258 ExternalArrayType GetExternalArrayType() const { return array_type_; } | |
1259 void SetExternalArrayType(ExternalArrayType array_type) { | |
1260 array_type_ = array_type; | |
1261 } | |
1262 | |
1263 // Type feedback information. | 1272 // Type feedback information. |
1264 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1273 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1265 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1274 virtual bool IsMonomorphic() { return is_monomorphic_; } |
1266 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1275 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
1267 virtual bool IsArrayLength() { return is_array_length_; } | 1276 virtual bool IsArrayLength() { return is_array_length_; } |
1268 virtual Handle<Map> GetMonomorphicReceiverType() { | 1277 virtual Handle<Map> GetMonomorphicReceiverType() { |
1269 return monomorphic_receiver_type_; | 1278 return monomorphic_receiver_type_; |
1270 } | 1279 } |
1271 | 1280 |
1272 private: | 1281 private: |
1273 Expression* obj_; | 1282 Expression* obj_; |
1274 Expression* key_; | 1283 Expression* key_; |
1275 int pos_; | 1284 int pos_; |
1276 Type type_; | 1285 Type type_; |
1277 | 1286 |
1278 ZoneMapList* receiver_types_; | 1287 ZoneMapList* receiver_types_; |
1279 bool is_monomorphic_ : 1; | 1288 bool is_monomorphic_ : 1; |
1280 bool is_array_length_ : 1; | 1289 bool is_array_length_ : 1; |
1281 bool is_string_length_ : 1; | 1290 bool is_string_length_ : 1; |
1282 bool is_string_access_ : 1; | 1291 bool is_string_access_ : 1; |
1283 bool is_function_prototype_ : 1; | 1292 bool is_function_prototype_ : 1; |
1284 bool is_arguments_access_ : 1; | 1293 bool is_arguments_access_ : 1; |
1285 Handle<Map> monomorphic_receiver_type_; | 1294 Handle<Map> monomorphic_receiver_type_; |
1286 ExternalArrayType array_type_; | |
1287 }; | 1295 }; |
1288 | 1296 |
1289 | 1297 |
1290 class Call: public Expression { | 1298 class Call: public Expression { |
1291 public: | 1299 public: |
1292 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1300 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
1293 : expression_(expression), | 1301 : expression_(expression), |
1294 arguments_(arguments), | 1302 arguments_(arguments), |
1295 pos_(pos), | 1303 pos_(pos), |
1296 is_monomorphic_(false), | 1304 is_monomorphic_(false), |
1297 check_type_(RECEIVER_MAP_CHECK), | 1305 check_type_(RECEIVER_MAP_CHECK), |
1298 receiver_types_(NULL), | 1306 receiver_types_(NULL), |
1299 return_id_(GetNextId()) { | 1307 return_id_(GetNextId()) { |
1300 } | 1308 } |
1301 | 1309 |
1302 DECLARE_NODE_TYPE(Call) | 1310 DECLARE_NODE_TYPE(Call) |
1303 | 1311 |
1304 virtual bool IsInlineable() const; | 1312 virtual bool IsInlineable() const; |
1305 | 1313 |
1306 Expression* expression() const { return expression_; } | 1314 Expression* expression() const { return expression_; } |
1307 ZoneList<Expression*>* arguments() const { return arguments_; } | 1315 ZoneList<Expression*>* arguments() const { return arguments_; } |
1308 int position() { return pos_; } | 1316 int position() const { return pos_; } |
1309 | 1317 |
1310 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1318 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1311 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1319 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
1312 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1320 virtual bool IsMonomorphic() { return is_monomorphic_; } |
1313 CheckType check_type() const { return check_type_; } | 1321 CheckType check_type() const { return check_type_; } |
1314 Handle<JSFunction> target() { return target_; } | 1322 Handle<JSFunction> target() { return target_; } |
1315 Handle<JSObject> holder() { return holder_; } | 1323 Handle<JSObject> holder() { return holder_; } |
1316 Handle<JSGlobalPropertyCell> cell() { return cell_; } | 1324 Handle<JSGlobalPropertyCell> cell() { return cell_; } |
1317 | 1325 |
1318 bool ComputeTarget(Handle<Map> type, Handle<String> name); | 1326 bool ComputeTarget(Handle<Map> type, Handle<String> name); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1376 public: | 1384 public: |
1377 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1385 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
1378 : expression_(expression), arguments_(arguments), pos_(pos) { } | 1386 : expression_(expression), arguments_(arguments), pos_(pos) { } |
1379 | 1387 |
1380 DECLARE_NODE_TYPE(CallNew) | 1388 DECLARE_NODE_TYPE(CallNew) |
1381 | 1389 |
1382 virtual bool IsInlineable() const; | 1390 virtual bool IsInlineable() const; |
1383 | 1391 |
1384 Expression* expression() const { return expression_; } | 1392 Expression* expression() const { return expression_; } |
1385 ZoneList<Expression*>* arguments() const { return arguments_; } | 1393 ZoneList<Expression*>* arguments() const { return arguments_; } |
1386 int position() { return pos_; } | 1394 int position() const { return pos_; } |
1387 | 1395 |
1388 private: | 1396 private: |
1389 Expression* expression_; | 1397 Expression* expression_; |
1390 ZoneList<Expression*>* arguments_; | 1398 ZoneList<Expression*>* arguments_; |
1391 int pos_; | 1399 int pos_; |
1392 }; | 1400 }; |
1393 | 1401 |
1394 | 1402 |
1395 // The CallRuntime class does not represent any official JavaScript | 1403 // The CallRuntime class does not represent any official JavaScript |
1396 // language construct. Instead it is used to call a C or JS function | 1404 // language construct. Instead it is used to call a C or JS function |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1520 } | 1528 } |
1521 | 1529 |
1522 Expression* expression() const { return increment_->expression(); } | 1530 Expression* expression() const { return increment_->expression(); } |
1523 IncrementOperation* increment() const { return increment_; } | 1531 IncrementOperation* increment() const { return increment_; } |
1524 int position() const { return pos_; } | 1532 int position() const { return pos_; } |
1525 | 1533 |
1526 virtual void MarkAsStatement() { is_prefix_ = true; } | 1534 virtual void MarkAsStatement() { is_prefix_ = true; } |
1527 | 1535 |
1528 virtual bool IsInlineable() const; | 1536 virtual bool IsInlineable() const; |
1529 | 1537 |
1538 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | |
1539 virtual bool IsMonomorphic() { return is_monomorphic_; } | |
1540 virtual Handle<Map> GetMonomorphicReceiverType() { | |
1541 return monomorphic_receiver_type_; | |
1542 } | |
1543 | |
1530 // Bailout support. | 1544 // Bailout support. |
1531 int AssignmentId() const { return assignment_id_; } | 1545 int AssignmentId() const { return assignment_id_; } |
1532 | 1546 |
1533 private: | 1547 private: |
1534 bool is_prefix_; | 1548 bool is_prefix_; |
1549 bool is_monomorphic_; | |
1535 IncrementOperation* increment_; | 1550 IncrementOperation* increment_; |
1536 int pos_; | 1551 int pos_; |
1537 int assignment_id_; | 1552 int assignment_id_; |
1553 Handle<Map> monomorphic_receiver_type_; | |
1538 }; | 1554 }; |
1539 | 1555 |
1540 | 1556 |
1541 class CompareOperation: public Expression { | 1557 class CompareOperation: public Expression { |
1542 public: | 1558 public: |
1543 CompareOperation(Token::Value op, | 1559 CompareOperation(Token::Value op, |
1544 Expression* left, | 1560 Expression* left, |
1545 Expression* right, | 1561 Expression* right, |
1546 int pos) | 1562 int pos) |
1547 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { | 1563 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1641 | 1657 |
1642 virtual bool IsInlineable() const; | 1658 virtual bool IsInlineable() const; |
1643 | 1659 |
1644 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 1660 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
1645 | 1661 |
1646 Token::Value binary_op() const; | 1662 Token::Value binary_op() const; |
1647 | 1663 |
1648 Token::Value op() const { return op_; } | 1664 Token::Value op() const { return op_; } |
1649 Expression* target() const { return target_; } | 1665 Expression* target() const { return target_; } |
1650 Expression* value() const { return value_; } | 1666 Expression* value() const { return value_; } |
1651 int position() { return pos_; } | 1667 int position() const { return pos_; } |
1652 BinaryOperation* binary_operation() const { return binary_operation_; } | 1668 BinaryOperation* binary_operation() const { return binary_operation_; } |
1653 | 1669 |
1654 // This check relies on the definition order of token in token.h. | 1670 // This check relies on the definition order of token in token.h. |
1655 bool is_compound() const { return op() > Token::ASSIGN; } | 1671 bool is_compound() const { return op() > Token::ASSIGN; } |
1656 | 1672 |
1657 // An initialization block is a series of statments of the form | 1673 // An initialization block is a series of statments of the form |
1658 // x.y.z.a = ...; x.y.z.b = ...; etc. The parser marks the beginning and | 1674 // x.y.z.a = ...; x.y.z.b = ...; etc. The parser marks the beginning and |
1659 // ending of these blocks to allow for optimizations of initialization | 1675 // ending of these blocks to allow for optimizations of initialization |
1660 // blocks. | 1676 // blocks. |
1661 bool starts_initialization_block() { return block_start_; } | 1677 bool starts_initialization_block() { return block_start_; } |
1662 bool ends_initialization_block() { return block_end_; } | 1678 bool ends_initialization_block() { return block_end_; } |
1663 void mark_block_start() { block_start_ = true; } | 1679 void mark_block_start() { block_start_ = true; } |
1664 void mark_block_end() { block_end_ = true; } | 1680 void mark_block_end() { block_end_ = true; } |
1665 | 1681 |
1666 // Type feedback information. | 1682 // Type feedback information. |
1667 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1683 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1668 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1684 virtual bool IsMonomorphic() { return is_monomorphic_; } |
1669 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1685 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
1670 virtual Handle<Map> GetMonomorphicReceiverType() { | 1686 virtual Handle<Map> GetMonomorphicReceiverType() { |
1671 return monomorphic_receiver_type_; | 1687 return monomorphic_receiver_type_; |
1672 } | 1688 } |
1673 ExternalArrayType GetExternalArrayType() const { return array_type_; } | |
1674 void SetExternalArrayType(ExternalArrayType array_type) { | |
1675 array_type_ = array_type; | |
1676 } | |
1677 | 1689 |
1678 // Bailout support. | 1690 // Bailout support. |
1679 int CompoundLoadId() const { return compound_load_id_; } | 1691 int CompoundLoadId() const { return compound_load_id_; } |
1680 int AssignmentId() const { return assignment_id_; } | 1692 int AssignmentId() const { return assignment_id_; } |
1681 | 1693 |
1682 private: | 1694 private: |
1683 Token::Value op_; | 1695 Token::Value op_; |
1684 Expression* target_; | 1696 Expression* target_; |
1685 Expression* value_; | 1697 Expression* value_; |
1686 int pos_; | 1698 int pos_; |
1687 BinaryOperation* binary_operation_; | 1699 BinaryOperation* binary_operation_; |
1688 int compound_load_id_; | 1700 int compound_load_id_; |
1689 int assignment_id_; | 1701 int assignment_id_; |
1690 | 1702 |
1691 bool block_start_; | 1703 bool block_start_; |
1692 bool block_end_; | 1704 bool block_end_; |
1693 | 1705 |
1694 bool is_monomorphic_; | 1706 bool is_monomorphic_; |
1695 ZoneMapList* receiver_types_; | 1707 ZoneMapList* receiver_types_; |
1696 Handle<Map> monomorphic_receiver_type_; | 1708 Handle<Map> monomorphic_receiver_type_; |
1697 ExternalArrayType array_type_; | |
1698 }; | 1709 }; |
1699 | 1710 |
1700 | 1711 |
1701 class Throw: public Expression { | 1712 class Throw: public Expression { |
1702 public: | 1713 public: |
1703 Throw(Expression* exception, int pos) | 1714 Throw(Expression* exception, int pos) |
1704 : exception_(exception), pos_(pos) {} | 1715 : exception_(exception), pos_(pos) {} |
1705 | 1716 |
1706 DECLARE_NODE_TYPE(Throw) | 1717 DECLARE_NODE_TYPE(Throw) |
1707 | 1718 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2225 | 2236 |
2226 private: | 2237 private: |
2227 Isolate* isolate_; | 2238 Isolate* isolate_; |
2228 bool stack_overflow_; | 2239 bool stack_overflow_; |
2229 }; | 2240 }; |
2230 | 2241 |
2231 | 2242 |
2232 } } // namespace v8::internal | 2243 } } // namespace v8::internal |
2233 | 2244 |
2234 #endif // V8_AST_H_ | 2245 #endif // V8_AST_H_ |
OLD | NEW |