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 | 567 |
568 | 568 |
| 569 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) { |
| 570 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
| 571 #if V8_OS_ANDROID |
| 572 // Android has higher physical memory requirements before raising the maximum |
| 573 // heap size limits since it has no swap space. |
| 574 const uint64_t low_limit = 512ul * i::MB; |
| 575 const uint64_t medium_limit = 1ul * i::GB; |
| 576 const uint64_t high_limit = 2ul * i::GB; |
| 577 #else |
| 578 const uint64_t low_limit = 512ul * i::MB; |
| 579 const uint64_t medium_limit = 768ul * i::MB; |
| 580 const uint64_t high_limit = 1ul * i::GB; |
| 581 #endif |
| 582 |
| 583 // The young_space_size should be a power of 2 and old_generation_size should |
| 584 // be a multiple of Page::kPageSize. |
| 585 if (physical_memory <= low_limit) { |
| 586 set_max_young_space_size(2 * lump_of_memory); |
| 587 set_max_old_space_size(128 * lump_of_memory); |
| 588 set_max_executable_size(96 * lump_of_memory); |
| 589 } else if (physical_memory <= medium_limit) { |
| 590 set_max_young_space_size(8 * lump_of_memory); |
| 591 set_max_old_space_size(256 * lump_of_memory); |
| 592 set_max_executable_size(192 * lump_of_memory); |
| 593 } else if (physical_memory <= high_limit) { |
| 594 set_max_young_space_size(16 * lump_of_memory); |
| 595 set_max_old_space_size(512 * lump_of_memory); |
| 596 set_max_executable_size(256 * lump_of_memory); |
| 597 } else { |
| 598 set_max_young_space_size(16 * lump_of_memory); |
| 599 set_max_old_space_size(700 * lump_of_memory); |
| 600 set_max_executable_size(256 * lump_of_memory); |
| 601 } |
| 602 } |
| 603 |
| 604 |
569 bool SetResourceConstraints(ResourceConstraints* constraints) { | 605 bool SetResourceConstraints(ResourceConstraints* constraints) { |
570 i::Isolate* isolate = EnterIsolateIfNeeded(); | 606 i::Isolate* isolate = EnterIsolateIfNeeded(); |
571 return SetResourceConstraints(reinterpret_cast<Isolate*>(isolate), | 607 return SetResourceConstraints(reinterpret_cast<Isolate*>(isolate), |
572 constraints); | 608 constraints); |
573 } | 609 } |
574 | 610 |
575 | 611 |
576 bool SetResourceConstraints(Isolate* v8_isolate, | 612 bool SetResourceConstraints(Isolate* v8_isolate, |
577 ResourceConstraints* constraints) { | 613 ResourceConstraints* constraints) { |
578 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 614 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
(...skipping 7040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7619 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7655 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7620 Address callback_address = | 7656 Address callback_address = |
7621 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7657 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7622 VMState<EXTERNAL> state(isolate); | 7658 VMState<EXTERNAL> state(isolate); |
7623 ExternalCallbackScope call_scope(isolate, callback_address); | 7659 ExternalCallbackScope call_scope(isolate, callback_address); |
7624 callback(info); | 7660 callback(info); |
7625 } | 7661 } |
7626 | 7662 |
7627 | 7663 |
7628 } } // namespace v8::internal | 7664 } } // namespace v8::internal |
OLD | NEW |