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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 auto_enable_(false) { | 457 auto_enable_(false) { |
458 CHECK(source != NULL || source_length_ == 0); | 458 CHECK(source != NULL || source_length_ == 0); |
459 } | 459 } |
460 | 460 |
461 | 461 |
462 ResourceConstraints::ResourceConstraints() | 462 ResourceConstraints::ResourceConstraints() |
463 : max_young_space_size_(0), | 463 : max_young_space_size_(0), |
464 max_old_space_size_(0), | 464 max_old_space_size_(0), |
465 max_executable_size_(0), | 465 max_executable_size_(0), |
466 stack_limit_(NULL), | 466 stack_limit_(NULL), |
467 max_available_threads_(0) { } | 467 max_available_threads_(0), |
| 468 code_range_size_(0) { } |
468 | 469 |
469 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 470 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
| 471 uint64_t virtual_memory_limit, |
470 uint32_t number_of_processors) { | 472 uint32_t number_of_processors) { |
471 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 473 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
472 #if V8_OS_ANDROID | 474 #if V8_OS_ANDROID |
473 // Android has higher physical memory requirements before raising the maximum | 475 // Android has higher physical memory requirements before raising the maximum |
474 // heap size limits since it has no swap space. | 476 // heap size limits since it has no swap space. |
475 const uint64_t low_limit = 512ul * i::MB; | 477 const uint64_t low_limit = 512ul * i::MB; |
476 const uint64_t medium_limit = 1ul * i::GB; | 478 const uint64_t medium_limit = 1ul * i::GB; |
477 const uint64_t high_limit = 2ul * i::GB; | 479 const uint64_t high_limit = 2ul * i::GB; |
478 #else | 480 #else |
479 const uint64_t low_limit = 512ul * i::MB; | 481 const uint64_t low_limit = 512ul * i::MB; |
(...skipping 15 matching lines...) Expand all Loading... |
495 set_max_young_space_size(16 * lump_of_memory); | 497 set_max_young_space_size(16 * lump_of_memory); |
496 set_max_old_space_size(512 * lump_of_memory); | 498 set_max_old_space_size(512 * lump_of_memory); |
497 set_max_executable_size(256 * lump_of_memory); | 499 set_max_executable_size(256 * lump_of_memory); |
498 } else { | 500 } else { |
499 set_max_young_space_size(16 * lump_of_memory); | 501 set_max_young_space_size(16 * lump_of_memory); |
500 set_max_old_space_size(700 * lump_of_memory); | 502 set_max_old_space_size(700 * lump_of_memory); |
501 set_max_executable_size(256 * lump_of_memory); | 503 set_max_executable_size(256 * lump_of_memory); |
502 } | 504 } |
503 | 505 |
504 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); | 506 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); |
| 507 |
| 508 if (virtual_memory_limit > 0 && i::kIs64BitArch) { |
| 509 // Reserve no more than 1/8 of the memory for the code range, but at most |
| 510 // 512 MB. |
| 511 set_code_range_size( |
| 512 i::Min(512 * i::MB, static_cast<int>(virtual_memory_limit >> 3))); |
| 513 } |
505 } | 514 } |
506 | 515 |
507 | 516 |
508 bool SetResourceConstraints(Isolate* v8_isolate, | 517 bool SetResourceConstraints(Isolate* v8_isolate, |
509 ResourceConstraints* constraints) { | 518 ResourceConstraints* constraints) { |
510 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 519 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
511 int young_space_size = constraints->max_young_space_size(); | 520 int young_space_size = constraints->max_young_space_size(); |
512 int old_gen_size = constraints->max_old_space_size(); | 521 int old_gen_size = constraints->max_old_space_size(); |
513 int max_executable_size = constraints->max_executable_size(); | 522 int max_executable_size = constraints->max_executable_size(); |
514 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { | 523 int code_range_size = constraints->code_range_size(); |
| 524 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 || |
| 525 code_range_size != 0) { |
515 // After initialization it's too late to change Heap constraints. | 526 // After initialization it's too late to change Heap constraints. |
516 ASSERT(!isolate->IsInitialized()); | 527 ASSERT(!isolate->IsInitialized()); |
517 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 528 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, |
518 old_gen_size, | 529 old_gen_size, |
519 max_executable_size); | 530 max_executable_size, |
| 531 code_range_size); |
520 if (!result) return false; | 532 if (!result) return false; |
521 } | 533 } |
522 if (constraints->stack_limit() != NULL) { | 534 if (constraints->stack_limit() != NULL) { |
523 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 535 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
524 isolate->stack_guard()->SetStackLimit(limit); | 536 isolate->stack_guard()->SetStackLimit(limit); |
525 } | 537 } |
526 | 538 |
527 isolate->set_max_available_threads(constraints->max_available_threads()); | 539 isolate->set_max_available_threads(constraints->max_available_threads()); |
528 return true; | 540 return true; |
529 } | 541 } |
(...skipping 7142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7672 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7684 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7673 Address callback_address = | 7685 Address callback_address = |
7674 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7686 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7675 VMState<EXTERNAL> state(isolate); | 7687 VMState<EXTERNAL> state(isolate); |
7676 ExternalCallbackScope call_scope(isolate, callback_address); | 7688 ExternalCallbackScope call_scope(isolate, callback_address); |
7677 callback(info); | 7689 callback(info); |
7678 } | 7690 } |
7679 | 7691 |
7680 | 7692 |
7681 } } // namespace v8::internal | 7693 } } // namespace v8::internal |
OLD | NEW |