Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 } | 940 } |
| 941 | 941 |
| 942 | 942 |
| 943 void NewSpace::Shrink() { | 943 void NewSpace::Shrink() { |
| 944 int new_capacity = Max(InitialCapacity(), 2 * SizeAsInt()); | 944 int new_capacity = Max(InitialCapacity(), 2 * SizeAsInt()); |
| 945 int rounded_new_capacity = | 945 int rounded_new_capacity = |
| 946 RoundUp(new_capacity, static_cast<int>(OS::AllocateAlignment())); | 946 RoundUp(new_capacity, static_cast<int>(OS::AllocateAlignment())); |
| 947 if (rounded_new_capacity < Capacity() && | 947 if (rounded_new_capacity < Capacity() && |
| 948 to_space_.ShrinkTo(rounded_new_capacity)) { | 948 to_space_.ShrinkTo(rounded_new_capacity)) { |
| 949 // Only shrink from space if we managed to shrink to space. | 949 // Only shrink from space if we managed to shrink to space. |
| 950 from_space_.Reset(); | |
|
Lasse Reichstein
2011/09/20 13:28:38
Could you change "from space" to "from-space" in t
Michael Starzinger
2011/09/20 13:34:17
Done.
| |
| 950 if (!from_space_.ShrinkTo(rounded_new_capacity)) { | 951 if (!from_space_.ShrinkTo(rounded_new_capacity)) { |
| 951 // If we managed to shrink to space but couldn't shrink from | 952 // If we managed to shrink to space but couldn't shrink from |
| 952 // space, attempt to grow to space again. | 953 // space, attempt to grow to space again. |
| 953 if (!to_space_.GrowTo(from_space_.Capacity())) { | 954 if (!to_space_.GrowTo(from_space_.Capacity())) { |
| 954 // We are in an inconsistent state because we could not | 955 // We are in an inconsistent state because we could not |
| 955 // commit/uncommit memory from new space. | 956 // commit/uncommit memory from new space. |
| 956 V8::FatalProcessOutOfMemory("Failed to shrink new space."); | 957 V8::FatalProcessOutOfMemory("Failed to shrink new space."); |
| 957 } | 958 } |
| 958 } | 959 } |
| 959 } | 960 } |
| (...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2500 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 2501 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
| 2501 if (obj->IsCode()) { | 2502 if (obj->IsCode()) { |
| 2502 Code* code = Code::cast(obj); | 2503 Code* code = Code::cast(obj); |
| 2503 isolate->code_kind_statistics()[code->kind()] += code->Size(); | 2504 isolate->code_kind_statistics()[code->kind()] += code->Size(); |
| 2504 } | 2505 } |
| 2505 } | 2506 } |
| 2506 } | 2507 } |
| 2507 #endif // DEBUG | 2508 #endif // DEBUG |
| 2508 | 2509 |
| 2509 } } // namespace v8::internal | 2510 } } // namespace v8::internal |
| OLD | NEW |