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

Side by Side Diff: src/ast.h

Issue 1102523003: Implement a 'trial parse' step, that will abort pre-parsing excessively (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use a seperate 'hint' bit for "to be executed once" code aging. Created 5 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/compiler.cc » ('j') | no next file with comments »
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_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/assembler.h" 10 #include "src/assembler.h"
(...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 kHasDuplicateParameters = 1 2423 kHasDuplicateParameters = 1
2424 }; 2424 };
2425 2425
2426 enum IsFunctionFlag { 2426 enum IsFunctionFlag {
2427 kGlobalOrEval, 2427 kGlobalOrEval,
2428 kIsFunction 2428 kIsFunction
2429 }; 2429 };
2430 2430
2431 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; 2431 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile };
2432 2432
2433 enum ShouldBeUsedOnceHint { kShouldBeUsedOnce, kDontKnowIfShouldBeUsedOnce };
2434
2433 enum ArityRestriction { 2435 enum ArityRestriction {
2434 NORMAL_ARITY, 2436 NORMAL_ARITY,
2435 GETTER_ARITY, 2437 GETTER_ARITY,
2436 SETTER_ARITY 2438 SETTER_ARITY
2437 }; 2439 };
2438 2440
2439 DECLARE_NODE_TYPE(FunctionLiteral) 2441 DECLARE_NODE_TYPE(FunctionLiteral)
2440 2442
2441 Handle<String> name() const { return raw_name_->string(); } 2443 Handle<String> name() const { return raw_name_->string(); }
2442 const AstRawString* raw_name() const { return raw_name_; } 2444 const AstRawString* raw_name() const { return raw_name_; }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 // function will be called immediately: 2520 // function will be called immediately:
2519 // - (function() { ... })(); 2521 // - (function() { ... })();
2520 // - var x = function() { ... }(); 2522 // - var x = function() { ... }();
2521 bool should_eager_compile() const { 2523 bool should_eager_compile() const {
2522 return EagerCompileHintBit::decode(bitfield_) == kShouldEagerCompile; 2524 return EagerCompileHintBit::decode(bitfield_) == kShouldEagerCompile;
2523 } 2525 }
2524 void set_should_eager_compile() { 2526 void set_should_eager_compile() {
2525 bitfield_ = EagerCompileHintBit::update(bitfield_, kShouldEagerCompile); 2527 bitfield_ = EagerCompileHintBit::update(bitfield_, kShouldEagerCompile);
2526 } 2528 }
2527 2529
2530 // A hint that we expect this function to be called (exactly) once,
2531 // i.e. we suspect it's an initialization function.
2532 bool should_be_used_once_hint() const {
2533 return ShouldBeUsedOnceHintBit::decode(bitfield_) == kShouldBeUsedOnce;
2534 }
2535 void set_should_be_used_once_hint() {
2536 bitfield_ = ShouldBeUsedOnceHintBit::update(bitfield_, kShouldBeUsedOnce);
2537 }
2538
2528 FunctionKind kind() { return FunctionKindBits::decode(bitfield_); } 2539 FunctionKind kind() { return FunctionKindBits::decode(bitfield_); }
2529 2540
2530 int ast_node_count() { return ast_properties_.node_count(); } 2541 int ast_node_count() { return ast_properties_.node_count(); }
2531 AstProperties::Flags* flags() { return ast_properties_.flags(); } 2542 AstProperties::Flags* flags() { return ast_properties_.flags(); }
2532 void set_ast_properties(AstProperties* ast_properties) { 2543 void set_ast_properties(AstProperties* ast_properties) {
2533 ast_properties_ = *ast_properties; 2544 ast_properties_ = *ast_properties;
2534 } 2545 }
2535 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { 2546 const ZoneFeedbackVectorSpec* feedback_vector_spec() const {
2536 return ast_properties_.get_spec(); 2547 return ast_properties_.get_spec();
2537 } 2548 }
(...skipping 24 matching lines...) Expand all
2562 expected_property_count_(expected_property_count), 2573 expected_property_count_(expected_property_count),
2563 handler_count_(handler_count), 2574 handler_count_(handler_count),
2564 parameter_count_(parameter_count), 2575 parameter_count_(parameter_count),
2565 function_token_position_(RelocInfo::kNoPosition) { 2576 function_token_position_(RelocInfo::kNoPosition) {
2566 bitfield_ = IsExpression::encode(function_type != DECLARATION) | 2577 bitfield_ = IsExpression::encode(function_type != DECLARATION) |
2567 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2578 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2568 Pretenure::encode(false) | 2579 Pretenure::encode(false) |
2569 HasDuplicateParameters::encode(has_duplicate_parameters) | 2580 HasDuplicateParameters::encode(has_duplicate_parameters) |
2570 IsFunction::encode(is_function) | 2581 IsFunction::encode(is_function) |
2571 EagerCompileHintBit::encode(eager_compile_hint) | 2582 EagerCompileHintBit::encode(eager_compile_hint) |
2572 FunctionKindBits::encode(kind); 2583 FunctionKindBits::encode(kind) |
2584 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce);
2573 DCHECK(IsValidFunctionKind(kind)); 2585 DCHECK(IsValidFunctionKind(kind));
2574 } 2586 }
2575 2587
2576 private: 2588 private:
2577 const AstRawString* raw_name_; 2589 const AstRawString* raw_name_;
2578 Handle<String> name_; 2590 Handle<String> name_;
2579 Handle<SharedFunctionInfo> shared_info_; 2591 Handle<SharedFunctionInfo> shared_info_;
2580 Scope* scope_; 2592 Scope* scope_;
2581 ZoneList<Statement*>* body_; 2593 ZoneList<Statement*>* body_;
2582 const AstString* raw_inferred_name_; 2594 const AstString* raw_inferred_name_;
2583 Handle<String> inferred_name_; 2595 Handle<String> inferred_name_;
2584 AstProperties ast_properties_; 2596 AstProperties ast_properties_;
2585 BailoutReason dont_optimize_reason_; 2597 BailoutReason dont_optimize_reason_;
2586 2598
2587 int materialized_literal_count_; 2599 int materialized_literal_count_;
2588 int expected_property_count_; 2600 int expected_property_count_;
2589 int handler_count_; 2601 int handler_count_;
2590 int parameter_count_; 2602 int parameter_count_;
2591 int function_token_position_; 2603 int function_token_position_;
2592 2604
2593 unsigned bitfield_; 2605 unsigned bitfield_;
2594 class IsExpression : public BitField<bool, 0, 1> {}; 2606 class IsExpression : public BitField<bool, 0, 1> {};
2595 class IsAnonymous : public BitField<bool, 1, 1> {}; 2607 class IsAnonymous : public BitField<bool, 1, 1> {};
2596 class Pretenure : public BitField<bool, 2, 1> {}; 2608 class Pretenure : public BitField<bool, 2, 1> {};
2597 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; 2609 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
2598 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; 2610 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
2599 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {}; 2611 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {};
2600 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; 2612 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {};
2613 class ShouldBeUsedOnceHintBit : public BitField<ShouldBeUsedOnceHint, 15, 1> {
2614 };
2601 }; 2615 };
2602 2616
2603 2617
2604 class ClassLiteral final : public Expression { 2618 class ClassLiteral final : public Expression {
2605 public: 2619 public:
2606 typedef ObjectLiteralProperty Property; 2620 typedef ObjectLiteralProperty Property;
2607 2621
2608 DECLARE_NODE_TYPE(ClassLiteral) 2622 DECLARE_NODE_TYPE(ClassLiteral)
2609 2623
2610 Handle<String> name() const { return raw_name_->string(); } 2624 Handle<String> name() const { return raw_name_->string(); }
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
3492 3506
3493 private: 3507 private:
3494 Zone* zone_; 3508 Zone* zone_;
3495 AstValueFactory* ast_value_factory_; 3509 AstValueFactory* ast_value_factory_;
3496 }; 3510 };
3497 3511
3498 3512
3499 } } // namespace v8::internal 3513 } } // namespace v8::internal
3500 3514
3501 #endif // V8_AST_H_ 3515 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698