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 07:31:00
We had another discussion about that function righ
rmcilroy
2013/09/24 10:50:55
Done. Kept the implementation here in api.cc thou
| |
637 ResourceConstraints* constraints) { | |
638 if (constraints == NULL) { | |
639 return false; | |
640 } | |
641 | |
Hannes Payer (out of office)
2013/09/24 07:31:00
Please add a comment which specifies the given con
rmcilroy
2013/09/24 10:50:55
Done.
| |
642 #if V8_TARGET_ARCH_X64 | |
643 uintptr_t lump_of_memory = i::Max(2 * i::MB, i::Page::kPageSize); | |
644 #else | |
645 uintptr_t lump_of_memory = i::Max(i::MB, i::Page::kPageSize); | |
646 #endif | |
647 | |
648 uintptr_t physical_memory = i::OS::TotalPhysicalMemory(); | |
649 if (physical_memory > 2ul * i::GB) { | |
650 constraints->set_max_young_space_size(8 * lump_of_memory); | |
651 constraints->set_max_old_space_size(700 * lump_of_memory); | |
652 constraints->set_max_executable_size(256 * lump_of_memory); | |
653 } else if (physical_memory > 512ul * i::MB) { | |
654 constraints->set_max_young_space_size(4 * lump_of_memory); | |
655 constraints->set_max_old_space_size(192 * lump_of_memory); | |
656 constraints->set_max_executable_size(192 * lump_of_memory); | |
657 } else /* (physical_memory <= 512GB) */ { | |
658 constraints->set_max_young_space_size(1 * lump_of_memory); | |
659 constraints->set_max_old_space_size(96 * lump_of_memory); | |
660 constraints->set_max_executable_size(96 * lump_of_memory); | |
661 } | |
662 return true; | |
663 } | |
664 | |
665 | |
666 bool SetDefaultResourceConstraintsForCurrentPlatform() { | |
667 ResourceConstraints constraints; | |
668 if (!ConfigureResourceConstraintsForCurrentPlatform(&constraints)) | |
669 return false; | |
670 return SetResourceConstraints(&constraints); | |
671 } | |
672 | |
673 | |
636 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 674 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
637 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; | 675 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; |
638 LOG_API(isolate, "Persistent::New"); | 676 LOG_API(isolate, "Persistent::New"); |
639 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 677 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
640 #ifdef DEBUG | 678 #ifdef DEBUG |
641 (*obj)->Verify(); | 679 (*obj)->Verify(); |
642 #endif // DEBUG | 680 #endif // DEBUG |
643 return result.location(); | 681 return result.location(); |
644 } | 682 } |
645 | 683 |
(...skipping 7239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7885 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7923 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7886 Address callback_address = | 7924 Address callback_address = |
7887 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7925 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7888 VMState<EXTERNAL> state(isolate); | 7926 VMState<EXTERNAL> state(isolate); |
7889 ExternalCallbackScope call_scope(isolate, callback_address); | 7927 ExternalCallbackScope call_scope(isolate, callback_address); |
7890 callback(info); | 7928 callback(info); |
7891 } | 7929 } |
7892 | 7930 |
7893 | 7931 |
7894 } } // namespace v8::internal | 7932 } } // namespace v8::internal |
OLD | NEW |