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 19 matching lines...) Expand all Loading... |
30 #undef USING_V8_SHARED | 30 #undef USING_V8_SHARED |
31 #include "../include/v8-defaults.h" | 31 #include "../include/v8-defaults.h" |
32 | 32 |
33 #include "platform.h" | 33 #include "platform.h" |
34 #include "globals.h" | 34 #include "globals.h" |
35 #include "v8.h" | 35 #include "v8.h" |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 | 38 |
39 | 39 |
40 #if V8_OS_ANDROID | |
41 const bool kOsHasSwap = false; | |
42 #else | |
43 const bool kOsHasSwap = true; | |
44 #endif | |
45 | |
46 | |
47 bool ConfigureResourceConstraintsForCurrentPlatform( | 40 bool ConfigureResourceConstraintsForCurrentPlatform( |
48 ResourceConstraints* constraints) { | 41 ResourceConstraints* constraints) { |
49 if (constraints == NULL) { | 42 if (constraints == NULL) { |
50 return false; | 43 return false; |
51 } | 44 } |
52 | 45 |
53 uint64_t physical_memory = i::OS::TotalPhysicalMemory(); | |
54 int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 46 int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
55 | 47 |
56 // The young_space_size should be a power of 2 and old_generation_size should | 48 // The young_space_size should be a power of 2 and old_generation_size should |
57 // be a multiple of Page::kPageSize. | 49 // be a multiple of Page::kPageSize. |
58 if (physical_memory <= 512ul * i::MB) { | 50 #if V8_OS_ANDROID |
59 constraints->set_max_young_space_size(2 * lump_of_memory); | 51 constraints->set_max_young_space_size(8 * lump_of_memory); |
60 constraints->set_max_old_space_size(128 * lump_of_memory); | 52 constraints->set_max_old_space_size(256 * lump_of_memory); |
61 constraints->set_max_executable_size(96 * lump_of_memory); | 53 constraints->set_max_executable_size(192 * lump_of_memory); |
62 } else if (physical_memory <= (kOsHasSwap ? 768ul * i::MB : 1ul * i::GB)) { | 54 #else |
63 constraints->set_max_young_space_size(8 * lump_of_memory); | 55 constraints->set_max_young_space_size(16 * lump_of_memory); |
64 constraints->set_max_old_space_size(256 * lump_of_memory); | 56 constraints->set_max_old_space_size(700 * lump_of_memory); |
65 constraints->set_max_executable_size(192 * lump_of_memory); | 57 constraints->set_max_executable_size(256 * lump_of_memory); |
66 } else if (physical_memory <= (kOsHasSwap ? 1ul * i::GB : 2ul * i::GB)) { | 58 #endif |
67 constraints->set_max_young_space_size(16 * lump_of_memory); | |
68 constraints->set_max_old_space_size(512 * lump_of_memory); | |
69 constraints->set_max_executable_size(256 * lump_of_memory); | |
70 } else { | |
71 constraints->set_max_young_space_size(16 * lump_of_memory); | |
72 constraints->set_max_old_space_size(700 * lump_of_memory); | |
73 constraints->set_max_executable_size(256 * lump_of_memory); | |
74 } | |
75 return true; | 59 return true; |
76 } | 60 } |
77 | 61 |
78 | 62 |
79 bool SetDefaultResourceConstraintsForCurrentPlatform() { | 63 bool SetDefaultResourceConstraintsForCurrentPlatform() { |
80 ResourceConstraints constraints; | 64 ResourceConstraints constraints; |
81 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) | 65 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) |
82 return false; | 66 return false; |
83 return SetResourceConstraints(&constraints); | 67 return SetResourceConstraints(&constraints); |
84 } | 68 } |
85 | 69 |
86 } // namespace v8 | 70 } // namespace v8 |
OLD | NEW |