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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 (source ? static_cast<int>(strlen(source)) : 0)), | 453 (source ? static_cast<int>(strlen(source)) : 0)), |
| 454 source_(source, source_length_), | 454 source_(source, source_length_), |
| 455 dep_count_(dep_count), | 455 dep_count_(dep_count), |
| 456 deps_(deps), | 456 deps_(deps), |
| 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_new_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 code_range_size_(0) { } |
| 469 | 469 |
| 470 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 470 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
| 471 uint64_t virtual_memory_limit, | 471 uint64_t virtual_memory_limit, |
| 472 uint32_t number_of_processors) { | 472 uint32_t number_of_processors) { |
| 473 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 473 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
|
rmcilroy
2014/04/16 08:28:15
nit - if you move lump_of_memory, to heap.h too, t
Hannes Payer (out of office)
2014/04/17 10:30:04
Done.
| |
| 474 #if V8_OS_ANDROID | 474 #if V8_OS_ANDROID |
| 475 // Android has higher physical memory requirements before raising the maximum | 475 // Android has higher physical memory requirements before raising the maximum |
| 476 // heap size limits since it has no swap space. | 476 // heap size limits since it has no swap space. |
| 477 const uint64_t low_limit = 512ul * i::MB; | 477 const uint64_t low_limit = 512ul * i::MB; |
| 478 const uint64_t medium_limit = 1ul * i::GB; | 478 const uint64_t medium_limit = 1ul * i::GB; |
| 479 const uint64_t high_limit = 2ul * i::GB; | 479 const uint64_t high_limit = 2ul * i::GB; |
| 480 #else | 480 #else |
| 481 const uint64_t low_limit = 512ul * i::MB; | 481 const uint64_t low_limit = 512ul * i::MB; |
| 482 const uint64_t medium_limit = 768ul * i::MB; | 482 const uint64_t medium_limit = 768ul * i::MB; |
| 483 const uint64_t high_limit = 1ul * i::GB; | 483 const uint64_t high_limit = 1ul * i::GB; |
| 484 #endif | 484 #endif |
| 485 | 485 |
| 486 // The young_space_size should be a power of 2 and old_generation_size should | |
| 487 // be a multiple of Page::kPageSize. | |
| 488 if (physical_memory <= low_limit) { | 486 if (physical_memory <= low_limit) { |
| 489 set_max_young_space_size(2 * lump_of_memory); | 487 set_max_new_space_size( |
| 490 set_max_old_space_size(128 * lump_of_memory); | 488 i::Heap::kMaxNewSpaceSizeLowMemoryDevice * lump_of_memory); |
| 491 set_max_executable_size(96 * lump_of_memory); | 489 set_max_old_space_size( |
| 490 i::Heap::kMaxOldSpaceSizeLowMemoryDevice * lump_of_memory); | |
| 491 set_max_executable_size( | |
| 492 i::Heap::kMaxExecutableSizeLowMemoryDevice * lump_of_memory); | |
| 492 } else if (physical_memory <= medium_limit) { | 493 } else if (physical_memory <= medium_limit) { |
| 493 set_max_young_space_size(8 * lump_of_memory); | 494 set_max_new_space_size( |
| 494 set_max_old_space_size(256 * lump_of_memory); | 495 i::Heap::kMaxNewSpaceSizeMediumMemoryDevice * lump_of_memory); |
| 495 set_max_executable_size(192 * lump_of_memory); | 496 set_max_old_space_size( |
| 497 i::Heap::kMaxOldSpaceSizeMediumMemoryDevice * lump_of_memory); | |
| 498 set_max_executable_size( | |
| 499 i::Heap::kMaxExecutableSizeMediumMemoryDevice * lump_of_memory); | |
| 496 } else if (physical_memory <= high_limit) { | 500 } else if (physical_memory <= high_limit) { |
| 497 set_max_young_space_size(16 * lump_of_memory); | 501 set_max_new_space_size( |
| 498 set_max_old_space_size(512 * lump_of_memory); | 502 i::Heap::kMaxNewSpaceSizeHighMemoryDevice * lump_of_memory); |
| 499 set_max_executable_size(256 * lump_of_memory); | 503 set_max_old_space_size( |
| 504 i::Heap::kMaxOldSpaceSizeHighMemoryDevice * lump_of_memory); | |
| 505 set_max_executable_size( | |
| 506 i::Heap::kMaxExecutableSizeHighMemoryDevice * lump_of_memory); | |
| 500 } else { | 507 } else { |
| 501 set_max_young_space_size(16 * lump_of_memory); | 508 set_max_new_space_size( |
| 502 set_max_old_space_size(700 * lump_of_memory); | 509 i::Heap::kMaxNewSpaceSizeHugeMemoryDevice * lump_of_memory); |
| 503 set_max_executable_size(256 * lump_of_memory); | 510 set_max_old_space_size( |
| 511 i::Heap::kMaxOldSpaceSizeHugeMemoryDevice * lump_of_memory); | |
| 512 set_max_executable_size( | |
| 513 i::Heap::kMaxExecutableSizeHugeMemoryDevice * lump_of_memory); | |
| 504 } | 514 } |
| 505 | 515 |
| 506 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); | 516 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); |
| 507 | 517 |
| 508 if (virtual_memory_limit > 0 && i::kIs64BitArch) { | 518 if (virtual_memory_limit > 0 && i::kIs64BitArch) { |
| 509 // Reserve no more than 1/8 of the memory for the code range, but at most | 519 // Reserve no more than 1/8 of the memory for the code range, but at most |
| 510 // 512 MB. | 520 // 512 MB. |
| 511 set_code_range_size( | 521 set_code_range_size( |
| 512 i::Min(512 * i::MB, static_cast<int>(virtual_memory_limit >> 3))); | 522 i::Min(512 * i::MB, static_cast<int>(virtual_memory_limit >> 3))); |
| 513 } | 523 } |
| 514 } | 524 } |
| 515 | 525 |
| 516 | 526 |
| 517 bool SetResourceConstraints(Isolate* v8_isolate, | 527 bool SetResourceConstraints(Isolate* v8_isolate, |
| 518 ResourceConstraints* constraints) { | 528 ResourceConstraints* constraints) { |
| 519 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 529 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 520 int young_space_size = constraints->max_young_space_size(); | 530 int new_space_size = constraints->max_new_space_size(); |
| 521 int old_gen_size = constraints->max_old_space_size(); | 531 int old_gen_size = constraints->max_old_space_size(); |
| 522 int max_executable_size = constraints->max_executable_size(); | 532 int max_executable_size = constraints->max_executable_size(); |
| 523 int code_range_size = constraints->code_range_size(); | 533 int code_range_size = constraints->code_range_size(); |
| 524 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 || | 534 if (new_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 || |
| 525 code_range_size != 0) { | 535 code_range_size != 0) { |
| 526 // After initialization it's too late to change Heap constraints. | 536 // After initialization it's too late to change Heap constraints. |
| 527 ASSERT(!isolate->IsInitialized()); | 537 ASSERT(!isolate->IsInitialized()); |
| 528 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 538 bool result = isolate->heap()->ConfigureHeap(new_space_size / 2, |
| 529 old_gen_size, | 539 old_gen_size, |
| 530 max_executable_size, | 540 max_executable_size, |
| 531 code_range_size); | 541 code_range_size); |
| 532 if (!result) return false; | 542 if (!result) return false; |
| 533 } | 543 } |
| 534 if (constraints->stack_limit() != NULL) { | 544 if (constraints->stack_limit() != NULL) { |
| 535 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 545 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
| 536 isolate->stack_guard()->SetStackLimit(limit); | 546 isolate->stack_guard()->SetStackLimit(limit); |
| 537 } | 547 } |
| 538 | 548 |
| (...skipping 7117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7656 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7666 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7657 Address callback_address = | 7667 Address callback_address = |
| 7658 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7668 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7659 VMState<EXTERNAL> state(isolate); | 7669 VMState<EXTERNAL> state(isolate); |
| 7660 ExternalCallbackScope call_scope(isolate, callback_address); | 7670 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7661 callback(info); | 7671 callback(info); |
| 7662 } | 7672 } |
| 7663 | 7673 |
| 7664 | 7674 |
| 7665 } } // namespace v8::internal | 7675 } } // namespace v8::internal |
| OLD | NEW |