| OLD | NEW |
| 1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), | 107 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), |
| 108 Encode(encoder, Builtins::kArrayCode)); | 108 Encode(encoder, Builtins::kArrayCode)); |
| 109 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), | 109 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), |
| 110 Encode(encoder, Runtime::kAbort)); | 110 Encode(encoder, Runtime::kAbort)); |
| 111 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), | 111 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), |
| 112 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); | 112 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); |
| 113 ExternalReference keyed_load_function_prototype = | 113 ExternalReference keyed_load_function_prototype = |
| 114 ExternalReference(isolate->counters()->keyed_load_function_prototype()); | 114 ExternalReference(isolate->counters()->keyed_load_function_prototype()); |
| 115 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), | 115 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), |
| 116 encoder.Encode(keyed_load_function_prototype.address())); | 116 encoder.Encode(keyed_load_function_prototype.address())); |
| 117 ExternalReference the_hole_value_location = | |
| 118 ExternalReference::the_hole_value_location(isolate); | |
| 119 CHECK_EQ(make_code(UNCLASSIFIED, 2), | |
| 120 encoder.Encode(the_hole_value_location.address())); | |
| 121 ExternalReference stack_limit_address = | 117 ExternalReference stack_limit_address = |
| 122 ExternalReference::address_of_stack_limit(isolate); | 118 ExternalReference::address_of_stack_limit(isolate); |
| 123 CHECK_EQ(make_code(UNCLASSIFIED, 4), | 119 CHECK_EQ(make_code(UNCLASSIFIED, 4), |
| 124 encoder.Encode(stack_limit_address.address())); | 120 encoder.Encode(stack_limit_address.address())); |
| 125 ExternalReference real_stack_limit_address = | 121 ExternalReference real_stack_limit_address = |
| 126 ExternalReference::address_of_real_stack_limit(isolate); | 122 ExternalReference::address_of_real_stack_limit(isolate); |
| 127 CHECK_EQ(make_code(UNCLASSIFIED, 5), | 123 CHECK_EQ(make_code(UNCLASSIFIED, 5), |
| 128 encoder.Encode(real_stack_limit_address.address())); | 124 encoder.Encode(real_stack_limit_address.address())); |
| 129 #ifdef ENABLE_DEBUGGER_SUPPORT | 125 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 130 CHECK_EQ(make_code(UNCLASSIFIED, 15), | 126 CHECK_EQ(make_code(UNCLASSIFIED, 16), |
| 131 encoder.Encode(ExternalReference::debug_break(isolate).address())); | 127 encoder.Encode(ExternalReference::debug_break(isolate).address())); |
| 132 #endif // ENABLE_DEBUGGER_SUPPORT | 128 #endif // ENABLE_DEBUGGER_SUPPORT |
| 133 CHECK_EQ(make_code(UNCLASSIFIED, 10), | 129 CHECK_EQ(make_code(UNCLASSIFIED, 10), |
| 134 encoder.Encode( | 130 encoder.Encode( |
| 135 ExternalReference::new_space_start(isolate).address())); | 131 ExternalReference::new_space_start(isolate).address())); |
| 136 CHECK_EQ(make_code(UNCLASSIFIED, 3), | 132 CHECK_EQ(make_code(UNCLASSIFIED, 3), |
| 137 encoder.Encode(ExternalReference::roots_address(isolate).address())); | 133 encoder.Encode(ExternalReference::roots_address(isolate).address())); |
| 138 } | 134 } |
| 139 | 135 |
| 140 | 136 |
| 141 TEST(ExternalReferenceDecoder) { | 137 TEST(ExternalReferenceDecoder) { |
| 142 Isolate* isolate = i::Isolate::Current(); | 138 Isolate* isolate = i::Isolate::Current(); |
| 143 isolate->stats_table()->SetCounterFunction(counter_function); | 139 isolate->stats_table()->SetCounterFunction(counter_function); |
| 144 v8::V8::Initialize(); | 140 v8::V8::Initialize(); |
| 145 | 141 |
| 146 ExternalReferenceDecoder decoder; | 142 ExternalReferenceDecoder decoder; |
| 147 CHECK_EQ(AddressOf(Builtins::kArrayCode), | 143 CHECK_EQ(AddressOf(Builtins::kArrayCode), |
| 148 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); | 144 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); |
| 149 CHECK_EQ(AddressOf(Runtime::kAbort), | 145 CHECK_EQ(AddressOf(Runtime::kAbort), |
| 150 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, | 146 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, |
| 151 Runtime::kAbort))); | 147 Runtime::kAbort))); |
| 152 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), | 148 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), |
| 153 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); | 149 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); |
| 154 ExternalReference keyed_load_function = | 150 ExternalReference keyed_load_function = |
| 155 ExternalReference(isolate->counters()->keyed_load_function_prototype()); | 151 ExternalReference(isolate->counters()->keyed_load_function_prototype()); |
| 156 CHECK_EQ(keyed_load_function.address(), | 152 CHECK_EQ(keyed_load_function.address(), |
| 157 decoder.Decode( | 153 decoder.Decode( |
| 158 make_code(STATS_COUNTER, | 154 make_code(STATS_COUNTER, |
| 159 Counters::k_keyed_load_function_prototype))); | 155 Counters::k_keyed_load_function_prototype))); |
| 160 CHECK_EQ(ExternalReference::the_hole_value_location(isolate).address(), | |
| 161 decoder.Decode(make_code(UNCLASSIFIED, 2))); | |
| 162 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), | 156 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), |
| 163 decoder.Decode(make_code(UNCLASSIFIED, 4))); | 157 decoder.Decode(make_code(UNCLASSIFIED, 4))); |
| 164 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), | 158 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), |
| 165 decoder.Decode(make_code(UNCLASSIFIED, 5))); | 159 decoder.Decode(make_code(UNCLASSIFIED, 5))); |
| 166 #ifdef ENABLE_DEBUGGER_SUPPORT | 160 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 167 CHECK_EQ(ExternalReference::debug_break(isolate).address(), | 161 CHECK_EQ(ExternalReference::debug_break(isolate).address(), |
| 168 decoder.Decode(make_code(UNCLASSIFIED, 15))); | 162 decoder.Decode(make_code(UNCLASSIFIED, 16))); |
| 169 #endif // ENABLE_DEBUGGER_SUPPORT | 163 #endif // ENABLE_DEBUGGER_SUPPORT |
| 170 CHECK_EQ(ExternalReference::new_space_start(isolate).address(), | 164 CHECK_EQ(ExternalReference::new_space_start(isolate).address(), |
| 171 decoder.Decode(make_code(UNCLASSIFIED, 10))); | 165 decoder.Decode(make_code(UNCLASSIFIED, 10))); |
| 172 } | 166 } |
| 173 | 167 |
| 174 | 168 |
| 175 class FileByteSink : public SnapshotByteSink { | 169 class FileByteSink : public SnapshotByteSink { |
| 176 public: | 170 public: |
| 177 explicit FileByteSink(const char* snapshot_file) { | 171 explicit FileByteSink(const char* snapshot_file) { |
| 178 fp_ = OS::FOpen(snapshot_file, "wb"); | 172 fp_ = OS::FOpen(snapshot_file, "wb"); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 352 |
| 359 v8::Persistent<v8::Context> env = v8::Context::New(); | 353 v8::Persistent<v8::Context> env = v8::Context::New(); |
| 360 ASSERT(!env.IsEmpty()); | 354 ASSERT(!env.IsEmpty()); |
| 361 env->Enter(); | 355 env->Enter(); |
| 362 // Make sure all builtin scripts are cached. | 356 // Make sure all builtin scripts are cached. |
| 363 { HandleScope scope; | 357 { HandleScope scope; |
| 364 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 358 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| 365 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); | 359 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); |
| 366 } | 360 } |
| 367 } | 361 } |
| 368 HEAP->CollectAllGarbage(true); | 362 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 369 HEAP->CollectAllGarbage(true); | 363 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 370 | 364 |
| 371 Object* raw_foo; | 365 Object* raw_foo; |
| 372 { | 366 { |
| 373 v8::HandleScope handle_scope; | 367 v8::HandleScope handle_scope; |
| 374 v8::Local<v8::String> foo = v8::String::New("foo"); | 368 v8::Local<v8::String> foo = v8::String::New("foo"); |
| 375 ASSERT(!foo.IsEmpty()); | 369 ASSERT(!foo.IsEmpty()); |
| 376 raw_foo = *(v8::Utils::OpenHandle(*foo)); | 370 raw_foo = *(v8::Utils::OpenHandle(*foo)); |
| 377 } | 371 } |
| 378 | 372 |
| 379 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 373 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 ASSERT(!env.IsEmpty()); | 477 ASSERT(!env.IsEmpty()); |
| 484 env->Enter(); | 478 env->Enter(); |
| 485 // Make sure all builtin scripts are cached. | 479 // Make sure all builtin scripts are cached. |
| 486 { HandleScope scope; | 480 { HandleScope scope; |
| 487 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 481 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| 488 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); | 482 Isolate::Current()->bootstrapper()->NativesSourceLookup(i); |
| 489 } | 483 } |
| 490 } | 484 } |
| 491 // If we don't do this then we end up with a stray root pointing at the | 485 // If we don't do this then we end up with a stray root pointing at the |
| 492 // context even after we have disposed of env. | 486 // context even after we have disposed of env. |
| 493 HEAP->CollectAllGarbage(true); | 487 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 494 | 488 |
| 495 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 489 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
| 496 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 490 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
| 497 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 491 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
| 498 | 492 |
| 499 env->Exit(); | 493 env->Exit(); |
| 500 | 494 |
| 501 Object* raw_context = *(v8::Utils::OpenHandle(*env)); | 495 Object* raw_context = *(v8::Utils::OpenHandle(*env)); |
| 502 | 496 |
| 503 env.Dispose(); | 497 env.Dispose(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 CHECK(root2->IsContext()); | 550 CHECK(root2->IsContext()); |
| 557 CHECK(*root_handle != root2); | 551 CHECK(*root_handle != root2); |
| 558 } | 552 } |
| 559 } | 553 } |
| 560 } | 554 } |
| 561 | 555 |
| 562 | 556 |
| 563 TEST(LinearAllocation) { | 557 TEST(LinearAllocation) { |
| 564 v8::V8::Initialize(); | 558 v8::V8::Initialize(); |
| 565 int new_space_max = 512 * KB; | 559 int new_space_max = 512 * KB; |
| 560 int paged_space_max = Page::kMaxHeapObjectSize; |
| 566 | 561 |
| 567 for (int size = 1000; size < 5 * MB; size += size >> 1) { | 562 for (int size = 1000; size < 5 * MB; size += size >> 1) { |
| 563 size &= ~8; // Round. |
| 568 int new_space_size = (size < new_space_max) ? size : new_space_max; | 564 int new_space_size = (size < new_space_max) ? size : new_space_max; |
| 565 int paged_space_size = (size < paged_space_max) ? size : paged_space_max; |
| 569 HEAP->ReserveSpace( | 566 HEAP->ReserveSpace( |
| 570 new_space_size, | 567 new_space_size, |
| 571 size, // Old pointer space. | 568 paged_space_size, // Old pointer space. |
| 572 size, // Old data space. | 569 paged_space_size, // Old data space. |
| 573 size, // Code space. | 570 HEAP->code_space()->RoundSizeDownToObjectAlignment(paged_space_size), |
| 574 size, // Map space. | 571 HEAP->map_space()->RoundSizeDownToObjectAlignment(paged_space_size), |
| 575 size, // Cell space. | 572 HEAP->cell_space()->RoundSizeDownToObjectAlignment(paged_space_size), |
| 576 size); // Large object space. | 573 size); // Large object space. |
| 577 LinearAllocationScope linear_allocation_scope; | 574 LinearAllocationScope linear_allocation_scope; |
| 578 const int kSmallFixedArrayLength = 4; | 575 const int kSmallFixedArrayLength = 4; |
| 579 const int kSmallFixedArraySize = | 576 const int kSmallFixedArraySize = |
| 580 FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize; | 577 FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize; |
| 581 const int kSmallStringLength = 16; | 578 const int kSmallStringLength = 16; |
| 582 const int kSmallStringSize = | 579 const int kSmallStringSize = |
| 583 (SeqAsciiString::kHeaderSize + kSmallStringLength + | 580 (SeqAsciiString::kHeaderSize + kSmallStringLength + |
| 584 kObjectAlignmentMask) & ~kObjectAlignmentMask; | 581 kObjectAlignmentMask) & ~kObjectAlignmentMask; |
| 585 const int kMapSize = Map::kSize; | 582 const int kMapSize = Map::kSize; |
| 586 | 583 |
| 587 Object* new_last = NULL; | 584 Object* new_last = NULL; |
| 588 for (int i = 0; | 585 for (int i = 0; |
| 589 i + kSmallFixedArraySize <= new_space_size; | 586 i + kSmallFixedArraySize <= new_space_size; |
| 590 i += kSmallFixedArraySize) { | 587 i += kSmallFixedArraySize) { |
| 591 Object* obj = | 588 Object* obj = |
| 592 HEAP->AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked(); | 589 HEAP->AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked(); |
| 593 if (new_last != NULL) { | 590 if (new_last != NULL) { |
| 594 CHECK(reinterpret_cast<char*>(obj) == | 591 CHECK(reinterpret_cast<char*>(obj) == |
| 595 reinterpret_cast<char*>(new_last) + kSmallFixedArraySize); | 592 reinterpret_cast<char*>(new_last) + kSmallFixedArraySize); |
| 596 } | 593 } |
| 597 new_last = obj; | 594 new_last = obj; |
| 598 } | 595 } |
| 599 | 596 |
| 600 Object* pointer_last = NULL; | 597 Object* pointer_last = NULL; |
| 601 for (int i = 0; | 598 for (int i = 0; |
| 602 i + kSmallFixedArraySize <= size; | 599 i + kSmallFixedArraySize <= paged_space_size; |
| 603 i += kSmallFixedArraySize) { | 600 i += kSmallFixedArraySize) { |
| 604 Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength, | 601 Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength, |
| 605 TENURED)->ToObjectChecked(); | 602 TENURED)->ToObjectChecked(); |
| 606 int old_page_fullness = i % Page::kPageSize; | 603 int old_page_fullness = i % Page::kPageSize; |
| 607 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; | 604 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; |
| 608 if (page_fullness < old_page_fullness || | 605 if (page_fullness < old_page_fullness || |
| 609 page_fullness > Page::kObjectAreaSize) { | 606 page_fullness > Page::kObjectAreaSize) { |
| 610 i = RoundUp(i, Page::kPageSize); | 607 i = RoundUp(i, Page::kPageSize); |
| 611 pointer_last = NULL; | 608 pointer_last = NULL; |
| 612 } | 609 } |
| 613 if (pointer_last != NULL) { | 610 if (pointer_last != NULL) { |
| 614 CHECK(reinterpret_cast<char*>(obj) == | 611 CHECK(reinterpret_cast<char*>(obj) == |
| 615 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize); | 612 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize); |
| 616 } | 613 } |
| 617 pointer_last = obj; | 614 pointer_last = obj; |
| 618 } | 615 } |
| 619 | 616 |
| 620 Object* data_last = NULL; | 617 Object* data_last = NULL; |
| 621 for (int i = 0; i + kSmallStringSize <= size; i += kSmallStringSize) { | 618 for (int i = 0; |
| 619 i + kSmallStringSize <= paged_space_size; |
| 620 i += kSmallStringSize) { |
| 622 Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength, | 621 Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength, |
| 623 TENURED)->ToObjectChecked(); | 622 TENURED)->ToObjectChecked(); |
| 624 int old_page_fullness = i % Page::kPageSize; | 623 int old_page_fullness = i % Page::kPageSize; |
| 625 int page_fullness = (i + kSmallStringSize) % Page::kPageSize; | 624 int page_fullness = (i + kSmallStringSize) % Page::kPageSize; |
| 626 if (page_fullness < old_page_fullness || | 625 if (page_fullness < old_page_fullness || |
| 627 page_fullness > Page::kObjectAreaSize) { | 626 page_fullness > Page::kObjectAreaSize) { |
| 628 i = RoundUp(i, Page::kPageSize); | 627 i = RoundUp(i, Page::kPageSize); |
| 629 data_last = NULL; | 628 data_last = NULL; |
| 630 } | 629 } |
| 631 if (data_last != NULL) { | 630 if (data_last != NULL) { |
| 632 CHECK(reinterpret_cast<char*>(obj) == | 631 CHECK(reinterpret_cast<char*>(obj) == |
| 633 reinterpret_cast<char*>(data_last) + kSmallStringSize); | 632 reinterpret_cast<char*>(data_last) + kSmallStringSize); |
| 634 } | 633 } |
| 635 data_last = obj; | 634 data_last = obj; |
| 636 } | 635 } |
| 637 | 636 |
| 638 Object* map_last = NULL; | 637 Object* map_last = NULL; |
| 639 for (int i = 0; i + kMapSize <= size; i += kMapSize) { | 638 for (int i = 0; i + kMapSize <= paged_space_size; i += kMapSize) { |
| 640 Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE, | 639 Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE, |
| 641 42 * kPointerSize)->ToObjectChecked(); | 640 42 * kPointerSize)->ToObjectChecked(); |
| 642 int old_page_fullness = i % Page::kPageSize; | 641 int old_page_fullness = i % Page::kPageSize; |
| 643 int page_fullness = (i + kMapSize) % Page::kPageSize; | 642 int page_fullness = (i + kMapSize) % Page::kPageSize; |
| 644 if (page_fullness < old_page_fullness || | 643 if (page_fullness < old_page_fullness || |
| 645 page_fullness > Page::kObjectAreaSize) { | 644 page_fullness > Page::kObjectAreaSize) { |
| 646 i = RoundUp(i, Page::kPageSize); | 645 i = RoundUp(i, Page::kPageSize); |
| 647 map_last = NULL; | 646 map_last = NULL; |
| 648 } | 647 } |
| 649 if (map_last != NULL) { | 648 if (map_last != NULL) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 674 TEST(TestThatAlwaysFails) { | 673 TEST(TestThatAlwaysFails) { |
| 675 bool ArtificialFailure = false; | 674 bool ArtificialFailure = false; |
| 676 CHECK(ArtificialFailure); | 675 CHECK(ArtificialFailure); |
| 677 } | 676 } |
| 678 | 677 |
| 679 | 678 |
| 680 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 679 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
| 681 bool ArtificialFailure2 = false; | 680 bool ArtificialFailure2 = false; |
| 682 CHECK(ArtificialFailure2); | 681 CHECK(ArtificialFailure2); |
| 683 } | 682 } |
| OLD | NEW |