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 : isolate_(reinterpret_cast<i::Isolate*>(isolate)) { |
| 6595 isolate_->handle_scope_implementer()->IncrementCallDepth(); |
| 6596 } |
| 6597 |
| 6598 |
| 6599 Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope() { |
| 6600 isolate_->handle_scope_implementer()->DecrementCallDepth(); |
| 6601 } |
| 6602 |
| 6603 |
6596 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { | 6604 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { |
6597 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6605 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
6598 if (!isolate->IsInitialized()) { | 6606 if (!isolate->IsInitialized()) { |
6599 heap_statistics->total_heap_size_ = 0; | 6607 heap_statistics->total_heap_size_ = 0; |
6600 heap_statistics->total_heap_size_executable_ = 0; | 6608 heap_statistics->total_heap_size_executable_ = 0; |
6601 heap_statistics->total_physical_size_ = 0; | 6609 heap_statistics->total_physical_size_ = 0; |
6602 heap_statistics->used_heap_size_ = 0; | 6610 heap_statistics->used_heap_size_ = 0; |
6603 heap_statistics->heap_size_limit_ = 0; | 6611 heap_statistics->heap_size_limit_ = 0; |
6604 return; | 6612 return; |
6605 } | 6613 } |
(...skipping 19 matching lines...) Expand all Loading... |
6625 isolate->AddCallCompletedCallback(callback); | 6633 isolate->AddCallCompletedCallback(callback); |
6626 } | 6634 } |
6627 | 6635 |
6628 | 6636 |
6629 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 6637 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
6630 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6638 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
6631 isolate->RemoveCallCompletedCallback(callback); | 6639 isolate->RemoveCallCompletedCallback(callback); |
6632 } | 6640 } |
6633 | 6641 |
6634 | 6642 |
| 6643 void Isolate::RunMicrotasks() { |
| 6644 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6645 i::HandleScope scope(i_isolate); |
| 6646 i_isolate->RunMicrotasks(); |
| 6647 } |
| 6648 |
| 6649 |
| 6650 void Isolate::EnqueueMicrotask(Handle<Function> microtask) { |
| 6651 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6652 ENTER_V8(i_isolate); |
| 6653 i::Execution::EnqueueMicrotask(i_isolate, Utils::OpenHandle(*microtask)); |
| 6654 } |
| 6655 |
| 6656 |
| 6657 void Isolate::SetAutorunMicrotasks(bool autorun) { |
| 6658 reinterpret_cast<i::Isolate*>(this)->set_autorun_microtasks(autorun); |
| 6659 } |
| 6660 |
| 6661 |
6635 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 6662 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
6636 : str_(NULL), length_(0) { | 6663 : str_(NULL), length_(0) { |
6637 i::Isolate* isolate = i::Isolate::Current(); | 6664 i::Isolate* isolate = i::Isolate::Current(); |
6638 if (obj.IsEmpty()) return; | 6665 if (obj.IsEmpty()) return; |
6639 ENTER_V8(isolate); | 6666 ENTER_V8(isolate); |
6640 i::HandleScope scope(isolate); | 6667 i::HandleScope scope(isolate); |
6641 TryCatch try_catch; | 6668 TryCatch try_catch; |
6642 Handle<String> str = obj->ToString(); | 6669 Handle<String> str = obj->ToString(); |
6643 if (str.IsEmpty()) return; | 6670 if (str.IsEmpty()) return; |
6644 i::Handle<i::String> i_str = Utils::OpenHandle(*str); | 6671 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()); | 7594 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7568 Address callback_address = | 7595 Address callback_address = |
7569 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7596 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7570 VMState<EXTERNAL> state(isolate); | 7597 VMState<EXTERNAL> state(isolate); |
7571 ExternalCallbackScope call_scope(isolate, callback_address); | 7598 ExternalCallbackScope call_scope(isolate, callback_address); |
7572 callback(info); | 7599 callback(info); |
7573 } | 7600 } |
7574 | 7601 |
7575 | 7602 |
7576 } } // namespace v8::internal | 7603 } } // namespace v8::internal |
OLD | NEW |