summaryrefslogtreecommitdiff
path: root/deps/v8/src/assembler.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/assembler.h')
-rw-r--r--deps/v8/src/assembler.h59
1 files changed, 55 insertions, 4 deletions
diff --git a/deps/v8/src/assembler.h b/deps/v8/src/assembler.h
index 157743359..d28bf4370 100644
--- a/deps/v8/src/assembler.h
+++ b/deps/v8/src/assembler.h
@@ -57,7 +57,7 @@ class Label BASE_EMBEDDED {
INLINE(void Unuse()) { pos_ = 0; }
- INLINE(bool is_bound() const) { return pos_ < 0; }
+ INLINE(bool is_bound() const) { return pos_ < 0; }
INLINE(bool is_unused() const) { return pos_ == 0; }
INLINE(bool is_linked() const) { return pos_ > 0; }
@@ -92,6 +92,57 @@ class Label BASE_EMBEDDED {
// -----------------------------------------------------------------------------
+// NearLabels are labels used for short jumps (in Intel jargon).
+// NearLabels should be used if it can be guaranteed that the jump range is
+// within -128 to +127. We already use short jumps when jumping backwards,
+// so using a NearLabel will only have performance impact if used for forward
+// jumps.
+class NearLabel BASE_EMBEDDED {
+ public:
+ NearLabel() { Unuse(); }
+ ~NearLabel() { ASSERT(!is_linked()); }
+
+ void Unuse() {
+ pos_ = -1;
+ unresolved_branches_ = 0;
+#ifdef DEBUG
+ for (int i = 0; i < kMaxUnresolvedBranches; i++) {
+ unresolved_positions_[i] = -1;
+ }
+#endif
+ }
+
+ int pos() {
+ ASSERT(is_bound());
+ return pos_;
+ }
+
+ bool is_bound() { return pos_ >= 0; }
+ bool is_linked() { return !is_bound() && unresolved_branches_ > 0; }
+ bool is_unused() { return !is_bound() && unresolved_branches_ == 0; }
+
+ void bind_to(int position) {
+ ASSERT(!is_bound());
+ pos_ = position;
+ }
+
+ void link_to(int position) {
+ ASSERT(!is_bound());
+ ASSERT(unresolved_branches_ < kMaxUnresolvedBranches);
+ unresolved_positions_[unresolved_branches_++] = position;
+ }
+
+ private:
+ static const int kMaxUnresolvedBranches = 8;
+ int pos_;
+ int unresolved_branches_;
+ int unresolved_positions_[kMaxUnresolvedBranches];
+
+ friend class Assembler;
+};
+
+
+// -----------------------------------------------------------------------------
// Relocation information
@@ -181,10 +232,10 @@ class RelocInfo BASE_EMBEDDED {
static inline int ModeMask(Mode mode) { return 1 << mode; }
// Accessors
- byte* pc() const { return pc_; }
+ byte* pc() const { return pc_; }
void set_pc(byte* pc) { pc_ = pc; }
Mode rmode() const { return rmode_; }
- intptr_t data() const { return data_; }
+ intptr_t data() const { return data_; }
// Apply a relocation by delta bytes
INLINE(void apply(intptr_t delta));
@@ -339,7 +390,7 @@ class RelocIterator: public Malloced {
explicit RelocIterator(const CodeDesc& desc, int mode_mask = -1);
// Iteration
- bool done() const { return done_; }
+ bool done() const { return done_; }
void next();
// Return pointer valid until next next().