| 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // get its wrapper. This allocates yet another weak handle that | 473 // get its wrapper. This allocates yet another weak handle that |
| 474 // indirectly refers to the external string. | 474 // indirectly refers to the external string. |
| 475 Handle<Script> script = Factory::NewScript(slice); | 475 Handle<Script> script = Factory::NewScript(slice); |
| 476 Handle<JSObject> wrapper = GetScriptWrapper(script); | 476 Handle<JSObject> wrapper = GetScriptWrapper(script); |
| 477 } | 477 } |
| 478 | 478 |
| 479 // When we collect all garbage, we cannot get rid of the sliced | 479 // When we collect all garbage, we cannot get rid of the sliced |
| 480 // symbol entry in the symbol table because it is used by the script | 480 // symbol entry in the symbol table because it is used by the script |
| 481 // kept alive by the weak wrapper. Make sure we don't destruct the | 481 // kept alive by the weak wrapper. Make sure we don't destruct the |
| 482 // external string. | 482 // external string. |
| 483 Heap::CollectAllGarbage(); | 483 Heap::CollectAllGarbage(false); |
| 484 CHECK(!resource_destructed); | 484 CHECK(!resource_destructed); |
| 485 | 485 |
| 486 { | 486 { |
| 487 v8::HandleScope scope; | 487 v8::HandleScope scope; |
| 488 | 488 |
| 489 // Make sure the sliced symbol is still in the table. | 489 // Make sure the sliced symbol is still in the table. |
| 490 Handle<String> symbol = Factory::LookupSymbol(key_vector); | 490 Handle<String> symbol = Factory::LookupSymbol(key_vector); |
| 491 CHECK(StringShape(*symbol).IsSliced()); | 491 CHECK(StringShape(*symbol).IsSliced()); |
| 492 | 492 |
| 493 // Make sure the buffer is still a two-byte external string. | 493 // Make sure the buffer is still a two-byte external string. |
| 494 Handle<String> buffer(Handle<SlicedString>::cast(symbol)->buffer()); | 494 Handle<String> buffer(Handle<SlicedString>::cast(symbol)->buffer()); |
| 495 CHECK(StringShape(*buffer).IsExternal()); | 495 CHECK(StringShape(*buffer).IsExternal()); |
| 496 CHECK(buffer->IsTwoByteRepresentation()); | 496 CHECK(buffer->IsTwoByteRepresentation()); |
| 497 } | 497 } |
| 498 | 498 |
| 499 // Forcing another garbage collection should let us get rid of the | 499 // Forcing another garbage collection should let us get rid of the |
| 500 // slice from the symbol table. The external string remains in the | 500 // slice from the symbol table. The external string remains in the |
| 501 // heap until the next GC. | 501 // heap until the next GC. |
| 502 Heap::CollectAllGarbage(); | 502 Heap::CollectAllGarbage(false); |
| 503 CHECK(!resource_destructed); | 503 CHECK(!resource_destructed); |
| 504 v8::HandleScope scope; | 504 v8::HandleScope scope; |
| 505 Handle<String> key_string = Factory::NewStringFromAscii(key_vector); | 505 Handle<String> key_string = Factory::NewStringFromAscii(key_vector); |
| 506 String* out; | 506 String* out; |
| 507 CHECK(!Heap::LookupSymbolIfExists(*key_string, &out)); | 507 CHECK(!Heap::LookupSymbolIfExists(*key_string, &out)); |
| 508 | 508 |
| 509 // Forcing yet another garbage collection must allow us to finally | 509 // Forcing yet another garbage collection must allow us to finally |
| 510 // get rid of the external string. | 510 // get rid of the external string. |
| 511 Heap::CollectAllGarbage(); | 511 Heap::CollectAllGarbage(false); |
| 512 CHECK(resource_destructed); | 512 CHECK(resource_destructed); |
| 513 | 513 |
| 514 delete[] source; | 514 delete[] source; |
| 515 delete[] key; | 515 delete[] key; |
| 516 } | 516 } |
| OLD | NEW |