| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef V8_ISOLATE_INL_H_ | 5 #ifndef V8_ISOLATE_INL_H_ |
| 6 #define V8_ISOLATE_INL_H_ | 6 #define V8_ISOLATE_INL_H_ |
| 7 | 7 |
| 8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 | 14 |
| 15 void Isolate::set_context(Context* context) { | 15 void Isolate::set_context(Context* context) { |
| 16 DCHECK(context == NULL || context->IsContext()); | 16 DCHECK(context == NULL || context->IsContext()); |
| 17 thread_local_top_.context_ = context; | 17 thread_local_top_.context_ = context; |
| 18 } | 18 } |
| 19 | 19 |
| 20 Handle<Context> Isolate::native_context() { |
| 21 return handle(context()->native_context(), this); |
| 22 } |
| 23 |
| 24 Context* Isolate::raw_native_context() { return context()->native_context(); } |
| 20 | 25 |
| 21 Object* Isolate::pending_exception() { | 26 Object* Isolate::pending_exception() { |
| 22 DCHECK(has_pending_exception()); | 27 DCHECK(has_pending_exception()); |
| 23 DCHECK(!thread_local_top_.pending_exception_->IsException(this)); | 28 DCHECK(!thread_local_top_.pending_exception_->IsException(this)); |
| 24 return thread_local_top_.pending_exception_; | 29 return thread_local_top_.pending_exception_; |
| 25 } | 30 } |
| 26 | 31 |
| 27 | 32 |
| 28 void Isolate::set_pending_exception(Object* exception_obj) { | 33 void Isolate::set_pending_exception(Object* exception_obj) { |
| 29 DCHECK(!exception_obj->IsException(this)); | 34 DCHECK(!exception_obj->IsException(this)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 void Isolate::clear_scheduled_exception() { | 69 void Isolate::clear_scheduled_exception() { |
| 65 DCHECK(!thread_local_top_.scheduled_exception_->IsException(this)); | 70 DCHECK(!thread_local_top_.scheduled_exception_->IsException(this)); |
| 66 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); | 71 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); |
| 67 } | 72 } |
| 68 | 73 |
| 69 | 74 |
| 70 bool Isolate::is_catchable_by_javascript(Object* exception) { | 75 bool Isolate::is_catchable_by_javascript(Object* exception) { |
| 71 return exception != heap()->termination_exception(); | 76 return exception != heap()->termination_exception(); |
| 72 } | 77 } |
| 73 | 78 |
| 79 void Isolate::FireBeforeCallEnteredCallback() { |
| 80 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) { |
| 81 before_call_entered_callbacks_.at(i)(reinterpret_cast<v8::Isolate*>(this)); |
| 82 } |
| 83 } |
| 74 | 84 |
| 75 Handle<JSGlobalObject> Isolate::global_object() { | 85 Handle<JSGlobalObject> Isolate::global_object() { |
| 76 return handle(context()->global_object(), this); | 86 return handle(context()->global_object(), this); |
| 77 } | 87 } |
| 78 | 88 |
| 79 Handle<JSObject> Isolate::global_proxy() { | 89 Handle<JSObject> Isolate::global_proxy() { |
| 80 return handle(context()->global_proxy(), this); | 90 return handle(context()->global_proxy(), this); |
| 81 } | 91 } |
| 82 | 92 |
| 83 | 93 |
| 84 Isolate::ExceptionScope::ExceptionScope(Isolate* isolate) | 94 Isolate::ExceptionScope::ExceptionScope(Isolate* isolate) |
| 85 : isolate_(isolate), | 95 : isolate_(isolate), |
| 86 pending_exception_(isolate_->pending_exception(), isolate_) {} | 96 pending_exception_(isolate_->pending_exception(), isolate_) {} |
| 87 | 97 |
| 88 | 98 |
| 89 Isolate::ExceptionScope::~ExceptionScope() { | 99 Isolate::ExceptionScope::~ExceptionScope() { |
| 90 isolate_->set_pending_exception(*pending_exception_); | 100 isolate_->set_pending_exception(*pending_exception_); |
| 91 } | 101 } |
| 92 | 102 |
| 93 | 103 #define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \ |
| 94 #define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \ | 104 Handle<type> Isolate::name() { \ |
| 95 Handle<type> Isolate::name() { \ | 105 return Handle<type>(raw_native_context()->name(), this); \ |
| 96 return Handle<type>(native_context()->name(), this); \ | 106 } \ |
| 97 } \ | 107 bool Isolate::is_##name(type* value) { \ |
| 98 bool Isolate::is_##name(type* value) { \ | 108 return raw_native_context()->is_##name(value); \ |
| 99 return native_context()->is_##name(value); \ | |
| 100 } | 109 } |
| 101 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR) | 110 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR) |
| 102 #undef NATIVE_CONTEXT_FIELD_ACCESSOR | 111 #undef NATIVE_CONTEXT_FIELD_ACCESSOR |
| 103 | 112 |
| 104 bool Isolate::IsArraySpeciesLookupChainIntact() { | 113 bool Isolate::IsArraySpeciesLookupChainIntact() { |
| 105 // Note: It would be nice to have debug checks to make sure that the | 114 // Note: It would be nice to have debug checks to make sure that the |
| 106 // species protector is accurate, but this would be hard to do for most of | 115 // species protector is accurate, but this would be hard to do for most of |
| 107 // what the protector stands for: | 116 // what the protector stands for: |
| 108 // - You'd need to traverse the heap to check that no Array instance has | 117 // - You'd need to traverse the heap to check that no Array instance has |
| 109 // a constructor property | 118 // a constructor property |
| (...skipping 11 matching lines...) Expand all Loading... |
| 121 | 130 |
| 122 bool Isolate::IsHasInstanceLookupChainIntact() { | 131 bool Isolate::IsHasInstanceLookupChainIntact() { |
| 123 PropertyCell* has_instance_cell = heap()->has_instance_protector(); | 132 PropertyCell* has_instance_cell = heap()->has_instance_protector(); |
| 124 return has_instance_cell->value() == Smi::FromInt(kArrayProtectorValid); | 133 return has_instance_cell->value() == Smi::FromInt(kArrayProtectorValid); |
| 125 } | 134 } |
| 126 | 135 |
| 127 } // namespace internal | 136 } // namespace internal |
| 128 } // namespace v8 | 137 } // namespace v8 |
| 129 | 138 |
| 130 #endif // V8_ISOLATE_INL_H_ | 139 #endif // V8_ISOLATE_INL_H_ |
| OLD | NEW |