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

Side by Side Diff: src/assembler.cc

Issue 115860: Change RelocInfo to write 64-bit data field on x64 architecture. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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 | « src/assembler.h ('k') | src/globals.h » ('j') | no next file with comments »
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // 00 [6 bits pc delta] 84 // 00 [6 bits pc delta]
85 // 85 //
86 // pc-jump: 00 1111 11, 86 // pc-jump: 00 1111 11,
87 // 00 [6 bits pc delta] 87 // 00 [6 bits pc delta]
88 // 88 //
89 // pc-jump: 01 1111 11, 89 // pc-jump: 01 1111 11,
90 // (variable length) 7 - 26 bit pc delta, written in chunks of 7 90 // (variable length) 7 - 26 bit pc delta, written in chunks of 7
91 // bits, the lowest 7 bits written first. 91 // bits, the lowest 7 bits written first.
92 // 92 //
93 // data-jump + pos: 00 1110 11, 93 // data-jump + pos: 00 1110 11,
94 // signed int, lowest byte written first 94 // signed intptr_t, lowest byte written first
95 // 95 //
96 // data-jump + st.pos: 01 1110 11, 96 // data-jump + st.pos: 01 1110 11,
97 // signed int, lowest byte written first 97 // signed intptr_t, lowest byte written first
98 // 98 //
99 // data-jump + comm.: 10 1110 11, 99 // data-jump + comm.: 10 1110 11,
100 // signed int, lowest byte written first 100 // signed intptr_t, lowest byte written first
101 // 101 //
102 const int kMaxRelocModes = 14; 102 const int kMaxRelocModes = 14;
103 103
104 const int kTagBits = 2; 104 const int kTagBits = 2;
105 const int kTagMask = (1 << kTagBits) - 1; 105 const int kTagMask = (1 << kTagBits) - 1;
106 const int kExtraTagBits = 4; 106 const int kExtraTagBits = 4;
107 const int kPositionTypeTagBits = 1; 107 const int kPositionTypeTagBits = 1;
108 const int kSmallDataBits = kBitsPerByte - kPositionTypeTagBits; 108 const int kSmallDataBits = kBitsPerByte - kPositionTypeTagBits;
109 109
110 const int kEmbeddedObjectTag = 0; 110 const int kEmbeddedObjectTag = 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 154
155 void RelocInfoWriter::WriteTaggedPC(uint32_t pc_delta, int tag) { 155 void RelocInfoWriter::WriteTaggedPC(uint32_t pc_delta, int tag) {
156 // Write a byte of tagged pc-delta, possibly preceded by var. length pc-jump. 156 // Write a byte of tagged pc-delta, possibly preceded by var. length pc-jump.
157 pc_delta = WriteVariableLengthPCJump(pc_delta); 157 pc_delta = WriteVariableLengthPCJump(pc_delta);
158 *--pos_ = pc_delta << kTagBits | tag; 158 *--pos_ = pc_delta << kTagBits | tag;
159 } 159 }
160 160
161 161
162 void RelocInfoWriter::WriteTaggedData(int32_t data_delta, int tag) { 162 void RelocInfoWriter::WriteTaggedData(intptr_t data_delta, int tag) {
163 *--pos_ = data_delta << kPositionTypeTagBits | tag; 163 *--pos_ = data_delta << kPositionTypeTagBits | tag;
164 } 164 }
165 165
166 166
167 void RelocInfoWriter::WriteExtraTag(int extra_tag, int top_tag) { 167 void RelocInfoWriter::WriteExtraTag(int extra_tag, int top_tag) {
168 *--pos_ = top_tag << (kTagBits + kExtraTagBits) | 168 *--pos_ = top_tag << (kTagBits + kExtraTagBits) |
169 extra_tag << kTagBits | 169 extra_tag << kTagBits |
170 kDefaultTag; 170 kDefaultTag;
171 } 171 }
172 172
173 173
174 void RelocInfoWriter::WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag) { 174 void RelocInfoWriter::WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag) {
175 // Write two-byte tagged pc-delta, possibly preceded by var. length pc-jump. 175 // Write two-byte tagged pc-delta, possibly preceded by var. length pc-jump.
176 pc_delta = WriteVariableLengthPCJump(pc_delta); 176 pc_delta = WriteVariableLengthPCJump(pc_delta);
177 WriteExtraTag(extra_tag, 0); 177 WriteExtraTag(extra_tag, 0);
178 *--pos_ = pc_delta; 178 *--pos_ = pc_delta;
179 } 179 }
180 180
181 181
182 void RelocInfoWriter::WriteExtraTaggedData(int32_t data_delta, int top_tag) { 182 void RelocInfoWriter::WriteExtraTaggedData(intptr_t data_delta, int top_tag) {
183 WriteExtraTag(kDataJumpTag, top_tag); 183 WriteExtraTag(kDataJumpTag, top_tag);
184 for (int i = 0; i < kIntSize; i++) { 184 for (int i = 0; i < kIntptrSize; i++) {
185 *--pos_ = data_delta; 185 *--pos_ = data_delta;
186 data_delta = ArithmeticShiftRight(data_delta, kBitsPerByte); 186 // Signed right shift is arithmetic shift. Tested in test-utils.cc.
187 data_delta = data_delta >> kBitsPerByte;
187 } 188 }
188 } 189 }
189 190
190 191
191 void RelocInfoWriter::Write(const RelocInfo* rinfo) { 192 void RelocInfoWriter::Write(const RelocInfo* rinfo) {
192 #ifdef DEBUG 193 #ifdef DEBUG
193 byte* begin_pos = pos_; 194 byte* begin_pos = pos_;
194 #endif 195 #endif
195 Counters::reloc_info_count.Increment(); 196 Counters::reloc_info_count.Increment();
196 ASSERT(rinfo->pc() - last_pc_ >= 0); 197 ASSERT(rinfo->pc() - last_pc_ >= 0);
197 ASSERT(RelocInfo::NUMBER_OF_MODES < kMaxRelocModes); 198 ASSERT(RelocInfo::NUMBER_OF_MODES < kMaxRelocModes);
198 // Use unsigned delta-encoding for pc. 199 // Use unsigned delta-encoding for pc.
199 uint32_t pc_delta = rinfo->pc() - last_pc_; 200 uint32_t pc_delta = rinfo->pc() - last_pc_;
200 RelocInfo::Mode rmode = rinfo->rmode(); 201 RelocInfo::Mode rmode = rinfo->rmode();
201 202
202 // The two most common modes are given small tags, and usually fit in a byte. 203 // The two most common modes are given small tags, and usually fit in a byte.
203 if (rmode == RelocInfo::EMBEDDED_OBJECT) { 204 if (rmode == RelocInfo::EMBEDDED_OBJECT) {
204 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); 205 WriteTaggedPC(pc_delta, kEmbeddedObjectTag);
205 } else if (rmode == RelocInfo::CODE_TARGET) { 206 } else if (rmode == RelocInfo::CODE_TARGET) {
206 WriteTaggedPC(pc_delta, kCodeTargetTag); 207 WriteTaggedPC(pc_delta, kCodeTargetTag);
207 } else if (RelocInfo::IsPosition(rmode)) { 208 } else if (RelocInfo::IsPosition(rmode)) {
208 // Use signed delta-encoding for data. 209 // Use signed delta-encoding for data.
209 int32_t data_delta = rinfo->data() - last_data_; 210 intptr_t data_delta = rinfo->data() - last_data_;
210 int pos_type_tag = rmode == RelocInfo::POSITION ? kNonstatementPositionTag 211 int pos_type_tag = rmode == RelocInfo::POSITION ? kNonstatementPositionTag
211 : kStatementPositionTag; 212 : kStatementPositionTag;
212 // Check if data is small enough to fit in a tagged byte. 213 // Check if data is small enough to fit in a tagged byte.
213 if (is_intn(data_delta, kSmallDataBits)) { 214 // We cannot use is_intn because data_delta is not an int32_t.
215 if (data_delta >= -(1 << (kSmallDataBits-1)) &&
216 data_delta < 1 << (kSmallDataBits-1)) {
214 WriteTaggedPC(pc_delta, kPositionTag); 217 WriteTaggedPC(pc_delta, kPositionTag);
215 WriteTaggedData(data_delta, pos_type_tag); 218 WriteTaggedData(data_delta, pos_type_tag);
216 last_data_ = rinfo->data(); 219 last_data_ = rinfo->data();
217 } else { 220 } else {
218 // Otherwise, use costly encoding. 221 // Otherwise, use costly encoding.
219 WriteExtraTaggedPC(pc_delta, kPCJumpTag); 222 WriteExtraTaggedPC(pc_delta, kPCJumpTag);
220 WriteExtraTaggedData(data_delta, pos_type_tag); 223 WriteExtraTaggedData(data_delta, pos_type_tag);
221 last_data_ = rinfo->data(); 224 last_data_ = rinfo->data();
222 } 225 }
223 } else if (RelocInfo::IsComment(rmode)) { 226 } else if (RelocInfo::IsComment(rmode)) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 rinfo_.pc_ += *pos_ >> kTagBits; 260 rinfo_.pc_ += *pos_ >> kTagBits;
258 } 261 }
259 262
260 263
261 inline void RelocIterator::AdvanceReadPC() { 264 inline void RelocIterator::AdvanceReadPC() {
262 rinfo_.pc_ += *--pos_; 265 rinfo_.pc_ += *--pos_;
263 } 266 }
264 267
265 268
266 void RelocIterator::AdvanceReadData() { 269 void RelocIterator::AdvanceReadData() {
267 int32_t x = 0; 270 intptr_t x = 0;
268 for (int i = 0; i < kIntSize; i++) { 271 for (int i = 0; i < kIntptrSize; i++) {
269 x |= *--pos_ << i * kBitsPerByte; 272 x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte;
270 } 273 }
271 rinfo_.data_ += x; 274 rinfo_.data_ += x;
272 } 275 }
273 276
274 277
275 void RelocIterator::AdvanceReadVariableLengthPCJump() { 278 void RelocIterator::AdvanceReadVariableLengthPCJump() {
276 // Read the 32-kSmallPCDeltaBits most significant bits of the 279 // Read the 32-kSmallPCDeltaBits most significant bits of the
277 // pc jump in kChunkBits bit chunks and shift them into place. 280 // pc jump in kChunkBits bit chunks and shift them into place.
278 // Stop when the last chunk is encountered. 281 // Stop when the last chunk is encountered.
279 uint32_t pc_jump = 0; 282 uint32_t pc_jump = 0;
280 for (int i = 0; i < kIntSize; i++) { 283 for (int i = 0; i < kIntSize; i++) {
281 byte pc_jump_part = *--pos_; 284 byte pc_jump_part = *--pos_;
282 pc_jump |= (pc_jump_part >> kLastChunkTagBits) << i * kChunkBits; 285 pc_jump |= (pc_jump_part >> kLastChunkTagBits) << i * kChunkBits;
283 if ((pc_jump_part & kLastChunkTagMask) == 1) break; 286 if ((pc_jump_part & kLastChunkTagMask) == 1) break;
284 } 287 }
285 // The least significant kSmallPCDeltaBits bits will be added 288 // The least significant kSmallPCDeltaBits bits will be added
286 // later. 289 // later.
287 rinfo_.pc_ += pc_jump << kSmallPCDeltaBits; 290 rinfo_.pc_ += pc_jump << kSmallPCDeltaBits;
288 } 291 }
289 292
290 293
291 inline int RelocIterator::GetPositionTypeTag() { 294 inline int RelocIterator::GetPositionTypeTag() {
292 return *pos_ & ((1 << kPositionTypeTagBits) - 1); 295 return *pos_ & ((1 << kPositionTypeTagBits) - 1);
293 } 296 }
294 297
295 298
296 inline void RelocIterator::ReadTaggedData() { 299 inline void RelocIterator::ReadTaggedData() {
297 int8_t signed_b = *pos_; 300 int8_t signed_b = *pos_;
298 rinfo_.data_ += ArithmeticShiftRight(signed_b, kPositionTypeTagBits); 301 // Signed right shift is arithmetic shift. Tested in test-utils.cc.
302 rinfo_.data_ += signed_b >> kPositionTypeTagBits;
299 } 303 }
300 304
301 305
302 inline RelocInfo::Mode RelocIterator::DebugInfoModeFromTag(int tag) { 306 inline RelocInfo::Mode RelocIterator::DebugInfoModeFromTag(int tag) {
303 if (tag == kStatementPositionTag) { 307 if (tag == kStatementPositionTag) {
304 return RelocInfo::STATEMENT_POSITION; 308 return RelocInfo::STATEMENT_POSITION;
305 } else if (tag == kNonstatementPositionTag) { 309 } else if (tag == kNonstatementPositionTag) {
306 return RelocInfo::POSITION; 310 return RelocInfo::POSITION;
307 } else { 311 } else {
308 ASSERT(tag == kCommentTag); 312 ASSERT(tag == kCommentTag);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return ExternalReference(FUNCTION_ADDR(Debug::Break)); 623 return ExternalReference(FUNCTION_ADDR(Debug::Break));
620 } 624 }
621 625
622 626
623 ExternalReference ExternalReference::debug_step_in_fp_address() { 627 ExternalReference ExternalReference::debug_step_in_fp_address() {
624 return ExternalReference(Debug::step_in_fp_addr()); 628 return ExternalReference(Debug::step_in_fp_addr());
625 } 629 }
626 #endif 630 #endif
627 631
628 } } // namespace v8::internal 632 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698