Revision: 17696
Author: [email protected]
Date: Wed Nov 13 14:05:06 2013 UTC
Log: Enable physical memory argument to be passed as an argument to
ConfigureResourceConstraintsForPlatform.
BUG=312241
[email protected]
Review URL: https://codereview.chromium.org/68203003
http://code.google.com/p/v8/source/detail?r=17696
Modified:
/branches/bleeding_edge/include/v8-defaults.h
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/d8.cc
/branches/bleeding_edge/src/defaults.cc
=======================================
--- /branches/bleeding_edge/include/v8-defaults.h Fri Sep 27 10:53:07 2013
UTC
+++ /branches/bleeding_edge/include/v8-defaults.h Wed Nov 13 14:05:06 2013
UTC
@@ -35,19 +35,13 @@
*/
namespace v8 {
-/**
- * Configures the constraints with reasonable default values based on the
- * capabilities of the current device the VM is running on.
- */
-bool V8_EXPORT ConfigureResourceConstraintsForCurrentPlatform(
- ResourceConstraints* constraints);
+V8_DEPRECATED("Use ResourceConstraints::ConfigureDefaults instead",
+ bool V8_EXPORT ConfigureResourceConstraintsForCurrentPlatform(
+ ResourceConstraints* constraints));
-/**
- * Convience function which performs SetResourceConstraints with the
settings
- * returned by ConfigureResourceConstraintsForCurrentPlatform.
- */
-bool V8_EXPORT SetDefaultResourceConstraintsForCurrentPlatform();
+V8_DEPRECATED("Use ResourceConstraints::ConfigureDefaults instead",
+ bool V8_EXPORT SetDefaultResourceConstraintsForCurrentPlatform());
} // namespace v8
=======================================
--- /branches/bleeding_edge/include/v8.h Wed Nov 13 12:18:52 2013 UTC
+++ /branches/bleeding_edge/include/v8.h Wed Nov 13 14:05:06 2013 UTC
@@ -3803,6 +3803,16 @@
class V8_EXPORT ResourceConstraints {
public:
ResourceConstraints();
+
+ /**
+ * Configures the constraints with reasonable default values based on the
+ * capabilities of the current device the VM is running on.
+ *
+ * \param physical_memory The total amount of physical memory on the
current
+ * device, in bytes.
+ */
+ void ConfigureDefaults(uint64_t physical_memory);
+
int max_young_space_size() const { return max_young_space_size_; }
void set_max_young_space_size(int value) { max_young_space_size_ =
value; }
int max_old_space_size() const { return max_old_space_size_; }
=======================================
--- /branches/bleeding_edge/src/api.cc Wed Nov 13 12:18:52 2013 UTC
+++ /branches/bleeding_edge/src/api.cc Wed Nov 13 14:05:06 2013 UTC
@@ -564,6 +564,42 @@
max_old_space_size_(0),
max_executable_size_(0),
stack_limit_(NULL) { }
+
+
+void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
+ const int lump_of_memory = (i::kPointerSize / 4) * i::MB;
+#if V8_OS_ANDROID
+ // Android has higher physical memory requirements before raising the
maximum
+ // heap size limits since it has no swap space.
+ const uint64_t low_limit = 512ul * i::MB;
+ const uint64_t medium_limit = 1ul * i::GB;
+ const uint64_t high_limit = 2ul * i::GB;
+#else
+ const uint64_t low_limit = 512ul * i::MB;
+ const uint64_t medium_limit = 768ul * i::MB;
+ const uint64_t high_limit = 1ul * i::GB;
+#endif
+
+ // The young_space_size should be a power of 2 and old_generation_size
should
+ // be a multiple of Page::kPageSize.
+ if (physical_memory <= low_limit) {
+ set_max_young_space_size(2 * lump_of_memory);
+ set_max_old_space_size(128 * lump_of_memory);
+ set_max_executable_size(96 * lump_of_memory);
+ } else if (physical_memory <= medium_limit) {
+ set_max_young_space_size(8 * lump_of_memory);
+ set_max_old_space_size(256 * lump_of_memory);
+ set_max_executable_size(192 * lump_of_memory);
+ } else if (physical_memory <= high_limit) {
+ set_max_young_space_size(16 * lump_of_memory);
+ set_max_old_space_size(512 * lump_of_memory);
+ set_max_executable_size(256 * lump_of_memory);
+ } else {
+ set_max_young_space_size(16 * lump_of_memory);
+ set_max_old_space_size(700 * lump_of_memory);
+ set_max_executable_size(256 * lump_of_memory);
+ }
+}
bool SetResourceConstraints(ResourceConstraints* constraints) {
=======================================
--- /branches/bleeding_edge/src/d8.cc Thu Nov 7 16:35:27 2013 UTC
+++ /branches/bleeding_edge/src/d8.cc Wed Nov 13 14:05:06 2013 UTC
@@ -1679,11 +1679,13 @@
#else
SetStandaloneFlagsViaCommandLine();
#endif
- v8::SetDefaultResourceConstraintsForCurrentPlatform();
ShellArrayBufferAllocator array_buffer_allocator;
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
int result = 0;
Isolate* isolate = Isolate::GetCurrent();
+ v8::ResourceConstraints constraints;
+ constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory());
+ v8::SetResourceConstraints(isolate, &constraints);
DumbLineEditor dumb_line_editor(isolate);
{
Initialize(isolate);
=======================================
--- /branches/bleeding_edge/src/defaults.cc Mon Oct 28 14:54:26 2013 UTC
+++ /branches/bleeding_edge/src/defaults.cc Wed Nov 13 14:05:06 2013 UTC
@@ -37,6 +37,7 @@
namespace v8 {
+// TODO(rmcilroy): Remove this function once it is no longer used in
Chrome.
bool ConfigureResourceConstraintsForCurrentPlatform(
ResourceConstraints* constraints) {
if (constraints == NULL) {
@@ -60,6 +61,7 @@
}
+// TODO(rmcilroy): Remove this function once it is no longer used in
Chrome.
bool SetDefaultResourceConstraintsForCurrentPlatform() {
ResourceConstraints constraints;
if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints))
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.