| OLD | NEW |
| 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 Loading... |
| 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: public ZoneObject { | 56 class HBasicBlock V8_FINAL : public ZoneObject { |
| 57 public: | 57 public: |
| 58 explicit HBasicBlock(HGraph* graph); | 58 explicit HBasicBlock(HGraph* graph); |
| 59 virtual ~HBasicBlock() { } | 59 ~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 Loading... |
| 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 BASE_EMBEDDED { | 223 class HPredecessorIterator V8_FINAL 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 BASE_EMBEDDED { | 238 class HInstructionIterator V8_FINAL 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: public ZoneObject { | 258 class HLoopInformation V8_FINAL : 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 virtual ~HLoopInformation() {} | 267 ~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 Loading... |
| 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: public ZoneObject { | 306 class HGraph V8_FINAL : 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 Loading... |
| 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: public ZoneObject { | 526 class HEnvironment V8_FINAL : 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 Loading... |
| 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: public AstContext { | 796 class EffectContext V8_FINAL : 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); | 803 virtual void ReturnValue(HValue* value) V8_OVERRIDE; |
| 804 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 804 virtual void ReturnInstruction(HInstruction* instr, |
| 805 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 805 BailoutId ast_id) V8_OVERRIDE; |
| 806 virtual void ReturnControl(HControlInstruction* instr, |
| 807 BailoutId ast_id) V8_OVERRIDE; |
| 806 virtual void ReturnContinuation(HIfContinuation* continuation, | 808 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 807 BailoutId ast_id); | 809 BailoutId ast_id) V8_OVERRIDE; |
| 808 }; | 810 }; |
| 809 | 811 |
| 810 | 812 |
| 811 class ValueContext: public AstContext { | 813 class ValueContext V8_FINAL : public AstContext { |
| 812 public: | 814 public: |
| 813 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) | 815 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) |
| 814 : AstContext(owner, Expression::kValue), flag_(flag) { | 816 : AstContext(owner, Expression::kValue), flag_(flag) { |
| 815 } | 817 } |
| 816 virtual ~ValueContext(); | 818 virtual ~ValueContext(); |
| 817 | 819 |
| 818 virtual void ReturnValue(HValue* value); | 820 virtual void ReturnValue(HValue* value) V8_OVERRIDE; |
| 819 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 821 virtual void ReturnInstruction(HInstruction* instr, |
| 820 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 822 BailoutId ast_id) V8_OVERRIDE; |
| 823 virtual void ReturnControl(HControlInstruction* instr, |
| 824 BailoutId ast_id) V8_OVERRIDE; |
| 821 virtual void ReturnContinuation(HIfContinuation* continuation, | 825 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 822 BailoutId ast_id); | 826 BailoutId ast_id) V8_OVERRIDE; |
| 823 | 827 |
| 824 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } | 828 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } |
| 825 | 829 |
| 826 private: | 830 private: |
| 827 ArgumentsAllowedFlag flag_; | 831 ArgumentsAllowedFlag flag_; |
| 828 }; | 832 }; |
| 829 | 833 |
| 830 | 834 |
| 831 class TestContext: public AstContext { | 835 class TestContext V8_FINAL : public AstContext { |
| 832 public: | 836 public: |
| 833 TestContext(HOptimizedGraphBuilder* owner, | 837 TestContext(HOptimizedGraphBuilder* owner, |
| 834 Expression* condition, | 838 Expression* condition, |
| 835 HBasicBlock* if_true, | 839 HBasicBlock* if_true, |
| 836 HBasicBlock* if_false) | 840 HBasicBlock* if_false) |
| 837 : AstContext(owner, Expression::kTest), | 841 : AstContext(owner, Expression::kTest), |
| 838 condition_(condition), | 842 condition_(condition), |
| 839 if_true_(if_true), | 843 if_true_(if_true), |
| 840 if_false_(if_false) { | 844 if_false_(if_false) { |
| 841 } | 845 } |
| 842 | 846 |
| 843 virtual void ReturnValue(HValue* value); | 847 virtual void ReturnValue(HValue* value) V8_OVERRIDE; |
| 844 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 848 virtual void ReturnInstruction(HInstruction* instr, |
| 845 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 849 BailoutId ast_id) V8_OVERRIDE; |
| 850 virtual void ReturnControl(HControlInstruction* instr, |
| 851 BailoutId ast_id) V8_OVERRIDE; |
| 846 virtual void ReturnContinuation(HIfContinuation* continuation, | 852 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 847 BailoutId ast_id); | 853 BailoutId ast_id) V8_OVERRIDE; |
| 848 | 854 |
| 849 static TestContext* cast(AstContext* context) { | 855 static TestContext* cast(AstContext* context) { |
| 850 ASSERT(context->IsTest()); | 856 ASSERT(context->IsTest()); |
| 851 return reinterpret_cast<TestContext*>(context); | 857 return reinterpret_cast<TestContext*>(context); |
| 852 } | 858 } |
| 853 | 859 |
| 854 Expression* condition() const { return condition_; } | 860 Expression* condition() const { return condition_; } |
| 855 HBasicBlock* if_true() const { return if_true_; } | 861 HBasicBlock* if_true() const { return if_true_; } |
| 856 HBasicBlock* if_false() const { return if_false_; } | 862 HBasicBlock* if_false() const { return if_false_; } |
| 857 | 863 |
| 858 private: | 864 private: |
| 859 // Build the shared core part of the translation unpacking a value into | 865 // Build the shared core part of the translation unpacking a value into |
| 860 // control flow. | 866 // control flow. |
| 861 void BuildBranch(HValue* value); | 867 void BuildBranch(HValue* value); |
| 862 | 868 |
| 863 Expression* condition_; | 869 Expression* condition_; |
| 864 HBasicBlock* if_true_; | 870 HBasicBlock* if_true_; |
| 865 HBasicBlock* if_false_; | 871 HBasicBlock* if_false_; |
| 866 }; | 872 }; |
| 867 | 873 |
| 868 | 874 |
| 869 class FunctionState { | 875 class FunctionState V8_FINAL { |
| 870 public: | 876 public: |
| 871 FunctionState(HOptimizedGraphBuilder* owner, | 877 FunctionState(HOptimizedGraphBuilder* owner, |
| 872 CompilationInfo* info, | 878 CompilationInfo* info, |
| 873 InliningKind inlining_kind); | 879 InliningKind inlining_kind); |
| 874 ~FunctionState(); | 880 ~FunctionState(); |
| 875 | 881 |
| 876 CompilationInfo* compilation_info() { return compilation_info_; } | 882 CompilationInfo* compilation_info() { return compilation_info_; } |
| 877 AstContext* call_context() { return call_context_; } | 883 AstContext* call_context() { return call_context_; } |
| 878 InliningKind inlining_kind() const { return inlining_kind_; } | 884 InliningKind inlining_kind() const { return inlining_kind_; } |
| 879 HBasicBlock* function_return() { return function_return_; } | 885 HBasicBlock* function_return() { return function_return_; } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 // entry. | 932 // entry. |
| 927 HEnterInlined* entry_; | 933 HEnterInlined* entry_; |
| 928 | 934 |
| 929 HArgumentsObject* arguments_object_; | 935 HArgumentsObject* arguments_object_; |
| 930 HArgumentsElements* arguments_elements_; | 936 HArgumentsElements* arguments_elements_; |
| 931 | 937 |
| 932 FunctionState* outer_; | 938 FunctionState* outer_; |
| 933 }; | 939 }; |
| 934 | 940 |
| 935 | 941 |
| 936 class HIfContinuation { | 942 class HIfContinuation V8_FINAL { |
| 937 public: | 943 public: |
| 938 HIfContinuation() { continuation_captured_ = false; } | 944 HIfContinuation() { continuation_captured_ = false; } |
| 939 ~HIfContinuation() { ASSERT(!continuation_captured_); } | 945 ~HIfContinuation() { ASSERT(!continuation_captured_); } |
| 940 | 946 |
| 941 void Capture(HBasicBlock* true_branch, | 947 void Capture(HBasicBlock* true_branch, |
| 942 HBasicBlock* false_branch, | 948 HBasicBlock* false_branch, |
| 943 int position) { | 949 int position) { |
| 944 ASSERT(!continuation_captured_); | 950 ASSERT(!continuation_captured_); |
| 945 true_branch_ = true_branch; | 951 true_branch_ = true_branch; |
| 946 false_branch_ = false_branch; | 952 false_branch_ = false_branch; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); | 1271 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); |
| 1266 | 1272 |
| 1267 void PushAndAdd(HInstruction* instr); | 1273 void PushAndAdd(HInstruction* instr); |
| 1268 | 1274 |
| 1269 void FinishExitWithHardDeoptimization(const char* reason, | 1275 void FinishExitWithHardDeoptimization(const char* reason, |
| 1270 HBasicBlock* continuation); | 1276 HBasicBlock* continuation); |
| 1271 | 1277 |
| 1272 void AddIncrementCounter(StatsCounter* counter, | 1278 void AddIncrementCounter(StatsCounter* counter, |
| 1273 HValue* context); | 1279 HValue* context); |
| 1274 | 1280 |
| 1275 class IfBuilder { | 1281 class IfBuilder V8_FINAL { |
| 1276 public: | 1282 public: |
| 1277 explicit IfBuilder(HGraphBuilder* builder, | 1283 explicit IfBuilder(HGraphBuilder* builder, |
| 1278 int position = RelocInfo::kNoPosition); | 1284 int position = RelocInfo::kNoPosition); |
| 1279 IfBuilder(HGraphBuilder* builder, | 1285 IfBuilder(HGraphBuilder* builder, |
| 1280 HIfContinuation* continuation); | 1286 HIfContinuation* continuation); |
| 1281 | 1287 |
| 1282 ~IfBuilder() { | 1288 ~IfBuilder() { |
| 1283 if (!finished_) End(); | 1289 if (!finished_) End(); |
| 1284 } | 1290 } |
| 1285 | 1291 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 bool did_or_ : 1; | 1401 bool did_or_ : 1; |
| 1396 bool captured_ : 1; | 1402 bool captured_ : 1; |
| 1397 bool needs_compare_ : 1; | 1403 bool needs_compare_ : 1; |
| 1398 HBasicBlock* first_true_block_; | 1404 HBasicBlock* first_true_block_; |
| 1399 HBasicBlock* last_true_block_; | 1405 HBasicBlock* last_true_block_; |
| 1400 HBasicBlock* first_false_block_; | 1406 HBasicBlock* first_false_block_; |
| 1401 HBasicBlock* split_edge_merge_block_; | 1407 HBasicBlock* split_edge_merge_block_; |
| 1402 HBasicBlock* merge_block_; | 1408 HBasicBlock* merge_block_; |
| 1403 }; | 1409 }; |
| 1404 | 1410 |
| 1405 class LoopBuilder { | 1411 class LoopBuilder V8_FINAL { |
| 1406 public: | 1412 public: |
| 1407 enum Direction { | 1413 enum Direction { |
| 1408 kPreIncrement, | 1414 kPreIncrement, |
| 1409 kPostIncrement, | 1415 kPostIncrement, |
| 1410 kPreDecrement, | 1416 kPreDecrement, |
| 1411 kPostDecrement | 1417 kPostDecrement |
| 1412 }; | 1418 }; |
| 1413 | 1419 |
| 1414 LoopBuilder(HGraphBuilder* builder, | 1420 LoopBuilder(HGraphBuilder* builder, |
| 1415 HValue* context, | 1421 HValue* context, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1436 HBasicBlock* exit_block_; | 1442 HBasicBlock* exit_block_; |
| 1437 Direction direction_; | 1443 Direction direction_; |
| 1438 bool finished_; | 1444 bool finished_; |
| 1439 }; | 1445 }; |
| 1440 | 1446 |
| 1441 HValue* BuildNewElementsCapacity(HValue* old_capacity); | 1447 HValue* BuildNewElementsCapacity(HValue* old_capacity); |
| 1442 | 1448 |
| 1443 void BuildNewSpaceArrayCheck(HValue* length, | 1449 void BuildNewSpaceArrayCheck(HValue* length, |
| 1444 ElementsKind kind); | 1450 ElementsKind kind); |
| 1445 | 1451 |
| 1446 class JSArrayBuilder { | 1452 class JSArrayBuilder V8_FINAL { |
| 1447 public: | 1453 public: |
| 1448 JSArrayBuilder(HGraphBuilder* builder, | 1454 JSArrayBuilder(HGraphBuilder* builder, |
| 1449 ElementsKind kind, | 1455 ElementsKind kind, |
| 1450 HValue* allocation_site_payload, | 1456 HValue* allocation_site_payload, |
| 1451 HValue* constructor_function, | 1457 HValue* constructor_function, |
| 1452 AllocationSiteOverrideMode override_mode); | 1458 AllocationSiteOverrideMode override_mode); |
| 1453 | 1459 |
| 1454 JSArrayBuilder(HGraphBuilder* builder, | 1460 JSArrayBuilder(HGraphBuilder* builder, |
| 1455 ElementsKind kind, | 1461 ElementsKind kind, |
| 1456 HValue* constructor_function); | 1462 HValue* constructor_function); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 return AddUncasted<HReturn>(static_cast<HValue*>(value)); | 1641 return AddUncasted<HReturn>(static_cast<HValue*>(value)); |
| 1636 } | 1642 } |
| 1637 | 1643 |
| 1638 | 1644 |
| 1639 template<> | 1645 template<> |
| 1640 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { | 1646 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { |
| 1641 return HContext::New(zone()); | 1647 return HContext::New(zone()); |
| 1642 } | 1648 } |
| 1643 | 1649 |
| 1644 | 1650 |
| 1645 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1651 class HOptimizedGraphBuilder V8_FINAL |
| 1652 : public HGraphBuilder, public AstVisitor { |
| 1646 public: | 1653 public: |
| 1647 // A class encapsulating (lazily-allocated) break and continue blocks for | 1654 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 1648 // a breakable statement. Separated from BreakAndContinueScope so that it | 1655 // a breakable statement. Separated from BreakAndContinueScope so that it |
| 1649 // can have a separate lifetime. | 1656 // can have a separate lifetime. |
| 1650 class BreakAndContinueInfo BASE_EMBEDDED { | 1657 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { |
| 1651 public: | 1658 public: |
| 1652 explicit BreakAndContinueInfo(BreakableStatement* target, | 1659 explicit BreakAndContinueInfo(BreakableStatement* target, |
| 1653 int drop_extra = 0) | 1660 int drop_extra = 0) |
| 1654 : target_(target), | 1661 : target_(target), |
| 1655 break_block_(NULL), | 1662 break_block_(NULL), |
| 1656 continue_block_(NULL), | 1663 continue_block_(NULL), |
| 1657 drop_extra_(drop_extra) { | 1664 drop_extra_(drop_extra) { |
| 1658 } | 1665 } |
| 1659 | 1666 |
| 1660 BreakableStatement* target() { return target_; } | 1667 BreakableStatement* target() { return target_; } |
| 1661 HBasicBlock* break_block() { return break_block_; } | 1668 HBasicBlock* break_block() { return break_block_; } |
| 1662 void set_break_block(HBasicBlock* block) { break_block_ = block; } | 1669 void set_break_block(HBasicBlock* block) { break_block_ = block; } |
| 1663 HBasicBlock* continue_block() { return continue_block_; } | 1670 HBasicBlock* continue_block() { return continue_block_; } |
| 1664 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } | 1671 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } |
| 1665 int drop_extra() { return drop_extra_; } | 1672 int drop_extra() { return drop_extra_; } |
| 1666 | 1673 |
| 1667 private: | 1674 private: |
| 1668 BreakableStatement* target_; | 1675 BreakableStatement* target_; |
| 1669 HBasicBlock* break_block_; | 1676 HBasicBlock* break_block_; |
| 1670 HBasicBlock* continue_block_; | 1677 HBasicBlock* continue_block_; |
| 1671 int drop_extra_; | 1678 int drop_extra_; |
| 1672 }; | 1679 }; |
| 1673 | 1680 |
| 1674 // A helper class to maintain a stack of current BreakAndContinueInfo | 1681 // A helper class to maintain a stack of current BreakAndContinueInfo |
| 1675 // structures mirroring BreakableStatement nesting. | 1682 // structures mirroring BreakableStatement nesting. |
| 1676 class BreakAndContinueScope BASE_EMBEDDED { | 1683 class BreakAndContinueScope V8_FINAL BASE_EMBEDDED { |
| 1677 public: | 1684 public: |
| 1678 BreakAndContinueScope(BreakAndContinueInfo* info, | 1685 BreakAndContinueScope(BreakAndContinueInfo* info, |
| 1679 HOptimizedGraphBuilder* owner) | 1686 HOptimizedGraphBuilder* owner) |
| 1680 : info_(info), owner_(owner), next_(owner->break_scope()) { | 1687 : info_(info), owner_(owner), next_(owner->break_scope()) { |
| 1681 owner->set_break_scope(this); | 1688 owner->set_break_scope(this); |
| 1682 } | 1689 } |
| 1683 | 1690 |
| 1684 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } | 1691 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } |
| 1685 | 1692 |
| 1686 BreakAndContinueInfo* info() { return info_; } | 1693 BreakAndContinueInfo* info() { return info_; } |
| 1687 HOptimizedGraphBuilder* owner() { return owner_; } | 1694 HOptimizedGraphBuilder* owner() { return owner_; } |
| 1688 BreakAndContinueScope* next() { return next_; } | 1695 BreakAndContinueScope* next() { return next_; } |
| 1689 | 1696 |
| 1690 // Search the break stack for a break or continue target. | 1697 // Search the break stack for a break or continue target. |
| 1691 enum BreakType { BREAK, CONTINUE }; | 1698 enum BreakType { BREAK, CONTINUE }; |
| 1692 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); | 1699 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); |
| 1693 | 1700 |
| 1694 private: | 1701 private: |
| 1695 BreakAndContinueInfo* info_; | 1702 BreakAndContinueInfo* info_; |
| 1696 HOptimizedGraphBuilder* owner_; | 1703 HOptimizedGraphBuilder* owner_; |
| 1697 BreakAndContinueScope* next_; | 1704 BreakAndContinueScope* next_; |
| 1698 }; | 1705 }; |
| 1699 | 1706 |
| 1700 explicit HOptimizedGraphBuilder(CompilationInfo* info); | 1707 explicit HOptimizedGraphBuilder(CompilationInfo* info); |
| 1701 | 1708 |
| 1702 virtual bool BuildGraph(); | 1709 virtual bool BuildGraph() V8_OVERRIDE; |
| 1703 | 1710 |
| 1704 // Simple accessors. | 1711 // Simple accessors. |
| 1705 BreakAndContinueScope* break_scope() const { return break_scope_; } | 1712 BreakAndContinueScope* break_scope() const { return break_scope_; } |
| 1706 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 1713 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
| 1707 | 1714 |
| 1708 bool inline_bailout() { return inline_bailout_; } | 1715 bool inline_bailout() { return inline_bailout_; } |
| 1709 | 1716 |
| 1710 HValue* context() { return environment()->context(); } | 1717 HValue* context() { return environment()->context(); } |
| 1711 | 1718 |
| 1712 void Bailout(BailoutReason reason); | 1719 void Bailout(BailoutReason reason); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 void VisitArgumentList(ZoneList<Expression*>* arguments); | 1885 void VisitArgumentList(ZoneList<Expression*>* arguments); |
| 1879 | 1886 |
| 1880 // Visit a list of expressions from left to right, each in a value context. | 1887 // Visit a list of expressions from left to right, each in a value context. |
| 1881 void VisitExpressions(ZoneList<Expression*>* exprs); | 1888 void VisitExpressions(ZoneList<Expression*>* exprs); |
| 1882 | 1889 |
| 1883 // Remove the arguments from the bailout environment and emit instructions | 1890 // Remove the arguments from the bailout environment and emit instructions |
| 1884 // to push them as outgoing parameters. | 1891 // to push them as outgoing parameters. |
| 1885 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); | 1892 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); |
| 1886 | 1893 |
| 1887 void SetUpScope(Scope* scope); | 1894 void SetUpScope(Scope* scope); |
| 1888 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1895 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; |
| 1889 | 1896 |
| 1890 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 1897 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; |
| 1891 AST_NODE_LIST(DECLARE_VISIT) | 1898 AST_NODE_LIST(DECLARE_VISIT) |
| 1892 #undef DECLARE_VISIT | 1899 #undef DECLARE_VISIT |
| 1893 | 1900 |
| 1894 // Helpers for flow graph construction. | 1901 // Helpers for flow graph construction. |
| 1895 enum GlobalPropertyAccess { | 1902 enum GlobalPropertyAccess { |
| 1896 kUseCell, | 1903 kUseCell, |
| 1897 kUseGeneric | 1904 kUseGeneric |
| 1898 }; | 1905 }; |
| 1899 GlobalPropertyAccess LookupGlobalProperty(Variable* var, | 1906 GlobalPropertyAccess LookupGlobalProperty(Variable* var, |
| 1900 LookupResult* lookup, | 1907 LookupResult* lookup, |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 friend class KeyedLoadFastElementStub; | 2166 friend class KeyedLoadFastElementStub; |
| 2160 friend class HOsrBuilder; | 2167 friend class HOsrBuilder; |
| 2161 | 2168 |
| 2162 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); | 2169 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); |
| 2163 }; | 2170 }; |
| 2164 | 2171 |
| 2165 | 2172 |
| 2166 Zone* AstContext::zone() const { return owner_->zone(); } | 2173 Zone* AstContext::zone() const { return owner_->zone(); } |
| 2167 | 2174 |
| 2168 | 2175 |
| 2169 class HStatistics: public Malloced { | 2176 class HStatistics V8_FINAL: public Malloced { |
| 2170 public: | 2177 public: |
| 2171 HStatistics() | 2178 HStatistics() |
| 2172 : timing_(5), | 2179 : timing_(5), |
| 2173 names_(5), | 2180 names_(5), |
| 2174 sizes_(5), | 2181 sizes_(5), |
| 2175 create_graph_(0), | 2182 create_graph_(0), |
| 2176 optimize_graph_(0), | 2183 optimize_graph_(0), |
| 2177 generate_code_(0), | 2184 generate_code_(0), |
| 2178 total_size_(0), | 2185 total_size_(0), |
| 2179 full_code_gen_(0), | 2186 full_code_gen_(0), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 protected: | 2225 protected: |
| 2219 HGraph* graph() const { return graph_; } | 2226 HGraph* graph() const { return graph_; } |
| 2220 | 2227 |
| 2221 private: | 2228 private: |
| 2222 HGraph* graph_; | 2229 HGraph* graph_; |
| 2223 | 2230 |
| 2224 DISALLOW_COPY_AND_ASSIGN(HPhase); | 2231 DISALLOW_COPY_AND_ASSIGN(HPhase); |
| 2225 }; | 2232 }; |
| 2226 | 2233 |
| 2227 | 2234 |
| 2228 class HTracer: public Malloced { | 2235 class HTracer V8_FINAL : public Malloced { |
| 2229 public: | 2236 public: |
| 2230 explicit HTracer(int isolate_id) | 2237 explicit HTracer(int isolate_id) |
| 2231 : trace_(&string_allocator_), indent_(0) { | 2238 : trace_(&string_allocator_), indent_(0) { |
| 2232 if (FLAG_trace_hydrogen_file == NULL) { | 2239 if (FLAG_trace_hydrogen_file == NULL) { |
| 2233 OS::SNPrintF(filename_, | 2240 OS::SNPrintF(filename_, |
| 2234 "hydrogen-%d-%d.cfg", | 2241 "hydrogen-%d-%d.cfg", |
| 2235 OS::GetCurrentProcessId(), | 2242 OS::GetCurrentProcessId(), |
| 2236 isolate_id); | 2243 isolate_id); |
| 2237 } else { | 2244 } else { |
| 2238 OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length()); | 2245 OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length()); |
| 2239 } | 2246 } |
| 2240 WriteChars(filename_.start(), "", 0, false); | 2247 WriteChars(filename_.start(), "", 0, false); |
| 2241 } | 2248 } |
| 2242 | 2249 |
| 2243 void TraceCompilation(CompilationInfo* info); | 2250 void TraceCompilation(CompilationInfo* info); |
| 2244 void TraceHydrogen(const char* name, HGraph* graph); | 2251 void TraceHydrogen(const char* name, HGraph* graph); |
| 2245 void TraceLithium(const char* name, LChunk* chunk); | 2252 void TraceLithium(const char* name, LChunk* chunk); |
| 2246 void TraceLiveRanges(const char* name, LAllocator* allocator); | 2253 void TraceLiveRanges(const char* name, LAllocator* allocator); |
| 2247 | 2254 |
| 2248 private: | 2255 private: |
| 2249 class Tag BASE_EMBEDDED { | 2256 class Tag V8_FINAL BASE_EMBEDDED { |
| 2250 public: | 2257 public: |
| 2251 Tag(HTracer* tracer, const char* name) { | 2258 Tag(HTracer* tracer, const char* name) { |
| 2252 name_ = name; | 2259 name_ = name; |
| 2253 tracer_ = tracer; | 2260 tracer_ = tracer; |
| 2254 tracer->PrintIndent(); | 2261 tracer->PrintIndent(); |
| 2255 tracer->trace_.Add("begin_%s\n", name); | 2262 tracer->trace_.Add("begin_%s\n", name); |
| 2256 tracer->indent_++; | 2263 tracer->indent_++; |
| 2257 } | 2264 } |
| 2258 | 2265 |
| 2259 ~Tag() { | 2266 ~Tag() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 } | 2311 } |
| 2305 } | 2312 } |
| 2306 | 2313 |
| 2307 EmbeddedVector<char, 64> filename_; | 2314 EmbeddedVector<char, 64> filename_; |
| 2308 HeapStringAllocator string_allocator_; | 2315 HeapStringAllocator string_allocator_; |
| 2309 StringStream trace_; | 2316 StringStream trace_; |
| 2310 int indent_; | 2317 int indent_; |
| 2311 }; | 2318 }; |
| 2312 | 2319 |
| 2313 | 2320 |
| 2314 class NoObservableSideEffectsScope { | 2321 class NoObservableSideEffectsScope V8_FINAL { |
| 2315 public: | 2322 public: |
| 2316 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : | 2323 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : |
| 2317 builder_(builder) { | 2324 builder_(builder) { |
| 2318 builder_->graph()->IncrementInNoSideEffectsScope(); | 2325 builder_->graph()->IncrementInNoSideEffectsScope(); |
| 2319 } | 2326 } |
| 2320 ~NoObservableSideEffectsScope() { | 2327 ~NoObservableSideEffectsScope() { |
| 2321 builder_->graph()->DecrementInNoSideEffectsScope(); | 2328 builder_->graph()->DecrementInNoSideEffectsScope(); |
| 2322 } | 2329 } |
| 2323 | 2330 |
| 2324 private: | 2331 private: |
| 2325 HGraphBuilder* builder_; | 2332 HGraphBuilder* builder_; |
| 2326 }; | 2333 }; |
| 2327 | 2334 |
| 2328 | 2335 |
| 2329 } } // namespace v8::internal | 2336 } } // namespace v8::internal |
| 2330 | 2337 |
| 2331 #endif // V8_HYDROGEN_H_ | 2338 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |