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 "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); | 458 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHighMemoryDevice); |
459 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); | 459 set_max_executable_size(i::Heap::kMaxExecutableSizeHighMemoryDevice); |
460 } else { | 460 } else { |
461 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); | 461 set_max_semi_space_size(i::Heap::kMaxSemiSpaceSizeHugeMemoryDevice); |
462 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); | 462 set_max_old_space_size(i::Heap::kMaxOldSpaceSizeHugeMemoryDevice); |
463 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); | 463 set_max_executable_size(i::Heap::kMaxExecutableSizeHugeMemoryDevice); |
464 } | 464 } |
465 | 465 |
466 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); | 466 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); |
467 | 467 |
468 if (virtual_memory_limit > 0 && i::kIs64BitArch) { | 468 if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { |
469 // Reserve no more than 1/8 of the memory for the code range, but at most | 469 // Reserve no more than 1/8 of the memory for the code range, but at most |
470 // 512 MB. | 470 // kMaximalCodeRangeSize. |
471 set_code_range_size( | 471 set_code_range_size( |
472 i::Min(512, static_cast<int>((virtual_memory_limit >> 3) / i::MB))); | 472 i::Min(i::kMaximalCodeRangeSize / i::MB, |
| 473 static_cast<size_t>((virtual_memory_limit >> 3) / i::MB))); |
473 } | 474 } |
474 } | 475 } |
475 | 476 |
476 | 477 |
477 bool SetResourceConstraints(Isolate* v8_isolate, | 478 bool SetResourceConstraints(Isolate* v8_isolate, |
478 ResourceConstraints* constraints) { | 479 ResourceConstraints* constraints) { |
479 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 480 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
480 int semi_space_size = constraints->max_semi_space_size(); | 481 int semi_space_size = constraints->max_semi_space_size(); |
481 int old_space_size = constraints->max_old_space_size(); | 482 int old_space_size = constraints->max_old_space_size(); |
482 int max_executable_size = constraints->max_executable_size(); | 483 int max_executable_size = constraints->max_executable_size(); |
483 int code_range_size = constraints->code_range_size(); | 484 size_t code_range_size = constraints->code_range_size(); |
484 if (semi_space_size != 0 || old_space_size != 0 || | 485 if (semi_space_size != 0 || old_space_size != 0 || |
485 max_executable_size != 0 || code_range_size != 0) { | 486 max_executable_size != 0 || code_range_size != 0) { |
486 // After initialization it's too late to change Heap constraints. | 487 // After initialization it's too late to change Heap constraints. |
487 ASSERT(!isolate->IsInitialized()); | 488 ASSERT(!isolate->IsInitialized()); |
488 bool result = isolate->heap()->ConfigureHeap(semi_space_size, | 489 bool result = isolate->heap()->ConfigureHeap(semi_space_size, |
489 old_space_size, | 490 old_space_size, |
490 max_executable_size, | 491 max_executable_size, |
491 code_range_size); | 492 code_range_size); |
492 if (!result) return false; | 493 if (!result) return false; |
493 } | 494 } |
(...skipping 7105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7599 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7600 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7600 Address callback_address = | 7601 Address callback_address = |
7601 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7602 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7602 VMState<EXTERNAL> state(isolate); | 7603 VMState<EXTERNAL> state(isolate); |
7603 ExternalCallbackScope call_scope(isolate, callback_address); | 7604 ExternalCallbackScope call_scope(isolate, callback_address); |
7604 callback(info); | 7605 callback(info); |
7605 } | 7606 } |
7606 | 7607 |
7607 | 7608 |
7608 } } // namespace v8::internal | 7609 } } // namespace v8::internal |
OLD | NEW |