| 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; | |
| 474 #if V8_OS_ANDROID | 473 #if V8_OS_ANDROID |
| 475 // Android has higher physical memory requirements before raising the maximum | 474 // Android has higher physical memory requirements before raising the maximum |
| 476 // heap size limits since it has no swap space. | 475 // heap size limits since it has no swap space. |
| 477 const uint64_t low_limit = 512ul * i::MB; | 476 const uint64_t low_limit = 512ul * i::MB; |
| 478 const uint64_t medium_limit = 1ul * i::GB; | 477 const uint64_t medium_limit = 1ul * i::GB; |
| 479 const uint64_t high_limit = 2ul * i::GB; | 478 const uint64_t high_limit = 2ul * i::GB; |
| 480 #else | 479 #else |
| 481 const uint64_t low_limit = 512ul * i::MB; | 480 const uint64_t low_limit = 512ul * i::MB; |
| 482 const uint64_t medium_limit = 768ul * i::MB; | 481 const uint64_t medium_limit = 768ul * i::MB; |
| 483 const uint64_t high_limit = 1ul * i::GB; | 482 const uint64_t high_limit = 1ul * i::GB; |
| 484 #endif | 483 #endif |
| 485 | 484 |
| 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) { | 485 if (physical_memory <= low_limit) { |
| 489 set_max_young_space_size(2 * lump_of_memory); | 486 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeLowMemoryDevice); |
| 490 set_max_old_space_size(128 * lump_of_memory); | 487 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice); |
| 491 set_max_executable_size(96 * lump_of_memory); | 488 set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice); |
| 492 } else if (physical_memory <= medium_limit) { | 489 } else if (physical_memory <= medium_limit) { |
| 493 set_max_young_space_size(8 * lump_of_memory); | 490 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeMediumMemoryDevice); |
| 494 set_max_old_space_size(256 * lump_of_memory); | 491 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice); |
| 495 set_max_executable_size(192 * lump_of_memory); | 492 set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice); |
| 496 } else if (physical_memory <= high_limit) { | 493 } else if (physical_memory <= high_limit) { |
| 497 set_max_young_space_size(16 * lump_of_memory); | 494 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHighMemoryDevice); |
| 498 set_max_old_space_size(512 * lump_of_memory); | 495 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); |
| 499 set_max_executable_size(256 * lump_of_memory); | 496 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); |
| 500 } else { | 497 } else { |
| 501 set_max_young_space_size(16 * lump_of_memory); | 498 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHugeMemoryDevice); |
| 502 set_max_old_space_size(700 * lump_of_memory); | 499 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); |
| 503 set_max_executable_size(256 * lump_of_memory); | 500 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); |
| 504 } | 501 } |
| 505 | 502 |
| 506 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); | 503 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); |
| 507 | 504 |
| 508 if (virtual_memory_limit > 0 && i::kIs64BitArch) { | 505 if (virtual_memory_limit > 0 && i::kIs64BitArch) { |
| 509 // Reserve no more than 1/8 of the memory for the code range, but at most | 506 // Reserve no more than 1/8 of the memory for the code range, but at most |
| 510 // 512 MB. | 507 // 512 MB. |
| 511 set_code_range_size( | 508 set_code_range_size( |
| 512 i::Min(512 * i::MB, static_cast<int>(virtual_memory_limit >> 3))); | 509 i::Min(512 * i::MB, static_cast<int>(virtual_memory_limit >> 3))); |
| 513 } | 510 } |
| 514 } | 511 } |
| 515 | 512 |
| 516 | 513 |
| 517 bool SetResourceConstraints(Isolate* v8_isolate, | 514 bool SetResourceConstraints(Isolate* v8_isolate, |
| 518 ResourceConstraints* constraints) { | 515 ResourceConstraints* constraints) { |
| 519 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 516 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 520 int young_space_size = constraints->max_young_space_size(); | 517 int new_space_size = constraints->max_new_space_size(); |
| 521 int old_gen_size = constraints->max_old_space_size(); | 518 int old_gen_size = constraints->max_old_space_size(); |
| 522 int max_executable_size = constraints->max_executable_size(); | 519 int max_executable_size = constraints->max_executable_size(); |
| 523 int code_range_size = constraints->code_range_size(); | 520 int code_range_size = constraints->code_range_size(); |
| 524 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 || | 521 if (new_space_size != 0 || old_gen_size != 0 || max_executable_size != 0 || |
| 525 code_range_size != 0) { | 522 code_range_size != 0) { |
| 526 // After initialization it's too late to change Heap constraints. | 523 // After initialization it's too late to change Heap constraints. |
| 527 ASSERT(!isolate->IsInitialized()); | 524 ASSERT(!isolate->IsInitialized()); |
| 528 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 525 bool result = isolate->heap()->ConfigureHeap(new_space_size / 2, |
| 529 old_gen_size, | 526 old_gen_size, |
| 530 max_executable_size, | 527 max_executable_size, |
| 531 code_range_size); | 528 code_range_size); |
| 532 if (!result) return false; | 529 if (!result) return false; |
| 533 } | 530 } |
| 534 if (constraints->stack_limit() != NULL) { | 531 if (constraints->stack_limit() != NULL) { |
| 535 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 532 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
| 536 isolate->stack_guard()->SetStackLimit(limit); | 533 isolate->stack_guard()->SetStackLimit(limit); |
| 537 } | 534 } |
| 538 | 535 |
| (...skipping 7117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7656 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7653 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7657 Address callback_address = | 7654 Address callback_address = |
| 7658 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7655 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7659 VMState<EXTERNAL> state(isolate); | 7656 VMState<EXTERNAL> state(isolate); |
| 7660 ExternalCallbackScope call_scope(isolate, callback_address); | 7657 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7661 callback(info); | 7658 callback(info); |
| 7662 } | 7659 } |
| 7663 | 7660 |
| 7664 | 7661 |
| 7665 } } // namespace v8::internal | 7662 } } // namespace v8::internal |
| OLD | NEW |