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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 auto_enable_(false) { | 473 auto_enable_(false) { |
474 CHECK(source != NULL || source_length_ == 0); | 474 CHECK(source != NULL || source_length_ == 0); |
475 } | 475 } |
476 | 476 |
477 | 477 |
478 ResourceConstraints::ResourceConstraints() | 478 ResourceConstraints::ResourceConstraints() |
479 : max_semi_space_size_(0), | 479 : max_semi_space_size_(0), |
480 max_old_space_size_(0), | 480 max_old_space_size_(0), |
481 max_executable_size_(0), | 481 max_executable_size_(0), |
482 stack_limit_(NULL), | 482 stack_limit_(NULL), |
483 max_available_threads_(0), | |
484 code_range_size_(0) { } | 483 code_range_size_(0) { } |
485 | 484 |
486 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 485 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
487 uint64_t virtual_memory_limit, | |
488 uint32_t number_of_processors) { | |
489 ConfigureDefaults(physical_memory, virtual_memory_limit); | |
490 } | |
491 | |
492 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | |
493 uint64_t virtual_memory_limit) { | 486 uint64_t virtual_memory_limit) { |
494 #if V8_OS_ANDROID | 487 #if V8_OS_ANDROID |
495 // Android has higher physical memory requirements before raising the maximum | 488 // Android has higher physical memory requirements before raising the maximum |
496 // heap size limits since it has no swap space. | 489 // heap size limits since it has no swap space. |
497 const uint64_t low_limit = 512ul * i::MB; | 490 const uint64_t low_limit = 512ul * i::MB; |
498 const uint64_t medium_limit = 1ul * i::GB; | 491 const uint64_t medium_limit = 1ul * i::GB; |
499 const uint64_t high_limit = 2ul * i::GB; | 492 const uint64_t high_limit = 2ul * i::GB; |
500 #else | 493 #else |
501 const uint64_t low_limit = 512ul * i::MB; | 494 const uint64_t low_limit = 512ul * i::MB; |
502 const uint64_t medium_limit = 768ul * i::MB; | 495 const uint64_t medium_limit = 768ul * i::MB; |
(...skipping 4866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5369 void v8::V8::SetEntropySource(EntropySource entropy_source) { | 5362 void v8::V8::SetEntropySource(EntropySource entropy_source) { |
5370 base::RandomNumberGenerator::SetEntropySource(entropy_source); | 5363 base::RandomNumberGenerator::SetEntropySource(entropy_source); |
5371 } | 5364 } |
5372 | 5365 |
5373 | 5366 |
5374 void v8::V8::SetReturnAddressLocationResolver( | 5367 void v8::V8::SetReturnAddressLocationResolver( |
5375 ReturnAddressLocationResolver return_address_resolver) { | 5368 ReturnAddressLocationResolver return_address_resolver) { |
5376 i::V8::SetReturnAddressLocationResolver(return_address_resolver); | 5369 i::V8::SetReturnAddressLocationResolver(return_address_resolver); |
5377 } | 5370 } |
5378 | 5371 |
5379 void v8::V8::SetArrayBufferAllocator( | |
5380 ArrayBuffer::Allocator* allocator) { | |
5381 if (!Utils::ApiCheck(i::V8::ArrayBufferAllocator() == NULL, | |
5382 "v8::V8::SetArrayBufferAllocator", | |
5383 "ArrayBufferAllocator might only be set once")) | |
5384 return; | |
5385 i::V8::SetArrayBufferAllocator(allocator); | |
5386 } | |
5387 | |
5388 | 5372 |
5389 bool v8::V8::Dispose() { | 5373 bool v8::V8::Dispose() { |
5390 i::V8::TearDown(); | 5374 i::V8::TearDown(); |
5391 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 5375 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
5392 i::DisposeNatives(); | 5376 i::DisposeNatives(); |
5393 #endif | 5377 #endif |
5394 return true; | 5378 return true; |
5395 } | 5379 } |
5396 | 5380 |
5397 | 5381 |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7093 } | 7077 } |
7094 } | 7078 } |
7095 | 7079 |
7096 | 7080 |
7097 Isolate* Isolate::GetCurrent() { | 7081 Isolate* Isolate::GetCurrent() { |
7098 i::Isolate* isolate = i::Isolate::Current(); | 7082 i::Isolate* isolate = i::Isolate::Current(); |
7099 return reinterpret_cast<Isolate*>(isolate); | 7083 return reinterpret_cast<Isolate*>(isolate); |
7100 } | 7084 } |
7101 | 7085 |
7102 | 7086 |
7103 Isolate* Isolate::New() { | |
7104 Isolate::CreateParams create_params; | |
7105 return New(create_params); | |
7106 } | |
7107 | |
7108 | |
7109 Isolate* Isolate::New(const Isolate::CreateParams& params) { | 7087 Isolate* Isolate::New(const Isolate::CreateParams& params) { |
7110 i::Isolate* isolate = new i::Isolate(false); | 7088 i::Isolate* isolate = new i::Isolate(false); |
7111 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); | 7089 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
7112 if (params.array_buffer_allocator != NULL) { | 7090 CHECK(params.array_buffer_allocator != NULL); |
7113 isolate->set_array_buffer_allocator(params.array_buffer_allocator); | 7091 isolate->set_array_buffer_allocator(params.array_buffer_allocator); |
7114 } else { | |
7115 isolate->set_array_buffer_allocator(i::V8::ArrayBufferAllocator()); | |
7116 } | |
7117 if (params.snapshot_blob != NULL) { | 7092 if (params.snapshot_blob != NULL) { |
7118 isolate->set_snapshot_blob(params.snapshot_blob); | 7093 isolate->set_snapshot_blob(params.snapshot_blob); |
7119 } else { | 7094 } else { |
7120 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); | 7095 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); |
7121 } | 7096 } |
7122 if (params.entry_hook) { | 7097 if (params.entry_hook) { |
7123 isolate->set_function_entry_hook(params.entry_hook); | 7098 isolate->set_function_entry_hook(params.entry_hook); |
7124 } | 7099 } |
7125 if (params.code_event_handler) { | 7100 if (params.code_event_handler) { |
7126 isolate->InitializeLoggingAndCounters(); | 7101 isolate->InitializeLoggingAndCounters(); |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8428 Address callback_address = | 8403 Address callback_address = |
8429 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8404 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8430 VMState<EXTERNAL> state(isolate); | 8405 VMState<EXTERNAL> state(isolate); |
8431 ExternalCallbackScope call_scope(isolate, callback_address); | 8406 ExternalCallbackScope call_scope(isolate, callback_address); |
8432 callback(info); | 8407 callback(info); |
8433 } | 8408 } |
8434 | 8409 |
8435 | 8410 |
8436 } // namespace internal | 8411 } // namespace internal |
8437 } // namespace v8 | 8412 } // namespace v8 |
OLD | NEW |