I'll take a look tomorrow.

Does it work on 64 bit?

On Thu, May 10, 2012 at 11:20 PM,  <[email protected]> wrote:
> Reviewers: Erik Corry,
>
> Message:
> Hi Erik
>
> Do you think it looks like a fix for
> http://code.google.com/p/v8/issues/detail?id=915
> ?
>
> Peter
>
> Description:
> Fix for Issue 915
>
>
> Please review this at http://codereview.chromium.org/10332101/
>
> SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
>
> Affected files:
>  M src/liveedit.cc
>
>
> Index: src/liveedit.cc
> diff --git a/src/liveedit.cc b/src/liveedit.cc
> index
> 22b82501e91f244b7bf16839e30ffb295c51e34d..76da4fc8424a076d703a940a2b7a14f63d03d97c
> 100644
> --- a/src/liveedit.cc
> +++ b/src/liveedit.cc
> @@ -922,33 +922,37 @@ void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray>
> array) {
>  }
>
>
> -// Visitor that collects all references to a particular code object,
> -// including "CODE_TARGET" references in other code objects.
> -// It works in context of ZoneScope.
> -class ReferenceCollectorVisitor : public ObjectVisitor {
> +// Visitor that finds all references to a particular code object,
> +// including "CODE_TARGET" references in other code objects and replaces
> +// them on the fly.
> +// TODO: Will heap iteration tolerate this changes-on-iteration?
> +// TODO: Do we have to deal with any kind of write barriers here?
> +class ReplacingVisitor : public ObjectVisitor {
>  public:
> -  explicit ReferenceCollectorVisitor(Code* original)
> -    : original_(original), rvalues_(10), reloc_infos_(10),
> code_entries_(10) {
> +  explicit ReplacingVisitor(Code* original, Code* substitution)
> +    : original_(original), substitution_(substitution) {
>   }
>
>   virtual void VisitPointers(Object** start, Object** end) {
>     for (Object** p = start; p < end; p++) {
>       if (*p == original_) {
> -        rvalues_.Add(p);
> +        *p = substitution_;
>       }
>     }
>   }
>
>   virtual void VisitCodeEntry(Address entry) {
>     if (Code::GetObjectFromEntryAddress(entry) == original_) {
> -      code_entries_.Add(entry);
> +      Address substitution_entry = substitution_->instruction_start();
> +      Memory::Address_at(entry) = substitution_entry;
>     }
>   }
>
>   virtual void VisitCodeTarget(RelocInfo* rinfo) {
>     if (RelocInfo::IsCodeTarget(rinfo->rmode()) &&
>         Code::GetCodeFromTargetAddress(rinfo->target_address()) ==
> original_) {
> -      reloc_infos_.Add(*rinfo);
> +      Address substitution_entry = substitution_->instruction_start();
> +      rinfo->set_target_address(substitution_entry);
>     }
>   }
>
> @@ -956,27 +960,9 @@ class ReferenceCollectorVisitor : public ObjectVisitor
> {
>     VisitCodeTarget(rinfo);
>   }
>
> -  // Post-visiting method that iterates over all collected references and
> -  // modifies them.
> -  void Replace(Code* substitution) {
> -    for (int i = 0; i < rvalues_.length(); i++) {
> -      *(rvalues_[i]) = substitution;
> -    }
> -    Address substitution_entry = substitution->instruction_start();
> -    for (int i = 0; i < reloc_infos_.length(); i++) {
> -      reloc_infos_[i].set_target_address(substitution_entry);
> -    }
> -    for (int i = 0; i < code_entries_.length(); i++) {
> -      Address entry = code_entries_[i];
> -      Memory::Address_at(entry) = substitution_entry;
> -    }
> -  }
> -
>  private:
>   Code* original_;
> -  ZoneList<Object**> rvalues_;
> -  ZoneList<RelocInfo> reloc_infos_;
> -  ZoneList<Address> code_entries_;
> +  Code* substitution_;
>  };
>
>
> @@ -984,28 +970,21 @@ class ReferenceCollectorVisitor : public ObjectVisitor
> {
>  static void ReplaceCodeObject(Code* original, Code* substitution) {
>   ASSERT(!HEAP->InNewSpace(substitution));
>
> -  HeapIterator iterator;
>   AssertNoAllocation no_allocations_please;
>
> -  // A zone scope for ReferenceCollectorVisitor.
> -  ZoneScope scope(Isolate::Current(), DELETE_ON_EXIT);
> -
> -  ReferenceCollectorVisitor visitor(original);
> +  ReplacingVisitor visitor(original, substitution);
>
>   // Iterate over all roots. Stack frames may have pointer into original
> code,
>   // so temporary replace the pointers with offset numbers
>   // in prologue/epilogue.
> -  {
> -    HEAP->IterateStrongRoots(&visitor, VISIT_ALL);
> -  }
> +  HEAP->IterateRoots(&visitor, VISIT_ALL);
>
>   // Now iterate over all pointers of all objects, including code_target
>   // implicit pointers.
> +  HeapIterator iterator;
>   for (HeapObject* obj = iterator.next(); obj != NULL; obj =
> iterator.next()) {
>     obj->Iterate(&visitor);
>   }
> -
> -  visitor.Replace(substitution);
>  }
>
>
>
>



-- 
Erik Corry, Software Engineer
Google Denmark ApS - Frederiksborggade 20B, 1 sal,
1360 København K - Denmark - CVR nr. 28 86 69 84

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

Reply via email to