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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 : max_young_space_size_(0), | 602 : max_young_space_size_(0), |
603 max_old_space_size_(0), | 603 max_old_space_size_(0), |
604 max_executable_size_(0), | 604 max_executable_size_(0), |
605 stack_limit_(NULL), | 605 stack_limit_(NULL), |
606 is_memory_constrained_() { } | 606 is_memory_constrained_() { } |
607 | 607 |
608 | 608 |
609 bool SetResourceConstraints(ResourceConstraints* constraints) { | 609 bool SetResourceConstraints(ResourceConstraints* constraints) { |
610 i::Isolate* isolate = EnterIsolateIfNeeded(); | 610 i::Isolate* isolate = EnterIsolateIfNeeded(); |
611 | 611 |
| 612 bool changed_memory_constrained = false; |
| 613 if (constraints->is_memory_constrained().has_value && |
| 614 !i::FLAG_force_memory_constrained.has_value) { |
| 615 isolate->set_is_memory_constrained( |
| 616 constraints->is_memory_constrained().value); |
| 617 changed_memory_constrained = true; |
| 618 } |
| 619 |
612 int young_space_size = constraints->max_young_space_size(); | 620 int young_space_size = constraints->max_young_space_size(); |
613 int old_gen_size = constraints->max_old_space_size(); | 621 int old_gen_size = constraints->max_old_space_size(); |
614 int max_executable_size = constraints->max_executable_size(); | 622 int max_executable_size = constraints->max_executable_size(); |
615 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { | 623 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 || |
| 624 changed_memory_constrained) { |
616 // After initialization it's too late to change Heap constraints. | 625 // After initialization it's too late to change Heap constraints. |
617 ASSERT(!isolate->IsInitialized()); | 626 ASSERT(!isolate->IsInitialized()); |
618 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 627 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, |
619 old_gen_size, | 628 old_gen_size, |
620 max_executable_size); | 629 max_executable_size); |
621 if (!result) return false; | 630 if (!result) return false; |
622 } | 631 } |
623 if (constraints->stack_limit() != NULL) { | 632 if (constraints->stack_limit() != NULL) { |
624 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 633 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
625 isolate->stack_guard()->SetStackLimit(limit); | 634 isolate->stack_guard()->SetStackLimit(limit); |
626 } | 635 } |
627 if (constraints->is_memory_constrained().has_value && | |
628 !i::FLAG_force_memory_constrained.has_value) { | |
629 isolate->set_is_memory_constrained( | |
630 constraints->is_memory_constrained().value); | |
631 } | |
632 return true; | 636 return true; |
633 } | 637 } |
634 | 638 |
635 | 639 |
636 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 640 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
637 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; | 641 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; |
638 LOG_API(isolate, "Persistent::New"); | 642 LOG_API(isolate, "Persistent::New"); |
639 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 643 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
640 #ifdef DEBUG | 644 #ifdef DEBUG |
641 (*obj)->Verify(); | 645 (*obj)->Verify(); |
(...skipping 7243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7885 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7889 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7886 Address callback_address = | 7890 Address callback_address = |
7887 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7891 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7888 VMState<EXTERNAL> state(isolate); | 7892 VMState<EXTERNAL> state(isolate); |
7889 ExternalCallbackScope call_scope(isolate, callback_address); | 7893 ExternalCallbackScope call_scope(isolate, callback_address); |
7890 callback(info); | 7894 callback(info); |
7891 } | 7895 } |
7892 | 7896 |
7893 | 7897 |
7894 } } // namespace v8::internal | 7898 } } // namespace v8::internal |
OLD | NEW |