| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { | 363 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { |
| 364 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 364 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 365 i::SetSnapshotFromFile(snapshot_blob); | 365 i::SetSnapshotFromFile(snapshot_blob); |
| 366 #else | 366 #else |
| 367 CHECK(false); | 367 CHECK(false); |
| 368 #endif | 368 #endif |
| 369 } | 369 } |
| 370 | 370 |
| 371 | 371 |
| 372 void V8::SetFatalErrorHandler(FatalErrorCallback that) { | 372 void V8::SetFatalErrorHandler(FatalErrorCallback that) { |
| 373 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 373 i::Isolate* isolate = i::Isolate::Current(); |
| 374 isolate->set_exception_behavior(that); | 374 isolate->set_exception_behavior(that); |
| 375 } | 375 } |
| 376 | 376 |
| 377 | 377 |
| 378 void V8::SetAllowCodeGenerationFromStringsCallback( | 378 void V8::SetAllowCodeGenerationFromStringsCallback( |
| 379 AllowCodeGenerationFromStringsCallback callback) { | 379 AllowCodeGenerationFromStringsCallback callback) { |
| 380 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 380 i::Isolate* isolate = i::Isolate::Current(); |
| 381 isolate->set_allow_code_gen_callback(callback); | 381 isolate->set_allow_code_gen_callback(callback); |
| 382 } | 382 } |
| 383 | 383 |
| 384 | 384 |
| 385 void V8::SetFlagsFromString(const char* str, int length) { | 385 void V8::SetFlagsFromString(const char* str, int length) { |
| 386 i::FlagList::SetFlagsFromString(str, length); | 386 i::FlagList::SetFlagsFromString(str, length); |
| 387 } | 387 } |
| 388 | 388 |
| 389 | 389 |
| 390 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { | 390 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { |
| (...skipping 6204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6595 } else { | 6595 } else { |
| 6596 ASSERT_EQ(kFullGarbageCollection, type); | 6596 ASSERT_EQ(kFullGarbageCollection, type); |
| 6597 reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage( | 6597 reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage( |
| 6598 i::Heap::kAbortIncrementalMarkingMask, | 6598 i::Heap::kAbortIncrementalMarkingMask, |
| 6599 "Isolate::RequestGarbageCollection", kGCCallbackFlagForced); | 6599 "Isolate::RequestGarbageCollection", kGCCallbackFlagForced); |
| 6600 } | 6600 } |
| 6601 } | 6601 } |
| 6602 | 6602 |
| 6603 | 6603 |
| 6604 Isolate* Isolate::GetCurrent() { | 6604 Isolate* Isolate::GetCurrent() { |
| 6605 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 6605 i::Isolate* isolate = i::Isolate::Current(); |
| 6606 return reinterpret_cast<Isolate*>(isolate); | 6606 return reinterpret_cast<Isolate*>(isolate); |
| 6607 } | 6607 } |
| 6608 | 6608 |
| 6609 | 6609 |
| 6610 Isolate* Isolate::New() { | 6610 Isolate* Isolate::New() { |
| 6611 i::Isolate* isolate = new i::Isolate(); | 6611 i::Isolate* isolate = new i::Isolate(); |
| 6612 return reinterpret_cast<Isolate*>(isolate); | 6612 return reinterpret_cast<Isolate*>(isolate); |
| 6613 } | 6613 } |
| 6614 | 6614 |
| 6615 | 6615 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6761 bool Isolate::WillAutorunMicrotasks() const { | 6761 bool Isolate::WillAutorunMicrotasks() const { |
| 6762 return reinterpret_cast<const i::Isolate*>(this)->autorun_microtasks(); | 6762 return reinterpret_cast<const i::Isolate*>(this)->autorun_microtasks(); |
| 6763 } | 6763 } |
| 6764 | 6764 |
| 6765 | 6765 |
| 6766 void Isolate::SetUseCounterCallback(UseCounterCallback callback) { | 6766 void Isolate::SetUseCounterCallback(UseCounterCallback callback) { |
| 6767 reinterpret_cast<i::Isolate*>(this)->SetUseCounterCallback(callback); | 6767 reinterpret_cast<i::Isolate*>(this)->SetUseCounterCallback(callback); |
| 6768 } | 6768 } |
| 6769 | 6769 |
| 6770 | 6770 |
| 6771 void Isolate::SetCounterFunction(CounterLookupCallback callback) { |
| 6772 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 6773 isolate->stats_table()->SetCounterFunction(callback); |
| 6774 isolate->InitializeLoggingAndCounters(); |
| 6775 isolate->counters()->ResetCounters(); |
| 6776 } |
| 6777 |
| 6778 |
| 6779 void Isolate::SetCreateHistogramFunction(CreateHistogramCallback callback) { |
| 6780 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 6781 isolate->stats_table()->SetCreateHistogramFunction(callback); |
| 6782 isolate->InitializeLoggingAndCounters(); |
| 6783 isolate->counters()->ResetHistograms(); |
| 6784 } |
| 6785 |
| 6786 |
| 6787 void Isolate::SetAddHistogramSampleFunction( |
| 6788 AddHistogramSampleCallback callback) { |
| 6789 reinterpret_cast<i::Isolate*>(this) |
| 6790 ->stats_table() |
| 6791 ->SetAddHistogramSampleFunction(callback); |
| 6792 } |
| 6793 |
| 6794 |
| 6771 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 6795 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
| 6772 : str_(NULL), length_(0) { | 6796 : str_(NULL), length_(0) { |
| 6773 i::Isolate* isolate = i::Isolate::Current(); | 6797 i::Isolate* isolate = i::Isolate::Current(); |
| 6774 if (obj.IsEmpty()) return; | 6798 if (obj.IsEmpty()) return; |
| 6775 ENTER_V8(isolate); | 6799 ENTER_V8(isolate); |
| 6776 i::HandleScope scope(isolate); | 6800 i::HandleScope scope(isolate); |
| 6777 TryCatch try_catch; | 6801 TryCatch try_catch; |
| 6778 Handle<String> str = obj->ToString(); | 6802 Handle<String> str = obj->ToString(); |
| 6779 if (str.IsEmpty()) return; | 6803 if (str.IsEmpty()) return; |
| 6780 i::Handle<i::String> i_str = Utils::OpenHandle(*str); | 6804 i::Handle<i::String> i_str = Utils::OpenHandle(*str); |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7661 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7685 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7662 Address callback_address = | 7686 Address callback_address = |
| 7663 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7687 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7664 VMState<EXTERNAL> state(isolate); | 7688 VMState<EXTERNAL> state(isolate); |
| 7665 ExternalCallbackScope call_scope(isolate, callback_address); | 7689 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7666 callback(info); | 7690 callback(info); |
| 7667 } | 7691 } |
| 7668 | 7692 |
| 7669 | 7693 |
| 7670 } } // namespace v8::internal | 7694 } } // namespace v8::internal |
| OLD | NEW |