V8 Project
source-position.h
Go to the documentation of this file.
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_COMPILER_SOURCE_POSITION_H_
6 #define V8_COMPILER_SOURCE_POSITION_H_
7 
8 #include "src/assembler.h"
10 
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14 
15 // Encapsulates encoding and decoding of sources positions from which Nodes
16 // originated.
17 class SourcePosition FINAL {
18  public:
19  explicit SourcePosition(int raw = kUnknownPosition) : raw_(raw) {}
20 
21  static SourcePosition Unknown() { return SourcePosition(kUnknownPosition); }
22  bool IsUnknown() const { return raw() == kUnknownPosition; }
23 
24  static SourcePosition Invalid() { return SourcePosition(kInvalidPosition); }
25  bool IsInvalid() const { return raw() == kInvalidPosition; }
26 
27  int raw() const { return raw_; }
28 
29  private:
30  static const int kInvalidPosition = -2;
31  static const int kUnknownPosition = RelocInfo::kNoPosition;
32  STATIC_ASSERT(kInvalidPosition != kUnknownPosition);
33  int raw_;
34 };
35 
36 
37 inline bool operator==(const SourcePosition& lhs, const SourcePosition& rhs) {
38  return lhs.raw() == rhs.raw();
39 }
40 
41 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) {
42  return !(lhs == rhs);
43 }
44 
45 
46 class SourcePositionTable FINAL {
47  public:
48  class Scope {
49  public:
50  Scope(SourcePositionTable* source_positions, SourcePosition position)
51  : source_positions_(source_positions),
52  prev_position_(source_positions->current_position_) {
53  Init(position);
54  }
55  Scope(SourcePositionTable* source_positions, Node* node)
56  : source_positions_(source_positions),
57  prev_position_(source_positions->current_position_) {
58  Init(source_positions_->GetSourcePosition(node));
59  }
60  ~Scope() { source_positions_->current_position_ = prev_position_; }
61 
62  private:
63  void Init(SourcePosition position) {
64  if (!position.IsUnknown() || prev_position_.IsInvalid()) {
65  source_positions_->current_position_ = position;
66  }
67  }
68 
69  SourcePositionTable* source_positions_;
70  SourcePosition prev_position_;
72  };
73 
74  explicit SourcePositionTable(Graph* graph);
76  if (decorator_ != NULL) RemoveDecorator();
77  }
78 
79  void AddDecorator();
81 
82  SourcePosition GetSourcePosition(Node* node);
83 
84  private:
85  class Decorator;
86 
87  Graph* graph_;
88  Decorator* decorator_;
89  SourcePosition current_position_;
91 
92  DISALLOW_COPY_AND_ASSIGN(SourcePositionTable);
93 };
94 
95 } // namespace compiler
96 } // namespace internal
97 } // namespace v8
98 
99 #endif
Source to read snapshot and builtins files from.
Definition: lithium-arm.h:372
static const int kNoPosition
Definition: assembler.h:317
SourcePositionTable * source_positions_
Scope(SourcePositionTable *source_positions, Node *node)
void Init(SourcePosition position)
Scope(SourcePositionTable *source_positions, SourcePosition position)
NodeAuxData< SourcePosition > table_
DISALLOW_COPY_AND_ASSIGN(SourcePositionTable)
static SourcePosition Invalid()
SourcePosition GetSourcePosition(Node *node)
SourcePosition(int raw=kUnknownPosition)
STATIC_ASSERT(kInvalidPosition !=kUnknownPosition)
static SourcePosition Unknown()
#define FINAL
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
bool operator==(const StoreRepresentation &rep1, const StoreRepresentation &rep2)
bool operator!=(const StoreRepresentation &rep1, const StoreRepresentation &rep2)
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20