OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 559 } |
560 | 560 |
561 | 561 |
562 ResourceConstraints::ResourceConstraints() | 562 ResourceConstraints::ResourceConstraints() |
563 : max_young_space_size_(0), | 563 : max_young_space_size_(0), |
564 max_old_space_size_(0), | 564 max_old_space_size_(0), |
565 max_executable_size_(0), | 565 max_executable_size_(0), |
566 stack_limit_(NULL), | 566 stack_limit_(NULL), |
567 max_available_threads_(0) { } | 567 max_available_threads_(0) { } |
568 | 568 |
569 | 569 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
570 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) { | 570 uint32_t number_of_processors) { |
571 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 571 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
572 #if V8_OS_ANDROID | 572 #if V8_OS_ANDROID |
573 // Android has higher physical memory requirements before raising the maximum | 573 // Android has higher physical memory requirements before raising the maximum |
574 // heap size limits since it has no swap space. | 574 // heap size limits since it has no swap space. |
575 const uint64_t low_limit = 512ul * i::MB; | 575 const uint64_t low_limit = 512ul * i::MB; |
576 const uint64_t medium_limit = 1ul * i::GB; | 576 const uint64_t medium_limit = 1ul * i::GB; |
577 const uint64_t high_limit = 2ul * i::GB; | 577 const uint64_t high_limit = 2ul * i::GB; |
578 #else | 578 #else |
579 const uint64_t low_limit = 512ul * i::MB; | 579 const uint64_t low_limit = 512ul * i::MB; |
580 const uint64_t medium_limit = 768ul * i::MB; | 580 const uint64_t medium_limit = 768ul * i::MB; |
(...skipping 13 matching lines...) Expand all Loading... |
594 } else if (physical_memory <= high_limit) { | 594 } else if (physical_memory <= high_limit) { |
595 set_max_young_space_size(16 * lump_of_memory); | 595 set_max_young_space_size(16 * lump_of_memory); |
596 set_max_old_space_size(512 * lump_of_memory); | 596 set_max_old_space_size(512 * lump_of_memory); |
597 set_max_executable_size(256 * lump_of_memory); | 597 set_max_executable_size(256 * lump_of_memory); |
598 } else { | 598 } else { |
599 set_max_young_space_size(16 * lump_of_memory); | 599 set_max_young_space_size(16 * lump_of_memory); |
600 set_max_old_space_size(700 * lump_of_memory); | 600 set_max_old_space_size(700 * lump_of_memory); |
601 set_max_executable_size(256 * lump_of_memory); | 601 set_max_executable_size(256 * lump_of_memory); |
602 } | 602 } |
603 | 603 |
604 set_max_available_threads(0); | 604 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); |
605 } | 605 } |
606 | 606 |
607 | 607 |
| 608 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) { |
| 609 ConfigureDefaults(physical_memory, i::CPU::NumberOfProcessorsOnline()); |
| 610 } |
| 611 |
| 612 |
608 bool SetResourceConstraints(ResourceConstraints* constraints) { | 613 bool SetResourceConstraints(ResourceConstraints* constraints) { |
609 i::Isolate* isolate = EnterIsolateIfNeeded(); | 614 i::Isolate* isolate = EnterIsolateIfNeeded(); |
610 return SetResourceConstraints(reinterpret_cast<Isolate*>(isolate), | 615 return SetResourceConstraints(reinterpret_cast<Isolate*>(isolate), |
611 constraints); | 616 constraints); |
612 } | 617 } |
613 | 618 |
614 | 619 |
615 bool SetResourceConstraints(Isolate* v8_isolate, | 620 bool SetResourceConstraints(Isolate* v8_isolate, |
616 ResourceConstraints* constraints) { | 621 ResourceConstraints* constraints) { |
617 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 622 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
(...skipping 7044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7662 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7667 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7663 Address callback_address = | 7668 Address callback_address = |
7664 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7669 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7665 VMState<EXTERNAL> state(isolate); | 7670 VMState<EXTERNAL> state(isolate); |
7666 ExternalCallbackScope call_scope(isolate, callback_address); | 7671 ExternalCallbackScope call_scope(isolate, callback_address); |
7667 callback(info); | 7672 callback(info); |
7668 } | 7673 } |
7669 | 7674 |
7670 | 7675 |
7671 } } // namespace v8::internal | 7676 } } // namespace v8::internal |
OLD | NEW |