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,
81 : next_chunk_pointer_(next_chunk_pointer), zone_(zone) {
82 (*next_chunk_pointer_) =
NULL;
84 void AddChunk(
int pos1,
int pos2,
int len1,
int len2) {
85 current_chunk_ =
new(zone_) DiffChunkStruct(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_;
96 void CompareStringsOneWay(
const char*
s1,
const char*
s2,
97 int expected_diff_parameter = -1) {
98 StringCompareInput input(s1, s2);
102 DiffChunkStruct* first_chunk;
103 ListDiffOutputWriter writer(&first_chunk, &zone);
105 Comparator::CalculateDifference(&input, &writer);
113 int diff_parameter = 0;
115 for (DiffChunkStruct* chunk = first_chunk;
117 chunk = chunk->next) {
118 int diff_pos1 = chunk->pos1;
119 int similar_part_length = diff_pos1 - pos1;
120 int diff_pos2 = pos2 + similar_part_length;
124 for (
int j = 0; j < similar_part_length; j++) {
129 diff_parameter += chunk->len1 + chunk->len2;
130 pos1 = diff_pos1 + chunk->len1;
131 pos2 = diff_pos2 + chunk->len2;
135 int similar_part_length = len1 - pos1;
136 ASSERT_EQ(similar_part_length, len2 - pos2);
138 for (
int j = 0; j < similar_part_length; j++) {
145 if (expected_diff_parameter != -1) {
146 ASSERT_EQ(expected_diff_parameter, diff_parameter);
151 void CompareStrings(
const char* s1,
const char* s2,
152 int expected_diff_parameter = -1) {
153 CompareStringsOneWay(s1, s2, expected_diff_parameter);
154 CompareStringsOneWay(s2, s1, expected_diff_parameter);
162 TEST(LiveEditDiffer) {
164 CompareStrings(
"zz1zzz12zz123zzz",
"zzzzzzzzzz", 6);
165 CompareStrings(
"zz1zzz12zz123zzz",
"zz0zzz0zz0zzz", 9);
166 CompareStrings(
"123456789",
"987654321", 16);
167 CompareStrings(
"zzz",
"yyy", 6);
168 CompareStrings(
"zzz",
"zzz12", 2);
169 CompareStrings(
"zzz",
"21zzz", 2);
170 CompareStrings(
"cat",
"cut", 2);
171 CompareStrings(
"ct",
"cut", 1);
172 CompareStrings(
"cat",
"ct", 1);
173 CompareStrings(
"cat",
"cat", 0);
174 CompareStrings(
"",
"", 0);
175 CompareStrings(
"cat",
"", 3);
176 CompareStrings(
"a cat",
"a capybara", 7);
177 CompareStrings(
"abbabababababaaabbabababababbabbbbbbbababa",
178 "bbbbabababbbabababbbabababababbabbababa");
181 #endif // ENABLE_DEBUGGER_SUPPORT
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static bool Initialize(Deserializer *des)
#define ASSERT(condition)
static i::Isolate * i_isolate()
int StrLength(const char *string)
#define ASSERT_EQ(v1, v2)