Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: src/api.cc

Issue 271843005: Simplify ConfigureHeap and change --max_new_space_size to --max_semi_space_size. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/flag-definitions.h » ('j') | src/heap.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_semi_space_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_semi_space_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_semi_space_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_semi_space_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_semi_space_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 semi_space_size = constraints->max_semi_space_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 (semi_space_size != 0 || old_space_size != 0 ||
481 code_range_size != 0) { 481 max_executable_size != 0 || 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(semi_space_size,
485 old_space_size, 485 old_space_size,
486 max_executable_size, 486 max_executable_size,
487 code_range_size); 487 code_range_size);
488 if (!result) return false; 488 if (!result) return false;
489 } 489 }
490 if (constraints->stack_limit() != NULL) { 490 if (constraints->stack_limit() != NULL) {
491 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); 491 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit());
492 isolate->stack_guard()->SetStackLimit(limit); 492 isolate->stack_guard()->SetStackLimit(limit);
493 } 493 }
494 494
(...skipping 7099 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/flag-definitions.h » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698