Chromium Code Reviews| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 } | 626 } |
| 627 if (constraints->is_memory_constrained().has_value && | 627 if (constraints->is_memory_constrained().has_value && |
| 628 !i::FLAG_force_memory_constrained.has_value) { | 628 !i::FLAG_force_memory_constrained.has_value) { |
| 629 isolate->set_is_memory_constrained( | 629 isolate->set_is_memory_constrained( |
| 630 constraints->is_memory_constrained().value); | 630 constraints->is_memory_constrained().value); |
| 631 } | 631 } |
| 632 return true; | 632 return true; |
| 633 } | 633 } |
| 634 | 634 |
| 635 | 635 |
| 636 bool ConfigureResourceConstraintsForCurrentPlatform( | |
|
Hannes Payer (out of office)
2013/09/24 11:27:17
We could also move the implementation in a separat
danno
2013/09/24 11:52:24
Yes, please put this in another file to make it cl
| |
| 637 ResourceConstraints* constraints) { | |
| 638 if (constraints == NULL) { | |
| 639 return false; | |
| 640 } | |
| 641 | |
| 642 // young_space_size should be a power of 2 and old_generation_size should be | |
| 643 // a multiple of Page::kPageSize. | |
| 644 uintptr_t physical_memory = i::OS::TotalPhysicalMemory(); | |
| 645 uintptr_t lump_of_memory = i::kIs64BitArch ? 2 * i::MB : i::MB; | |
| 646 if (physical_memory > 2ul * i::GB) { | |
| 647 constraints->set_max_young_space_size(8 * lump_of_memory); | |
| 648 constraints->set_max_old_space_size(700 * lump_of_memory); | |
| 649 constraints->set_max_executable_size(256 * lump_of_memory); | |
| 650 } else if (physical_memory > 512ul * i::MB) { | |
| 651 constraints->set_max_young_space_size(4 * lump_of_memory); | |
| 652 constraints->set_max_old_space_size(192 * lump_of_memory); | |
| 653 constraints->set_max_executable_size(192 * lump_of_memory); | |
| 654 } else /* (physical_memory <= 512GB) */ { | |
| 655 constraints->set_max_young_space_size(1 * lump_of_memory); | |
| 656 constraints->set_max_old_space_size(96 * lump_of_memory); | |
| 657 constraints->set_max_executable_size(96 * lump_of_memory); | |
| 658 } | |
| 659 return true; | |
| 660 } | |
| 661 | |
| 662 | |
| 663 bool SetDefaultResourceConstraintsForCurrentPlatform() { | |
| 664 ResourceConstraints constraints; | |
| 665 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) | |
| 666 return false; | |
| 667 return SetResourceConstraints(&constraints); | |
| 668 } | |
| 669 | |
| 670 | |
| 636 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 671 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
| 637 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; | 672 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; |
| 638 LOG_API(isolate, "Persistent::New"); | 673 LOG_API(isolate, "Persistent::New"); |
| 639 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 674 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
| 640 #ifdef DEBUG | 675 #ifdef DEBUG |
| 641 (*obj)->Verify(); | 676 (*obj)->Verify(); |
| 642 #endif // DEBUG | 677 #endif // DEBUG |
| 643 return result.location(); | 678 return result.location(); |
| 644 } | 679 } |
| 645 | 680 |
| (...skipping 7239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7885 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7920 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7886 Address callback_address = | 7921 Address callback_address = |
| 7887 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7922 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7888 VMState<EXTERNAL> state(isolate); | 7923 VMState<EXTERNAL> state(isolate); |
| 7889 ExternalCallbackScope call_scope(isolate, callback_address); | 7924 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7890 callback(info); | 7925 callback(info); |
| 7891 } | 7926 } |
| 7892 | 7927 |
| 7893 | 7928 |
| 7894 } } // namespace v8::internal | 7929 } } // namespace v8::internal |
| OLD | NEW |