| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 CHECK(!string->IsSlicedString()); | 522 CHECK(!string->IsSlicedString()); |
| 523 | 523 |
| 524 string = FACTORY->NewSubString(string, 0, 26); | 524 string = FACTORY->NewSubString(string, 0, 26); |
| 525 CHECK(!string->IsSlicedString()); | 525 CHECK(!string->IsSlicedString()); |
| 526 result = CompileRun(crosscheck); | 526 result = CompileRun(crosscheck); |
| 527 CHECK(result->IsString()); | 527 CHECK(result->IsString()); |
| 528 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); | 528 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); |
| 529 CHECK(string->IsSlicedString()); | 529 CHECK(string->IsSlicedString()); |
| 530 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); | 530 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); |
| 531 } | 531 } |
| 532 |
| 533 |
| 534 TEST(SliceConversion) { |
| 535 // This tests whether a slice promoted during scavenging is properly |
| 536 // converted to a sequential string when being copied into old space. |
| 537 FLAG_string_slices = true; |
| 538 InitializeVM(); |
| 539 HandleScope scope; |
| 540 v8::Local<v8::Value> result; |
| 541 Handle<String> string; |
| 542 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';"; |
| 543 const char* slice = "str.slice(2,24)"; |
| 544 const char* fill_new_space = |
| 545 "var fill = [];" |
| 546 "for (var i = 0; i < 100000; i++) fill.push(i + ' ');"; |
| 547 |
| 548 |
| 549 CompileRun(init); |
| 550 |
| 551 result = CompileRun(slice); |
| 552 CHECK(result->IsString()); |
| 553 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); |
| 554 CHECK(HEAP->InNewSpace(*string)); |
| 555 CHECK(string->IsSlicedString()); |
| 556 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); |
| 557 |
| 558 CompileRun(fill_new_space); |
| 559 HEAP->PerformScavenge(); |
| 560 |
| 561 CHECK(!HEAP->InNewSpace(*string)); |
| 562 CHECK(string->IsSeqString()); |
| 563 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); |
| 564 } |
| OLD | NEW |