OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "api.h" | 5 #include "api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #include <cmath> // For isnan. | 8 #include <cmath> // For isnan. |
9 #include "../include/v8-debug.h" | 9 #include "../include/v8-debug.h" |
10 #include "../include/v8-profiler.h" | 10 #include "../include/v8-profiler.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 (source ? static_cast<int>(strlen(source)) : 0)), | 412 (source ? static_cast<int>(strlen(source)) : 0)), |
413 source_(source, source_length_), | 413 source_(source, source_length_), |
414 dep_count_(dep_count), | 414 dep_count_(dep_count), |
415 deps_(deps), | 415 deps_(deps), |
416 auto_enable_(false) { | 416 auto_enable_(false) { |
417 CHECK(source != NULL || source_length_ == 0); | 417 CHECK(source != NULL || source_length_ == 0); |
418 } | 418 } |
419 | 419 |
420 | 420 |
421 ResourceConstraints::ResourceConstraints() | 421 ResourceConstraints::ResourceConstraints() |
422 : max_new_space_size_(0), | 422 : max_semispace_size_(0), |
423 max_old_space_size_(0), | 423 max_old_space_size_(0), |
424 max_executable_size_(0), | 424 max_executable_size_(0), |
425 stack_limit_(NULL), | 425 stack_limit_(NULL), |
426 max_available_threads_(0), | 426 max_available_threads_(0), |
427 code_range_size_(0) { } | 427 code_range_size_(0) { } |
428 | 428 |
429 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 429 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
430 uint64_t virtual_memory_limit, | 430 uint64_t virtual_memory_limit, |
431 uint32_t number_of_processors) { | 431 uint32_t number_of_processors) { |
432 #if V8_OS_ANDROID | 432 #if V8_OS_ANDROID |
433 // Android has higher physical memory requirements before raising the maximum | 433 // Android has higher physical memory requirements before raising the maximum |
434 // heap size limits since it has no swap space. | 434 // heap size limits since it has no swap space. |
435 const uint64_t low_limit = 512ul * i::MB; | 435 const uint64_t low_limit = 512ul * i::MB; |
436 const uint64_t medium_limit = 1ul * i::GB; | 436 const uint64_t medium_limit = 1ul * i::GB; |
437 const uint64_t high_limit = 2ul * i::GB; | 437 const uint64_t high_limit = 2ul * i::GB; |
438 #else | 438 #else |
439 const uint64_t low_limit = 512ul * i::MB; | 439 const uint64_t low_limit = 512ul * i::MB; |
440 const uint64_t medium_limit = 768ul * i::MB; | 440 const uint64_t medium_limit = 768ul * i::MB; |
441 const uint64_t high_limit = 1ul * i::GB; | 441 const uint64_t high_limit = 1ul * i::GB; |
442 #endif | 442 #endif |
443 | 443 |
444 if (physical_memory <= low_limit) { | 444 if (physical_memory <= low_limit) { |
445 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeLowMemoryDevice); | 445 set_max_semispace_size(i::Heap::kMaxSemiSpaceSizeLowMemoryDevice); |
446 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice); | 446 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeLowMemoryDevice); |
447 set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice); | 447 set_max_executable_size(i::Heap::kMaxExecutableSizeLowMemoryDevice); |
448 } else if (physical_memory <= medium_limit) { | 448 } else if (physical_memory <= medium_limit) { |
449 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeMediumMemoryDevice); | 449 set_max_semispace_size(i::Heap::kMaxSemiSpaceSizeMediumMemoryDevice); |
450 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice); | 450 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeMediumMemoryDevice); |
451 set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice); | 451 set_max_executable_size(i::Heap::kMaxExecutableSizeMediumMemoryDevice); |
452 } else if (physical_memory <= high_limit) { | 452 } else if (physical_memory <= high_limit) { |
453 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHighMemoryDevice); | 453 set_max_semispace_size(i::Heap::kMaxSemiSpaceSizeHighMemoryDevice); |
454 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); | 454 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); |
455 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); | 455 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); |
456 } else { | 456 } else { |
457 set_max_new_space_size(i::Heap::kMaxNewSpaceSizeHugeMemoryDevice); | 457 set_max_semispace_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); |
458 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); | 458 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); |
459 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); | 459 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); |
460 } | 460 } |
461 | 461 |
462 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); | 462 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); |
463 | 463 |
464 if (virtual_memory_limit > 0 && i::kIs64BitArch) { | 464 if (virtual_memory_limit > 0 && i::kIs64BitArch) { |
465 // Reserve no more than 1/8 of the memory for the code range, but at most | 465 // Reserve no more than 1/8 of the memory for the code range, but at most |
466 // 512 MB. | 466 // 512 MB. |
467 set_code_range_size( | 467 set_code_range_size( |
468 i::Min(512 * i::MB, static_cast<int>(virtual_memory_limit >> 3))); | 468 i::Min(512, static_cast<int>((virtual_memory_limit >> 3) / i::MB))); |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 | 472 |
473 bool SetResourceConstraints(Isolate* v8_isolate, | 473 bool SetResourceConstraints(Isolate* v8_isolate, |
474 ResourceConstraints* constraints) { | 474 ResourceConstraints* constraints) { |
475 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 475 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
476 int new_space_size = constraints->max_new_space_size(); | 476 int new_space_size = constraints->max_semispace_size(); |
477 int old_space_size = constraints->max_old_space_size(); | 477 int old_space_size = constraints->max_old_space_size(); |
478 int max_executable_size = constraints->max_executable_size(); | 478 int max_executable_size = constraints->max_executable_size(); |
479 int code_range_size = constraints->code_range_size(); | 479 int code_range_size = constraints->code_range_size(); |
480 if (new_space_size != 0 || old_space_size != 0 || max_executable_size != 0 || | 480 if (new_space_size != 0 || old_space_size != 0 || max_executable_size != 0 || |
481 code_range_size != 0) { | 481 code_range_size != 0) { |
482 // After initialization it's too late to change Heap constraints. | 482 // After initialization it's too late to change Heap constraints. |
483 ASSERT(!isolate->IsInitialized()); | 483 ASSERT(!isolate->IsInitialized()); |
484 bool result = isolate->heap()->ConfigureHeap(new_space_size / 2, | 484 bool result = isolate->heap()->ConfigureHeap(new_space_size / 2, |
485 old_space_size, | 485 old_space_size, |
486 max_executable_size, | 486 max_executable_size, |
(...skipping 7107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7594 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7594 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7595 Address callback_address = | 7595 Address callback_address = |
7596 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7596 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7597 VMState<EXTERNAL> state(isolate); | 7597 VMState<EXTERNAL> state(isolate); |
7598 ExternalCallbackScope call_scope(isolate, callback_address); | 7598 ExternalCallbackScope call_scope(isolate, callback_address); |
7599 callback(info); | 7599 callback(info); |
7600 } | 7600 } |
7601 | 7601 |
7602 | 7602 |
7603 } } // namespace v8::internal | 7603 } } // namespace v8::internal |
OLD | NEW |