Chromium Code Reviews| 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_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
| 6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast.h" | 9 #include "src/ast.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression. | 23 ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression. |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 struct OffsetRange { | 26 struct OffsetRange { |
| 27 OffsetRange(int from, int to) : from(from), to(to) {} | 27 OffsetRange(int from, int to) : from(from), to(to) {} |
| 28 int from; | 28 int from; |
| 29 int to; | 29 int to; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 | 32 |
| 33 // This class encapsulates encoding and decoding of sources positions from | |
| 34 // which hydrogen values originated. | |
| 35 // When FLAG_track_hydrogen_positions is set this object encodes the | |
| 36 // identifier of the inlining and absolute offset from the start of the | |
| 37 // inlined function. | |
| 38 // When the flag is not set we simply track absolute offset from the | |
| 39 // script start. | |
| 40 class SourcePosition { | |
| 41 public: | |
| 42 SourcePosition(const SourcePosition& other) : value_(other.value_) {} | |
| 43 | |
| 44 static SourcePosition Unknown() { | |
| 45 return SourcePosition(RelocInfo::kNoPosition); | |
| 46 } | |
| 47 | |
| 48 bool IsUnknown() const { return value_ == RelocInfo::kNoPosition; } | |
| 49 | |
| 50 int position() const { return PositionField::decode(value_); } | |
| 51 void set_position(int position) { | |
| 52 if (FLAG_hydrogen_track_positions) { | |
| 53 value_ = static_cast<int>(PositionField::update(value_, position)); | |
| 54 } else { | |
| 55 value_ = position; | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 int inlining_id() const { return InliningIdField::decode(value_); } | |
| 60 void set_inlining_id(int inlining_id) { | |
| 61 if (FLAG_hydrogen_track_positions) { | |
| 62 value_ = static_cast<int>(InliningIdField::update(value_, inlining_id)); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 int raw() const { return value_; } | |
| 67 | |
| 68 private: | |
| 69 typedef BitField<int, 0, 9> InliningIdField; | |
| 70 | |
| 71 // Offset from the start of the inlined function. | |
| 72 typedef BitField<int, 9, 23> PositionField; | |
| 73 | |
| 74 explicit SourcePosition(int value) : value_(value) {} | |
| 75 | |
| 76 friend class HPositionInfo; | |
| 77 friend class LCodeGenBase; | |
| 78 | |
| 79 // If FLAG_hydrogen_track_positions is set contains bitfields InliningIdField | |
| 80 // and PositionField. | |
| 81 // Otherwise contains absolute offset from the script start. | |
| 82 int value_; | |
|
Sven Panne
2015/02/17 11:08:03
What I meant in previous comments is that "int" is
| |
| 83 }; | |
| 84 | |
| 85 | |
| 86 std::ostream& operator<<(std::ostream& os, const SourcePosition& p); | |
| 87 | |
| 88 | |
| 33 class InlinedFunctionInfo { | 89 class InlinedFunctionInfo { |
| 34 public: | 90 public: |
| 35 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared) | 91 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared) |
| 36 : shared_(shared), start_position_(shared->start_position()) {} | 92 : shared_(shared), start_position_(shared->start_position()) {} |
| 37 | 93 |
| 38 Handle<SharedFunctionInfo> shared() const { return shared_; } | 94 Handle<SharedFunctionInfo> shared() const { return shared_; } |
| 39 int start_position() const { return start_position_; } | 95 int start_position() const { return start_position_; } |
| 40 | 96 |
| 41 private: | 97 private: |
| 42 Handle<SharedFunctionInfo> shared_; | 98 Handle<SharedFunctionInfo> shared_; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 no_frame_ranges_ = NULL; | 452 no_frame_ranges_ = NULL; |
| 397 return result; | 453 return result; |
| 398 } | 454 } |
| 399 | 455 |
| 400 List<InlinedFunctionInfo>* inlined_function_infos() { | 456 List<InlinedFunctionInfo>* inlined_function_infos() { |
| 401 return inlined_function_infos_; | 457 return inlined_function_infos_; |
| 402 } | 458 } |
| 403 List<int>* inlining_id_to_function_id() { | 459 List<int>* inlining_id_to_function_id() { |
| 404 return inlining_id_to_function_id_; | 460 return inlining_id_to_function_id_; |
| 405 } | 461 } |
| 406 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, int raw_position); | 462 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
| 463 SourcePosition raw_position); | |
|
Sven Panne
2015/02/17 11:08:03
s/raw_position/position/
| |
| 407 | 464 |
| 408 Handle<Foreign> object_wrapper() { | 465 Handle<Foreign> object_wrapper() { |
| 409 if (object_wrapper_.is_null()) { | 466 if (object_wrapper_.is_null()) { |
| 410 object_wrapper_ = | 467 object_wrapper_ = |
| 411 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); | 468 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); |
| 412 } | 469 } |
| 413 return object_wrapper_; | 470 return object_wrapper_; |
| 414 } | 471 } |
| 415 | 472 |
| 416 void AbortDueToDependencyChange() { | 473 void AbortDueToDependencyChange() { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 Zone zone_; | 857 Zone zone_; |
| 801 size_t info_zone_start_allocation_size_; | 858 size_t info_zone_start_allocation_size_; |
| 802 base::ElapsedTimer timer_; | 859 base::ElapsedTimer timer_; |
| 803 | 860 |
| 804 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 861 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 805 }; | 862 }; |
| 806 | 863 |
| 807 } } // namespace v8::internal | 864 } } // namespace v8::internal |
| 808 | 865 |
| 809 #endif // V8_COMPILER_H_ | 866 #endif // V8_COMPILER_H_ |
| OLD | NEW |