| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 | 2 |
| 3 // Check that we can traverse very deep stacks of ConsStrings using | 3 // Check that we can traverse very deep stacks of ConsStrings using |
| 4 // StringInputBuffer. Check that Get(int) works on very deep stacks | 4 // StringInputBuffer. Check that Get(int) works on very deep stacks |
| 5 // of ConsStrings. These operations may not be very fast, but they | 5 // of ConsStrings. These operations may not be very fast, but they |
| 6 // should be possible without getting errors due to too deep recursion. | 6 // should be possible without getting errors due to too deep recursion. |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "v8.h" | 10 #include "v8.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 answer); | 147 answer); |
| 148 } | 148 } |
| 149 return answer; | 149 return answer; |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 static Handle<String> ConstructBalancedHelper( | 153 static Handle<String> ConstructBalancedHelper( |
| 154 Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS], | 154 Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS], |
| 155 int from, | 155 int from, |
| 156 int to) { | 156 int to) { |
| 157 ASSERT(to > from); | 157 CHECK(to > from); |
| 158 if (to - from == 1) { | 158 if (to - from == 1) { |
| 159 return building_blocks[from % NUMBER_OF_BUILDING_BLOCKS]; | 159 return building_blocks[from % NUMBER_OF_BUILDING_BLOCKS]; |
| 160 } | 160 } |
| 161 if (to - from == 2) { | 161 if (to - from == 2) { |
| 162 return Factory::NewConsString( | 162 return Factory::NewConsString( |
| 163 building_blocks[from % NUMBER_OF_BUILDING_BLOCKS], | 163 building_blocks[from % NUMBER_OF_BUILDING_BLOCKS], |
| 164 building_blocks[(from+1) % NUMBER_OF_BUILDING_BLOCKS]); | 164 building_blocks[(from+1) % NUMBER_OF_BUILDING_BLOCKS]); |
| 165 } | 165 } |
| 166 Handle<String> part1 = | 166 Handle<String> part1 = |
| 167 ConstructBalancedHelper(building_blocks, from, from + ((to - from) / 2)); | 167 ConstructBalancedHelper(building_blocks, from, from + ((to - from) / 2)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return Factory::NewStringSlice(underlying, | 272 return Factory::NewStringSlice(underlying, |
| 273 start, | 273 start, |
| 274 end); | 274 end); |
| 275 } | 275 } |
| 276 | 276 |
| 277 | 277 |
| 278 static Handle<String> ConstructSliceTree( | 278 static Handle<String> ConstructSliceTree( |
| 279 Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS], | 279 Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS], |
| 280 int from, | 280 int from, |
| 281 int to) { | 281 int to) { |
| 282 ASSERT(to > from); | 282 CHECK(to > from); |
| 283 if (to - from <= 1) | 283 if (to - from <= 1) |
| 284 return SliceOf(building_blocks[from % NUMBER_OF_BUILDING_BLOCKS]); | 284 return SliceOf(building_blocks[from % NUMBER_OF_BUILDING_BLOCKS]); |
| 285 if (to - from == 2) { | 285 if (to - from == 2) { |
| 286 Handle<String> lhs = building_blocks[from % NUMBER_OF_BUILDING_BLOCKS]; | 286 Handle<String> lhs = building_blocks[from % NUMBER_OF_BUILDING_BLOCKS]; |
| 287 if (gen() % 2 == 0) | 287 if (gen() % 2 == 0) |
| 288 lhs = SliceOf(lhs); | 288 lhs = SliceOf(lhs); |
| 289 Handle<String> rhs = building_blocks[(from+1) % NUMBER_OF_BUILDING_BLOCKS]; | 289 Handle<String> rhs = building_blocks[(from+1) % NUMBER_OF_BUILDING_BLOCKS]; |
| 290 if (gen() % 2 == 0) | 290 if (gen() % 2 == 0) |
| 291 rhs = SliceOf(rhs); | 291 rhs = SliceOf(rhs); |
| 292 return Factory::NewConsString(lhs, rhs); | 292 return Factory::NewConsString(lhs, rhs); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 CHECK_EQ(false, string->IsEqualTo(one_byte_vec)); | 437 CHECK_EQ(false, string->IsEqualTo(one_byte_vec)); |
| 438 #if !defined(DEBUG) | 438 #if !defined(DEBUG) |
| 439 // These tests only work in non-debug as there are ASSERTs in the code that | 439 // These tests only work in non-debug as there are ASSERTs in the code that |
| 440 // do prevent the ability to even get into the broken code when running the | 440 // do prevent the ability to even get into the broken code when running the |
| 441 // debug version of V8. | 441 // debug version of V8. |
| 442 CHECK_EQ(false, string->Equals(*compare)); | 442 CHECK_EQ(false, string->Equals(*compare)); |
| 443 CHECK_EQ(false, compare->Equals(*string)); | 443 CHECK_EQ(false, compare->Equals(*string)); |
| 444 CHECK_EQ(false, string->Equals(Heap::empty_string())); | 444 CHECK_EQ(false, string->Equals(Heap::empty_string())); |
| 445 #endif // !defined(DEBUG) | 445 #endif // !defined(DEBUG) |
| 446 } | 446 } |
| OLD | NEW |