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_CONTEXTS_INL_H_ | 5 #ifndef V8_CONTEXTS_INL_H_ |
6 #define V8_CONTEXTS_INL_H_ | 6 #define V8_CONTEXTS_INL_H_ |
7 | 7 |
8 #include "src/contexts.h" | 8 #include "src/contexts.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 | 50 |
51 Context* Context::previous() { | 51 Context* Context::previous() { |
52 Object* result = get(PREVIOUS_INDEX); | 52 Object* result = get(PREVIOUS_INDEX); |
53 DCHECK(IsBootstrappingOrValidParentContext(result, this)); | 53 DCHECK(IsBootstrappingOrValidParentContext(result, this)); |
54 return reinterpret_cast<Context*>(result); | 54 return reinterpret_cast<Context*>(result); |
55 } | 55 } |
56 void Context::set_previous(Context* context) { set(PREVIOUS_INDEX, context); } | 56 void Context::set_previous(Context* context) { set(PREVIOUS_INDEX, context); } |
57 | 57 |
58 | 58 |
59 bool Context::has_extension() { return extension() != nullptr; } | 59 bool Context::has_extension() { return !extension()->IsTheHole(); } |
60 Object* Context::extension() { return get(EXTENSION_INDEX); } | 60 HeapObject* Context::extension() { |
61 void Context::set_extension(Object* object) { set(EXTENSION_INDEX, object); } | 61 return HeapObject::cast(get(EXTENSION_INDEX)); |
| 62 } |
| 63 void Context::set_extension(HeapObject* object) { |
| 64 set(EXTENSION_INDEX, object); |
| 65 } |
62 | 66 |
63 | 67 |
64 JSModule* Context::module() { return JSModule::cast(get(EXTENSION_INDEX)); } | 68 JSModule* Context::module() { return JSModule::cast(get(EXTENSION_INDEX)); } |
65 void Context::set_module(JSModule* module) { set(EXTENSION_INDEX, module); } | 69 void Context::set_module(JSModule* module) { set(EXTENSION_INDEX, module); } |
66 | 70 |
67 | 71 |
68 Context* Context::native_context() { | 72 Context* Context::native_context() { |
69 Object* result = get(NATIVE_CONTEXT_INDEX); | 73 Object* result = get(NATIVE_CONTEXT_INDEX); |
70 DCHECK(IsBootstrappingOrNativeContext(this->GetIsolate(), result)); | 74 DCHECK(IsBootstrappingOrNativeContext(this->GetIsolate(), result)); |
71 return reinterpret_cast<Context*>(result); | 75 return reinterpret_cast<Context*>(result); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 return type::cast(get(index)); \ | 143 return type::cast(get(index)); \ |
140 } | 144 } |
141 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS) | 145 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS) |
142 #undef NATIVE_CONTEXT_FIELD_ACCESSORS | 146 #undef NATIVE_CONTEXT_FIELD_ACCESSORS |
143 | 147 |
144 | 148 |
145 } // namespace internal | 149 } // namespace internal |
146 } // namespace v8 | 150 } // namespace v8 |
147 | 151 |
148 #endif // V8_CONTEXTS_INL_H_ | 152 #endif // V8_CONTEXTS_INL_H_ |
OLD | NEW |