OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 Context* Context::global_context() { | 48 Context* Context::global_context() { |
49 // Fast case: the global object for this context has been set. In | 49 // Fast case: the global object for this context has been set. In |
50 // that case, the global object has a direct pointer to the global | 50 // that case, the global object has a direct pointer to the global |
51 // context. | 51 // context. |
52 if (global()->IsGlobalObject()) { | 52 if (global()->IsGlobalObject()) { |
53 return global()->global_context(); | 53 return global()->global_context(); |
54 } | 54 } |
| 55 |
55 // During bootstrapping, the global object might not be set and we | 56 // During bootstrapping, the global object might not be set and we |
56 // have to search the context chain to find the global context. | 57 // have to search the context chain to find the global context. |
| 58 ASSERT(Bootstrapper::IsActive()); |
57 Context* current = this; | 59 Context* current = this; |
58 while (!current->IsGlobalContext()) { | 60 while (!current->IsGlobalContext()) { |
59 current = Context::cast(JSFunction::cast(current->closure())->context()); | 61 JSFunction* closure = JSFunction::cast(current->closure()); |
| 62 current = Context::cast(closure->context()); |
60 } | 63 } |
61 return current; | 64 return current; |
62 } | 65 } |
63 | 66 |
64 | 67 |
65 JSObject* Context::global_proxy() { | 68 JSObject* Context::global_proxy() { |
66 return global_context()->global_proxy_object(); | 69 return global_context()->global_proxy_object(); |
67 } | 70 } |
68 | 71 |
69 void Context::set_global_proxy(JSObject* object) { | 72 void Context::set_global_proxy(JSObject* object) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 247 |
245 | 248 |
246 bool Context::IsBootstrappingOrGlobalObject(Object* object) { | 249 bool Context::IsBootstrappingOrGlobalObject(Object* object) { |
247 // During bootstrapping we allow all objects to pass as global | 250 // During bootstrapping we allow all objects to pass as global |
248 // objects. This is necessary to fix circular dependencies. | 251 // objects. This is necessary to fix circular dependencies. |
249 return Bootstrapper::IsActive() || object->IsGlobalObject(); | 252 return Bootstrapper::IsActive() || object->IsGlobalObject(); |
250 } | 253 } |
251 #endif | 254 #endif |
252 | 255 |
253 } } // namespace v8::internal | 256 } } // namespace v8::internal |
OLD | NEW |