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

Side by Side Diff: src/ast.h

Issue 1157213004: Drop computed handler count and index from AST. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 6 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 | « src/arm64/full-codegen-arm64.cc ('k') | src/full-codegen.h » ('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 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 1154
1155 Expression* condition_; 1155 Expression* condition_;
1156 Statement* then_statement_; 1156 Statement* then_statement_;
1157 Statement* else_statement_; 1157 Statement* else_statement_;
1158 int base_id_; 1158 int base_id_;
1159 }; 1159 };
1160 1160
1161 1161
1162 class TryStatement : public Statement { 1162 class TryStatement : public Statement {
1163 public: 1163 public:
1164 int index() const { return index_; }
1165 Block* try_block() const { return try_block_; } 1164 Block* try_block() const { return try_block_; }
1166 1165
1167 protected: 1166 protected:
1168 TryStatement(Zone* zone, int index, Block* try_block, int pos) 1167 TryStatement(Zone* zone, Block* try_block, int pos)
1169 : Statement(zone, pos), index_(index), try_block_(try_block) {} 1168 : Statement(zone, pos), try_block_(try_block) {}
1170 1169
1171 private: 1170 private:
1172 // Unique (per-function) index of this handler. This is not an AST ID.
1173 int index_;
1174
1175 Block* try_block_; 1171 Block* try_block_;
1176 }; 1172 };
1177 1173
1178 1174
1179 class TryCatchStatement final : public TryStatement { 1175 class TryCatchStatement final : public TryStatement {
1180 public: 1176 public:
1181 DECLARE_NODE_TYPE(TryCatchStatement) 1177 DECLARE_NODE_TYPE(TryCatchStatement)
1182 1178
1183 Scope* scope() { return scope_; } 1179 Scope* scope() { return scope_; }
1184 Variable* variable() { return variable_; } 1180 Variable* variable() { return variable_; }
1185 Block* catch_block() const { return catch_block_; } 1181 Block* catch_block() const { return catch_block_; }
1186 1182
1187 protected: 1183 protected:
1188 TryCatchStatement(Zone* zone, 1184 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope,
1189 int index, 1185 Variable* variable, Block* catch_block, int pos)
1190 Block* try_block, 1186 : TryStatement(zone, try_block, pos),
1191 Scope* scope,
1192 Variable* variable,
1193 Block* catch_block,
1194 int pos)
1195 : TryStatement(zone, index, try_block, pos),
1196 scope_(scope), 1187 scope_(scope),
1197 variable_(variable), 1188 variable_(variable),
1198 catch_block_(catch_block) { 1189 catch_block_(catch_block) {}
1199 }
1200 1190
1201 private: 1191 private:
1202 Scope* scope_; 1192 Scope* scope_;
1203 Variable* variable_; 1193 Variable* variable_;
1204 Block* catch_block_; 1194 Block* catch_block_;
1205 }; 1195 };
1206 1196
1207 1197
1208 class TryFinallyStatement final : public TryStatement { 1198 class TryFinallyStatement final : public TryStatement {
1209 public: 1199 public:
1210 DECLARE_NODE_TYPE(TryFinallyStatement) 1200 DECLARE_NODE_TYPE(TryFinallyStatement)
1211 1201
1212 Block* finally_block() const { return finally_block_; } 1202 Block* finally_block() const { return finally_block_; }
1213 1203
1214 protected: 1204 protected:
1215 TryFinallyStatement( 1205 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block,
1216 Zone* zone, int index, Block* try_block, Block* finally_block, int pos) 1206 int pos)
1217 : TryStatement(zone, index, try_block, pos), 1207 : TryStatement(zone, try_block, pos), finally_block_(finally_block) {}
1218 finally_block_(finally_block) { }
1219 1208
1220 private: 1209 private:
1221 Block* finally_block_; 1210 Block* finally_block_;
1222 }; 1211 };
1223 1212
1224 1213
1225 class DebuggerStatement final : public Statement { 1214 class DebuggerStatement final : public Statement {
1226 public: 1215 public:
1227 DECLARE_NODE_TYPE(DebuggerStatement) 1216 DECLARE_NODE_TYPE(DebuggerStatement)
1228 1217
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2398 kInitial, // The initial yield that returns the unboxed generator object. 2387 kInitial, // The initial yield that returns the unboxed generator object.
2399 kSuspend, // A normal yield: { value: EXPRESSION, done: false } 2388 kSuspend, // A normal yield: { value: EXPRESSION, done: false }
2400 kDelegating, // A yield*. 2389 kDelegating, // A yield*.
2401 kFinal // A return: { value: EXPRESSION, done: true } 2390 kFinal // A return: { value: EXPRESSION, done: true }
2402 }; 2391 };
2403 2392
2404 Expression* generator_object() const { return generator_object_; } 2393 Expression* generator_object() const { return generator_object_; }
2405 Expression* expression() const { return expression_; } 2394 Expression* expression() const { return expression_; }
2406 Kind yield_kind() const { return yield_kind_; } 2395 Kind yield_kind() const { return yield_kind_; }
2407 2396
2408 // Delegating yield surrounds the "yield" in a "try/catch". This index
2409 // locates the catch handler in the handler table, and is equivalent to
2410 // TryCatchStatement::index().
2411 int index() const {
2412 DCHECK_EQ(kDelegating, yield_kind());
2413 return index_;
2414 }
2415 void set_index(int index) {
2416 DCHECK_EQ(kDelegating, yield_kind());
2417 index_ = index;
2418 }
2419
2420 // Type feedback information. 2397 // Type feedback information.
2421 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; } 2398 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; }
2422 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 2399 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
2423 Isolate* isolate, const ICSlotCache* cache) override { 2400 Isolate* isolate, const ICSlotCache* cache) override {
2424 return FeedbackVectorRequirements(0, HasFeedbackSlots() ? 3 : 0); 2401 return FeedbackVectorRequirements(0, HasFeedbackSlots() ? 3 : 0);
2425 } 2402 }
2426 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, 2403 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2427 ICSlotCache* cache) override { 2404 ICSlotCache* cache) override {
2428 yield_first_feedback_slot_ = slot; 2405 yield_first_feedback_slot_ = slot;
2429 } 2406 }
(...skipping 12 matching lines...) Expand all
2442 2419
2443 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } 2420 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); }
2444 2421
2445 protected: 2422 protected:
2446 Yield(Zone* zone, Expression* generator_object, Expression* expression, 2423 Yield(Zone* zone, Expression* generator_object, Expression* expression,
2447 Kind yield_kind, int pos) 2424 Kind yield_kind, int pos)
2448 : Expression(zone, pos), 2425 : Expression(zone, pos),
2449 generator_object_(generator_object), 2426 generator_object_(generator_object),
2450 expression_(expression), 2427 expression_(expression),
2451 yield_kind_(yield_kind), 2428 yield_kind_(yield_kind),
2452 index_(-1),
2453 yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} 2429 yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {}
2454 2430
2455 private: 2431 private:
2456 Expression* generator_object_; 2432 Expression* generator_object_;
2457 Expression* expression_; 2433 Expression* expression_;
2458 Kind yield_kind_; 2434 Kind yield_kind_;
2459 int index_;
2460 FeedbackVectorICSlot yield_first_feedback_slot_; 2435 FeedbackVectorICSlot yield_first_feedback_slot_;
2461 }; 2436 };
2462 2437
2463 2438
2464 class Throw final : public Expression { 2439 class Throw final : public Expression {
2465 public: 2440 public:
2466 DECLARE_NODE_TYPE(Throw) 2441 DECLARE_NODE_TYPE(Throw)
2467 2442
2468 Expression* exception() const { return exception_; } 2443 Expression* exception() const { return exception_; }
2469 2444
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 int end_position() const; 2491 int end_position() const;
2517 int SourceSize() const { return end_position() - start_position(); } 2492 int SourceSize() const { return end_position() - start_position(); }
2518 bool is_expression() const { return IsExpression::decode(bitfield_); } 2493 bool is_expression() const { return IsExpression::decode(bitfield_); }
2519 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } 2494 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
2520 LanguageMode language_mode() const; 2495 LanguageMode language_mode() const;
2521 2496
2522 static bool NeedsHomeObject(Expression* expr); 2497 static bool NeedsHomeObject(Expression* expr);
2523 2498
2524 int materialized_literal_count() { return materialized_literal_count_; } 2499 int materialized_literal_count() { return materialized_literal_count_; }
2525 int expected_property_count() { return expected_property_count_; } 2500 int expected_property_count() { return expected_property_count_; }
2526 int handler_count() { return handler_count_; }
2527 int parameter_count() { return parameter_count_; } 2501 int parameter_count() { return parameter_count_; }
2528 2502
2529 bool AllowsLazyCompilation(); 2503 bool AllowsLazyCompilation();
2530 bool AllowsLazyCompilationWithoutContext(); 2504 bool AllowsLazyCompilationWithoutContext();
2531 2505
2532 void InitializeSharedInfo(Handle<Code> code); 2506 void InitializeSharedInfo(Handle<Code> code);
2533 2507
2534 Handle<String> debug_name() const { 2508 Handle<String> debug_name() const {
2535 if (raw_name_ != NULL && !raw_name_->IsEmpty()) { 2509 if (raw_name_ != NULL && !raw_name_->IsEmpty()) {
2536 return raw_name_->string(); 2510 return raw_name_->string();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2585 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2612 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2586 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2613 void set_dont_optimize_reason(BailoutReason reason) { 2587 void set_dont_optimize_reason(BailoutReason reason) {
2614 dont_optimize_reason_ = reason; 2588 dont_optimize_reason_ = reason;
2615 } 2589 }
2616 2590
2617 protected: 2591 protected:
2618 FunctionLiteral(Zone* zone, const AstRawString* name, 2592 FunctionLiteral(Zone* zone, const AstRawString* name,
2619 AstValueFactory* ast_value_factory, Scope* scope, 2593 AstValueFactory* ast_value_factory, Scope* scope,
2620 ZoneList<Statement*>* body, int materialized_literal_count, 2594 ZoneList<Statement*>* body, int materialized_literal_count,
2621 int expected_property_count, int handler_count, 2595 int expected_property_count, int parameter_count,
2622 int parameter_count, FunctionType function_type, 2596 FunctionType function_type,
2623 ParameterFlag has_duplicate_parameters, 2597 ParameterFlag has_duplicate_parameters,
2624 IsFunctionFlag is_function, 2598 IsFunctionFlag is_function,
2625 EagerCompileHint eager_compile_hint, FunctionKind kind, 2599 EagerCompileHint eager_compile_hint, FunctionKind kind,
2626 int position) 2600 int position)
2627 : Expression(zone, position), 2601 : Expression(zone, position),
2628 raw_name_(name), 2602 raw_name_(name),
2629 scope_(scope), 2603 scope_(scope),
2630 body_(body), 2604 body_(body),
2631 raw_inferred_name_(ast_value_factory->empty_string()), 2605 raw_inferred_name_(ast_value_factory->empty_string()),
2632 ast_properties_(zone), 2606 ast_properties_(zone),
2633 dont_optimize_reason_(kNoReason), 2607 dont_optimize_reason_(kNoReason),
2634 materialized_literal_count_(materialized_literal_count), 2608 materialized_literal_count_(materialized_literal_count),
2635 expected_property_count_(expected_property_count), 2609 expected_property_count_(expected_property_count),
2636 handler_count_(handler_count),
2637 parameter_count_(parameter_count), 2610 parameter_count_(parameter_count),
2638 function_token_position_(RelocInfo::kNoPosition) { 2611 function_token_position_(RelocInfo::kNoPosition) {
2639 bitfield_ = IsExpression::encode(function_type != DECLARATION) | 2612 bitfield_ = IsExpression::encode(function_type != DECLARATION) |
2640 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2613 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2641 Pretenure::encode(false) | 2614 Pretenure::encode(false) |
2642 HasDuplicateParameters::encode(has_duplicate_parameters) | 2615 HasDuplicateParameters::encode(has_duplicate_parameters) |
2643 IsFunction::encode(is_function) | 2616 IsFunction::encode(is_function) |
2644 EagerCompileHintBit::encode(eager_compile_hint) | 2617 EagerCompileHintBit::encode(eager_compile_hint) |
2645 FunctionKindBits::encode(kind) | 2618 FunctionKindBits::encode(kind) |
2646 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce); 2619 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce);
2647 DCHECK(IsValidFunctionKind(kind)); 2620 DCHECK(IsValidFunctionKind(kind));
2648 } 2621 }
2649 2622
2650 private: 2623 private:
2651 const AstRawString* raw_name_; 2624 const AstRawString* raw_name_;
2652 Handle<String> name_; 2625 Handle<String> name_;
2653 Handle<SharedFunctionInfo> shared_info_; 2626 Handle<SharedFunctionInfo> shared_info_;
2654 Scope* scope_; 2627 Scope* scope_;
2655 ZoneList<Statement*>* body_; 2628 ZoneList<Statement*>* body_;
2656 const AstString* raw_inferred_name_; 2629 const AstString* raw_inferred_name_;
2657 Handle<String> inferred_name_; 2630 Handle<String> inferred_name_;
2658 AstProperties ast_properties_; 2631 AstProperties ast_properties_;
2659 BailoutReason dont_optimize_reason_; 2632 BailoutReason dont_optimize_reason_;
2660 2633
2661 int materialized_literal_count_; 2634 int materialized_literal_count_;
2662 int expected_property_count_; 2635 int expected_property_count_;
2663 int handler_count_;
2664 int parameter_count_; 2636 int parameter_count_;
2665 int function_token_position_; 2637 int function_token_position_;
2666 2638
2667 unsigned bitfield_; 2639 unsigned bitfield_;
2668 class IsExpression : public BitField<bool, 0, 1> {}; 2640 class IsExpression : public BitField<bool, 0, 1> {};
2669 class IsAnonymous : public BitField<bool, 1, 1> {}; 2641 class IsAnonymous : public BitField<bool, 1, 1> {};
2670 class Pretenure : public BitField<bool, 2, 1> {}; 2642 class Pretenure : public BitField<bool, 2, 1> {};
2671 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; 2643 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
2672 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; 2644 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
2673 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {}; 2645 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {};
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
3353 } 3325 }
3354 3326
3355 IfStatement* NewIfStatement(Expression* condition, 3327 IfStatement* NewIfStatement(Expression* condition,
3356 Statement* then_statement, 3328 Statement* then_statement,
3357 Statement* else_statement, 3329 Statement* else_statement,
3358 int pos) { 3330 int pos) {
3359 return new (zone_) 3331 return new (zone_)
3360 IfStatement(zone_, condition, then_statement, else_statement, pos); 3332 IfStatement(zone_, condition, then_statement, else_statement, pos);
3361 } 3333 }
3362 3334
3363 TryCatchStatement* NewTryCatchStatement(int index, 3335 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope,
3364 Block* try_block,
3365 Scope* scope,
3366 Variable* variable, 3336 Variable* variable,
3367 Block* catch_block, 3337 Block* catch_block, int pos) {
3368 int pos) { 3338 return new (zone_)
3369 return new (zone_) TryCatchStatement(zone_, index, try_block, scope, 3339 TryCatchStatement(zone_, try_block, scope, variable, catch_block, pos);
3370 variable, catch_block, pos);
3371 } 3340 }
3372 3341
3373 TryFinallyStatement* NewTryFinallyStatement(int index, 3342 TryFinallyStatement* NewTryFinallyStatement(Block* try_block,
3374 Block* try_block, 3343 Block* finally_block, int pos) {
3375 Block* finally_block,
3376 int pos) {
3377 return new (zone_) 3344 return new (zone_)
3378 TryFinallyStatement(zone_, index, try_block, finally_block, pos); 3345 TryFinallyStatement(zone_, try_block, finally_block, pos);
3379 } 3346 }
3380 3347
3381 DebuggerStatement* NewDebuggerStatement(int pos) { 3348 DebuggerStatement* NewDebuggerStatement(int pos) {
3382 return new (zone_) DebuggerStatement(zone_, pos); 3349 return new (zone_) DebuggerStatement(zone_, pos);
3383 } 3350 }
3384 3351
3385 EmptyStatement* NewEmptyStatement(int pos) { 3352 EmptyStatement* NewEmptyStatement(int pos) {
3386 return new(zone_) EmptyStatement(zone_, pos); 3353 return new(zone_) EmptyStatement(zone_, pos);
3387 } 3354 }
3388 3355
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3570 Yield(zone_, generator_object, expression, yield_kind, pos); 3537 Yield(zone_, generator_object, expression, yield_kind, pos);
3571 } 3538 }
3572 3539
3573 Throw* NewThrow(Expression* exception, int pos) { 3540 Throw* NewThrow(Expression* exception, int pos) {
3574 return new (zone_) Throw(zone_, exception, pos); 3541 return new (zone_) Throw(zone_, exception, pos);
3575 } 3542 }
3576 3543
3577 FunctionLiteral* NewFunctionLiteral( 3544 FunctionLiteral* NewFunctionLiteral(
3578 const AstRawString* name, AstValueFactory* ast_value_factory, 3545 const AstRawString* name, AstValueFactory* ast_value_factory,
3579 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3546 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3580 int expected_property_count, int handler_count, int parameter_count, 3547 int expected_property_count, int parameter_count,
3581 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3548 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3582 FunctionLiteral::FunctionType function_type, 3549 FunctionLiteral::FunctionType function_type,
3583 FunctionLiteral::IsFunctionFlag is_function, 3550 FunctionLiteral::IsFunctionFlag is_function,
3584 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, 3551 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
3585 int position) { 3552 int position) {
3586 return new (zone_) FunctionLiteral( 3553 return new (zone_) FunctionLiteral(
3587 zone_, name, ast_value_factory, scope, body, materialized_literal_count, 3554 zone_, name, ast_value_factory, scope, body, materialized_literal_count,
3588 expected_property_count, handler_count, parameter_count, function_type, 3555 expected_property_count, parameter_count, function_type,
3589 has_duplicate_parameters, is_function, eager_compile_hint, kind, 3556 has_duplicate_parameters, is_function, eager_compile_hint, kind,
3590 position); 3557 position);
3591 } 3558 }
3592 3559
3593 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope, 3560 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope,
3594 VariableProxy* proxy, Expression* extends, 3561 VariableProxy* proxy, Expression* extends,
3595 FunctionLiteral* constructor, 3562 FunctionLiteral* constructor,
3596 ZoneList<ObjectLiteral::Property*>* properties, 3563 ZoneList<ObjectLiteral::Property*>* properties,
3597 int start_position, int end_position) { 3564 int start_position, int end_position) {
3598 return new (zone_) 3565 return new (zone_)
(...skipping 28 matching lines...) Expand all
3627 3594
3628 private: 3595 private:
3629 Zone* zone_; 3596 Zone* zone_;
3630 AstValueFactory* ast_value_factory_; 3597 AstValueFactory* ast_value_factory_;
3631 }; 3598 };
3632 3599
3633 3600
3634 } } // namespace v8::internal 3601 } } // namespace v8::internal
3635 3602
3636 #endif // V8_AST_H_ 3603 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698