| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 GlobalObject* object = global_object(); | 48 GlobalObject* object = global_object(); |
| 49 if (object->IsJSGlobalObject()) { | 49 if (object->IsJSGlobalObject()) { |
| 50 return JSGlobalObject::cast(object)->builtins(); | 50 return JSGlobalObject::cast(object)->builtins(); |
| 51 } else { | 51 } else { |
| 52 ASSERT(object->IsJSBuiltinsObject()); | 52 ASSERT(object->IsJSBuiltinsObject()); |
| 53 return JSBuiltinsObject::cast(object); | 53 return JSBuiltinsObject::cast(object); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 Context* Context::global_context() { |
| 59 Context* current = this; |
| 60 while (!current->IsGlobalContext()) { |
| 61 current = current->previous(); |
| 62 } |
| 63 return current; |
| 64 } |
| 65 |
| 66 |
| 58 Context* Context::native_context() { | 67 Context* Context::native_context() { |
| 59 // Fast case: the global object for this context has been set. In | 68 // Fast case: the global object for this context has been set. In |
| 60 // that case, the global object has a direct pointer to the global | 69 // that case, the global object has a direct pointer to the global |
| 61 // context. | 70 // context. |
| 62 if (global_object()->IsGlobalObject()) { | 71 if (global_object()->IsGlobalObject()) { |
| 63 return global_object()->native_context(); | 72 return global_object()->native_context(); |
| 64 } | 73 } |
| 65 | 74 |
| 66 // During bootstrapping, the global object might not be set and we | 75 // During bootstrapping, the global object might not be set and we |
| 67 // have to search the context chain to find the native context. | 76 // have to search the context chain to find the native context. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 *attributes = READ_ONLY; | 185 *attributes = READ_ONLY; |
| 177 *binding_flags = (init_flag == kNeedsInitialization) | 186 *binding_flags = (init_flag == kNeedsInitialization) |
| 178 ? IMMUTABLE_CHECK_INITIALIZED : IMMUTABLE_IS_INITIALIZED; | 187 ? IMMUTABLE_CHECK_INITIALIZED : IMMUTABLE_IS_INITIALIZED; |
| 179 break; | 188 break; |
| 180 case CONST_HARMONY: | 189 case CONST_HARMONY: |
| 181 *attributes = READ_ONLY; | 190 *attributes = READ_ONLY; |
| 182 *binding_flags = (init_flag == kNeedsInitialization) | 191 *binding_flags = (init_flag == kNeedsInitialization) |
| 183 ? IMMUTABLE_CHECK_INITIALIZED_HARMONY : | 192 ? IMMUTABLE_CHECK_INITIALIZED_HARMONY : |
| 184 IMMUTABLE_IS_INITIALIZED_HARMONY; | 193 IMMUTABLE_IS_INITIALIZED_HARMONY; |
| 185 break; | 194 break; |
| 195 case MODULE: |
| 196 *attributes = READ_ONLY; |
| 197 *binding_flags = IMMUTABLE_IS_INITIALIZED_HARMONY; |
| 198 break; |
| 186 case DYNAMIC: | 199 case DYNAMIC: |
| 187 case DYNAMIC_GLOBAL: | 200 case DYNAMIC_GLOBAL: |
| 188 case DYNAMIC_LOCAL: | 201 case DYNAMIC_LOCAL: |
| 189 case TEMPORARY: | 202 case TEMPORARY: |
| 190 UNREACHABLE(); | 203 UNREACHABLE(); |
| 191 break; | 204 break; |
| 192 } | 205 } |
| 193 return context; | 206 return context; |
| 194 } | 207 } |
| 195 | 208 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // During bootstrapping we allow all objects to pass as global | 347 // During bootstrapping we allow all objects to pass as global |
| 335 // objects. This is necessary to fix circular dependencies. | 348 // objects. This is necessary to fix circular dependencies. |
| 336 Isolate* isolate = Isolate::Current(); | 349 Isolate* isolate = Isolate::Current(); |
| 337 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 350 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
| 338 isolate->bootstrapper()->IsActive() || | 351 isolate->bootstrapper()->IsActive() || |
| 339 object->IsGlobalObject(); | 352 object->IsGlobalObject(); |
| 340 } | 353 } |
| 341 #endif | 354 #endif |
| 342 | 355 |
| 343 } } // namespace v8::internal | 356 } } // namespace v8::internal |
| OLD | NEW |