| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const bool kOsHasSwap = true; | 43 const bool kOsHasSwap = true; |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 | 46 |
| 47 bool ConfigureResourceConstraintsForCurrentPlatform( | 47 bool ConfigureResourceConstraintsForCurrentPlatform( |
| 48 ResourceConstraints* constraints) { | 48 ResourceConstraints* constraints) { |
| 49 if (constraints == NULL) { | 49 if (constraints == NULL) { |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 uint64_t physical_memory = i::OS::TotalPhysicalMemory(); | 53 uint64_t physical_memory; |
| 54 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 55 if (isolate != NULL && |
| 56 isolate->thread_local_top()->total_physical_memory_callback_ != NULL) { |
| 57 physical_memory = |
| 58 isolate->thread_local_top()->total_physical_memory_callback_(); |
| 59 } else { |
| 60 physical_memory = i::OS::TotalPhysicalMemory(); |
| 61 } |
| 54 int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 62 int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
| 55 | 63 |
| 56 // The young_space_size should be a power of 2 and old_generation_size should | 64 // The young_space_size should be a power of 2 and old_generation_size should |
| 57 // be a multiple of Page::kPageSize. | 65 // be a multiple of Page::kPageSize. |
| 58 if (physical_memory <= 512ul * i::MB) { | 66 if (physical_memory <= 512ul * i::MB) { |
| 59 constraints->set_max_young_space_size(2 * lump_of_memory); | 67 constraints->set_max_young_space_size(2 * lump_of_memory); |
| 60 constraints->set_max_old_space_size(128 * lump_of_memory); | 68 constraints->set_max_old_space_size(128 * lump_of_memory); |
| 61 constraints->set_max_executable_size(96 * lump_of_memory); | 69 constraints->set_max_executable_size(96 * lump_of_memory); |
| 62 } else if (physical_memory <= (kOsHasSwap ? 768ul * i::MB : 1ul * i::GB)) { | 70 } else if (physical_memory <= (kOsHasSwap ? 768ul * i::MB : 1ul * i::GB)) { |
| 63 constraints->set_max_young_space_size(8 * lump_of_memory); | 71 constraints->set_max_young_space_size(8 * lump_of_memory); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 77 | 85 |
| 78 | 86 |
| 79 bool SetDefaultResourceConstraintsForCurrentPlatform() { | 87 bool SetDefaultResourceConstraintsForCurrentPlatform() { |
| 80 ResourceConstraints constraints; | 88 ResourceConstraints constraints; |
| 81 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) | 89 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) |
| 82 return false; | 90 return false; |
| 83 return SetResourceConstraints(&constraints); | 91 return SetResourceConstraints(&constraints); |
| 84 } | 92 } |
| 85 | 93 |
| 86 } // namespace v8 | 94 } // namespace v8 |
| OLD | NEW |