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 6422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6433 PrintF("Context size : %d bytes\n", measure.Size()); | 6433 PrintF("Context size : %d bytes\n", measure.Size()); |
6434 PrintF("Context object count: %d\n", measure.Count()); | 6434 PrintF("Context object count: %d\n", measure.Count()); |
6435 | 6435 |
6436 CHECK_LE(1000, measure.Count()); | 6436 CHECK_LE(1000, measure.Count()); |
6437 CHECK_LE(50000, measure.Size()); | 6437 CHECK_LE(50000, measure.Size()); |
6438 | 6438 |
6439 CHECK_LE(measure.Count(), count_upper_limit); | 6439 CHECK_LE(measure.Count(), count_upper_limit); |
6440 CHECK_LE(measure.Size(), size_upper_limit); | 6440 CHECK_LE(measure.Size(), size_upper_limit); |
6441 } | 6441 } |
6442 | 6442 |
| 6443 |
| 6444 TEST(ScriptIterator) { |
| 6445 CcTest::InitializeVM(); |
| 6446 v8::HandleScope scope(CcTest::isolate()); |
| 6447 Isolate* isolate = CcTest::i_isolate(); |
| 6448 Heap* heap = CcTest::heap(); |
| 6449 LocalContext context; |
| 6450 |
| 6451 heap->CollectAllGarbage(); |
| 6452 |
| 6453 int script_count = 0; |
| 6454 { |
| 6455 HeapIterator it(heap); |
| 6456 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { |
| 6457 if (obj->IsScript()) script_count++; |
| 6458 } |
| 6459 } |
| 6460 |
| 6461 { |
| 6462 Script::Iterator iterator(isolate); |
| 6463 while (iterator.Next()) script_count--; |
| 6464 } |
| 6465 |
| 6466 CHECK_EQ(0, script_count); |
| 6467 } |
| 6468 |
| 6469 |
| 6470 TEST(SharedFunctionInfoIterator) { |
| 6471 CcTest::InitializeVM(); |
| 6472 v8::HandleScope scope(CcTest::isolate()); |
| 6473 Isolate* isolate = CcTest::i_isolate(); |
| 6474 Heap* heap = CcTest::heap(); |
| 6475 LocalContext context; |
| 6476 |
| 6477 heap->CollectAllGarbage(); |
| 6478 heap->CollectAllGarbage(); |
| 6479 |
| 6480 int sfi_count = 0; |
| 6481 { |
| 6482 HeapIterator it(heap); |
| 6483 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { |
| 6484 if (!obj->IsSharedFunctionInfo()) continue; |
| 6485 // Shared function infos without a script (API functions or C++ builtins) |
| 6486 // are not returned by the iterator because they are not created from a |
| 6487 // script. They are not interesting for type feedback vector anyways. |
| 6488 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); |
| 6489 if (shared->script()->IsUndefined()) { |
| 6490 CHECK_EQ(0, shared->feedback_vector()->ICSlots()); |
| 6491 } else { |
| 6492 sfi_count++; |
| 6493 } |
| 6494 } |
| 6495 } |
| 6496 |
| 6497 { |
| 6498 SharedFunctionInfo::Iterator iterator(isolate); |
| 6499 while (iterator.Next()) sfi_count--; |
| 6500 } |
| 6501 |
| 6502 CHECK_EQ(0, sfi_count); |
| 6503 } |
| 6504 |
6443 } // namespace internal | 6505 } // namespace internal |
6444 } // namespace v8 | 6506 } // namespace v8 |
OLD | NEW |