Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: src/assembler.h

Issue 3388004: Add support for near labels.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ia32/assembler-ia32.h » ('j') | src/x64/full-codegen-x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 friend class Assembler; 86 friend class Assembler;
87 friend class RegexpAssembler; 87 friend class RegexpAssembler;
88 friend class Displacement; 88 friend class Displacement;
89 friend class ShadowTarget; 89 friend class ShadowTarget;
90 friend class RegExpMacroAssemblerIrregexp; 90 friend class RegExpMacroAssemblerIrregexp;
91 }; 91 };
92 92
93 93
94 // ----------------------------------------------------------------------------- 94 // -----------------------------------------------------------------------------
95 // NearLabels are labels used for short jumps (in Intel jargon).
96 // NearLabels should be used if it can be guaranteed that the jump range is
97 // within -128 to +127. We already use short jumps when jumping backwards,
98 // so using a NearLabel will only have performance impact if used for forward
99 // jumps.
100 class NearLabel BASE_EMBEDDED {
Søren Thygesen Gjesse 2010/09/15 10:38:20 How about adding a type to the Label class class
101 public:
102 NearLabel() { Unuse(); }
103 ~NearLabel() { ASSERT(!is_linked()); }
104
105 void Unuse() {
106 pos_ = -1;
107 unresolved_branches_ = 0;
108 #ifdef DEBUG
109 for (int i = 0; i < kMaxUnresolvedBranches; i++) {
110 unresolved_positions_[i] = -1;
111 }
112 #endif
113 }
114
115 int pos() {
116 ASSERT(is_bound());
117 return pos_;
118 }
119
120 bool is_bound() { return pos_ >= 0; }
121 bool is_linked() { return !is_bound() && unresolved_branches_ > 0; }
122 bool is_unused() { return !is_bound() && unresolved_branches_ == 0; }
123
124 void bind_to(int position) {
125 ASSERT(!is_bound());
126 pos_ = position;
127 }
128
129 void link_to(int position) {
130 ASSERT(!is_bound());
131 ASSERT(unresolved_branches_ < kMaxUnresolvedBranches);
132 unresolved_positions_[unresolved_branches_++] = position;
133 }
134
135 private:
136 static const int kMaxUnresolvedBranches = 8;
137 int pos_;
138 int unresolved_branches_;
139 int unresolved_positions_[kMaxUnresolvedBranches];
140
141 friend class Assembler;
142 };
143
144
145 // -----------------------------------------------------------------------------
95 // Relocation information 146 // Relocation information
96 147
97 148
98 // Relocation information consists of the address (pc) of the datum 149 // Relocation information consists of the address (pc) of the datum
99 // to which the relocation information applies, the relocation mode 150 // to which the relocation information applies, the relocation mode
100 // (rmode), and an optional data field. The relocation mode may be 151 // (rmode), and an optional data field. The relocation mode may be
101 // "descriptive" and not indicate a need for relocation, but simply 152 // "descriptive" and not indicate a need for relocation, but simply
102 // describe a property of the datum. Such rmodes are useful for GC 153 // describe a property of the datum. Such rmodes are useful for GC
103 // and nice disassembly output. 154 // and nice disassembly output.
104 155
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 unsigned int num_bits_set; 616 unsigned int num_bits_set;
566 for (num_bits_set = 0; x; x >>= 1) { 617 for (num_bits_set = 0; x; x >>= 1) {
567 num_bits_set += x & 1; 618 num_bits_set += x & 1;
568 } 619 }
569 return num_bits_set; 620 return num_bits_set;
570 } 621 }
571 622
572 } } // namespace v8::internal 623 } } // namespace v8::internal
573 624
574 #endif // V8_ASSEMBLER_H_ 625 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « no previous file | src/ia32/assembler-ia32.h » ('j') | src/x64/full-codegen-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698