V8 Project
v8::internal::RelocIterator Class Reference

#include <assembler.h>

+ Inheritance diagram for v8::internal::RelocIterator:
+ Collaboration diagram for v8::internal::RelocIterator:

Public Member Functions

 RelocIterator (Code *code, int mode_mask=-1)
 
 RelocIterator (const CodeDesc &desc, int mode_mask=-1)
 
bool done () const
 
void next ()
 
RelocInforinfo ()
 
- Public Member Functions inherited from v8::internal::Malloced
void * operator new (size_t size)
 
void operator delete (void *p)
 

Private Member Functions

void Advance (int bytes=1)
 
int AdvanceGetTag ()
 
int GetExtraTag ()
 
int GetTopTag ()
 
void ReadTaggedPC ()
 
void AdvanceReadPC ()
 
void AdvanceReadId ()
 
void AdvanceReadPoolData ()
 
void AdvanceReadPosition ()
 
void AdvanceReadData ()
 
void AdvanceReadVariableLengthPCJump ()
 
int GetLocatableTypeTag ()
 
void ReadTaggedId ()
 
void ReadTaggedPosition ()
 
bool SetMode (RelocInfo::Mode mode)
 
 DISALLOW_COPY_AND_ASSIGN (RelocIterator)
 

Private Attributes

bytepos_
 
byteend_
 
bytecode_age_sequence_
 
RelocInfo rinfo_
 
bool done_
 
int mode_mask_
 
int last_id_
 
int last_position_
 

Additional Inherited Members

- Static Public Member Functions inherited from v8::internal::Malloced
static void FatalProcessOutOfMemory ()
 
static void * New (size_t size)
 
static void Delete (void *p)
 

Detailed Description

Definition at line 672 of file assembler.h.

Constructor & Destructor Documentation

◆ RelocIterator() [1/2]

v8::internal::RelocIterator::RelocIterator ( Code code,
int  mode_mask = -1 
)
explicit

Definition at line 688 of file assembler.cc.

688  {
689  rinfo_.host_ = code;
690  rinfo_.pc_ = code->instruction_start();
691  rinfo_.data_ = 0;
692  // Relocation info is read backwards.
693  pos_ = code->relocation_start() + code->relocation_size();
694  end_ = code->relocation_start();
695  done_ = false;
696  mode_mask_ = mode_mask;
697  last_id_ = 0;
698  last_position_ = 0;
699  byte* sequence = code->FindCodeAgeSequence();
700  // We get the isolate from the map, because at serialization time
701  // the code pointer has been cloned and isn't really in heap space.
702  Isolate* isolate = code->map()->GetIsolate();
703  if (sequence != NULL && !Code::IsYoungSequence(isolate, sequence)) {
704  code_age_sequence_ = sequence;
705  } else {
707  }
708  if (mode_mask_ == 0) pos_ = end_;
709  next();
710 }
static bool IsYoungSequence(Isolate *isolate, byte *sequence)
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

References code_age_sequence_, v8::internal::RelocInfo::data_, done_, end_, v8::internal::Code::FindCodeAgeSequence(), v8::internal::HeapObject::GetIsolate(), v8::internal::RelocInfo::host_, v8::internal::Code::instruction_start(), v8::internal::Code::IsYoungSequence(), last_id_, last_position_, v8::internal::HeapObject::map(), mode_mask_, next(), NULL, v8::internal::RelocInfo::pc_, pos_, v8::internal::Code::relocation_size(), v8::internal::Code::relocation_start(), and rinfo_.

+ Here is the call graph for this function:

◆ RelocIterator() [2/2]

v8::internal::RelocIterator::RelocIterator ( const CodeDesc desc,
int  mode_mask = -1 
)
explicit

Definition at line 713 of file assembler.cc.

713  {
714  rinfo_.pc_ = desc.buffer;
715  rinfo_.data_ = 0;
716  // Relocation info is read backwards.
717  pos_ = desc.buffer + desc.buffer_size;
718  end_ = pos_ - desc.reloc_size;
719  done_ = false;
720  mode_mask_ = mode_mask;
721  last_id_ = 0;
722  last_position_ = 0;
724  if (mode_mask_ == 0) pos_ = end_;
725  next();
726 }

References v8::internal::CodeDesc::buffer, v8::internal::CodeDesc::buffer_size, code_age_sequence_, v8::internal::RelocInfo::data_, done_, end_, last_id_, last_position_, mode_mask_, next(), NULL, v8::internal::RelocInfo::pc_, pos_, v8::internal::CodeDesc::reloc_size, and rinfo_.

+ Here is the call graph for this function:

Member Function Documentation

◆ Advance()

void v8::internal::RelocIterator::Advance ( int  bytes = 1)
inlineprivate

Definition at line 695 of file assembler.h.

695 { pos_ -= bytes; }

References pos_.

Referenced by next().

+ Here is the caller graph for this function:

◆ AdvanceGetTag()

int v8::internal::RelocIterator::AdvanceGetTag ( )
inlineprivate

Definition at line 481 of file assembler.cc.

481  {
482  return *--pos_ & kTagMask;
483 }
const int kTagMask
Definition: assembler.cc:295

References v8::internal::kTagMask, and pos_.

Referenced by next().

+ Here is the caller graph for this function:

◆ AdvanceReadData()

void v8::internal::RelocIterator::AdvanceReadData ( )
private

Definition at line 535 of file assembler.cc.

535  {
536  intptr_t x = 0;
537  for (int i = 0; i < kIntptrSize; i++) {
538  x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte;
539  }
540  rinfo_.data_ = x;
541 }
const int kIntptrSize
Definition: globals.h:128
const int kBitsPerByte
Definition: globals.h:162

References v8::internal::RelocInfo::data_, v8::internal::kBitsPerByte, v8::internal::kIntptrSize, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ AdvanceReadId()

void v8::internal::RelocIterator::AdvanceReadId ( )
private

Definition at line 506 of file assembler.cc.

506  {
507  int x = 0;
508  for (int i = 0; i < kIntSize; i++) {
509  x |= static_cast<int>(*--pos_) << i * kBitsPerByte;
510  }
511  last_id_ += x;
513 }
const int kIntSize
Definition: globals.h:124

References v8::internal::RelocInfo::data_, v8::internal::kBitsPerByte, v8::internal::kIntSize, last_id_, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ AdvanceReadPC()

void v8::internal::RelocIterator::AdvanceReadPC ( )
inlineprivate

Definition at line 501 of file assembler.cc.

501  {
502  rinfo_.pc_ += *--pos_;
503 }

References v8::internal::RelocInfo::pc_, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ AdvanceReadPoolData()

void v8::internal::RelocIterator::AdvanceReadPoolData ( )
private

Definition at line 516 of file assembler.cc.

516  {
517  int x = 0;
518  for (int i = 0; i < kIntSize; i++) {
519  x |= static_cast<int>(*--pos_) << i * kBitsPerByte;
520  }
521  rinfo_.data_ = x;
522 }

References v8::internal::RelocInfo::data_, v8::internal::kBitsPerByte, v8::internal::kIntSize, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ AdvanceReadPosition()

void v8::internal::RelocIterator::AdvanceReadPosition ( )
private

Definition at line 525 of file assembler.cc.

525  {
526  int x = 0;
527  for (int i = 0; i < kIntSize; i++) {
528  x |= static_cast<int>(*--pos_) << i * kBitsPerByte;
529  }
530  last_position_ += x;
532 }

References v8::internal::RelocInfo::data_, v8::internal::kBitsPerByte, v8::internal::kIntSize, last_position_, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ AdvanceReadVariableLengthPCJump()

void v8::internal::RelocIterator::AdvanceReadVariableLengthPCJump ( )
private

Definition at line 544 of file assembler.cc.

544  {
545  // Read the 32-kSmallPCDeltaBits most significant bits of the
546  // pc jump in kChunkBits bit chunks and shift them into place.
547  // Stop when the last chunk is encountered.
548  uint32_t pc_jump = 0;
549  for (int i = 0; i < kIntSize; i++) {
550  byte pc_jump_part = *--pos_;
551  pc_jump |= (pc_jump_part >> kLastChunkTagBits) << i * kChunkBits;
552  if ((pc_jump_part & kLastChunkTagMask) == 1) break;
553  }
554  // The least significant kSmallPCDeltaBits bits will be added
555  // later.
556  rinfo_.pc_ += pc_jump << kSmallPCDeltaBits;
557 }
const int kLastChunkTagBits
Definition: assembler.cc:314
const int kLastChunkTagMask
Definition: assembler.cc:315
const int kChunkBits
Definition: assembler.cc:312
const int kSmallPCDeltaBits
Definition: assembler.cc:307

References v8::internal::kChunkBits, v8::internal::kIntSize, v8::internal::kLastChunkTagBits, v8::internal::kLastChunkTagMask, v8::internal::kSmallPCDeltaBits, v8::internal::RelocInfo::pc_, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::RelocIterator::DISALLOW_COPY_AND_ASSIGN ( RelocIterator  )
private

◆ done()

◆ GetExtraTag()

int v8::internal::RelocIterator::GetExtraTag ( )
inlineprivate

Definition at line 486 of file assembler.cc.

486  {
487  return (*pos_ >> kTagBits) & ((1 << kExtraTagBits) - 1);
488 }
const int kExtraTagBits
Definition: assembler.cc:296
const int kTagBits
Definition: assembler.cc:294

References v8::internal::kExtraTagBits, v8::internal::kTagBits, and pos_.

Referenced by next().

+ Here is the caller graph for this function:

◆ GetLocatableTypeTag()

int v8::internal::RelocIterator::GetLocatableTypeTag ( )
inlineprivate

Definition at line 560 of file assembler.cc.

560  {
561  return *pos_ & ((1 << kLocatableTypeTagBits) - 1);
562 }
const int kLocatableTypeTagBits
Definition: assembler.cc:297

References v8::internal::kLocatableTypeTagBits, and pos_.

Referenced by next().

+ Here is the caller graph for this function:

◆ GetTopTag()

int v8::internal::RelocIterator::GetTopTag ( )
inlineprivate

Definition at line 491 of file assembler.cc.

491  {
492  return *pos_ >> (kTagBits + kExtraTagBits);
493 }

References v8::internal::kExtraTagBits, v8::internal::kTagBits, and pos_.

Referenced by next().

+ Here is the caller graph for this function:

◆ next()

void v8::internal::RelocIterator::next ( )

Definition at line 590 of file assembler.cc.

590  {
591  DCHECK(!done());
592  // Basically, do the opposite of RelocInfoWriter::Write.
593  // Reading of data is as far as possible avoided for unwanted modes,
594  // but we must always update the pc.
595  //
596  // We exit this loop by returning when we find a mode we want.
597  while (pos_ > end_) {
598  int tag = AdvanceGetTag();
599  if (tag == kEmbeddedObjectTag) {
600  ReadTaggedPC();
601  if (SetMode(RelocInfo::EMBEDDED_OBJECT)) return;
602  } else if (tag == kCodeTargetTag) {
603  ReadTaggedPC();
604  if (SetMode(RelocInfo::CODE_TARGET)) return;
605  } else if (tag == kLocatableTag) {
606  ReadTaggedPC();
607  Advance();
608  int locatable_tag = GetLocatableTypeTag();
609  if (locatable_tag == kCodeWithIdTag) {
611  ReadTaggedId();
612  return;
613  }
614  } else {
615  // Compact encoding is never used for comments,
616  // so it must be a position.
617  DCHECK(locatable_tag == kNonstatementPositionTag ||
618  locatable_tag == kStatementPositionTag);
621  if (SetMode(GetPositionModeFromTag(locatable_tag))) return;
622  }
623  }
624  } else {
625  DCHECK(tag == kDefaultTag);
626  int extra_tag = GetExtraTag();
627  if (extra_tag == kPCJumpExtraTag) {
630  } else {
631  AdvanceReadPC();
632  }
633  } else if (extra_tag == kDataJumpExtraTag) {
634  int locatable_tag = GetTopTag();
635  if (locatable_tag == kCodeWithIdTag) {
637  AdvanceReadId();
638  return;
639  }
640  Advance(kIntSize);
641  } else if (locatable_tag != kCommentTag) {
642  DCHECK(locatable_tag == kNonstatementPositionTag ||
643  locatable_tag == kStatementPositionTag);
646  if (SetMode(GetPositionModeFromTag(locatable_tag))) return;
647  } else {
648  Advance(kIntSize);
649  }
650  } else {
651  DCHECK(locatable_tag == kCommentTag);
653  AdvanceReadData();
654  return;
655  }
657  }
658  } else if (extra_tag == kPoolExtraTag) {
659  int pool_type = GetTopTag();
660  DCHECK(pool_type == kConstPoolTag || pool_type == kVeneerPoolTag);
661  RelocInfo::Mode rmode = (pool_type == kConstPoolTag) ?
663  if (SetMode(rmode)) {
665  return;
666  }
667  Advance(kIntSize);
668  } else {
669  AdvanceReadPC();
670  int rmode = extra_tag + RelocInfo::LAST_COMPACT_ENUM;
671  if (SetMode(static_cast<RelocInfo::Mode>(rmode))) return;
672  }
673  }
674  }
675  if (code_age_sequence_ != NULL) {
676  byte* old_code_age_sequence = code_age_sequence_;
679  rinfo_.data_ = 0;
680  rinfo_.pc_ = old_code_age_sequence;
681  return;
682  }
683  }
684  done_ = true;
685 }
static const int kPositionMask
Definition: assembler.h:588
bool SetMode(RelocInfo::Mode mode)
Definition: assembler.h:712
void Advance(int bytes=1)
Definition: assembler.h:695
#define DCHECK(condition)
Definition: logging.h:205
const int kEmbeddedObjectTag
Definition: assembler.cc:300
const int kPoolExtraTag
Definition: assembler.cc:326
const int kDataJumpExtraTag
Definition: assembler.cc:319
const int kCommentTag
Definition: assembler.cc:324
const int kCodeWithIdTag
Definition: assembler.cc:321
const int kVeneerPoolTag
Definition: assembler.cc:328
const int kConstPoolTag
Definition: assembler.cc:327
const int kCodeTargetTag
Definition: assembler.cc:301
const int kPCJumpExtraTag
Definition: assembler.cc:305
const int kStatementPositionTag
Definition: assembler.cc:323
const int kNonstatementPositionTag
Definition: assembler.cc:322
static RelocInfo::Mode GetPositionModeFromTag(int tag)
Definition: assembler.cc:581
const int kLocatableTag
Definition: assembler.cc:302
const int kDefaultTag
Definition: assembler.cc:303
const int kVariableLengthPCJumpTopTag
Definition: assembler.cc:311

References Advance(), AdvanceGetTag(), AdvanceReadData(), AdvanceReadId(), AdvanceReadPC(), AdvanceReadPoolData(), AdvanceReadPosition(), AdvanceReadVariableLengthPCJump(), v8::internal::RelocInfo::CODE_AGE_SEQUENCE, code_age_sequence_, v8::internal::RelocInfo::CODE_TARGET, v8::internal::RelocInfo::CODE_TARGET_WITH_ID, v8::internal::RelocInfo::COMMENT, v8::internal::RelocInfo::CONST_POOL, v8::internal::RelocInfo::data_, DCHECK, done(), done_, v8::internal::RelocInfo::EMBEDDED_OBJECT, end_, GetExtraTag(), GetLocatableTypeTag(), v8::internal::GetPositionModeFromTag(), GetTopTag(), v8::internal::kCodeTargetTag, v8::internal::kCodeWithIdTag, v8::internal::kCommentTag, v8::internal::kConstPoolTag, v8::internal::kDataJumpExtraTag, v8::internal::kDefaultTag, v8::internal::kEmbeddedObjectTag, v8::internal::kIntptrSize, v8::internal::kIntSize, v8::internal::kLocatableTag, v8::internal::kNonstatementPositionTag, v8::internal::kPCJumpExtraTag, v8::internal::kPoolExtraTag, v8::internal::RelocInfo::kPositionMask, v8::internal::kStatementPositionTag, v8::internal::kVariableLengthPCJumpTopTag, v8::internal::kVeneerPoolTag, v8::internal::RelocInfo::LAST_COMPACT_ENUM, mode_mask_, NULL, v8::internal::RelocInfo::pc_, pos_, ReadTaggedId(), ReadTaggedPC(), ReadTaggedPosition(), rinfo_, SetMode(), and v8::internal::RelocInfo::VENEER_POOL.

Referenced by v8::internal::Code::CodeIterateBody(), v8::internal::Debug::IsBreakAtReturn(), RelocIterator(), v8::internal::BreakLocationIterator::RinfoNext(), v8::internal::RUNTIME_FUNCTION(), v8::internal::Debug::SetAfterBreakTarget(), v8::internal::Code::SourcePosition(), and v8::internal::Code::SourceStatementPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadTaggedId()

void v8::internal::RelocIterator::ReadTaggedId ( )
inlineprivate

Definition at line 565 of file assembler.cc.

565  {
566  int8_t signed_b = *pos_;
567  // Signed right shift is arithmetic shift. Tested in test-utils.cc.
568  last_id_ += signed_b >> kLocatableTypeTagBits;
570 }

References v8::internal::RelocInfo::data_, v8::internal::kLocatableTypeTagBits, last_id_, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ ReadTaggedPC()

void v8::internal::RelocIterator::ReadTaggedPC ( )
inlineprivate

Definition at line 496 of file assembler.cc.

496  {
497  rinfo_.pc_ += *pos_ >> kTagBits;
498 }

References v8::internal::kTagBits, v8::internal::RelocInfo::pc_, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ ReadTaggedPosition()

void v8::internal::RelocIterator::ReadTaggedPosition ( )
inlineprivate

Definition at line 573 of file assembler.cc.

573  {
574  int8_t signed_b = *pos_;
575  // Signed right shift is arithmetic shift. Tested in test-utils.cc.
576  last_position_ += signed_b >> kLocatableTypeTagBits;
578 }

References v8::internal::RelocInfo::data_, v8::internal::kLocatableTypeTagBits, last_position_, pos_, and rinfo_.

Referenced by next().

+ Here is the caller graph for this function:

◆ rinfo()

RelocInfo* v8::internal::RelocIterator::rinfo ( )
inline

Definition at line 686 of file assembler.h.

686  {
687  DCHECK(!done());
688  return &rinfo_;
689  }

References DCHECK, done(), and rinfo_.

Referenced by v8::internal::Code::CodeIterateBody(), v8::internal::Debug::IsBreakAtReturn(), v8::internal::BreakLocationIterator::original_rinfo(), v8::internal::BreakLocationIterator::original_rmode(), v8::internal::BreakLocationIterator::pc(), v8::internal::BreakLocationIterator::rinfo(), v8::internal::BreakLocationIterator::rmode(), v8::internal::RUNTIME_FUNCTION(), v8::internal::Debug::SetAfterBreakTarget(), v8::internal::Code::SourcePosition(), and v8::internal::Code::SourceStatementPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetMode()

bool v8::internal::RelocIterator::SetMode ( RelocInfo::Mode  mode)
inlineprivate

Definition at line 712 of file assembler.h.

712  {
713  return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false;
714  }
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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp

References mode(), mode_mask_, rinfo_, and v8::internal::RelocInfo::rmode_.

Referenced by next().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ code_age_sequence_

byte* v8::internal::RelocIterator::code_age_sequence_
private

Definition at line 718 of file assembler.h.

Referenced by next(), and RelocIterator().

◆ done_

bool v8::internal::RelocIterator::done_
private

Definition at line 720 of file assembler.h.

Referenced by done(), next(), and RelocIterator().

◆ end_

byte* v8::internal::RelocIterator::end_
private

Definition at line 717 of file assembler.h.

Referenced by next(), and RelocIterator().

◆ last_id_

int v8::internal::RelocIterator::last_id_
private

Definition at line 722 of file assembler.h.

Referenced by AdvanceReadId(), ReadTaggedId(), and RelocIterator().

◆ last_position_

int v8::internal::RelocIterator::last_position_
private

Definition at line 723 of file assembler.h.

Referenced by AdvanceReadPosition(), ReadTaggedPosition(), and RelocIterator().

◆ mode_mask_

int v8::internal::RelocIterator::mode_mask_
private

Definition at line 721 of file assembler.h.

Referenced by next(), RelocIterator(), and SetMode().

◆ pos_

◆ rinfo_


The documentation for this class was generated from the following files: