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

Side by Side Diff: src/hydrogen.h

Issue 23143007: Revert "Use V8_FINAL and V8_OVERRIDE in various places, fixing bugs revealed by them." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/ast.cc ('k') | src/hydrogen.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 // 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class HEnvironment; 46 class HEnvironment;
47 class HGraph; 47 class HGraph;
48 class HLoopInformation; 48 class HLoopInformation;
49 class HOsrBuilder; 49 class HOsrBuilder;
50 class HTracer; 50 class HTracer;
51 class LAllocator; 51 class LAllocator;
52 class LChunk; 52 class LChunk;
53 class LiveRange; 53 class LiveRange;
54 54
55 55
56 class HBasicBlock V8_FINAL : public ZoneObject { 56 class HBasicBlock: public ZoneObject {
57 public: 57 public:
58 explicit HBasicBlock(HGraph* graph); 58 explicit HBasicBlock(HGraph* graph);
59 ~HBasicBlock() { } 59 virtual ~HBasicBlock() { }
60 60
61 // Simple accessors. 61 // Simple accessors.
62 int block_id() const { return block_id_; } 62 int block_id() const { return block_id_; }
63 void set_block_id(int id) { block_id_ = id; } 63 void set_block_id(int id) { block_id_ = id; }
64 HGraph* graph() const { return graph_; } 64 HGraph* graph() const { return graph_; }
65 Isolate* isolate() const; 65 Isolate* isolate() const;
66 const ZoneList<HPhi*>* phis() const { return &phis_; } 66 const ZoneList<HPhi*>* phis() const { return &phis_; }
67 HInstruction* first() const { return first_; } 67 HInstruction* first() const { return first_; }
68 HInstruction* last() const { return last_; } 68 HInstruction* last() const { return last_; }
69 void set_last(HInstruction* instr) { last_ = instr; } 69 void set_last(HInstruction* instr) { last_ = instr; }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 HBasicBlock* parent_loop_header_; 213 HBasicBlock* parent_loop_header_;
214 // For blocks marked as inline return target: the block with HEnterInlined. 214 // For blocks marked as inline return target: the block with HEnterInlined.
215 HBasicBlock* inlined_entry_block_; 215 HBasicBlock* inlined_entry_block_;
216 bool is_inline_return_target_ : 1; 216 bool is_inline_return_target_ : 1;
217 bool is_deoptimizing_ : 1; 217 bool is_deoptimizing_ : 1;
218 bool dominates_loop_successors_ : 1; 218 bool dominates_loop_successors_ : 1;
219 bool is_osr_entry_ : 1; 219 bool is_osr_entry_ : 1;
220 }; 220 };
221 221
222 222
223 class HPredecessorIterator V8_FINAL BASE_EMBEDDED { 223 class HPredecessorIterator BASE_EMBEDDED {
224 public: 224 public:
225 explicit HPredecessorIterator(HBasicBlock* block) 225 explicit HPredecessorIterator(HBasicBlock* block)
226 : predecessor_list_(block->predecessors()), current_(0) { } 226 : predecessor_list_(block->predecessors()), current_(0) { }
227 227
228 bool Done() { return current_ >= predecessor_list_->length(); } 228 bool Done() { return current_ >= predecessor_list_->length(); }
229 HBasicBlock* Current() { return predecessor_list_->at(current_); } 229 HBasicBlock* Current() { return predecessor_list_->at(current_); }
230 void Advance() { current_++; } 230 void Advance() { current_++; }
231 231
232 private: 232 private:
233 const ZoneList<HBasicBlock*>* predecessor_list_; 233 const ZoneList<HBasicBlock*>* predecessor_list_;
234 int current_; 234 int current_;
235 }; 235 };
236 236
237 237
238 class HInstructionIterator V8_FINAL BASE_EMBEDDED { 238 class HInstructionIterator BASE_EMBEDDED {
239 public: 239 public:
240 explicit HInstructionIterator(HBasicBlock* block) 240 explicit HInstructionIterator(HBasicBlock* block)
241 : instr_(block->first()) { 241 : instr_(block->first()) {
242 next_ = Done() ? NULL : instr_->next(); 242 next_ = Done() ? NULL : instr_->next();
243 } 243 }
244 244
245 inline bool Done() const { return instr_ == NULL; } 245 inline bool Done() const { return instr_ == NULL; }
246 inline HInstruction* Current() { return instr_; } 246 inline HInstruction* Current() { return instr_; }
247 inline void Advance() { 247 inline void Advance() {
248 instr_ = next_; 248 instr_ = next_;
249 next_ = Done() ? NULL : instr_->next(); 249 next_ = Done() ? NULL : instr_->next();
250 } 250 }
251 251
252 private: 252 private:
253 HInstruction* instr_; 253 HInstruction* instr_;
254 HInstruction* next_; 254 HInstruction* next_;
255 }; 255 };
256 256
257 257
258 class HLoopInformation V8_FINAL : public ZoneObject { 258 class HLoopInformation: public ZoneObject {
259 public: 259 public:
260 HLoopInformation(HBasicBlock* loop_header, Zone* zone) 260 HLoopInformation(HBasicBlock* loop_header, Zone* zone)
261 : back_edges_(4, zone), 261 : back_edges_(4, zone),
262 loop_header_(loop_header), 262 loop_header_(loop_header),
263 blocks_(8, zone), 263 blocks_(8, zone),
264 stack_check_(NULL) { 264 stack_check_(NULL) {
265 blocks_.Add(loop_header, zone); 265 blocks_.Add(loop_header, zone);
266 } 266 }
267 ~HLoopInformation() {} 267 virtual ~HLoopInformation() {}
268 268
269 const ZoneList<HBasicBlock*>* back_edges() const { return &back_edges_; } 269 const ZoneList<HBasicBlock*>* back_edges() const { return &back_edges_; }
270 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } 270 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
271 HBasicBlock* loop_header() const { return loop_header_; } 271 HBasicBlock* loop_header() const { return loop_header_; }
272 HBasicBlock* GetLastBackEdge() const; 272 HBasicBlock* GetLastBackEdge() const;
273 void RegisterBackEdge(HBasicBlock* block); 273 void RegisterBackEdge(HBasicBlock* block);
274 274
275 HStackCheck* stack_check() const { return stack_check_; } 275 HStackCheck* stack_check() const { return stack_check_; }
276 void set_stack_check(HStackCheck* stack_check) { 276 void set_stack_check(HStackCheck* stack_check) {
277 stack_check_ = stack_check; 277 stack_check_ = stack_check;
(...skipping 18 matching lines...) Expand all
296 296
297 ZoneList<HBasicBlock*> back_edges_; 297 ZoneList<HBasicBlock*> back_edges_;
298 HBasicBlock* loop_header_; 298 HBasicBlock* loop_header_;
299 ZoneList<HBasicBlock*> blocks_; 299 ZoneList<HBasicBlock*> blocks_;
300 HStackCheck* stack_check_; 300 HStackCheck* stack_check_;
301 }; 301 };
302 302
303 303
304 class BoundsCheckTable; 304 class BoundsCheckTable;
305 class InductionVariableBlocksTable; 305 class InductionVariableBlocksTable;
306 class HGraph V8_FINAL : public ZoneObject { 306 class HGraph: public ZoneObject {
307 public: 307 public:
308 explicit HGraph(CompilationInfo* info); 308 explicit HGraph(CompilationInfo* info);
309 309
310 Isolate* isolate() const { return isolate_; } 310 Isolate* isolate() const { return isolate_; }
311 Zone* zone() const { return zone_; } 311 Zone* zone() const { return zone_; }
312 CompilationInfo* info() const { return info_; } 312 CompilationInfo* info() const { return info_; }
313 313
314 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } 314 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
315 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } 315 const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
316 HBasicBlock* entry_block() const { return entry_block_; } 316 HBasicBlock* entry_block() const { return entry_block_; }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 enum FrameType { 516 enum FrameType {
517 JS_FUNCTION, 517 JS_FUNCTION,
518 JS_CONSTRUCT, 518 JS_CONSTRUCT,
519 JS_GETTER, 519 JS_GETTER,
520 JS_SETTER, 520 JS_SETTER,
521 ARGUMENTS_ADAPTOR, 521 ARGUMENTS_ADAPTOR,
522 STUB 522 STUB
523 }; 523 };
524 524
525 525
526 class HEnvironment V8_FINAL : public ZoneObject { 526 class HEnvironment: public ZoneObject {
527 public: 527 public:
528 HEnvironment(HEnvironment* outer, 528 HEnvironment(HEnvironment* outer,
529 Scope* scope, 529 Scope* scope,
530 Handle<JSFunction> closure, 530 Handle<JSFunction> closure,
531 Zone* zone); 531 Zone* zone);
532 532
533 HEnvironment(Zone* zone, int parameter_count); 533 HEnvironment(Zone* zone, int parameter_count);
534 534
535 HEnvironment* arguments_environment() { 535 HEnvironment* arguments_environment() {
536 return outer()->frame_type() == ARGUMENTS_ADAPTOR ? outer() : this; 536 return outer()->frame_type() == ARGUMENTS_ADAPTOR ? outer() : this;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 #endif 786 #endif
787 787
788 private: 788 private:
789 HOptimizedGraphBuilder* owner_; 789 HOptimizedGraphBuilder* owner_;
790 Expression::Context kind_; 790 Expression::Context kind_;
791 AstContext* outer_; 791 AstContext* outer_;
792 bool for_typeof_; 792 bool for_typeof_;
793 }; 793 };
794 794
795 795
796 class EffectContext V8_FINAL : public AstContext { 796 class EffectContext: public AstContext {
797 public: 797 public:
798 explicit EffectContext(HOptimizedGraphBuilder* owner) 798 explicit EffectContext(HOptimizedGraphBuilder* owner)
799 : AstContext(owner, Expression::kEffect) { 799 : AstContext(owner, Expression::kEffect) {
800 } 800 }
801 virtual ~EffectContext(); 801 virtual ~EffectContext();
802 802
803 virtual void ReturnValue(HValue* value) V8_OVERRIDE; 803 virtual void ReturnValue(HValue* value);
804 virtual void ReturnInstruction(HInstruction* instr, 804 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id);
805 BailoutId ast_id) V8_OVERRIDE; 805 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id);
806 virtual void ReturnControl(HControlInstruction* instr,
807 BailoutId ast_id) V8_OVERRIDE;
808 virtual void ReturnContinuation(HIfContinuation* continuation, 806 virtual void ReturnContinuation(HIfContinuation* continuation,
809 BailoutId ast_id) V8_OVERRIDE; 807 BailoutId ast_id);
810 }; 808 };
811 809
812 810
813 class ValueContext V8_FINAL : public AstContext { 811 class ValueContext: public AstContext {
814 public: 812 public:
815 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) 813 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag)
816 : AstContext(owner, Expression::kValue), flag_(flag) { 814 : AstContext(owner, Expression::kValue), flag_(flag) {
817 } 815 }
818 virtual ~ValueContext(); 816 virtual ~ValueContext();
819 817
820 virtual void ReturnValue(HValue* value) V8_OVERRIDE; 818 virtual void ReturnValue(HValue* value);
821 virtual void ReturnInstruction(HInstruction* instr, 819 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id);
822 BailoutId ast_id) V8_OVERRIDE; 820 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id);
823 virtual void ReturnControl(HControlInstruction* instr,
824 BailoutId ast_id) V8_OVERRIDE;
825 virtual void ReturnContinuation(HIfContinuation* continuation, 821 virtual void ReturnContinuation(HIfContinuation* continuation,
826 BailoutId ast_id) V8_OVERRIDE; 822 BailoutId ast_id);
827 823
828 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } 824 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; }
829 825
830 private: 826 private:
831 ArgumentsAllowedFlag flag_; 827 ArgumentsAllowedFlag flag_;
832 }; 828 };
833 829
834 830
835 class TestContext V8_FINAL : public AstContext { 831 class TestContext: public AstContext {
836 public: 832 public:
837 TestContext(HOptimizedGraphBuilder* owner, 833 TestContext(HOptimizedGraphBuilder* owner,
838 Expression* condition, 834 Expression* condition,
839 HBasicBlock* if_true, 835 HBasicBlock* if_true,
840 HBasicBlock* if_false) 836 HBasicBlock* if_false)
841 : AstContext(owner, Expression::kTest), 837 : AstContext(owner, Expression::kTest),
842 condition_(condition), 838 condition_(condition),
843 if_true_(if_true), 839 if_true_(if_true),
844 if_false_(if_false) { 840 if_false_(if_false) {
845 } 841 }
846 842
847 virtual void ReturnValue(HValue* value) V8_OVERRIDE; 843 virtual void ReturnValue(HValue* value);
848 virtual void ReturnInstruction(HInstruction* instr, 844 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id);
849 BailoutId ast_id) V8_OVERRIDE; 845 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id);
850 virtual void ReturnControl(HControlInstruction* instr,
851 BailoutId ast_id) V8_OVERRIDE;
852 virtual void ReturnContinuation(HIfContinuation* continuation, 846 virtual void ReturnContinuation(HIfContinuation* continuation,
853 BailoutId ast_id) V8_OVERRIDE; 847 BailoutId ast_id);
854 848
855 static TestContext* cast(AstContext* context) { 849 static TestContext* cast(AstContext* context) {
856 ASSERT(context->IsTest()); 850 ASSERT(context->IsTest());
857 return reinterpret_cast<TestContext*>(context); 851 return reinterpret_cast<TestContext*>(context);
858 } 852 }
859 853
860 Expression* condition() const { return condition_; } 854 Expression* condition() const { return condition_; }
861 HBasicBlock* if_true() const { return if_true_; } 855 HBasicBlock* if_true() const { return if_true_; }
862 HBasicBlock* if_false() const { return if_false_; } 856 HBasicBlock* if_false() const { return if_false_; }
863 857
864 private: 858 private:
865 // Build the shared core part of the translation unpacking a value into 859 // Build the shared core part of the translation unpacking a value into
866 // control flow. 860 // control flow.
867 void BuildBranch(HValue* value); 861 void BuildBranch(HValue* value);
868 862
869 Expression* condition_; 863 Expression* condition_;
870 HBasicBlock* if_true_; 864 HBasicBlock* if_true_;
871 HBasicBlock* if_false_; 865 HBasicBlock* if_false_;
872 }; 866 };
873 867
874 868
875 class FunctionState V8_FINAL { 869 class FunctionState {
876 public: 870 public:
877 FunctionState(HOptimizedGraphBuilder* owner, 871 FunctionState(HOptimizedGraphBuilder* owner,
878 CompilationInfo* info, 872 CompilationInfo* info,
879 InliningKind inlining_kind); 873 InliningKind inlining_kind);
880 ~FunctionState(); 874 ~FunctionState();
881 875
882 CompilationInfo* compilation_info() { return compilation_info_; } 876 CompilationInfo* compilation_info() { return compilation_info_; }
883 AstContext* call_context() { return call_context_; } 877 AstContext* call_context() { return call_context_; }
884 InliningKind inlining_kind() const { return inlining_kind_; } 878 InliningKind inlining_kind() const { return inlining_kind_; }
885 HBasicBlock* function_return() { return function_return_; } 879 HBasicBlock* function_return() { return function_return_; }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 // entry. 926 // entry.
933 HEnterInlined* entry_; 927 HEnterInlined* entry_;
934 928
935 HArgumentsObject* arguments_object_; 929 HArgumentsObject* arguments_object_;
936 HArgumentsElements* arguments_elements_; 930 HArgumentsElements* arguments_elements_;
937 931
938 FunctionState* outer_; 932 FunctionState* outer_;
939 }; 933 };
940 934
941 935
942 class HIfContinuation V8_FINAL { 936 class HIfContinuation {
943 public: 937 public:
944 HIfContinuation() { continuation_captured_ = false; } 938 HIfContinuation() { continuation_captured_ = false; }
945 ~HIfContinuation() { ASSERT(!continuation_captured_); } 939 ~HIfContinuation() { ASSERT(!continuation_captured_); }
946 940
947 void Capture(HBasicBlock* true_branch, 941 void Capture(HBasicBlock* true_branch,
948 HBasicBlock* false_branch, 942 HBasicBlock* false_branch,
949 int position) { 943 int position) {
950 ASSERT(!continuation_captured_); 944 ASSERT(!continuation_captured_);
951 true_branch_ = true_branch; 945 true_branch_ = true_branch;
952 false_branch_ = false_branch; 946 false_branch_ = false_branch;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); 1265 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected);
1272 1266
1273 void PushAndAdd(HInstruction* instr); 1267 void PushAndAdd(HInstruction* instr);
1274 1268
1275 void FinishExitWithHardDeoptimization(const char* reason, 1269 void FinishExitWithHardDeoptimization(const char* reason,
1276 HBasicBlock* continuation); 1270 HBasicBlock* continuation);
1277 1271
1278 void AddIncrementCounter(StatsCounter* counter, 1272 void AddIncrementCounter(StatsCounter* counter,
1279 HValue* context); 1273 HValue* context);
1280 1274
1281 class IfBuilder V8_FINAL { 1275 class IfBuilder {
1282 public: 1276 public:
1283 explicit IfBuilder(HGraphBuilder* builder, 1277 explicit IfBuilder(HGraphBuilder* builder,
1284 int position = RelocInfo::kNoPosition); 1278 int position = RelocInfo::kNoPosition);
1285 IfBuilder(HGraphBuilder* builder, 1279 IfBuilder(HGraphBuilder* builder,
1286 HIfContinuation* continuation); 1280 HIfContinuation* continuation);
1287 1281
1288 ~IfBuilder() { 1282 ~IfBuilder() {
1289 if (!finished_) End(); 1283 if (!finished_) End();
1290 } 1284 }
1291 1285
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 bool did_or_ : 1; 1395 bool did_or_ : 1;
1402 bool captured_ : 1; 1396 bool captured_ : 1;
1403 bool needs_compare_ : 1; 1397 bool needs_compare_ : 1;
1404 HBasicBlock* first_true_block_; 1398 HBasicBlock* first_true_block_;
1405 HBasicBlock* last_true_block_; 1399 HBasicBlock* last_true_block_;
1406 HBasicBlock* first_false_block_; 1400 HBasicBlock* first_false_block_;
1407 HBasicBlock* split_edge_merge_block_; 1401 HBasicBlock* split_edge_merge_block_;
1408 HBasicBlock* merge_block_; 1402 HBasicBlock* merge_block_;
1409 }; 1403 };
1410 1404
1411 class LoopBuilder V8_FINAL { 1405 class LoopBuilder {
1412 public: 1406 public:
1413 enum Direction { 1407 enum Direction {
1414 kPreIncrement, 1408 kPreIncrement,
1415 kPostIncrement, 1409 kPostIncrement,
1416 kPreDecrement, 1410 kPreDecrement,
1417 kPostDecrement 1411 kPostDecrement
1418 }; 1412 };
1419 1413
1420 LoopBuilder(HGraphBuilder* builder, 1414 LoopBuilder(HGraphBuilder* builder,
1421 HValue* context, 1415 HValue* context,
(...skipping 20 matching lines...) Expand all
1442 HBasicBlock* exit_block_; 1436 HBasicBlock* exit_block_;
1443 Direction direction_; 1437 Direction direction_;
1444 bool finished_; 1438 bool finished_;
1445 }; 1439 };
1446 1440
1447 HValue* BuildNewElementsCapacity(HValue* old_capacity); 1441 HValue* BuildNewElementsCapacity(HValue* old_capacity);
1448 1442
1449 void BuildNewSpaceArrayCheck(HValue* length, 1443 void BuildNewSpaceArrayCheck(HValue* length,
1450 ElementsKind kind); 1444 ElementsKind kind);
1451 1445
1452 class JSArrayBuilder V8_FINAL { 1446 class JSArrayBuilder {
1453 public: 1447 public:
1454 JSArrayBuilder(HGraphBuilder* builder, 1448 JSArrayBuilder(HGraphBuilder* builder,
1455 ElementsKind kind, 1449 ElementsKind kind,
1456 HValue* allocation_site_payload, 1450 HValue* allocation_site_payload,
1457 HValue* constructor_function, 1451 HValue* constructor_function,
1458 AllocationSiteOverrideMode override_mode); 1452 AllocationSiteOverrideMode override_mode);
1459 1453
1460 JSArrayBuilder(HGraphBuilder* builder, 1454 JSArrayBuilder(HGraphBuilder* builder,
1461 ElementsKind kind, 1455 ElementsKind kind,
1462 HValue* constructor_function); 1456 HValue* constructor_function);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 return AddUncasted<HReturn>(static_cast<HValue*>(value)); 1635 return AddUncasted<HReturn>(static_cast<HValue*>(value));
1642 } 1636 }
1643 1637
1644 1638
1645 template<> 1639 template<>
1646 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { 1640 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() {
1647 return HContext::New(zone()); 1641 return HContext::New(zone());
1648 } 1642 }
1649 1643
1650 1644
1651 class HOptimizedGraphBuilder V8_FINAL 1645 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
1652 : public HGraphBuilder, public AstVisitor {
1653 public: 1646 public:
1654 // A class encapsulating (lazily-allocated) break and continue blocks for 1647 // A class encapsulating (lazily-allocated) break and continue blocks for
1655 // a breakable statement. Separated from BreakAndContinueScope so that it 1648 // a breakable statement. Separated from BreakAndContinueScope so that it
1656 // can have a separate lifetime. 1649 // can have a separate lifetime.
1657 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { 1650 class BreakAndContinueInfo BASE_EMBEDDED {
1658 public: 1651 public:
1659 explicit BreakAndContinueInfo(BreakableStatement* target, 1652 explicit BreakAndContinueInfo(BreakableStatement* target,
1660 int drop_extra = 0) 1653 int drop_extra = 0)
1661 : target_(target), 1654 : target_(target),
1662 break_block_(NULL), 1655 break_block_(NULL),
1663 continue_block_(NULL), 1656 continue_block_(NULL),
1664 drop_extra_(drop_extra) { 1657 drop_extra_(drop_extra) {
1665 } 1658 }
1666 1659
1667 BreakableStatement* target() { return target_; } 1660 BreakableStatement* target() { return target_; }
1668 HBasicBlock* break_block() { return break_block_; } 1661 HBasicBlock* break_block() { return break_block_; }
1669 void set_break_block(HBasicBlock* block) { break_block_ = block; } 1662 void set_break_block(HBasicBlock* block) { break_block_ = block; }
1670 HBasicBlock* continue_block() { return continue_block_; } 1663 HBasicBlock* continue_block() { return continue_block_; }
1671 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } 1664 void set_continue_block(HBasicBlock* block) { continue_block_ = block; }
1672 int drop_extra() { return drop_extra_; } 1665 int drop_extra() { return drop_extra_; }
1673 1666
1674 private: 1667 private:
1675 BreakableStatement* target_; 1668 BreakableStatement* target_;
1676 HBasicBlock* break_block_; 1669 HBasicBlock* break_block_;
1677 HBasicBlock* continue_block_; 1670 HBasicBlock* continue_block_;
1678 int drop_extra_; 1671 int drop_extra_;
1679 }; 1672 };
1680 1673
1681 // A helper class to maintain a stack of current BreakAndContinueInfo 1674 // A helper class to maintain a stack of current BreakAndContinueInfo
1682 // structures mirroring BreakableStatement nesting. 1675 // structures mirroring BreakableStatement nesting.
1683 class BreakAndContinueScope V8_FINAL BASE_EMBEDDED { 1676 class BreakAndContinueScope BASE_EMBEDDED {
1684 public: 1677 public:
1685 BreakAndContinueScope(BreakAndContinueInfo* info, 1678 BreakAndContinueScope(BreakAndContinueInfo* info,
1686 HOptimizedGraphBuilder* owner) 1679 HOptimizedGraphBuilder* owner)
1687 : info_(info), owner_(owner), next_(owner->break_scope()) { 1680 : info_(info), owner_(owner), next_(owner->break_scope()) {
1688 owner->set_break_scope(this); 1681 owner->set_break_scope(this);
1689 } 1682 }
1690 1683
1691 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } 1684 ~BreakAndContinueScope() { owner_->set_break_scope(next_); }
1692 1685
1693 BreakAndContinueInfo* info() { return info_; } 1686 BreakAndContinueInfo* info() { return info_; }
1694 HOptimizedGraphBuilder* owner() { return owner_; } 1687 HOptimizedGraphBuilder* owner() { return owner_; }
1695 BreakAndContinueScope* next() { return next_; } 1688 BreakAndContinueScope* next() { return next_; }
1696 1689
1697 // Search the break stack for a break or continue target. 1690 // Search the break stack for a break or continue target.
1698 enum BreakType { BREAK, CONTINUE }; 1691 enum BreakType { BREAK, CONTINUE };
1699 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); 1692 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra);
1700 1693
1701 private: 1694 private:
1702 BreakAndContinueInfo* info_; 1695 BreakAndContinueInfo* info_;
1703 HOptimizedGraphBuilder* owner_; 1696 HOptimizedGraphBuilder* owner_;
1704 BreakAndContinueScope* next_; 1697 BreakAndContinueScope* next_;
1705 }; 1698 };
1706 1699
1707 explicit HOptimizedGraphBuilder(CompilationInfo* info); 1700 explicit HOptimizedGraphBuilder(CompilationInfo* info);
1708 1701
1709 virtual bool BuildGraph() V8_OVERRIDE; 1702 virtual bool BuildGraph();
1710 1703
1711 // Simple accessors. 1704 // Simple accessors.
1712 BreakAndContinueScope* break_scope() const { return break_scope_; } 1705 BreakAndContinueScope* break_scope() const { return break_scope_; }
1713 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } 1706 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
1714 1707
1715 bool inline_bailout() { return inline_bailout_; } 1708 bool inline_bailout() { return inline_bailout_; }
1716 1709
1717 HValue* context() { return environment()->context(); } 1710 HValue* context() { return environment()->context(); }
1718 1711
1719 void Bailout(BailoutReason reason); 1712 void Bailout(BailoutReason reason);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 void VisitArgumentList(ZoneList<Expression*>* arguments); 1878 void VisitArgumentList(ZoneList<Expression*>* arguments);
1886 1879
1887 // Visit a list of expressions from left to right, each in a value context. 1880 // Visit a list of expressions from left to right, each in a value context.
1888 void VisitExpressions(ZoneList<Expression*>* exprs); 1881 void VisitExpressions(ZoneList<Expression*>* exprs);
1889 1882
1890 // Remove the arguments from the bailout environment and emit instructions 1883 // Remove the arguments from the bailout environment and emit instructions
1891 // to push them as outgoing parameters. 1884 // to push them as outgoing parameters.
1892 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); 1885 template <class Instruction> HInstruction* PreProcessCall(Instruction* call);
1893 1886
1894 void SetUpScope(Scope* scope); 1887 void SetUpScope(Scope* scope);
1895 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; 1888 virtual void VisitStatements(ZoneList<Statement*>* statements);
1896 1889
1897 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; 1890 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
1898 AST_NODE_LIST(DECLARE_VISIT) 1891 AST_NODE_LIST(DECLARE_VISIT)
1899 #undef DECLARE_VISIT 1892 #undef DECLARE_VISIT
1900 1893
1901 // Helpers for flow graph construction. 1894 // Helpers for flow graph construction.
1902 enum GlobalPropertyAccess { 1895 enum GlobalPropertyAccess {
1903 kUseCell, 1896 kUseCell,
1904 kUseGeneric 1897 kUseGeneric
1905 }; 1898 };
1906 GlobalPropertyAccess LookupGlobalProperty(Variable* var, 1899 GlobalPropertyAccess LookupGlobalProperty(Variable* var,
1907 LookupResult* lookup, 1900 LookupResult* lookup,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 friend class KeyedLoadFastElementStub; 2159 friend class KeyedLoadFastElementStub;
2167 friend class HOsrBuilder; 2160 friend class HOsrBuilder;
2168 2161
2169 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); 2162 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder);
2170 }; 2163 };
2171 2164
2172 2165
2173 Zone* AstContext::zone() const { return owner_->zone(); } 2166 Zone* AstContext::zone() const { return owner_->zone(); }
2174 2167
2175 2168
2176 class HStatistics V8_FINAL: public Malloced { 2169 class HStatistics: public Malloced {
2177 public: 2170 public:
2178 HStatistics() 2171 HStatistics()
2179 : timing_(5), 2172 : timing_(5),
2180 names_(5), 2173 names_(5),
2181 sizes_(5), 2174 sizes_(5),
2182 create_graph_(0), 2175 create_graph_(0),
2183 optimize_graph_(0), 2176 optimize_graph_(0),
2184 generate_code_(0), 2177 generate_code_(0),
2185 total_size_(0), 2178 total_size_(0),
2186 full_code_gen_(0), 2179 full_code_gen_(0),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 protected: 2218 protected:
2226 HGraph* graph() const { return graph_; } 2219 HGraph* graph() const { return graph_; }
2227 2220
2228 private: 2221 private:
2229 HGraph* graph_; 2222 HGraph* graph_;
2230 2223
2231 DISALLOW_COPY_AND_ASSIGN(HPhase); 2224 DISALLOW_COPY_AND_ASSIGN(HPhase);
2232 }; 2225 };
2233 2226
2234 2227
2235 class HTracer V8_FINAL : public Malloced { 2228 class HTracer: public Malloced {
2236 public: 2229 public:
2237 explicit HTracer(int isolate_id) 2230 explicit HTracer(int isolate_id)
2238 : trace_(&string_allocator_), indent_(0) { 2231 : trace_(&string_allocator_), indent_(0) {
2239 if (FLAG_trace_hydrogen_file == NULL) { 2232 if (FLAG_trace_hydrogen_file == NULL) {
2240 OS::SNPrintF(filename_, 2233 OS::SNPrintF(filename_,
2241 "hydrogen-%d-%d.cfg", 2234 "hydrogen-%d-%d.cfg",
2242 OS::GetCurrentProcessId(), 2235 OS::GetCurrentProcessId(),
2243 isolate_id); 2236 isolate_id);
2244 } else { 2237 } else {
2245 OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length()); 2238 OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length());
2246 } 2239 }
2247 WriteChars(filename_.start(), "", 0, false); 2240 WriteChars(filename_.start(), "", 0, false);
2248 } 2241 }
2249 2242
2250 void TraceCompilation(CompilationInfo* info); 2243 void TraceCompilation(CompilationInfo* info);
2251 void TraceHydrogen(const char* name, HGraph* graph); 2244 void TraceHydrogen(const char* name, HGraph* graph);
2252 void TraceLithium(const char* name, LChunk* chunk); 2245 void TraceLithium(const char* name, LChunk* chunk);
2253 void TraceLiveRanges(const char* name, LAllocator* allocator); 2246 void TraceLiveRanges(const char* name, LAllocator* allocator);
2254 2247
2255 private: 2248 private:
2256 class Tag V8_FINAL BASE_EMBEDDED { 2249 class Tag BASE_EMBEDDED {
2257 public: 2250 public:
2258 Tag(HTracer* tracer, const char* name) { 2251 Tag(HTracer* tracer, const char* name) {
2259 name_ = name; 2252 name_ = name;
2260 tracer_ = tracer; 2253 tracer_ = tracer;
2261 tracer->PrintIndent(); 2254 tracer->PrintIndent();
2262 tracer->trace_.Add("begin_%s\n", name); 2255 tracer->trace_.Add("begin_%s\n", name);
2263 tracer->indent_++; 2256 tracer->indent_++;
2264 } 2257 }
2265 2258
2266 ~Tag() { 2259 ~Tag() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 } 2304 }
2312 } 2305 }
2313 2306
2314 EmbeddedVector<char, 64> filename_; 2307 EmbeddedVector<char, 64> filename_;
2315 HeapStringAllocator string_allocator_; 2308 HeapStringAllocator string_allocator_;
2316 StringStream trace_; 2309 StringStream trace_;
2317 int indent_; 2310 int indent_;
2318 }; 2311 };
2319 2312
2320 2313
2321 class NoObservableSideEffectsScope V8_FINAL { 2314 class NoObservableSideEffectsScope {
2322 public: 2315 public:
2323 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : 2316 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) :
2324 builder_(builder) { 2317 builder_(builder) {
2325 builder_->graph()->IncrementInNoSideEffectsScope(); 2318 builder_->graph()->IncrementInNoSideEffectsScope();
2326 } 2319 }
2327 ~NoObservableSideEffectsScope() { 2320 ~NoObservableSideEffectsScope() {
2328 builder_->graph()->DecrementInNoSideEffectsScope(); 2321 builder_->graph()->DecrementInNoSideEffectsScope();
2329 } 2322 }
2330 2323
2331 private: 2324 private:
2332 HGraphBuilder* builder_; 2325 HGraphBuilder* builder_;
2333 }; 2326 };
2334 2327
2335 2328
2336 } } // namespace v8::internal 2329 } } // namespace v8::internal
2337 2330
2338 #endif // V8_HYDROGEN_H_ 2331 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698