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 6437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6448 | 6448 |
6449 | 6449 |
6450 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { | 6450 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { |
6451 i::Isolate* isolate = i::Isolate::Current(); | 6451 i::Isolate* isolate = i::Isolate::Current(); |
6452 isolate->memory_allocator()->RemoveMemoryAllocationCallback( | 6452 isolate->memory_allocator()->RemoveMemoryAllocationCallback( |
6453 callback); | 6453 callback); |
6454 } | 6454 } |
6455 | 6455 |
6456 | 6456 |
6457 void V8::RunMicrotasks(Isolate* isolate) { | 6457 void V8::RunMicrotasks(Isolate* isolate) { |
6458 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6458 isolate->RunMicrotasks(); |
6459 i::HandleScope scope(i_isolate); | |
6460 i::V8::RunMicrotasks(i_isolate); | |
6461 } | 6459 } |
6462 | 6460 |
6463 | 6461 |
6464 void V8::EnqueueMicrotask(Isolate* isolate, Handle<Function> microtask) { | 6462 void V8::EnqueueMicrotask(Isolate* isolate, Handle<Function> microtask) { |
6465 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6463 isolate->EnqueueMicrotask(microtask); |
6466 ENTER_V8(i_isolate); | |
6467 i::Execution::EnqueueMicrotask(i_isolate, Utils::OpenHandle(*microtask)); | |
6468 } | 6464 } |
6469 | 6465 |
6470 | 6466 |
6471 void V8::SetAutorunMicrotasks(Isolate* isolate, bool autorun) { | 6467 void V8::SetAutorunMicrotasks(Isolate* isolate, bool autorun) { |
6472 reinterpret_cast<i::Isolate*>(isolate)->set_autorun_microtasks(autorun); | 6468 isolate->SetAutorunMicrotasks(autorun); |
6473 } | 6469 } |
6474 | 6470 |
6475 | 6471 |
6476 void V8::TerminateExecution(Isolate* isolate) { | 6472 void V8::TerminateExecution(Isolate* isolate) { |
6477 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); | 6473 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); |
6478 } | 6474 } |
6479 | 6475 |
6480 | 6476 |
6481 bool V8::IsExecutionTerminating(Isolate* isolate) { | 6477 bool V8::IsExecutionTerminating(Isolate* isolate) { |
6482 i::Isolate* i_isolate = isolate != NULL ? | 6478 i::Isolate* i_isolate = isolate != NULL ? |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6586 new i::NoThrowOnJavascriptExecution(i_isolate)); | 6582 new i::NoThrowOnJavascriptExecution(i_isolate)); |
6587 } | 6583 } |
6588 | 6584 |
6589 | 6585 |
6590 Isolate::AllowJavascriptExecutionScope::~AllowJavascriptExecutionScope() { | 6586 Isolate::AllowJavascriptExecutionScope::~AllowJavascriptExecutionScope() { |
6591 delete reinterpret_cast<i::AllowJavascriptExecution*>(internal_assert_); | 6587 delete reinterpret_cast<i::AllowJavascriptExecution*>(internal_assert_); |
6592 delete reinterpret_cast<i::NoThrowOnJavascriptExecution*>(internal_throws_); | 6588 delete reinterpret_cast<i::NoThrowOnJavascriptExecution*>(internal_throws_); |
6593 } | 6589 } |
6594 | 6590 |
6595 | 6591 |
| 6592 Isolate::SuppressMicrotaskExecutionScope::SuppressMicrotaskExecutionScope( |
| 6593 Isolate* isolate) { |
| 6594 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6595 i_isolate->handle_scope_implementer()->IncrementCallDepth(); |
| 6596 internal_ = i_isolate; |
| 6597 } |
| 6598 |
| 6599 |
| 6600 Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope() { |
| 6601 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(internal_); |
| 6602 i_isolate->handle_scope_implementer()->DecrementCallDepth(); |
| 6603 } |
| 6604 |
| 6605 |
6596 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { | 6606 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { |
6597 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6607 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
6598 if (!isolate->IsInitialized()) { | 6608 if (!isolate->IsInitialized()) { |
6599 heap_statistics->total_heap_size_ = 0; | 6609 heap_statistics->total_heap_size_ = 0; |
6600 heap_statistics->total_heap_size_executable_ = 0; | 6610 heap_statistics->total_heap_size_executable_ = 0; |
6601 heap_statistics->total_physical_size_ = 0; | 6611 heap_statistics->total_physical_size_ = 0; |
6602 heap_statistics->used_heap_size_ = 0; | 6612 heap_statistics->used_heap_size_ = 0; |
6603 heap_statistics->heap_size_limit_ = 0; | 6613 heap_statistics->heap_size_limit_ = 0; |
6604 return; | 6614 return; |
6605 } | 6615 } |
(...skipping 19 matching lines...) Expand all Loading... |
6625 isolate->AddCallCompletedCallback(callback); | 6635 isolate->AddCallCompletedCallback(callback); |
6626 } | 6636 } |
6627 | 6637 |
6628 | 6638 |
6629 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 6639 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
6630 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6640 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
6631 isolate->RemoveCallCompletedCallback(callback); | 6641 isolate->RemoveCallCompletedCallback(callback); |
6632 } | 6642 } |
6633 | 6643 |
6634 | 6644 |
| 6645 void Isolate::RunMicrotasks() { |
| 6646 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6647 i::HandleScope scope(i_isolate); |
| 6648 i_isolate->RunMicrotasks(); |
| 6649 } |
| 6650 |
| 6651 |
| 6652 void Isolate::EnqueueMicrotask(Handle<Function> microtask) { |
| 6653 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6654 ENTER_V8(i_isolate); |
| 6655 i::Execution::EnqueueMicrotask(i_isolate, Utils::OpenHandle(*microtask)); |
| 6656 } |
| 6657 |
| 6658 |
| 6659 void Isolate::SetAutorunMicrotasks(bool autorun) { |
| 6660 reinterpret_cast<i::Isolate*>(this)->set_autorun_microtasks(autorun); |
| 6661 } |
| 6662 |
| 6663 |
6635 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 6664 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
6636 : str_(NULL), length_(0) { | 6665 : str_(NULL), length_(0) { |
6637 i::Isolate* isolate = i::Isolate::Current(); | 6666 i::Isolate* isolate = i::Isolate::Current(); |
6638 if (obj.IsEmpty()) return; | 6667 if (obj.IsEmpty()) return; |
6639 ENTER_V8(isolate); | 6668 ENTER_V8(isolate); |
6640 i::HandleScope scope(isolate); | 6669 i::HandleScope scope(isolate); |
6641 TryCatch try_catch; | 6670 TryCatch try_catch; |
6642 Handle<String> str = obj->ToString(); | 6671 Handle<String> str = obj->ToString(); |
6643 if (str.IsEmpty()) return; | 6672 if (str.IsEmpty()) return; |
6644 i::Handle<i::String> i_str = Utils::OpenHandle(*str); | 6673 i::Handle<i::String> i_str = Utils::OpenHandle(*str); |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7567 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7596 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7568 Address callback_address = | 7597 Address callback_address = |
7569 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7598 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7570 VMState<EXTERNAL> state(isolate); | 7599 VMState<EXTERNAL> state(isolate); |
7571 ExternalCallbackScope call_scope(isolate, callback_address); | 7600 ExternalCallbackScope call_scope(isolate, callback_address); |
7572 callback(info); | 7601 callback(info); |
7573 } | 7602 } |
7574 | 7603 |
7575 | 7604 |
7576 } } // namespace v8::internal | 7605 } } // namespace v8::internal |
OLD | NEW |