Commit af63e616 authored by peter.rybin@gmail.com's avatar peter.rybin@gmail.com

Support multi-chunk differences

Review URL: http://codereview.chromium.org/1672006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4467 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e44869ae
This diff is collapsed.
...@@ -346,7 +346,7 @@ class LineArrayCompareInput : public Compare::Input { ...@@ -346,7 +346,7 @@ class LineArrayCompareInput : public Compare::Input {
// Stores compare result in JSArray. Each chunk is stored as 3 array elements: // Stores compare result in JSArray. Each chunk is stored as 3 array elements:
// (pos1, len1, len2). // (pos1_begin, pos1_end, pos2_end).
class LineArrayCompareOutput : public Compare::Output { class LineArrayCompareOutput : public Compare::Output {
public: public:
LineArrayCompareOutput(LineEndsWrapper line_ends1, LineEndsWrapper line_ends2) LineArrayCompareOutput(LineEndsWrapper line_ends1, LineEndsWrapper line_ends2)
...@@ -362,9 +362,9 @@ class LineArrayCompareOutput : public Compare::Output { ...@@ -362,9 +362,9 @@ class LineArrayCompareOutput : public Compare::Output {
SetElement(array_, current_size_, Handle<Object>(Smi::FromInt(char_pos1))); SetElement(array_, current_size_, Handle<Object>(Smi::FromInt(char_pos1)));
SetElement(array_, current_size_ + 1, SetElement(array_, current_size_ + 1,
Handle<Object>(Smi::FromInt(char_len1))); Handle<Object>(Smi::FromInt(char_pos1 + char_len1)));
SetElement(array_, current_size_ + 2, SetElement(array_, current_size_ + 2,
Handle<Object>(Smi::FromInt(char_len2))); Handle<Object>(Smi::FromInt(char_pos2 + char_len2)));
current_size_ += 3; current_size_ += 3;
} }
...@@ -717,8 +717,8 @@ class ReferenceCollectorVisitor : public ObjectVisitor { ...@@ -717,8 +717,8 @@ class ReferenceCollectorVisitor : public ObjectVisitor {
} }
void VisitCodeTarget(RelocInfo* rinfo) { void VisitCodeTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); if (RelocInfo::IsCodeTarget(rinfo->rmode()) &&
if (Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) { Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) {
reloc_infos_.Add(*rinfo); reloc_infos_.Add(*rinfo);
} }
} }
......
...@@ -111,7 +111,7 @@ class LiveEdit : AllStatic { ...@@ -111,7 +111,7 @@ class LiveEdit : AllStatic {
}; };
// Compares 2 strings line-by-line and returns diff in form of array of // Compares 2 strings line-by-line and returns diff in form of array of
// triplets (pos1, len1, len2) describing list of diff chunks. // triplets (pos1, pos1_end, pos2_end) describing list of diff chunks.
static Handle<JSArray> CompareStringsLinewise(Handle<String> s1, static Handle<JSArray> CompareStringsLinewise(Handle<String> s1,
Handle<String> s2); Handle<String> s2);
}; };
......
...@@ -9766,7 +9766,7 @@ static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) { ...@@ -9766,7 +9766,7 @@ static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) {
} }
// Compares 2 strings line-by-line and returns diff in form of JSArray of // Compares 2 strings line-by-line and returns diff in form of JSArray of
// triplets (pos1, len1, len2) describing list of diff chunks. // triplets (pos1, pos1_end, pos2_end) describing list of diff chunks.
static Object* Runtime_LiveEditCompareStringsLinewise(Arguments args) { static Object* Runtime_LiveEditCompareStringsLinewise(Arguments args) {
ASSERT(args.length() == 2); ASSERT(args.length() == 2);
HandleScope scope; HandleScope scope;
......
...@@ -30,18 +30,39 @@ ...@@ -30,18 +30,39 @@
Debug = debug.Debug Debug = debug.Debug
eval("var something1 = 25; " eval("var something1 = 25; \n"
+ " function ChooseAnimal() { return 'Cat'; } " + "var something2 = 2010; \n"
+ " ChooseAnimal.Helper = function() { return 'Help!'; }"); + "function ChooseAnimal() {\n"
+ " return 'Cat';\n"
+ "} \n"
+ "function ChooseFurniture() {\n"
+ " return 'Table';\n"
+ "} \n"
+ "function ChooseNumber() { return 17; } \n"
+ "ChooseAnimal.Factory = function Factory() {\n"
+ " return function FactoryImpl(name) {\n"
+ " return 'Help ' + name;\n"
+ " }\n"
+ "}\n");
assertEquals("Cat", ChooseAnimal()); assertEquals("Cat", ChooseAnimal());
assertEquals(25, something1);
var script = Debug.findScript(ChooseAnimal); var script = Debug.findScript(ChooseAnimal);
var new_source = script.source.replace("Cat", "Cap' + 'yb' + 'ara"); var new_source = script.source.replace("Cat", "Cap' + 'yb' + 'ara");
var new_source = new_source.replace("25", "26");
var new_source = new_source.replace("Help", "Hello");
var new_source = new_source.replace("17", "18");
print("new source: " + new_source); print("new source: " + new_source);
var change_log = new Array(); var change_log = new Array();
Debug.LiveEdit.SetScriptSource(script, new_source, change_log); Debug.LiveEdit.SetScriptSource(script, new_source, change_log);
print("Change log: " + JSON.stringify(change_log) + "\n");
assertEquals("Capybara", ChooseAnimal()); assertEquals("Capybara", ChooseAnimal());
// Global variable do not get changed (without restarting script).
assertEquals(25, something1);
// Function is oneliner, so currently it is treated as damaged and not patched.
assertEquals(17, ChooseNumber());
assertEquals("Hello Peter", ChooseAnimal.Factory()("Peter"));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment