OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 5055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5066 Handle<JSArray> array = factory->NewJSArray(2); | 5066 Handle<JSArray> array = factory->NewJSArray(2); |
5067 | 5067 |
5068 Handle<String> name = factory->InternalizeUtf8String("testArray"); | 5068 Handle<String> name = factory->InternalizeUtf8String("testArray"); |
5069 JSReceiver::SetProperty(global, name, array, SLOPPY).Check(); | 5069 JSReceiver::SetProperty(global, name, array, SLOPPY).Check(); |
5070 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); | 5070 CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); |
5071 heap->CollectGarbage(OLD_POINTER_SPACE); | 5071 heap->CollectGarbage(OLD_POINTER_SPACE); |
5072 } | 5072 } |
5073 | 5073 |
5074 | 5074 |
5075 TEST(NumberStringCacheSize) { | 5075 TEST(NumberStringCacheSize) { |
5076 if (!Snapshot::HaveASnapshotToStartFrom()) return; | |
5077 // Test that the number-string cache has not been resized in the snapshot. | 5076 // Test that the number-string cache has not been resized in the snapshot. |
5078 CcTest::InitializeVM(); | 5077 CcTest::InitializeVM(); |
5079 Isolate* isolate = CcTest::i_isolate(); | 5078 Isolate* isolate = CcTest::i_isolate(); |
| 5079 if (!isolate->snapshot_available()) return; |
5080 Heap* heap = isolate->heap(); | 5080 Heap* heap = isolate->heap(); |
5081 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, | 5081 CHECK_EQ(TestHeap::kInitialNumberStringCacheSize * 2, |
5082 heap->number_string_cache()->length()); | 5082 heap->number_string_cache()->length()); |
5083 } | 5083 } |
5084 | 5084 |
5085 | 5085 |
5086 #ifdef DEBUG | 5086 #ifdef DEBUG |
5087 TEST(PathTracer) { | 5087 TEST(PathTracer) { |
5088 CcTest::InitializeVM(); | 5088 CcTest::InitializeVM(); |
5089 v8::HandleScope scope(CcTest::isolate()); | 5089 v8::HandleScope scope(CcTest::isolate()); |
5090 | 5090 |
5091 v8::Local<v8::Value> result = CompileRun("'abc'"); | 5091 v8::Local<v8::Value> result = CompileRun("'abc'"); |
5092 Handle<Object> o = v8::Utils::OpenHandle(*result); | 5092 Handle<Object> o = v8::Utils::OpenHandle(*result); |
5093 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 5093 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
5094 } | 5094 } |
5095 #endif // DEBUG | 5095 #endif // DEBUG |
5096 | |
5097 | |
5098 TEST(FirstPageFitsStartup) { | |
5099 // Test that the first page sizes provided by the default snapshot are large | |
5100 // enough to fit everything right after startup and creating one context. | |
5101 // If this test fails, we are allocating too much aside from deserialization. | |
5102 if (!Snapshot::HaveASnapshotToStartFrom()) return; | |
5103 if (Snapshot::EmbedsScript()) return; | |
5104 CcTest::InitializeVM(); | |
5105 LocalContext env; | |
5106 PagedSpaces spaces(CcTest::heap()); | |
5107 for (PagedSpace* s = spaces.next(); s != NULL; s = spaces.next()) { | |
5108 uint32_t default_size = s->AreaSize(); | |
5109 uint32_t reduced_size = Snapshot::SizeOfFirstPage(s->identity()); | |
5110 if (reduced_size == default_size) continue; | |
5111 int counter = 0; | |
5112 Page* page = NULL; | |
5113 for (PageIterator it(s); it.has_next(); page = it.next()) counter++; | |
5114 CHECK_LE(counter, 1); | |
5115 CHECK(static_cast<uint32_t>(page->area_size()) == reduced_size); | |
5116 } | |
5117 } | |
OLD | NEW |