5 #ifndef V8_ISOLATE_INL_H_ 6 #define V8_ISOLATE_INL_H_ 8 #include "src/heap/heap-inl.h" 9 #include "src/isolate.h" 10 #include "src/objects-inl.h" 11 #include "src/objects/regexp-match-info.h" 16 IsolateAllocationMode Isolate::isolate_allocation_mode() {
17 return isolate_allocator_->mode();
20 bool Isolate::FromWritableHeapObject(HeapObject* obj, Isolate** isolate) {
22 if (chunk->owner()->identity() == i::RO_SPACE) {
26 *isolate = chunk->heap()->isolate();
30 void Isolate::set_context(Context context) {
31 DCHECK(context.is_null() || context->IsContext());
32 thread_local_top_.context_ = context;
35 Handle<NativeContext> Isolate::native_context() {
36 return handle(context()->native_context(),
this);
39 NativeContext Isolate::raw_native_context() {
40 return context()->native_context();
43 Object* Isolate::pending_exception() {
44 DCHECK(has_pending_exception());
45 DCHECK(!thread_local_top_.pending_exception_->IsException(
this));
46 return thread_local_top_.pending_exception_;
50 void Isolate::set_pending_exception(Object* exception_obj) {
51 DCHECK(!exception_obj->IsException(
this));
52 thread_local_top_.pending_exception_ = exception_obj;
56 void Isolate::clear_pending_exception() {
57 DCHECK(!thread_local_top_.pending_exception_->IsException(
this));
58 thread_local_top_.pending_exception_ = ReadOnlyRoots(
this).the_hole_value();
62 bool Isolate::has_pending_exception() {
63 DCHECK(!thread_local_top_.pending_exception_->IsException(
this));
64 return !thread_local_top_.pending_exception_->IsTheHole(
this);
68 void Isolate::clear_pending_message() {
69 thread_local_top_.pending_message_obj_ = ReadOnlyRoots(
this).the_hole_value();
73 Object* Isolate::scheduled_exception() {
74 DCHECK(has_scheduled_exception());
75 DCHECK(!thread_local_top_.scheduled_exception_->IsException(
this));
76 return thread_local_top_.scheduled_exception_;
80 bool Isolate::has_scheduled_exception() {
81 DCHECK(!thread_local_top_.scheduled_exception_->IsException(
this));
82 return thread_local_top_.scheduled_exception_ !=
83 ReadOnlyRoots(
this).the_hole_value();
87 void Isolate::clear_scheduled_exception() {
88 DCHECK(!thread_local_top_.scheduled_exception_->IsException(
this));
89 thread_local_top_.scheduled_exception_ = ReadOnlyRoots(
this).the_hole_value();
92 bool Isolate::is_catchable_by_javascript(Object* exception) {
93 return exception != ReadOnlyRoots(heap()).termination_exception();
96 void Isolate::FireBeforeCallEnteredCallback() {
97 for (
auto& callback : before_call_entered_callbacks_) {
98 callback(reinterpret_cast<v8::Isolate*>(
this));
102 void Isolate::FireMicrotasksCompletedCallback() {
103 std::vector<MicrotasksCompletedCallback> callbacks(
104 microtasks_completed_callbacks_);
105 for (
auto& callback : callbacks) {
106 callback(reinterpret_cast<v8::Isolate*>(
this));
110 Handle<JSGlobalObject> Isolate::global_object() {
111 return handle(context()->global_object(),
this);
114 Handle<JSObject> Isolate::global_proxy() {
115 return handle(context()->global_proxy(),
this);
119 Isolate::ExceptionScope::ExceptionScope(Isolate* isolate)
121 pending_exception_(isolate_->pending_exception(), isolate_) {}
124 Isolate::ExceptionScope::~ExceptionScope() {
125 isolate_->set_pending_exception(*pending_exception_);
128 #define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \ 129 Handle<type> Isolate::name() { \ 130 return Handle<type>(raw_native_context()->name(), this); \ 132 bool Isolate::is_##name(type##ArgType value) { \ 133 return raw_native_context()->is_##name(value); \ 135 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
136 #undef NATIVE_CONTEXT_FIELD_ACCESSOR 138 bool Isolate::IsArrayConstructorIntact() {
139 Cell* array_constructor_cell = heap()->array_constructor_protector();
140 return array_constructor_cell->value() == Smi::FromInt(kProtectorValid);
143 bool Isolate::IsArraySpeciesLookupChainIntact() {
156 PropertyCell* species_cell = heap()->array_species_protector();
157 return species_cell->value()->IsSmi() &&
158 Smi::ToInt(species_cell->value()) == kProtectorValid;
161 bool Isolate::IsTypedArraySpeciesLookupChainIntact() {
162 PropertyCell* species_cell = heap()->typed_array_species_protector();
163 return species_cell->value()->IsSmi() &&
164 Smi::ToInt(species_cell->value()) == kProtectorValid;
167 bool Isolate::IsRegExpSpeciesLookupChainIntact() {
168 PropertyCell* species_cell = heap()->regexp_species_protector();
169 return species_cell->value()->IsSmi() &&
170 Smi::ToInt(species_cell->value()) == kProtectorValid;
173 bool Isolate::IsPromiseSpeciesLookupChainIntact() {
174 PropertyCell* species_cell = heap()->promise_species_protector();
175 return species_cell->value()->IsSmi() &&
176 Smi::ToInt(species_cell->value()) == kProtectorValid;
179 bool Isolate::IsStringLengthOverflowIntact() {
180 Cell* string_length_cell = heap()->string_length_protector();
181 return string_length_cell->value() == Smi::FromInt(kProtectorValid);
184 bool Isolate::IsArrayBufferNeuteringIntact() {
185 PropertyCell* buffer_neutering = heap()->array_buffer_neutering_protector();
186 return buffer_neutering->value() == Smi::FromInt(kProtectorValid);
189 bool Isolate::IsArrayIteratorLookupChainIntact() {
190 PropertyCell* array_iterator_cell = heap()->array_iterator_protector();
191 return array_iterator_cell->value() == Smi::FromInt(kProtectorValid);
194 bool Isolate::IsMapIteratorLookupChainIntact() {
195 PropertyCell* map_iterator_cell = heap()->map_iterator_protector();
196 return map_iterator_cell->value() == Smi::FromInt(kProtectorValid);
199 bool Isolate::IsSetIteratorLookupChainIntact() {
200 PropertyCell* set_iterator_cell = heap()->set_iterator_protector();
201 return set_iterator_cell->value() == Smi::FromInt(kProtectorValid);
204 bool Isolate::IsStringIteratorLookupChainIntact() {
205 PropertyCell* string_iterator_cell = heap()->string_iterator_protector();
206 return string_iterator_cell->value() == Smi::FromInt(kProtectorValid);
212 #endif // V8_ISOLATE_INL_H_