Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: src/defaults.cc

Issue 68203003: Enable physical memory argument to be passed as an argument to ConfigureResourceConstraintsForPlatf… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
Sven Panne 2013/11/12 07:45:03 Move the #if into the function below to reduce its
rmcilroy 2013/11/12 12:13:58 Done (defined three names for consistency).
41 const bool kOsHasSwap = false;
42 #else
43 const bool kOsHasSwap = true;
44 #endif
45
46
47 bool ConfigureDefaultResourceConstraints(
48 ResourceConstraints* constraints, uint64_t physical_memory) {
49 if (constraints == NULL) {
Sven Panne 2013/11/12 07:45:03 This looks strange and a bit ugly: Why do we need
rmcilroy 2013/11/12 12:13:58 I like the idea of making the function a member of
50 return false;
51 }
52
53 int lump_of_memory = (i::kPointerSize / 4) * i::MB;
Sven Panne 2013/11/12 07:45:03 const
rmcilroy 2013/11/12 12:13:58 Done.
54
55 // The young_space_size should be a power of 2 and old_generation_size should
56 // be a multiple of Page::kPageSize.
57 if (physical_memory <= 512ul * i::MB) {
58 constraints->set_max_young_space_size(2 * lump_of_memory);
59 constraints->set_max_old_space_size(128 * lump_of_memory);
60 constraints->set_max_executable_size(96 * lump_of_memory);
61 } else if (physical_memory <= (kOsHasSwap ? 768ul * i::MB : 1ul * i::GB)) {
62 constraints->set_max_young_space_size(8 * lump_of_memory);
63 constraints->set_max_old_space_size(256 * lump_of_memory);
64 constraints->set_max_executable_size(192 * lump_of_memory);
65 } else if (physical_memory <= (kOsHasSwap ? 1ul * i::GB : 2ul * i::GB)) {
66 constraints->set_max_young_space_size(16 * lump_of_memory);
67 constraints->set_max_old_space_size(512 * lump_of_memory);
68 constraints->set_max_executable_size(256 * lump_of_memory);
69 } else {
70 constraints->set_max_young_space_size(16 * lump_of_memory);
71 constraints->set_max_old_space_size(700 * lump_of_memory);
72 constraints->set_max_executable_size(256 * lump_of_memory);
73 }
74 return true;
75 }
76
77
78 // TODO(rmcilroy): Remove this function once it is no longer used in Chrome.
40 bool ConfigureResourceConstraintsForCurrentPlatform( 79 bool ConfigureResourceConstraintsForCurrentPlatform(
41 ResourceConstraints* constraints) { 80 ResourceConstraints* constraints) {
42 if (constraints == NULL) { 81 if (constraints == NULL) {
43 return false; 82 return false;
44 } 83 }
45 84
46 int lump_of_memory = (i::kPointerSize / 4) * i::MB; 85 int lump_of_memory = (i::kPointerSize / 4) * i::MB;
47 86
48 // The young_space_size should be a power of 2 and old_generation_size should 87 // The young_space_size should be a power of 2 and old_generation_size should
49 // be a multiple of Page::kPageSize. 88 // be a multiple of Page::kPageSize.
50 #if V8_OS_ANDROID 89 #if V8_OS_ANDROID
51 constraints->set_max_young_space_size(8 * lump_of_memory); 90 constraints->set_max_young_space_size(8 * lump_of_memory);
52 constraints->set_max_old_space_size(256 * lump_of_memory); 91 constraints->set_max_old_space_size(256 * lump_of_memory);
53 constraints->set_max_executable_size(192 * lump_of_memory); 92 constraints->set_max_executable_size(192 * lump_of_memory);
54 #else 93 #else
55 constraints->set_max_young_space_size(16 * lump_of_memory); 94 constraints->set_max_young_space_size(16 * lump_of_memory);
56 constraints->set_max_old_space_size(700 * lump_of_memory); 95 constraints->set_max_old_space_size(700 * lump_of_memory);
57 constraints->set_max_executable_size(256 * lump_of_memory); 96 constraints->set_max_executable_size(256 * lump_of_memory);
58 #endif 97 #endif
59 return true; 98 return true;
60 } 99 }
61 100
62 101
102 // TODO(rmcilroy): Remove this function once it is no longer used in Chrome.
63 bool SetDefaultResourceConstraintsForCurrentPlatform() { 103 bool SetDefaultResourceConstraintsForCurrentPlatform() {
64 ResourceConstraints constraints; 104 ResourceConstraints constraints;
65 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) 105 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints))
66 return false; 106 return false;
67 return SetResourceConstraints(&constraints); 107 return SetResourceConstraints(&constraints);
68 } 108 }
69 109
70 } // namespace v8 110 } // namespace v8
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698