OLD | NEW |
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_CRANKSHAFT_HYDROGEN_H_ | 5 #ifndef V8_CRANKSHAFT_HYDROGEN_H_ |
6 #define V8_CRANKSHAFT_HYDROGEN_H_ | 6 #define V8_CRANKSHAFT_HYDROGEN_H_ |
7 | 7 |
8 #include "src/accessors.h" | 8 #include "src/accessors.h" |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/ast/ast-type-bounds.h" | 10 #include "src/ast/ast-type-bounds.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 private: | 312 private: |
313 void AddBlock(HBasicBlock* block); | 313 void AddBlock(HBasicBlock* block); |
314 | 314 |
315 ZoneList<HBasicBlock*> back_edges_; | 315 ZoneList<HBasicBlock*> back_edges_; |
316 HBasicBlock* loop_header_; | 316 HBasicBlock* loop_header_; |
317 ZoneList<HBasicBlock*> blocks_; | 317 ZoneList<HBasicBlock*> blocks_; |
318 HStackCheck* stack_check_; | 318 HStackCheck* stack_check_; |
319 }; | 319 }; |
320 | 320 |
321 struct HInlinedFunctionInfo { | |
322 explicit HInlinedFunctionInfo(int start_position) | |
323 : start_position(start_position) {} | |
324 int start_position; | |
325 }; | |
326 | |
327 class HGraph final : public ZoneObject { | 321 class HGraph final : public ZoneObject { |
328 public: | 322 public: |
329 explicit HGraph(CompilationInfo* info, CallInterfaceDescriptor descriptor); | 323 explicit HGraph(CompilationInfo* info, CallInterfaceDescriptor descriptor); |
330 | 324 |
331 Isolate* isolate() const { return isolate_; } | 325 Isolate* isolate() const { return isolate_; } |
332 Zone* zone() const { return zone_; } | 326 Zone* zone() const { return zone_; } |
333 CompilationInfo* info() const { return info_; } | 327 CompilationInfo* info() const { return info_; } |
334 CallInterfaceDescriptor descriptor() const { return descriptor_; } | 328 CallInterfaceDescriptor descriptor() const { return descriptor_; } |
335 | 329 |
336 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 330 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } | 462 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } |
469 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } | 463 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } |
470 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } | 464 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } |
471 | 465 |
472 // If we are tracking source positions then this function assigns a unique | 466 // If we are tracking source positions then this function assigns a unique |
473 // identifier to each inlining and dumps function source if it was inlined | 467 // identifier to each inlining and dumps function source if it was inlined |
474 // for the first time during the current optimization. | 468 // for the first time during the current optimization. |
475 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 469 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
476 SourcePosition position); | 470 SourcePosition position); |
477 | 471 |
478 // Converts given SourcePosition to the absolute offset from the start of | |
479 // the corresponding script. | |
480 int SourcePositionToScriptPosition(SourcePosition position); | |
481 | |
482 ZoneVector<HInlinedFunctionInfo>& inlined_function_infos() { | |
483 return inlined_function_infos_; | |
484 } | |
485 | |
486 private: | 472 private: |
487 HConstant* ReinsertConstantIfNecessary(HConstant* constant); | 473 HConstant* ReinsertConstantIfNecessary(HConstant* constant); |
488 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, | 474 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, |
489 int32_t integer_value); | 475 int32_t integer_value); |
490 | 476 |
491 template<class Phase> | 477 template<class Phase> |
492 void Run() { | 478 void Run() { |
493 Phase phase(this); | 479 Phase phase(this); |
494 phase.Run(); | 480 phase.Run(); |
495 } | 481 } |
(...skipping 25 matching lines...) Expand all Loading... |
521 | 507 |
522 bool allow_code_motion_; | 508 bool allow_code_motion_; |
523 bool use_optimistic_licm_; | 509 bool use_optimistic_licm_; |
524 bool depends_on_empty_array_proto_elements_; | 510 bool depends_on_empty_array_proto_elements_; |
525 bool depends_on_string_length_overflow_; | 511 bool depends_on_string_length_overflow_; |
526 int type_change_checksum_; | 512 int type_change_checksum_; |
527 int maximum_environment_size_; | 513 int maximum_environment_size_; |
528 int no_side_effects_scope_count_; | 514 int no_side_effects_scope_count_; |
529 bool disallow_adding_new_values_; | 515 bool disallow_adding_new_values_; |
530 | 516 |
531 ZoneVector<HInlinedFunctionInfo> inlined_function_infos_; | |
532 | |
533 DISALLOW_COPY_AND_ASSIGN(HGraph); | 517 DISALLOW_COPY_AND_ASSIGN(HGraph); |
534 }; | 518 }; |
535 | 519 |
536 | 520 |
537 Zone* HBasicBlock::zone() const { return graph_->zone(); } | 521 Zone* HBasicBlock::zone() const { return graph_->zone(); } |
538 | 522 |
539 | 523 |
540 // Type of stack frame an environment might refer to. | 524 // Type of stack frame an environment might refer to. |
541 enum FrameType { | 525 enum FrameType { |
542 JS_FUNCTION, | 526 JS_FUNCTION, |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 public: | 1050 public: |
1067 explicit HGraphBuilder(CompilationInfo* info, | 1051 explicit HGraphBuilder(CompilationInfo* info, |
1068 CallInterfaceDescriptor descriptor, | 1052 CallInterfaceDescriptor descriptor, |
1069 bool track_positions) | 1053 bool track_positions) |
1070 : info_(info), | 1054 : info_(info), |
1071 descriptor_(descriptor), | 1055 descriptor_(descriptor), |
1072 graph_(NULL), | 1056 graph_(NULL), |
1073 current_block_(NULL), | 1057 current_block_(NULL), |
1074 scope_(info->scope()), | 1058 scope_(info->scope()), |
1075 position_(SourcePosition::Unknown()), | 1059 position_(SourcePosition::Unknown()), |
1076 start_position_(0), | |
1077 track_positions_(track_positions) {} | 1060 track_positions_(track_positions) {} |
1078 virtual ~HGraphBuilder() {} | 1061 virtual ~HGraphBuilder() {} |
1079 | 1062 |
1080 Scope* scope() const { return scope_; } | 1063 Scope* scope() const { return scope_; } |
1081 void set_scope(Scope* scope) { scope_ = scope; } | 1064 void set_scope(Scope* scope) { scope_ = scope; } |
1082 | 1065 |
1083 HBasicBlock* current_block() const { return current_block_; } | 1066 HBasicBlock* current_block() const { return current_block_; } |
1084 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 1067 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
1085 HEnvironment* environment() const { | 1068 HEnvironment* environment() const { |
1086 return current_block()->last_environment(); | 1069 return current_block()->last_environment(); |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 | 1820 |
1838 HInstruction* BuildGetArrayFunction(); | 1821 HInstruction* BuildGetArrayFunction(); |
1839 HValue* BuildArrayBufferViewFieldAccessor(HValue* object, | 1822 HValue* BuildArrayBufferViewFieldAccessor(HValue* object, |
1840 HValue* checked_object, | 1823 HValue* checked_object, |
1841 FieldIndex index); | 1824 FieldIndex index); |
1842 | 1825 |
1843 | 1826 |
1844 protected: | 1827 protected: |
1845 void SetSourcePosition(int position) { | 1828 void SetSourcePosition(int position) { |
1846 if (position != kNoSourcePosition) { | 1829 if (position != kNoSourcePosition) { |
1847 position_.set_position(position - start_position_); | 1830 position_.SetScriptOffset(position); |
1848 } | 1831 } |
1849 // Otherwise position remains unknown. | 1832 // Otherwise position remains unknown. |
1850 } | 1833 } |
1851 | 1834 |
1852 void EnterInlinedSource(int start_position, int id) { | 1835 void EnterInlinedSource(int inlining_id) { |
1853 if (is_tracking_positions()) { | 1836 if (is_tracking_positions()) { |
1854 start_position_ = start_position; | 1837 position_.SetInliningId(inlining_id); |
1855 position_.set_inlining_id(id); | |
1856 } | 1838 } |
1857 } | 1839 } |
1858 | 1840 |
1859 // Convert the given absolute offset from the start of the script to | 1841 // Convert the given absolute offset from the start of the script to |
1860 // the SourcePosition assuming that this position corresponds to the | 1842 // the SourcePosition assuming that this position corresponds to the |
1861 // same function as current position_. | 1843 // same function as position_. |
1862 SourcePosition ScriptPositionToSourcePosition(int position) { | 1844 SourcePosition ScriptPositionToSourcePosition(int position) { |
1863 if (position == kNoSourcePosition) { | 1845 if (position == kNoSourcePosition) { |
1864 return SourcePosition::Unknown(); | 1846 return SourcePosition::Unknown(); |
1865 } | 1847 } |
1866 SourcePosition pos = position_; | 1848 return SourcePosition(position, position_.InliningId()); |
1867 pos.set_position(position - start_position_); | |
1868 return pos; | |
1869 } | 1849 } |
1870 | 1850 |
1871 SourcePosition source_position() { return position_; } | 1851 SourcePosition source_position() { return position_; } |
1872 void set_source_position(SourcePosition position) { position_ = position; } | 1852 void set_source_position(SourcePosition position) { position_ = position; } |
1873 | 1853 |
1874 bool is_tracking_positions() { return track_positions_; } | 1854 bool is_tracking_positions() { return track_positions_; } |
1875 | 1855 |
1876 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 1856 void TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
1877 SourcePosition position); | 1857 SourcePosition position, int inlining_id); |
1878 | 1858 |
1879 HValue* BuildAllocateEmptyArrayBuffer(HValue* byte_length); | 1859 HValue* BuildAllocateEmptyArrayBuffer(HValue* byte_length); |
1880 template <typename ViewClass> | 1860 template <typename ViewClass> |
1881 void BuildArrayBufferViewInitialization(HValue* obj, | 1861 void BuildArrayBufferViewInitialization(HValue* obj, |
1882 HValue* buffer, | 1862 HValue* buffer, |
1883 HValue* byte_offset, | 1863 HValue* byte_offset, |
1884 HValue* byte_length); | 1864 HValue* byte_length); |
1885 | 1865 |
1886 private: | 1866 private: |
1887 HGraphBuilder(); | 1867 HGraphBuilder(); |
1888 | 1868 |
1889 template <class I> | 1869 template <class I> |
1890 I* AddInstructionTyped(I* instr) { | 1870 I* AddInstructionTyped(I* instr) { |
1891 return I::cast(AddInstruction(instr)); | 1871 return I::cast(AddInstruction(instr)); |
1892 } | 1872 } |
1893 | 1873 |
1894 CompilationInfo* info_; | 1874 CompilationInfo* info_; |
1895 CallInterfaceDescriptor descriptor_; | 1875 CallInterfaceDescriptor descriptor_; |
1896 HGraph* graph_; | 1876 HGraph* graph_; |
1897 HBasicBlock* current_block_; | 1877 HBasicBlock* current_block_; |
1898 Scope* scope_; | 1878 Scope* scope_; |
1899 SourcePosition position_; | 1879 SourcePosition position_; |
1900 int start_position_; | |
1901 bool track_positions_; | 1880 bool track_positions_; |
1902 }; | 1881 }; |
1903 | 1882 |
1904 template <> | 1883 template <> |
1905 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( | 1884 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( |
1906 DeoptimizeReason reason, Deoptimizer::BailoutType type) { | 1885 DeoptimizeReason reason, Deoptimizer::BailoutType type) { |
1907 if (type == Deoptimizer::SOFT) { | 1886 if (type == Deoptimizer::SOFT) { |
1908 isolate()->counters()->soft_deopts_requested()->Increment(); | 1887 isolate()->counters()->soft_deopts_requested()->Increment(); |
1909 if (FLAG_always_opt) return NULL; | 1888 if (FLAG_always_opt) return NULL; |
1910 } | 1889 } |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 } | 2987 } |
3009 | 2988 |
3010 private: | 2989 private: |
3011 HOptimizedGraphBuilder* builder_; | 2990 HOptimizedGraphBuilder* builder_; |
3012 }; | 2991 }; |
3013 | 2992 |
3014 } // namespace internal | 2993 } // namespace internal |
3015 } // namespace v8 | 2994 } // namespace v8 |
3016 | 2995 |
3017 #endif // V8_CRANKSHAFT_HYDROGEN_H_ | 2996 #endif // V8_CRANKSHAFT_HYDROGEN_H_ |
OLD | NEW |