28 #ifdef ENABLE_DEBUGGER_SUPPORT
38 using namespace v8::internal;
43 class StringCompareInput :
public Comparator::Input {
45 StringCompareInput(
const char*
s1,
const char*
s2) : s1_(s1), s2_(s2) {
53 bool Equals(
int index1,
int index2) {
54 return s1_[index1] == s2_[index2];
65 DiffChunkStruct(
int pos1_param,
int pos2_param,
66 int len1_param,
int len2_param)
67 : pos1(pos1_param), pos2(pos2_param),
68 len1(len1_param), len2(len2_param), next(
NULL) {}
73 DiffChunkStruct* next;
77 class ListDiffOutputWriter :
public Comparator::Output {
79 explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer)
80 : next_chunk_pointer_(next_chunk_pointer) {
81 (*next_chunk_pointer_) =
NULL;
83 void AddChunk(
int pos1,
int pos2,
int len1,
int len2) {
84 current_chunk_ =
new(Isolate::Current()->runtime_zone()) DiffChunkStruct(
85 pos1, pos2, len1, len2);
86 (*next_chunk_pointer_) = current_chunk_;
87 next_chunk_pointer_ = ¤t_chunk_->next;
90 DiffChunkStruct** next_chunk_pointer_;
91 DiffChunkStruct* current_chunk_;
95 void CompareStringsOneWay(
const char*
s1,
const char*
s2,
96 int expected_diff_parameter = -1) {
97 StringCompareInput input(s1, s2);
99 ZoneScope zone_scope(Isolate::Current()->runtime_zone(),
DELETE_ON_EXIT);
101 DiffChunkStruct* first_chunk;
102 ListDiffOutputWriter writer(&first_chunk);
104 Comparator::CalculateDifference(&input, &writer);
112 int diff_parameter = 0;
114 for (DiffChunkStruct* chunk = first_chunk;
116 chunk = chunk->next) {
117 int diff_pos1 = chunk->pos1;
118 int similar_part_length = diff_pos1 - pos1;
119 int diff_pos2 = pos2 + similar_part_length;
123 for (
int j = 0; j < similar_part_length; j++) {
128 diff_parameter += chunk->len1 + chunk->len2;
129 pos1 = diff_pos1 + chunk->len1;
130 pos2 = diff_pos2 + chunk->len2;
134 int similar_part_length = len1 - pos1;
135 ASSERT_EQ(similar_part_length, len2 - pos2);
137 for (
int j = 0; j < similar_part_length; j++) {
144 if (expected_diff_parameter != -1) {
145 ASSERT_EQ(expected_diff_parameter, diff_parameter);
150 void CompareStrings(
const char* s1,
const char* s2,
151 int expected_diff_parameter = -1) {
152 CompareStringsOneWay(s1, s2, expected_diff_parameter);
153 CompareStringsOneWay(s2, s1, expected_diff_parameter);
161 TEST(LiveEditDiffer) {
163 CompareStrings(
"zz1zzz12zz123zzz",
"zzzzzzzzzz", 6);
164 CompareStrings(
"zz1zzz12zz123zzz",
"zz0zzz0zz0zzz", 9);
165 CompareStrings(
"123456789",
"987654321", 16);
166 CompareStrings(
"zzz",
"yyy", 6);
167 CompareStrings(
"zzz",
"zzz12", 2);
168 CompareStrings(
"zzz",
"21zzz", 2);
169 CompareStrings(
"cat",
"cut", 2);
170 CompareStrings(
"ct",
"cut", 1);
171 CompareStrings(
"cat",
"ct", 1);
172 CompareStrings(
"cat",
"cat", 0);
173 CompareStrings(
"",
"", 0);
174 CompareStrings(
"cat",
"", 3);
175 CompareStrings(
"a cat",
"a capybara", 7);
176 CompareStrings(
"abbabababababaaabbabababababbabbbbbbbababa",
177 "bbbbabababbbabababbbabababababbabbababa");
180 #endif // ENABLE_DEBUGGER_SUPPORT
static bool Initialize(Deserializer *des)
#define ASSERT(condition)
int StrLength(const char *string)
#define ASSERT_EQ(v1, v2)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL