| 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); | 551 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); |
| 552 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); | 552 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); |
| 553 | 553 |
| 554 result = CompileRun(slice_from_slice); | 554 result = CompileRun(slice_from_slice); |
| 555 CHECK(result->IsString()); | 555 CHECK(result->IsString()); |
| 556 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); | 556 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); |
| 557 CHECK(string->IsSlicedString()); | 557 CHECK(string->IsSlicedString()); |
| 558 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); | 558 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); |
| 559 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); | 559 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); |
| 560 } | 560 } |
| 561 |
| 562 |
| 563 TEST(SliceConversion) { |
| 564 // This tests whether a slice promoted during scavenging is properly |
| 565 // converted to a sequential string when being copied into old space. |
| 566 FLAG_string_slices = true; |
| 567 InitializeVM(); |
| 568 HandleScope scope; |
| 569 v8::Local<v8::Value> result; |
| 570 Handle<String> string; |
| 571 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';"; |
| 572 const char* slice = "str.slice(2,24)"; |
| 573 const char* fill_new_space = |
| 574 "var fill = [];" |
| 575 "for (var i = 0; i < 100000; i++) fill.push(i + ' ');"; |
| 576 |
| 577 CompileRun(init); |
| 578 |
| 579 result = CompileRun(slice); |
| 580 CHECK(result->IsString()); |
| 581 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); |
| 582 CHECK(HEAP->InNewSpace(*string)); |
| 583 CHECK(string->IsSlicedString()); |
| 584 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); |
| 585 |
| 586 CompileRun(fill_new_space); |
| 587 HEAP->PerformScavenge(); |
| 588 |
| 589 CHECK(!HEAP->InNewSpace(*string)); |
| 590 CHECK(string->IsSeqString()); |
| 591 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); |
| 592 } |
| OLD | NEW |