Author: [email protected]
Date: Tue Jun 23 02:50:51 2009
New Revision: 2252

Modified:
    branches/bleeding_edge/src/arm/assembler-arm-inl.h
    branches/bleeding_edge/src/assembler.h
    branches/bleeding_edge/src/ia32/assembler-ia32-inl.h
    branches/bleeding_edge/src/ia32/assembler-ia32.h
    branches/bleeding_edge/src/x64/assembler-x64-inl.h
    branches/bleeding_edge/src/x64/assembler-x64.cc
    branches/bleeding_edge/src/x64/assembler-x64.h

Log:
X64 implementation: Change argument to relocator to take a 64-bit delta.   
Change maximum relocation info encoding length.
Review URL: http://codereview.chromium.org/146021

Modified: branches/bleeding_edge/src/arm/assembler-arm-inl.h
==============================================================================
--- branches/bleeding_edge/src/arm/assembler-arm-inl.h  (original)
+++ branches/bleeding_edge/src/arm/assembler-arm-inl.h  Tue Jun 23 02:50:51  
2009
@@ -50,7 +50,7 @@
  }


-void RelocInfo::apply(int delta) {
+void RelocInfo::apply(intptr_t delta) {
    if (RelocInfo::IsInternalReference(rmode_)) {
      // absolute code pointer inside code object moves with the code object.
      int32_t* p = reinterpret_cast<int32_t*>(pc_);

Modified: branches/bleeding_edge/src/assembler.h
==============================================================================
--- branches/bleeding_edge/src/assembler.h      (original)
+++ branches/bleeding_edge/src/assembler.h      Tue Jun 23 02:50:51 2009
@@ -183,7 +183,7 @@
    intptr_t data() const  { return data_; }

    // Apply a relocation by delta bytes
-  INLINE(void apply(int delta));
+  INLINE(void apply(intptr_t delta));

    // Read/modify the code target in the branch/call instruction
    // this relocation applies to;
@@ -265,8 +265,12 @@
      last_pc_ = pc;
    }

-  // Max size (bytes) of a written RelocInfo.
-  static const int kMaxSize = 12;
+  // Max size (bytes) of a written RelocInfo. Longest encoding is
+  // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag,  
data_delta.
+  // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12.
+  // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16;
+  // Here we use the maximum of the two.
+  static const int kMaxSize = 16;

   private:
    inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);

Modified: branches/bleeding_edge/src/ia32/assembler-ia32-inl.h
==============================================================================
--- branches/bleeding_edge/src/ia32/assembler-ia32-inl.h        (original)
+++ branches/bleeding_edge/src/ia32/assembler-ia32-inl.h        Tue Jun 23  
02:50:51 2009
@@ -48,7 +48,7 @@


  // The modes possibly affected by apply must be in kApplyMask.
-void RelocInfo::apply(int delta) {
+void RelocInfo::apply(intptr_t delta) {
    if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) {
      int32_t* p = reinterpret_cast<int32_t*>(pc_);
      *p -= delta;  // relocate entry

Modified: branches/bleeding_edge/src/ia32/assembler-ia32.h
==============================================================================
--- branches/bleeding_edge/src/ia32/assembler-ia32.h    (original)
+++ branches/bleeding_edge/src/ia32/assembler-ia32.h    Tue Jun 23 02:50:51  
2009
@@ -396,10 +396,15 @@

  class Assembler : public Malloced {
   private:
-  // The relocation writer's position is kGap bytes below the end of
+  // We check before assembling an instruction that there is sufficient
+  // space to write an instruction and its relocation information.
+  // The relocation writer's position must be kGap bytes above the end of
    // the generated instructions. This leaves enough space for the
-  // longest possible ia32 instruction (17 bytes as of 9/26/06) and
-  // allows for a single, fast space check per instruction.
+  // longest possible ia32 instruction, 15 bytes, and the longest possible
+  // relocation information encoding, RelocInfoWriter::kMaxLength == 16.
+  // (There is a 15 byte limit on ia32 instruction length that rules out  
some
+  // otherwise valid instructions.)
+  // This allows for a single, fast space check per instruction.
    static const int kGap = 32;

   public:

Modified: branches/bleeding_edge/src/x64/assembler-x64-inl.h
==============================================================================
--- branches/bleeding_edge/src/x64/assembler-x64-inl.h  (original)
+++ branches/bleeding_edge/src/x64/assembler-x64-inl.h  Tue Jun 23 02:50:51  
2009
@@ -147,11 +147,8 @@
  // Implementation of RelocInfo

  // The modes possibly affected by apply must be in kApplyMask.
-void RelocInfo::apply(int delta) {
-  if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) {
-    intptr_t* p = reinterpret_cast<intptr_t*>(pc_);
-    *p -= delta;  // relocate entry
-  } else if (IsInternalReference(rmode_)) {
+void RelocInfo::apply(intptr_t delta) {
+  if (IsInternalReference(rmode_)) {
      // absolute code pointer inside code object moves with the code object.
      intptr_t* p = reinterpret_cast<intptr_t*>(pc_);
      *p += delta;  // relocate entry

Modified: branches/bleeding_edge/src/x64/assembler-x64.cc
==============================================================================
--- branches/bleeding_edge/src/x64/assembler-x64.cc     (original)
+++ branches/bleeding_edge/src/x64/assembler-x64.cc     Tue Jun 23 02:50:51 2009
@@ -341,8 +341,9 @@
  #endif

    // copy the data
-  int pc_delta = desc.buffer - buffer_;
-  int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ +  
buffer_size_);
+  intptr_t pc_delta = desc.buffer - buffer_;
+  intptr_t rc_delta = (desc.buffer + desc.buffer_size) -
+      (buffer_ + buffer_size_);
    memmove(desc.buffer, buffer_, desc.instr_size);
    memmove(rc_delta + reloc_info_writer.pos(),
            reloc_info_writer.pos(), desc.reloc_size);
@@ -365,11 +366,8 @@
    // relocate runtime entries
    for (RelocIterator it(desc); !it.done(); it.next()) {
      RelocInfo::Mode rmode = it.rinfo()->rmode();
-    if (rmode == RelocInfo::RUNTIME_ENTRY) {
-      int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc());
-      *p -= pc_delta;  // relocate entry
-    } else if (rmode == RelocInfo::INTERNAL_REFERENCE) {
-      int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc());
+    if (rmode == RelocInfo::INTERNAL_REFERENCE) {
+      intptr_t* p = reinterpret_cast<intptr_t*>(it.rinfo()->pc());
        if (*p != 0) {  // 0 means uninitialized.
          *p += pc_delta;
        }
@@ -1825,9 +1823,7 @@
  }


-const int RelocInfo::kApplyMask =
-  RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY |
-    1 << RelocInfo::JS_RETURN | 1 << RelocInfo::INTERNAL_REFERENCE;
+const int RelocInfo::kApplyMask = 1 << RelocInfo::INTERNAL_REFERENCE;


  } }  // namespace v8::internal

Modified: branches/bleeding_edge/src/x64/assembler-x64.h
==============================================================================
--- branches/bleeding_edge/src/x64/assembler-x64.h      (original)
+++ branches/bleeding_edge/src/x64/assembler-x64.h      Tue Jun 23 02:50:51 2009
@@ -378,11 +378,15 @@

  class Assembler : public Malloced {
   private:
-  // The relocation writer's position is kGap bytes below the end of
+  // We check before assembling an instruction that there is sufficient
+  // space to write an instruction and its relocation information.
+  // The relocation writer's position must be kGap bytes above the end of
    // the generated instructions. This leaves enough space for the
-  // longest possible x64 instruction (There is a 15 byte limit on
-  // instruction length, ruling out some otherwise valid instructions) and
-  // allows for a single, fast space check per instruction.
+  // longest possible x64 instruction, 15 bytes, and the longest possible
+  // relocation information encoding, RelocInfoWriter::kMaxLength == 16.
+  // (There is a 15 byte limit on x64 instruction length that rules out  
some
+  // otherwise valid instructions.)
+  // This allows for a single, fast space check per instruction.
    static const int kGap = 32;

   public:

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to