| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/debug/liveedit.h" | 5 #include "src/debug/liveedit.h" |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/compilation-cache.h" | 8 #include "src/compilation-cache.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 | 903 |
| 904 // Visitor that finds all references to a particular code object, | 904 // Visitor that finds all references to a particular code object, |
| 905 // including "CODE_TARGET" references in other code objects and replaces | 905 // including "CODE_TARGET" references in other code objects and replaces |
| 906 // them on the fly. | 906 // them on the fly. |
| 907 class ReplacingVisitor : public ObjectVisitor { | 907 class ReplacingVisitor : public ObjectVisitor { |
| 908 public: | 908 public: |
| 909 explicit ReplacingVisitor(Code* original, Code* substitution) | 909 explicit ReplacingVisitor(Code* original, Code* substitution) |
| 910 : original_(original), substitution_(substitution) { | 910 : original_(original), substitution_(substitution) { |
| 911 } | 911 } |
| 912 | 912 |
| 913 virtual void VisitPointers(Object** start, Object** end) { | 913 void VisitPointers(Object** start, Object** end) override { |
| 914 for (Object** p = start; p < end; p++) { | 914 for (Object** p = start; p < end; p++) { |
| 915 if (*p == original_) { | 915 if (*p == original_) { |
| 916 *p = substitution_; | 916 *p = substitution_; |
| 917 } | 917 } |
| 918 } | 918 } |
| 919 } | 919 } |
| 920 | 920 |
| 921 virtual void VisitCodeEntry(Address entry) { | 921 void VisitCodeEntry(Address entry) override { |
| 922 if (Code::GetObjectFromEntryAddress(entry) == original_) { | 922 if (Code::GetObjectFromEntryAddress(entry) == original_) { |
| 923 Address substitution_entry = substitution_->instruction_start(); | 923 Address substitution_entry = substitution_->instruction_start(); |
| 924 Memory::Address_at(entry) = substitution_entry; | 924 Memory::Address_at(entry) = substitution_entry; |
| 925 } | 925 } |
| 926 } | 926 } |
| 927 | 927 |
| 928 virtual void VisitCodeTarget(RelocInfo* rinfo) { | 928 void VisitCodeTarget(RelocInfo* rinfo) override { |
| 929 if (RelocInfo::IsCodeTarget(rinfo->rmode()) && | 929 if (RelocInfo::IsCodeTarget(rinfo->rmode()) && |
| 930 Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) { | 930 Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) { |
| 931 Address substitution_entry = substitution_->instruction_start(); | 931 Address substitution_entry = substitution_->instruction_start(); |
| 932 rinfo->set_target_address(substitution_entry); | 932 rinfo->set_target_address(substitution_entry); |
| 933 } | 933 } |
| 934 } | 934 } |
| 935 | 935 |
| 936 virtual void VisitDebugTarget(RelocInfo* rinfo) { | 936 void VisitDebugTarget(RelocInfo* rinfo) override { VisitCodeTarget(rinfo); } |
| 937 VisitCodeTarget(rinfo); | |
| 938 } | |
| 939 | 937 |
| 940 private: | 938 private: |
| 941 Code* original_; | 939 Code* original_; |
| 942 Code* substitution_; | 940 Code* substitution_; |
| 943 }; | 941 }; |
| 944 | 942 |
| 945 | 943 |
| 946 // Finds all references to original and replaces them with substitution. | 944 // Finds all references to original and replaces them with substitution. |
| 947 static void ReplaceCodeObject(Handle<Code> original, | 945 static void ReplaceCodeObject(Handle<Code> original, |
| 948 Handle<Code> substitution) { | 946 Handle<Code> substitution) { |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2005 isolate_->active_function_info_listener()->FunctionCode(code); | 2003 isolate_->active_function_info_listener()->FunctionCode(code); |
| 2006 } | 2004 } |
| 2007 | 2005 |
| 2008 | 2006 |
| 2009 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2007 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
| 2010 return isolate->active_function_info_listener() != NULL; | 2008 return isolate->active_function_info_listener() != NULL; |
| 2011 } | 2009 } |
| 2012 | 2010 |
| 2013 } // namespace internal | 2011 } // namespace internal |
| 2014 } // namespace v8 | 2012 } // namespace v8 |
| OLD | NEW |