| 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 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 | 1209 |
| 1210 int object_size = my_map->instance_size(); | 1210 int object_size = my_map->instance_size(); |
| 1211 | 1211 |
| 1212 // Step 2: allocate a lot of objects so to almost fill new space: we need | 1212 // Step 2: allocate a lot of objects so to almost fill new space: we need |
| 1213 // just enough room to allocate JSObject and thus fill the newspace. | 1213 // just enough room to allocate JSObject and thus fill the newspace. |
| 1214 | 1214 |
| 1215 int allocation_amount = Min(FixedArray::kMaxSize, | 1215 int allocation_amount = Min(FixedArray::kMaxSize, |
| 1216 Page::kMaxRegularHeapObjectSize + kPointerSize); | 1216 Page::kMaxRegularHeapObjectSize + kPointerSize); |
| 1217 int allocation_len = LenFromSize(allocation_amount); | 1217 int allocation_len = LenFromSize(allocation_amount); |
| 1218 NewSpace* new_space = heap->new_space(); | 1218 NewSpace* new_space = heap->new_space(); |
| 1219 DisableInlineAllocationSteps(new_space); |
| 1219 Address* top_addr = new_space->allocation_top_address(); | 1220 Address* top_addr = new_space->allocation_top_address(); |
| 1220 Address* limit_addr = new_space->allocation_limit_address(); | 1221 Address* limit_addr = new_space->allocation_limit_address(); |
| 1221 while ((*limit_addr - *top_addr) > allocation_amount) { | 1222 while ((*limit_addr - *top_addr) > allocation_amount) { |
| 1222 CHECK(!heap->always_allocate()); | 1223 CHECK(!heap->always_allocate()); |
| 1223 Object* array = heap->AllocateFixedArray(allocation_len).ToObjectChecked(); | 1224 Object* array = heap->AllocateFixedArray(allocation_len).ToObjectChecked(); |
| 1224 CHECK(new_space->Contains(array)); | 1225 CHECK(new_space->Contains(array)); |
| 1225 } | 1226 } |
| 1226 | 1227 |
| 1227 // Step 3: now allocate fixed array and JSObject to fill the whole new space. | 1228 // Step 3: now allocate fixed array and JSObject to fill the whole new space. |
| 1228 int to_fill = static_cast<int>(*limit_addr - *top_addr - object_size); | 1229 int to_fill = static_cast<int>(*limit_addr - *top_addr - object_size); |
| (...skipping 4427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5656 v8::Isolate::CreateParams create_params; | 5657 v8::Isolate::CreateParams create_params; |
| 5657 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 5658 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 5658 v8::Isolate* isolate = v8::Isolate::New(create_params); | 5659 v8::Isolate* isolate = v8::Isolate::New(create_params); |
| 5659 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5660 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5660 { | 5661 { |
| 5661 v8::Isolate::Scope isolate_scope(isolate); | 5662 v8::Isolate::Scope isolate_scope(isolate); |
| 5662 v8::HandleScope handle_scope(isolate); | 5663 v8::HandleScope handle_scope(isolate); |
| 5663 v8::Context::New(isolate)->Enter(); | 5664 v8::Context::New(isolate)->Enter(); |
| 5664 Heap* heap = i_isolate->heap(); | 5665 Heap* heap = i_isolate->heap(); |
| 5665 NewSpace* new_space = heap->new_space(); | 5666 NewSpace* new_space = heap->new_space(); |
| 5667 DisableInlineAllocationSteps(new_space); |
| 5666 | 5668 |
| 5667 // In this test we will try to overwrite the promotion queue which is at the | 5669 // In this test we will try to overwrite the promotion queue which is at the |
| 5668 // end of to-space. To actually make that possible, we need at least two | 5670 // end of to-space. To actually make that possible, we need at least two |
| 5669 // semi-space pages and take advantage of fragmentation. | 5671 // semi-space pages and take advantage of fragmentation. |
| 5670 // (1) Grow semi-space to two pages. | 5672 // (1) Grow semi-space to two pages. |
| 5671 // (2) Create a few small long living objects and call the scavenger to | 5673 // (2) Create a few small long living objects and call the scavenger to |
| 5672 // move them to the other semi-space. | 5674 // move them to the other semi-space. |
| 5673 // (3) Create a huge object, i.e., remainder of first semi-space page and | 5675 // (3) Create a huge object, i.e., remainder of first semi-space page and |
| 5674 // create another huge object which should be of maximum allocatable memory | 5676 // create another huge object which should be of maximum allocatable memory |
| 5675 // size of the second semi-space page. | 5677 // size of the second semi-space page. |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6513 // The CollectGarbage call above starts sweeper threads. | 6515 // The CollectGarbage call above starts sweeper threads. |
| 6514 // The crash will happen if the following two functions | 6516 // The crash will happen if the following two functions |
| 6515 // are called before sweeping finishes. | 6517 // are called before sweeping finishes. |
| 6516 heap->StartIncrementalMarking(); | 6518 heap->StartIncrementalMarking(); |
| 6517 heap->FinalizeIncrementalMarkingIfComplete("test"); | 6519 heap->FinalizeIncrementalMarkingIfComplete("test"); |
| 6518 } | 6520 } |
| 6519 | 6521 |
| 6520 | 6522 |
| 6521 } // namespace internal | 6523 } // namespace internal |
| 6522 } // namespace v8 | 6524 } // namespace v8 |
| OLD | NEW |