Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: src/ast.h

Issue 110573004: Merge bleeding_edge 17696:18016. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 }; 1402 };
1403 1403
1404 1404
1405 // Base class for literals that needs space in the corresponding JSFunction. 1405 // Base class for literals that needs space in the corresponding JSFunction.
1406 class MaterializedLiteral : public Expression { 1406 class MaterializedLiteral : public Expression {
1407 public: 1407 public:
1408 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 1408 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1409 1409
1410 int literal_index() { return literal_index_; } 1410 int literal_index() { return literal_index_; }
1411 1411
1412 int depth() const {
1413 // only callable after initialization.
1414 ASSERT(depth_ >= 1);
1415 return depth_;
1416 }
1417
1412 protected: 1418 protected:
1413 MaterializedLiteral(Isolate* isolate, 1419 MaterializedLiteral(Isolate* isolate,
1414 int literal_index, 1420 int literal_index,
1415 int pos) 1421 int pos)
1416 : Expression(isolate, pos), 1422 : Expression(isolate, pos),
1417 literal_index_(literal_index), 1423 literal_index_(literal_index),
1418 is_simple_(false) {} 1424 is_simple_(false),
1425 depth_(0) {}
1419 1426
1420 // A materialized literal is simple if the values consist of only 1427 // A materialized literal is simple if the values consist of only
1421 // constants and simple object and array literals. 1428 // constants and simple object and array literals.
1422 bool is_simple() const { return is_simple_; } 1429 bool is_simple() const { return is_simple_; }
1423 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } 1430 void set_is_simple(bool is_simple) { is_simple_ = is_simple; }
1424 friend class CompileTimeValue; 1431 friend class CompileTimeValue;
1425 1432
1433 void set_depth(int depth) {
1434 ASSERT(depth >= 1);
1435 depth_ = depth;
1436 }
1437
1426 // Populate the constant properties/elements fixed array. 1438 // Populate the constant properties/elements fixed array.
1427 void BuildConstants(Isolate* isolate, int* depth); 1439 void BuildConstants(Isolate* isolate);
1428 friend class ArrayLiteral; 1440 friend class ArrayLiteral;
1429 friend class ObjectLiteral; 1441 friend class ObjectLiteral;
1430 1442
1431 // If the expression is a literal, return the literal value; 1443 // If the expression is a literal, return the literal value;
1432 // if the expression is a materialized literal and is simple return a 1444 // if the expression is a materialized literal and is simple return a
1433 // compile time value as encoded by CompileTimeValue::GetValue(). 1445 // compile time value as encoded by CompileTimeValue::GetValue().
1434 // Otherwise, return undefined literal as the placeholder 1446 // Otherwise, return undefined literal as the placeholder
1435 // in the object literal boilerplate. 1447 // in the object literal boilerplate.
1436 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); 1448 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate);
1437 1449
1438 private: 1450 private:
1439 int literal_index_; 1451 int literal_index_;
1440 bool is_simple_; 1452 bool is_simple_;
1453 int depth_;
1441 }; 1454 };
1442 1455
1443 1456
1444 // Property is used for passing information 1457 // Property is used for passing information
1445 // about an object literal's properties from the parser 1458 // about an object literal's properties from the parser
1446 // to the code generator. 1459 // to the code generator.
1447 class ObjectLiteralProperty V8_FINAL : public ZoneObject { 1460 class ObjectLiteralProperty V8_FINAL : public ZoneObject {
1448 public: 1461 public:
1449 enum Kind { 1462 enum Kind {
1450 CONSTANT, // Property with constant value (compile time). 1463 CONSTANT, // Property with constant value (compile time).
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 } 1511 }
1499 ZoneList<Property*>* properties() const { return properties_; } 1512 ZoneList<Property*>* properties() const { return properties_; }
1500 bool fast_elements() const { return fast_elements_; } 1513 bool fast_elements() const { return fast_elements_; }
1501 bool may_store_doubles() const { return may_store_doubles_; } 1514 bool may_store_doubles() const { return may_store_doubles_; }
1502 bool has_function() const { return has_function_; } 1515 bool has_function() const { return has_function_; }
1503 1516
1504 // Decide if a property should be in the object boilerplate. 1517 // Decide if a property should be in the object boilerplate.
1505 static bool IsBoilerplateProperty(Property* property); 1518 static bool IsBoilerplateProperty(Property* property);
1506 1519
1507 // Populate the constant properties fixed array. 1520 // Populate the constant properties fixed array.
1508 void BuildConstantProperties(Isolate* isolate, int* depth = NULL); 1521 void BuildConstantProperties(Isolate* isolate);
1509 1522
1510 // Mark all computed expressions that are bound to a key that 1523 // Mark all computed expressions that are bound to a key that
1511 // is shadowed by a later occurrence of the same key. For the 1524 // is shadowed by a later occurrence of the same key. For the
1512 // marked expressions, no store code is emitted. 1525 // marked expressions, no store code is emitted.
1513 void CalculateEmitStore(Zone* zone); 1526 void CalculateEmitStore(Zone* zone);
1514 1527
1515 enum Flags { 1528 enum Flags {
1516 kNoFlags = 0, 1529 kNoFlags = 0,
1517 kFastElements = 1, 1530 kFastElements = 1,
1518 kHasFunction = 1 << 1 1531 kHasFunction = 1 << 1
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 Handle<String> flags() const { return flags_; } 1570 Handle<String> flags() const { return flags_; }
1558 1571
1559 protected: 1572 protected:
1560 RegExpLiteral(Isolate* isolate, 1573 RegExpLiteral(Isolate* isolate,
1561 Handle<String> pattern, 1574 Handle<String> pattern,
1562 Handle<String> flags, 1575 Handle<String> flags,
1563 int literal_index, 1576 int literal_index,
1564 int pos) 1577 int pos)
1565 : MaterializedLiteral(isolate, literal_index, pos), 1578 : MaterializedLiteral(isolate, literal_index, pos),
1566 pattern_(pattern), 1579 pattern_(pattern),
1567 flags_(flags) {} 1580 flags_(flags) {
1581 set_depth(1);
1582 }
1568 1583
1569 private: 1584 private:
1570 Handle<String> pattern_; 1585 Handle<String> pattern_;
1571 Handle<String> flags_; 1586 Handle<String> flags_;
1572 }; 1587 };
1573 1588
1574 1589
1575 // An array literal has a literals object that is used 1590 // An array literal has a literals object that is used
1576 // for minimizing the work when constructing it at runtime. 1591 // for minimizing the work when constructing it at runtime.
1577 class ArrayLiteral V8_FINAL : public MaterializedLiteral { 1592 class ArrayLiteral V8_FINAL : public MaterializedLiteral {
1578 public: 1593 public:
1579 DECLARE_NODE_TYPE(ArrayLiteral) 1594 DECLARE_NODE_TYPE(ArrayLiteral)
1580 1595
1581 Handle<FixedArray> constant_elements() const { return constant_elements_; } 1596 Handle<FixedArray> constant_elements() const { return constant_elements_; }
1582 ZoneList<Expression*>* values() const { return values_; } 1597 ZoneList<Expression*>* values() const { return values_; }
1583 1598
1584 // Return an AST id for an element that is used in simulate instructions. 1599 // Return an AST id for an element that is used in simulate instructions.
1585 BailoutId GetIdForElement(int i) { 1600 BailoutId GetIdForElement(int i) {
1586 return BailoutId(first_element_id_.ToInt() + i); 1601 return BailoutId(first_element_id_.ToInt() + i);
1587 } 1602 }
1588 1603
1589 // Populate the constant elements fixed array. 1604 // Populate the constant elements fixed array.
1590 void BuildConstantElements(Isolate* isolate, int* depth = NULL); 1605 void BuildConstantElements(Isolate* isolate);
1591 1606
1592 protected: 1607 protected:
1593 ArrayLiteral(Isolate* isolate, 1608 ArrayLiteral(Isolate* isolate,
1594 ZoneList<Expression*>* values, 1609 ZoneList<Expression*>* values,
1595 int literal_index, 1610 int literal_index,
1596 int pos) 1611 int pos)
1597 : MaterializedLiteral(isolate, literal_index, pos), 1612 : MaterializedLiteral(isolate, literal_index, pos),
1598 values_(values), 1613 values_(values),
1599 first_element_id_(ReserveIdRange(isolate, values->length())) {} 1614 first_element_id_(ReserveIdRange(isolate, values->length())) {}
1600 1615
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 Expression* expression() const { return expression_; } 1736 Expression* expression() const { return expression_; }
1722 ZoneList<Expression*>* arguments() const { return arguments_; } 1737 ZoneList<Expression*>* arguments() const { return arguments_; }
1723 1738
1724 // Type feedback information. 1739 // Type feedback information.
1725 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } 1740 TypeFeedbackId CallFeedbackId() const { return reuse(id()); }
1726 void RecordTypeFeedback(TypeFeedbackOracle* oracle, CallKind call_kind); 1741 void RecordTypeFeedback(TypeFeedbackOracle* oracle, CallKind call_kind);
1727 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 1742 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
1728 return &receiver_types_; 1743 return &receiver_types_;
1729 } 1744 }
1730 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1745 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1746 bool KeyedArrayCallIsHoley() { return keyed_array_call_is_holey_; }
1731 CheckType check_type() const { return check_type_; } 1747 CheckType check_type() const { return check_type_; }
1732 1748
1733 void set_string_check(Handle<JSObject> holder) { 1749 void set_string_check(Handle<JSObject> holder) {
1734 holder_ = holder; 1750 holder_ = holder;
1735 check_type_ = STRING_CHECK; 1751 check_type_ = STRING_CHECK;
1736 } 1752 }
1737 1753
1738 void set_number_check(Handle<JSObject> holder) { 1754 void set_number_check(Handle<JSObject> holder) {
1739 holder_ = holder; 1755 holder_ = holder;
1740 check_type_ = NUMBER_CHECK; 1756 check_type_ = NUMBER_CHECK;
(...skipping 30 matching lines...) Expand all
1771 1787
1772 protected: 1788 protected:
1773 Call(Isolate* isolate, 1789 Call(Isolate* isolate,
1774 Expression* expression, 1790 Expression* expression,
1775 ZoneList<Expression*>* arguments, 1791 ZoneList<Expression*>* arguments,
1776 int pos) 1792 int pos)
1777 : Expression(isolate, pos), 1793 : Expression(isolate, pos),
1778 expression_(expression), 1794 expression_(expression),
1779 arguments_(arguments), 1795 arguments_(arguments),
1780 is_monomorphic_(false), 1796 is_monomorphic_(false),
1797 keyed_array_call_is_holey_(true),
1781 check_type_(RECEIVER_MAP_CHECK), 1798 check_type_(RECEIVER_MAP_CHECK),
1782 return_id_(GetNextId(isolate)) { } 1799 return_id_(GetNextId(isolate)) { }
1783 1800
1784 private: 1801 private:
1785 Expression* expression_; 1802 Expression* expression_;
1786 ZoneList<Expression*>* arguments_; 1803 ZoneList<Expression*>* arguments_;
1787 1804
1788 bool is_monomorphic_; 1805 bool is_monomorphic_;
1806 bool keyed_array_call_is_holey_;
1789 CheckType check_type_; 1807 CheckType check_type_;
1790 SmallMapList receiver_types_; 1808 SmallMapList receiver_types_;
1791 Handle<JSFunction> target_; 1809 Handle<JSFunction> target_;
1792 Handle<JSObject> holder_; 1810 Handle<JSObject> holder_;
1793 Handle<Cell> cell_; 1811 Handle<Cell> cell_;
1794 1812
1795 const BailoutId return_id_; 1813 const BailoutId return_id_;
1796 }; 1814 };
1797 1815
1798 1816
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 private: 3285 private:
3268 Isolate* isolate_; 3286 Isolate* isolate_;
3269 Zone* zone_; 3287 Zone* zone_;
3270 Visitor visitor_; 3288 Visitor visitor_;
3271 }; 3289 };
3272 3290
3273 3291
3274 } } // namespace v8::internal 3292 } } // namespace v8::internal
3275 3293
3276 #endif // V8_AST_H_ 3294 #endif // V8_AST_H_
OLDNEW
« include/v8-platform.h ('K') | « src/assembler.cc ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698