| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 return v8::Handle<Boolean>(); | 556 return v8::Handle<Boolean>(); |
| 557 } | 557 } |
| 558 return ToApiHandle<Boolean>(isolate->factory()->false_value()); | 558 return ToApiHandle<Boolean>(isolate->factory()->false_value()); |
| 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 | 568 |
| 568 | 569 |
| 569 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) { | 570 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) { |
| 570 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 571 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
| 571 #if V8_OS_ANDROID | 572 #if V8_OS_ANDROID |
| 572 // Android has higher physical memory requirements before raising the maximum | 573 // Android has higher physical memory requirements before raising the maximum |
| 573 // heap size limits since it has no swap space. | 574 // heap size limits since it has no swap space. |
| 574 const uint64_t low_limit = 512ul * i::MB; | 575 const uint64_t low_limit = 512ul * i::MB; |
| 575 const uint64_t medium_limit = 1ul * i::GB; | 576 const uint64_t medium_limit = 1ul * i::GB; |
| 576 const uint64_t high_limit = 2ul * i::GB; | 577 const uint64_t high_limit = 2ul * i::GB; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 592 set_max_executable_size(192 * lump_of_memory); | 593 set_max_executable_size(192 * lump_of_memory); |
| 593 } else if (physical_memory <= high_limit) { | 594 } else if (physical_memory <= high_limit) { |
| 594 set_max_young_space_size(16 * lump_of_memory); | 595 set_max_young_space_size(16 * lump_of_memory); |
| 595 set_max_old_space_size(512 * lump_of_memory); | 596 set_max_old_space_size(512 * lump_of_memory); |
| 596 set_max_executable_size(256 * lump_of_memory); | 597 set_max_executable_size(256 * lump_of_memory); |
| 597 } else { | 598 } else { |
| 598 set_max_young_space_size(16 * lump_of_memory); | 599 set_max_young_space_size(16 * lump_of_memory); |
| 599 set_max_old_space_size(700 * lump_of_memory); | 600 set_max_old_space_size(700 * lump_of_memory); |
| 600 set_max_executable_size(256 * lump_of_memory); | 601 set_max_executable_size(256 * lump_of_memory); |
| 601 } | 602 } |
| 603 |
| 604 set_max_available_threads(0); |
| 602 } | 605 } |
| 603 | 606 |
| 604 | 607 |
| 605 bool SetResourceConstraints(ResourceConstraints* constraints) { | 608 bool SetResourceConstraints(ResourceConstraints* constraints) { |
| 606 i::Isolate* isolate = EnterIsolateIfNeeded(); | 609 i::Isolate* isolate = EnterIsolateIfNeeded(); |
| 607 return SetResourceConstraints(reinterpret_cast<Isolate*>(isolate), | 610 return SetResourceConstraints(reinterpret_cast<Isolate*>(isolate), |
| 608 constraints); | 611 constraints); |
| 609 } | 612 } |
| 610 | 613 |
| 611 | 614 |
| 612 bool SetResourceConstraints(Isolate* v8_isolate, | 615 bool SetResourceConstraints(Isolate* v8_isolate, |
| 613 ResourceConstraints* constraints) { | 616 ResourceConstraints* constraints) { |
| 614 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 617 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 615 int young_space_size = constraints->max_young_space_size(); | 618 int young_space_size = constraints->max_young_space_size(); |
| 616 int old_gen_size = constraints->max_old_space_size(); | 619 int old_gen_size = constraints->max_old_space_size(); |
| 617 int max_executable_size = constraints->max_executable_size(); | 620 int max_executable_size = constraints->max_executable_size(); |
| 618 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { | 621 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { |
| 619 // After initialization it's too late to change Heap constraints. | 622 // After initialization it's too late to change Heap constraints. |
| 620 ASSERT(!isolate->IsInitialized()); | 623 ASSERT(!isolate->IsInitialized()); |
| 621 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 624 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, |
| 622 old_gen_size, | 625 old_gen_size, |
| 623 max_executable_size); | 626 max_executable_size); |
| 624 if (!result) return false; | 627 if (!result) return false; |
| 625 } | 628 } |
| 626 if (constraints->stack_limit() != NULL) { | 629 if (constraints->stack_limit() != NULL) { |
| 627 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 630 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
| 628 isolate->stack_guard()->SetStackLimit(limit); | 631 isolate->stack_guard()->SetStackLimit(limit); |
| 629 } | 632 } |
| 633 |
| 634 isolate->set_max_available_threads(constraints->max_available_threads()); |
| 630 return true; | 635 return true; |
| 631 } | 636 } |
| 632 | 637 |
| 633 | 638 |
| 634 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 639 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
| 635 LOG_API(isolate, "Persistent::New"); | 640 LOG_API(isolate, "Persistent::New"); |
| 636 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 641 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
| 637 #ifdef DEBUG | 642 #ifdef DEBUG |
| 638 (*obj)->Verify(); | 643 (*obj)->Verify(); |
| 639 #endif // DEBUG | 644 #endif // DEBUG |
| (...skipping 7017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7657 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7662 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7658 Address callback_address = | 7663 Address callback_address = |
| 7659 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7664 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7660 VMState<EXTERNAL> state(isolate); | 7665 VMState<EXTERNAL> state(isolate); |
| 7661 ExternalCallbackScope call_scope(isolate, callback_address); | 7666 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7662 callback(info); | 7667 callback(info); |
| 7663 } | 7668 } |
| 7664 | 7669 |
| 7665 | 7670 |
| 7666 } } // namespace v8::internal | 7671 } } // namespace v8::internal |
| OLD | NEW |