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

Side by Side Diff: src/assembler.cc

Issue 3186: Refactor the enum RelocMode changing the naming scheme from lower case to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 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 | « src/assembler.h ('k') | src/assembler-arm.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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 } 186 }
187 187
188 188
189 void RelocInfoWriter::Write(const RelocInfo* rinfo) { 189 void RelocInfoWriter::Write(const RelocInfo* rinfo) {
190 #ifdef DEBUG 190 #ifdef DEBUG
191 byte* begin_pos = pos_; 191 byte* begin_pos = pos_;
192 #endif 192 #endif
193 Counters::reloc_info_count.Increment(); 193 Counters::reloc_info_count.Increment();
194 ASSERT(rinfo->pc() - last_pc_ >= 0); 194 ASSERT(rinfo->pc() - last_pc_ >= 0);
195 ASSERT(reloc_mode_count < kMaxRelocModes); 195 ASSERT(RelocInfo::NUMBER_OF_MODES < kMaxRelocModes);
196 // Use unsigned delta-encoding for pc. 196 // Use unsigned delta-encoding for pc.
197 uint32_t pc_delta = rinfo->pc() - last_pc_; 197 uint32_t pc_delta = rinfo->pc() - last_pc_;
198 RelocMode rmode = rinfo->rmode(); 198 RelocInfo::Mode rmode = rinfo->rmode();
199 199
200 // The two most common modes are given small tags, and usually fit in a byte. 200 // The two most common modes are given small tags, and usually fit in a byte.
201 if (rmode == embedded_object) { 201 if (rmode == RelocInfo::EMBEDDED_OBJECT) {
202 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); 202 WriteTaggedPC(pc_delta, kEmbeddedObjectTag);
203 } else if (rmode == code_target) { 203 } else if (rmode == RelocInfo::CODE_TARGET) {
204 WriteTaggedPC(pc_delta, kCodeTargetTag); 204 WriteTaggedPC(pc_delta, kCodeTargetTag);
205 } else if (rmode == position || rmode == statement_position) { 205 } else if (RelocInfo::IsPosition(rmode)) {
206 // Use signed delta-encoding for data. 206 // Use signed delta-encoding for data.
207 int32_t data_delta = rinfo->data() - last_data_; 207 int32_t data_delta = rinfo->data() - last_data_;
208 int pos_type_tag = rmode == position ? kNonstatementPositionTag 208 int pos_type_tag = rmode == RelocInfo::POSITION ? kNonstatementPositionTag
209 : kStatementPositionTag; 209 : kStatementPositionTag;
210 // Check if data is small enough to fit in a tagged byte. 210 // Check if data is small enough to fit in a tagged byte.
211 if (is_intn(data_delta, kSmallDataBits)) { 211 if (is_intn(data_delta, kSmallDataBits)) {
212 WriteTaggedPC(pc_delta, kPositionTag); 212 WriteTaggedPC(pc_delta, kPositionTag);
213 WriteTaggedData(data_delta, pos_type_tag); 213 WriteTaggedData(data_delta, pos_type_tag);
214 last_data_ = rinfo->data(); 214 last_data_ = rinfo->data();
215 } else { 215 } else {
216 // Otherwise, use costly encoding. 216 // Otherwise, use costly encoding.
217 WriteExtraTaggedPC(pc_delta, kPCJumpTag); 217 WriteExtraTaggedPC(pc_delta, kPCJumpTag);
218 WriteExtraTaggedData(data_delta, pos_type_tag); 218 WriteExtraTaggedData(data_delta, pos_type_tag);
219 last_data_ = rinfo->data(); 219 last_data_ = rinfo->data();
220 } 220 }
221 } else if (rmode == comment) { 221 } else if (RelocInfo::IsComment(rmode)) {
222 // Comments are normally not generated, so we use the costly encoding. 222 // Comments are normally not generated, so we use the costly encoding.
223 WriteExtraTaggedPC(pc_delta, kPCJumpTag); 223 WriteExtraTaggedPC(pc_delta, kPCJumpTag);
224 WriteExtraTaggedData(rinfo->data() - last_data_, kCommentTag); 224 WriteExtraTaggedData(rinfo->data() - last_data_, kCommentTag);
225 last_data_ = rinfo->data(); 225 last_data_ = rinfo->data();
226 } else { 226 } else {
227 // For all other modes we simply use the mode as the extra tag. 227 // For all other modes we simply use the mode as the extra tag.
228 // None of these modes need a data component. 228 // None of these modes need a data component.
229 ASSERT(rmode < kPCJumpTag && rmode < kDataJumpTag); 229 ASSERT(rmode < kPCJumpTag && rmode < kDataJumpTag);
230 WriteExtraTaggedPC(pc_delta, rmode); 230 WriteExtraTaggedPC(pc_delta, rmode);
231 } 231 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 return *pos_ & ((1 << kPositionTypeTagBits) - 1); 290 return *pos_ & ((1 << kPositionTypeTagBits) - 1);
291 } 291 }
292 292
293 293
294 inline void RelocIterator::ReadTaggedData() { 294 inline void RelocIterator::ReadTaggedData() {
295 int8_t signed_b = *pos_; 295 int8_t signed_b = *pos_;
296 rinfo_.data_ += ArithmeticShiftRight(signed_b, kPositionTypeTagBits); 296 rinfo_.data_ += ArithmeticShiftRight(signed_b, kPositionTypeTagBits);
297 } 297 }
298 298
299 299
300 inline RelocMode RelocIterator::DebugInfoModeFromTag(int tag) { 300 inline RelocInfo::Mode RelocIterator::DebugInfoModeFromTag(int tag) {
301 if (tag == kStatementPositionTag) { 301 if (tag == kStatementPositionTag) {
302 return statement_position; 302 return RelocInfo::STATEMENT_POSITION;
303 } else if (tag == kNonstatementPositionTag) { 303 } else if (tag == kNonstatementPositionTag) {
304 return position; 304 return RelocInfo::POSITION;
305 } else { 305 } else {
306 ASSERT(tag == kCommentTag); 306 ASSERT(tag == kCommentTag);
307 return comment; 307 return RelocInfo::COMMENT;
308 } 308 }
309 } 309 }
310 310
311 311
312 void RelocIterator::next() { 312 void RelocIterator::next() {
313 ASSERT(!done()); 313 ASSERT(!done());
314 // Basically, do the opposite of RelocInfoWriter::Write. 314 // Basically, do the opposite of RelocInfoWriter::Write.
315 // Reading of data is as far as possible avoided for unwanted modes, 315 // Reading of data is as far as possible avoided for unwanted modes,
316 // but we must always update the pc. 316 // but we must always update the pc.
317 // 317 //
318 // We exit this loop by returning when we find a mode we want. 318 // We exit this loop by returning when we find a mode we want.
319 while (pos_ > end_) { 319 while (pos_ > end_) {
320 int tag = AdvanceGetTag(); 320 int tag = AdvanceGetTag();
321 if (tag == kEmbeddedObjectTag) { 321 if (tag == kEmbeddedObjectTag) {
322 ReadTaggedPC(); 322 ReadTaggedPC();
323 if (SetMode(embedded_object)) return; 323 if (SetMode(RelocInfo::EMBEDDED_OBJECT)) return;
324 } else if (tag == kCodeTargetTag) { 324 } else if (tag == kCodeTargetTag) {
325 ReadTaggedPC(); 325 ReadTaggedPC();
326 if (*(reinterpret_cast<int**>(rinfo_.pc())) == 326 if (*(reinterpret_cast<int**>(rinfo_.pc())) ==
327 reinterpret_cast<int*>(0x61)) { 327 reinterpret_cast<int*>(0x61)) {
328 tag = 0; 328 tag = 0;
329 } 329 }
330 if (SetMode(code_target)) return; 330 if (SetMode(RelocInfo::CODE_TARGET)) return;
331 } else if (tag == kPositionTag) { 331 } else if (tag == kPositionTag) {
332 ReadTaggedPC(); 332 ReadTaggedPC();
333 Advance(); 333 Advance();
334 // Check if we want source positions. 334 // Check if we want source positions.
335 if (mode_mask_ & RelocInfo::kPositionMask) { 335 if (mode_mask_ & RelocInfo::kPositionMask) {
336 // Check if we want this type of source position. 336 // Check if we want this type of source position.
337 if (SetMode(DebugInfoModeFromTag(GetPositionTypeTag()))) { 337 if (SetMode(DebugInfoModeFromTag(GetPositionTypeTag()))) {
338 // Finally read the data before returning. 338 // Finally read the data before returning.
339 ReadTaggedData(); 339 ReadTaggedData();
340 return; 340 return;
(...skipping 14 matching lines...) Expand all
355 if (mode_mask_ & RelocInfo::kDebugMask) { 355 if (mode_mask_ & RelocInfo::kDebugMask) {
356 int top_tag = GetTopTag(); 356 int top_tag = GetTopTag();
357 AdvanceReadData(); 357 AdvanceReadData();
358 if (SetMode(DebugInfoModeFromTag(top_tag))) return; 358 if (SetMode(DebugInfoModeFromTag(top_tag))) return;
359 } else { 359 } else {
360 // Otherwise, just skip over the data. 360 // Otherwise, just skip over the data.
361 Advance(kIntSize); 361 Advance(kIntSize);
362 } 362 }
363 } else { 363 } else {
364 AdvanceReadPC(); 364 AdvanceReadPC();
365 if (SetMode(static_cast<RelocMode>(extra_tag))) return; 365 if (SetMode(static_cast<RelocInfo::Mode>(extra_tag))) return;
366 } 366 }
367 } 367 }
368 } 368 }
369 done_ = true; 369 done_ = true;
370 } 370 }
371 371
372 372
373 RelocIterator::RelocIterator(Code* code, int mode_mask) { 373 RelocIterator::RelocIterator(Code* code, int mode_mask) {
374 rinfo_.pc_ = code->instruction_start(); 374 rinfo_.pc_ = code->instruction_start();
375 rinfo_.data_ = 0; 375 rinfo_.data_ = 0;
(...skipping 18 matching lines...) Expand all
394 if (mode_mask_ == 0) pos_ = end_; 394 if (mode_mask_ == 0) pos_ = end_;
395 next(); 395 next();
396 } 396 }
397 397
398 398
399 // ----------------------------------------------------------------------------- 399 // -----------------------------------------------------------------------------
400 // Implementation of RelocInfo 400 // Implementation of RelocInfo
401 401
402 402
403 #ifdef ENABLE_DISASSEMBLER 403 #ifdef ENABLE_DISASSEMBLER
404 const char* RelocInfo::RelocModeName(RelocMode rmode) { 404 const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
405 switch (rmode) { 405 switch (rmode) {
406 case no_reloc: 406 case RelocInfo::NONE:
407 return "no reloc"; 407 return "no reloc";
408 case embedded_object: 408 case RelocInfo::EMBEDDED_OBJECT:
409 return "embedded object"; 409 return "embedded object";
410 case embedded_string: 410 case RelocInfo::EMBEDDED_STRING:
411 return "embedded string"; 411 return "embedded string";
412 case js_construct_call: 412 case RelocInfo::CONSTRUCT_CALL:
413 return "code target (js construct call)"; 413 return "code target (js construct call)";
414 case exit_js_frame: 414 case RelocInfo::CODE_TARGET_CONTEXT:
415 return "code target (exit js frame)";
416 case code_target_context:
417 return "code target (context)"; 415 return "code target (context)";
418 case code_target: 416 case RelocInfo::CODE_TARGET:
419 return "code target"; 417 return "code target";
420 case runtime_entry: 418 case RelocInfo::RUNTIME_ENTRY:
421 return "runtime entry"; 419 return "runtime entry";
422 case js_return: 420 case RelocInfo::JS_RETURN:
423 return "js return"; 421 return "js return";
424 case comment: 422 case RelocInfo::COMMENT:
425 return "comment"; 423 return "comment";
426 case position: 424 case RelocInfo::POSITION:
427 return "position"; 425 return "position";
428 case statement_position: 426 case RelocInfo::STATEMENT_POSITION:
429 return "statement position"; 427 return "statement position";
430 case external_reference: 428 case RelocInfo::EXTERNAL_REFERENCE:
431 return "external reference"; 429 return "external reference";
432 case internal_reference: 430 case RelocInfo::INTERNAL_REFERENCE:
433 return "internal reference"; 431 return "internal reference";
434 case reloc_mode_count: 432 case RelocInfo::NUMBER_OF_MODES:
435 UNREACHABLE(); 433 UNREACHABLE();
436 return "reloc_mode_count"; 434 return "number_of_modes";
437 } 435 }
438 return "unknown relocation type"; 436 return "unknown relocation type";
439 } 437 }
440 438
441 439
442 void RelocInfo::Print() { 440 void RelocInfo::Print() {
443 PrintF("%p %s", pc_, RelocModeName(rmode_)); 441 PrintF("%p %s", pc_, RelocModeName(rmode_));
444 if (rmode_ == comment) { 442 if (IsComment(rmode_)) {
445 PrintF(" (%s)", data_); 443 PrintF(" (%s)", data_);
446 } else if (rmode_ == embedded_object) { 444 } else if (rmode_ == EMBEDDED_OBJECT) {
447 PrintF(" ("); 445 PrintF(" (");
448 target_object()->ShortPrint(); 446 target_object()->ShortPrint();
449 PrintF(")"); 447 PrintF(")");
450 } else if (rmode_ == external_reference) { 448 } else if (rmode_ == EXTERNAL_REFERENCE) {
451 ExternalReferenceEncoder ref_encoder; 449 ExternalReferenceEncoder ref_encoder;
452 PrintF(" (%s) (%p)", 450 PrintF(" (%s) (%p)",
453 ref_encoder.NameOfAddress(*target_reference_address()), 451 ref_encoder.NameOfAddress(*target_reference_address()),
454 *target_reference_address()); 452 *target_reference_address());
455 } else if (is_code_target(rmode_)) { 453 } else if (IsCodeTarget(rmode_)) {
456 Code* code = Debug::GetCodeTarget(target_address()); 454 Code* code = Debug::GetCodeTarget(target_address());
457 PrintF(" (%s) (%p)", Code::Kind2String(code->kind()), target_address()); 455 PrintF(" (%s) (%p)", Code::Kind2String(code->kind()), target_address());
458 } else if (is_position(rmode_)) { 456 } else if (IsPosition(rmode_)) {
459 PrintF(" (%d)", data()); 457 PrintF(" (%d)", data());
460 } 458 }
461 459
462 PrintF("\n"); 460 PrintF("\n");
463 } 461 }
464 #endif // ENABLE_DISASSEMBLER 462 #endif // ENABLE_DISASSEMBLER
465 463
466 464
467 #ifdef DEBUG 465 #ifdef DEBUG
468 void RelocInfo::Verify() { 466 void RelocInfo::Verify() {
469 switch (rmode_) { 467 switch (rmode_) {
470 case embedded_object: 468 case EMBEDDED_OBJECT:
471 Object::VerifyPointer(target_object()); 469 Object::VerifyPointer(target_object());
472 break; 470 break;
473 case js_construct_call: 471 case CONSTRUCT_CALL:
474 case exit_js_frame: 472 case CODE_TARGET_CONTEXT:
475 case code_target_context: 473 case CODE_TARGET: {
476 case code_target: {
477 // convert inline target address to code object 474 // convert inline target address to code object
478 Address addr = target_address(); 475 Address addr = target_address();
479 ASSERT(addr != NULL); 476 ASSERT(addr != NULL);
480 // Check that we can find the right code object. 477 // Check that we can find the right code object.
481 HeapObject* code = HeapObject::FromAddress(addr - Code::kHeaderSize); 478 HeapObject* code = HeapObject::FromAddress(addr - Code::kHeaderSize);
482 Object* found = Heap::FindCodeObject(addr); 479 Object* found = Heap::FindCodeObject(addr);
483 ASSERT(found->IsCode()); 480 ASSERT(found->IsCode());
484 ASSERT(code->address() == HeapObject::cast(found)->address()); 481 ASSERT(code->address() == HeapObject::cast(found)->address());
485 break; 482 break;
486 } 483 }
487 case embedded_string: 484 case RelocInfo::EMBEDDED_STRING:
488 case runtime_entry: 485 case RUNTIME_ENTRY:
489 case js_return: 486 case JS_RETURN:
490 case comment: 487 case COMMENT:
491 case position: 488 case POSITION:
492 case statement_position: 489 case STATEMENT_POSITION:
493 case external_reference: 490 case EXTERNAL_REFERENCE:
494 case internal_reference: 491 case INTERNAL_REFERENCE:
495 case no_reloc: 492 case NONE:
496 break; 493 break;
497 case reloc_mode_count: 494 case NUMBER_OF_MODES:
498 UNREACHABLE(); 495 UNREACHABLE();
499 break; 496 break;
500 } 497 }
501 } 498 }
502 #endif // DEBUG 499 #endif // DEBUG
503 500
504 501
505 // ----------------------------------------------------------------------------- 502 // -----------------------------------------------------------------------------
506 // Implementation of ExternalReference 503 // Implementation of ExternalReference
507 504
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 567
571 ExternalReference ExternalReference::new_space_allocation_limit_address() { 568 ExternalReference ExternalReference::new_space_allocation_limit_address() {
572 return ExternalReference(Heap::NewSpaceAllocationLimitAddress()); 569 return ExternalReference(Heap::NewSpaceAllocationLimitAddress());
573 } 570 }
574 571
575 ExternalReference ExternalReference::debug_step_in_fp_address() { 572 ExternalReference ExternalReference::debug_step_in_fp_address() {
576 return ExternalReference(Debug::step_in_fp_addr()); 573 return ExternalReference(Debug::step_in_fp_addr());
577 } 574 }
578 575
579 } } // namespace v8::internal 576 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698