yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1 | // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 | |
| 3 | // Check that we can traverse very deep stacks of ConsStrings using |
| 4 | // StringCharacterStram. Check that Get(int) works on very deep stacks |
| 5 | // of ConsStrings. These operations may not be very fast, but they |
| 6 | // should be possible without getting errors due to too deep recursion. |
| 7 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 8 | // TODO(dcarney): remove |
| 9 | #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
| 10 | #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW |
| 11 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 12 | #include "v8.h" |
| 13 | |
| 14 | #include "cctest.h" |
| 15 | #include "objects.h" |
| 16 | |
| 17 | using namespace v8::internal; |
| 18 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 19 | |
| 20 | TEST(Create) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 21 | CcTest::InitializeVM(); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 22 | Isolate* isolate = Isolate::Current(); |
| 23 | HandleScope scope(isolate); |
| 24 | |
| 25 | const int kNumSymbols = 30; |
| 26 | Handle<Symbol> symbols[kNumSymbols]; |
| 27 | |
| 28 | for (int i = 0; i < kNumSymbols; ++i) { |
| 29 | symbols[i] = isolate->factory()->NewSymbol(); |
| 30 | CHECK(symbols[i]->IsName()); |
| 31 | CHECK(symbols[i]->IsSymbol()); |
| 32 | CHECK(symbols[i]->HasHashCode()); |
| 33 | CHECK_GT(symbols[i]->Hash(), 0); |
| 34 | symbols[i]->ShortPrint(); |
| 35 | PrintF("\n"); |
| 36 | #if OBJECT_PRINT |
| 37 | symbols[i]->Print(); |
| 38 | #endif |
| 39 | #if VERIFY_HEAP |
| 40 | symbols[i]->Verify(); |
| 41 | #endif |
| 42 | } |
| 43 | |
| 44 | HEAP->PerformScavenge(); |
| 45 | HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 46 | |
| 47 | // All symbols should be distinct. |
| 48 | for (int i = 0; i < kNumSymbols; ++i) { |
| 49 | CHECK(symbols[i]->SameValue(*symbols[i])); |
| 50 | for (int j = i + 1; j < kNumSymbols; ++j) { |
| 51 | CHECK(!symbols[i]->SameValue(*symbols[j])); |
| 52 | } |
| 53 | } |
| 54 | } |