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

Side by Side Diff: src/ast/ast.h

Issue 1841543003: [esnext] implement frontend changes for async/await proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix more problems Created 4 years, 7 months 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
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | src/globals.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 DCHECK(!BailoutId(base_id_).IsNone()); 385 DCHECK(!BailoutId(base_id_).IsNone());
386 return base_id_; 386 return base_id_;
387 } 387 }
388 388
389 private: 389 private:
390 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 390 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
391 391
392 int base_id_; 392 int base_id_;
393 Bounds bounds_; 393 Bounds bounds_;
394 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; 394 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {};
395
396 protected:
397 static const int kExpressionBitFieldNext = ToBooleanTypesField::kNext;
395 uint16_t bit_field_; 398 uint16_t bit_field_;
396 // Ends with 16-bit field; deriving classes in turn begin with 399 // Ends with 16-bit field; deriving classes in turn begin with
397 // 16-bit fields for optimum packing efficiency. 400 // 16-bit fields for optimum packing efficiency.
398 }; 401 };
399 402
400 403
401 class BreakableStatement : public Statement { 404 class BreakableStatement : public Statement {
402 public: 405 public:
403 enum BreakableType { 406 enum BreakableType {
404 TARGET_FOR_ANONYMOUS, 407 TARGET_FOR_ANONYMOUS,
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 1421
1419 // Type feedback information. 1422 // Type feedback information.
1420 bool IsMonomorphic() { return !receiver_type_.is_null(); } 1423 bool IsMonomorphic() { return !receiver_type_.is_null(); }
1421 Handle<Map> GetReceiverType() { return receiver_type_; } 1424 Handle<Map> GetReceiverType() { return receiver_type_; }
1422 1425
1423 bool IsCompileTimeValue(); 1426 bool IsCompileTimeValue();
1424 1427
1425 void set_emit_store(bool emit_store); 1428 void set_emit_store(bool emit_store);
1426 bool emit_store(); 1429 bool emit_store();
1427 1430
1428 bool is_static() const { return is_static_; } 1431 bool is_static() const { return IsStaticMethod(method_kind_); }
1429 bool is_computed_name() const { return is_computed_name_; } 1432 bool is_computed_name() const { return is_computed_name_; }
1430 1433
1431 FeedbackVectorSlot GetSlot(int offset = 0) const { 1434 FeedbackVectorSlot GetSlot(int offset = 0) const {
1432 DCHECK_LT(offset, static_cast<int>(arraysize(slots_))); 1435 DCHECK_LT(offset, static_cast<int>(arraysize(slots_)));
1433 return slots_[offset]; 1436 return slots_[offset];
1434 } 1437 }
1435 void SetSlot(FeedbackVectorSlot slot, int offset = 0) { 1438 void SetSlot(FeedbackVectorSlot slot, int offset = 0) {
1436 DCHECK_LT(offset, static_cast<int>(arraysize(slots_))); 1439 DCHECK_LT(offset, static_cast<int>(arraysize(slots_)));
1437 slots_[offset] = slot; 1440 slots_[offset] = slot;
1438 } 1441 }
1439 1442
1440 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } 1443 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; }
1441 1444
1442 bool NeedsSetFunctionName() const; 1445 bool NeedsSetFunctionName() const;
1443 1446
1444 protected: 1447 protected:
1445 friend class AstNodeFactory; 1448 friend class AstNodeFactory;
1446 1449
1447 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind, 1450 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind,
1448 bool is_static, bool is_computed_name); 1451 MethodKind method_kind, bool is_computed_name);
1449 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key, 1452 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key,
1450 Expression* value, bool is_static, 1453 Expression* value, MethodKind method_kind,
1451 bool is_computed_name); 1454 bool is_computed_name);
1452 1455
1453 private: 1456 private:
1454 Expression* key_; 1457 Expression* key_;
1455 Expression* value_; 1458 Expression* value_;
1456 FeedbackVectorSlot slots_[2]; 1459 FeedbackVectorSlot slots_[2];
1457 Kind kind_; 1460 Kind kind_;
1461 MethodKind method_kind_;
1458 bool emit_store_; 1462 bool emit_store_;
1459 bool is_static_;
1460 bool is_computed_name_; 1463 bool is_computed_name_;
1461 Handle<Map> receiver_type_; 1464 Handle<Map> receiver_type_;
1462 }; 1465 };
1463 1466
1464 1467
1465 // An object literal has a boilerplate object that is used 1468 // An object literal has a boilerplate object that is used
1466 // for minimizing the work when constructing it at runtime. 1469 // for minimizing the work when constructing it at runtime.
1467 class ObjectLiteral final : public MaterializedLiteral { 1470 class ObjectLiteral final : public MaterializedLiteral {
1468 public: 1471 public:
1469 typedef ObjectLiteralProperty Property; 1472 typedef ObjectLiteralProperty Property;
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 Handle<String> name() const { return raw_name_->string(); } 2595 Handle<String> name() const { return raw_name_->string(); }
2593 const AstString* raw_name() const { return raw_name_; } 2596 const AstString* raw_name() const { return raw_name_; }
2594 void set_raw_name(const AstString* name) { raw_name_ = name; } 2597 void set_raw_name(const AstString* name) { raw_name_ = name; }
2595 Scope* scope() const { return scope_; } 2598 Scope* scope() const { return scope_; }
2596 ZoneList<Statement*>* body() const { return body_; } 2599 ZoneList<Statement*>* body() const { return body_; }
2597 void set_function_token_position(int pos) { function_token_position_ = pos; } 2600 void set_function_token_position(int pos) { function_token_position_ = pos; }
2598 int function_token_position() const { return function_token_position_; } 2601 int function_token_position() const { return function_token_position_; }
2599 int start_position() const; 2602 int start_position() const;
2600 int end_position() const; 2603 int end_position() const;
2601 int SourceSize() const { return end_position() - start_position(); } 2604 int SourceSize() const { return end_position() - start_position(); }
2602 bool is_declaration() const { return IsDeclaration::decode(bitfield_); } 2605 bool is_declaration() const {
2606 return IsDeclaration::decode(Expression::bit_field_);
2607 }
2603 bool is_named_expression() const { 2608 bool is_named_expression() const {
2604 return IsNamedExpression::decode(bitfield_); 2609 return IsNamedExpression::decode(bitfield_);
2605 } 2610 }
2606 bool is_anonymous_expression() const { 2611 bool is_anonymous_expression() const {
2607 return IsAnonymousExpression::decode(bitfield_); 2612 return IsAnonymousExpression::decode(bitfield_);
2608 } 2613 }
2609 LanguageMode language_mode() const; 2614 LanguageMode language_mode() const;
2610 2615
2611 static bool NeedsHomeObject(Expression* expr); 2616 static bool NeedsHomeObject(Expression* expr);
2612 2617
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 body_(body), 2724 body_(body),
2720 raw_inferred_name_(ast_value_factory->empty_string()), 2725 raw_inferred_name_(ast_value_factory->empty_string()),
2721 ast_properties_(zone), 2726 ast_properties_(zone),
2722 dont_optimize_reason_(kNoReason), 2727 dont_optimize_reason_(kNoReason),
2723 materialized_literal_count_(materialized_literal_count), 2728 materialized_literal_count_(materialized_literal_count),
2724 expected_property_count_(expected_property_count), 2729 expected_property_count_(expected_property_count),
2725 parameter_count_(parameter_count), 2730 parameter_count_(parameter_count),
2726 function_token_position_(RelocInfo::kNoPosition), 2731 function_token_position_(RelocInfo::kNoPosition),
2727 yield_count_(0) { 2732 yield_count_(0) {
2728 bitfield_ = 2733 bitfield_ =
2729 IsDeclaration::encode(function_type == kDeclaration) |
2730 IsNamedExpression::encode(function_type == kNamedExpression) | 2734 IsNamedExpression::encode(function_type == kNamedExpression) |
2731 IsAnonymousExpression::encode(function_type == kAnonymousExpression) | 2735 IsAnonymousExpression::encode(function_type == kAnonymousExpression) |
2732 Pretenure::encode(false) | 2736 Pretenure::encode(false) |
2733 HasDuplicateParameters::encode(has_duplicate_parameters == 2737 HasDuplicateParameters::encode(has_duplicate_parameters ==
2734 kHasDuplicateParameters) | 2738 kHasDuplicateParameters) |
2735 IsFunction::encode(is_function) | 2739 IsFunction::encode(is_function) |
2736 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | 2740 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) |
2737 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); 2741 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false);
2738 DCHECK(IsValidFunctionKind(kind)); 2742 DCHECK(IsValidFunctionKind(kind));
2739 } 2743 }
2740 2744
2741 private: 2745 private:
2742 class IsDeclaration : public BitField16<bool, 0, 1> {}; 2746 STATIC_ASSERT((Expression::kExpressionBitFieldNext + 1) < 16);
2743 class IsNamedExpression : public BitField16<bool, 1, 1> {}; 2747 class IsDeclaration
2744 class IsAnonymousExpression : public BitField16<bool, 2, 1> {}; 2748 : public BitField16<bool, Expression::kExpressionBitFieldNext, 1> {};
2745 class Pretenure : public BitField16<bool, 3, 1> {}; 2749 class IsNamedExpression : public BitField16<bool, 0, 1> {};
2746 class HasDuplicateParameters : public BitField16<bool, 4, 1> {}; 2750 class IsAnonymousExpression : public BitField16<bool, 1, 1> {};
2747 class IsFunction : public BitField16<bool, 5, 1> {}; 2751 class Pretenure : public BitField16<bool, 2, 1> {};
2748 class ShouldEagerCompile : public BitField16<bool, 6, 1> {}; 2752 class HasDuplicateParameters : public BitField16<bool, 3, 1> {};
2749 class ShouldBeUsedOnceHint : public BitField16<bool, 7, 1> {}; 2753 class IsFunction : public BitField16<bool, 4, 1> {};
2750 class FunctionKindBits : public BitField16<FunctionKind, 8, 8> {}; 2754 class ShouldEagerCompile : public BitField16<bool, 5, 1> {};
2755 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {};
2756 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {};
2751 2757
2752 // Start with 16-bit field, which should get packed together 2758 // Start with 16-bit field, which should get packed together
2753 // with Expression's trailing 16-bit field. 2759 // with Expression's trailing 16-bit field.
2754 uint16_t bitfield_; 2760 uint16_t bitfield_;
2755 2761
2756 const AstString* raw_name_; 2762 const AstString* raw_name_;
2757 Scope* scope_; 2763 Scope* scope_;
2758 ZoneList<Statement*>* body_; 2764 ZoneList<Statement*>* body_;
2759 const AstString* raw_inferred_name_; 2765 const AstString* raw_inferred_name_;
2760 Handle<String> inferred_name_; 2766 Handle<String> inferred_name_;
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 ZoneList<ObjectLiteral::Property*>* properties, 3258 ZoneList<ObjectLiteral::Property*>* properties,
3253 int literal_index, 3259 int literal_index,
3254 int boilerplate_properties, 3260 int boilerplate_properties,
3255 int pos) { 3261 int pos) {
3256 return new (local_zone_) ObjectLiteral( 3262 return new (local_zone_) ObjectLiteral(
3257 local_zone_, properties, literal_index, boilerplate_properties, pos); 3263 local_zone_, properties, literal_index, boilerplate_properties, pos);
3258 } 3264 }
3259 3265
3260 ObjectLiteral::Property* NewObjectLiteralProperty( 3266 ObjectLiteral::Property* NewObjectLiteralProperty(
3261 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, 3267 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind,
3262 bool is_static, bool is_computed_name) { 3268 MethodKind method_kind, bool is_computed_name) {
3263 return new (local_zone_) 3269 return new (local_zone_) ObjectLiteral::Property(
3264 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); 3270 key, value, kind, method_kind, is_computed_name);
3265 } 3271 }
3266 3272
3267 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, 3273 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
3268 Expression* value, 3274 Expression* value,
3269 bool is_static, 3275 MethodKind method_kind,
3270 bool is_computed_name) { 3276 bool is_computed_name) {
3271 return new (local_zone_) ObjectLiteral::Property( 3277 return new (local_zone_) ObjectLiteral::Property(
3272 ast_value_factory_, key, value, is_static, is_computed_name); 3278 ast_value_factory_, key, value, method_kind, is_computed_name);
3273 } 3279 }
3274 3280
3275 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags, 3281 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags,
3276 int literal_index, int pos) { 3282 int literal_index, int pos) {
3277 return new (local_zone_) 3283 return new (local_zone_)
3278 RegExpLiteral(local_zone_, pattern, flags, literal_index, pos); 3284 RegExpLiteral(local_zone_, pattern, flags, literal_index, pos);
3279 } 3285 }
3280 3286
3281 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3287 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3282 int literal_index, 3288 int literal_index,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 : NULL; \ 3564 : NULL; \
3559 } 3565 }
3560 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3566 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3561 #undef DECLARE_NODE_FUNCTIONS 3567 #undef DECLARE_NODE_FUNCTIONS
3562 3568
3563 3569
3564 } // namespace internal 3570 } // namespace internal
3565 } // namespace v8 3571 } // namespace v8
3566 3572
3567 #endif // V8_AST_AST_H_ 3573 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | src/globals.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698