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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 Context* Context::native_context() { | 67 Context* Context::native_context() { |
68 // 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 |
69 // 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 |
70 // context. | 70 // context. |
71 if (global_object()->IsGlobalObject()) { | 71 if (global_object()->IsGlobalObject()) { |
72 return global_object()->native_context(); | 72 return global_object()->native_context(); |
73 } | 73 } |
74 | 74 |
75 // During bootstrapping, the global object might not be set and we | 75 // During bootstrapping, the global object might not be set and we |
76 // have to search the context chain to find the native context. | 76 // have to search the context chain to find the native context. |
77 ASSERT(Isolate::Current()->bootstrapper()->IsActive()); | 77 ASSERT(this->GetIsolate()->bootstrapper()->IsActive()); |
78 Context* current = this; | 78 Context* current = this; |
79 while (!current->IsNativeContext()) { | 79 while (!current->IsNativeContext()) { |
80 JSFunction* closure = JSFunction::cast(current->closure()); | 80 JSFunction* closure = JSFunction::cast(current->closure()); |
81 current = Context::cast(closure->context()); | 81 current = Context::cast(closure->context()); |
82 } | 82 } |
83 return current; | 83 return current; |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 JSObject* Context::global_proxy() { | 87 JSObject* Context::global_proxy() { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // During bootstrapping we allow all objects to pass as | 345 // During bootstrapping we allow all objects to pass as |
346 // contexts. This is necessary to fix circular dependencies. | 346 // contexts. This is necessary to fix circular dependencies. |
347 if (child->GetIsolate()->bootstrapper()->IsActive()) return true; | 347 if (child->GetIsolate()->bootstrapper()->IsActive()) return true; |
348 if (!object->IsContext()) return false; | 348 if (!object->IsContext()) return false; |
349 Context* context = Context::cast(object); | 349 Context* context = Context::cast(object); |
350 return context->IsNativeContext() || context->IsGlobalContext() || | 350 return context->IsNativeContext() || context->IsGlobalContext() || |
351 context->IsModuleContext() || !child->IsModuleContext(); | 351 context->IsModuleContext() || !child->IsModuleContext(); |
352 } | 352 } |
353 | 353 |
354 | 354 |
355 bool Context::IsBootstrappingOrGlobalObject(Object* object) { | 355 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { |
356 // During bootstrapping we allow all objects to pass as global | 356 // During bootstrapping we allow all objects to pass as global |
357 // objects. This is necessary to fix circular dependencies. | 357 // objects. This is necessary to fix circular dependencies. |
358 Isolate* isolate = Isolate::Current(); | |
359 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 358 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
360 isolate->bootstrapper()->IsActive() || | 359 isolate->bootstrapper()->IsActive() || |
361 object->IsGlobalObject(); | 360 object->IsGlobalObject(); |
362 } | 361 } |
363 #endif | 362 #endif |
364 | 363 |
365 } } // namespace v8::internal | 364 } } // namespace v8::internal |
OLD | NEW |