OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 bool V8::IsGlobalWeak(void** obj) { | 369 bool V8::IsGlobalWeak(void** obj) { |
370 LOG_API("IsGlobalWeak"); | 370 LOG_API("IsGlobalWeak"); |
371 if (has_shut_down) return false; | 371 if (has_shut_down) return false; |
372 return i::GlobalHandles::IsWeak(reinterpret_cast<i::Object**>(obj)); | 372 return i::GlobalHandles::IsWeak(reinterpret_cast<i::Object**>(obj)); |
373 } | 373 } |
374 | 374 |
375 | 375 |
376 void V8::DisposeGlobal(void** obj) { | 376 void V8::DisposeGlobal(void** obj) { |
377 LOG_API("DisposeGlobal"); | 377 LOG_API("DisposeGlobal"); |
378 if (has_shut_down) return; | 378 if (has_shut_down) return; |
379 i::GlobalHandles::Destroy(reinterpret_cast<i::Object**>(obj)); | 379 i::Object** ptr = reinterpret_cast<i::Object**>(obj); |
| 380 if ((*ptr)->IsGlobalContext()) i::Heap::NotifyContextDisposed(); |
| 381 i::GlobalHandles::Destroy(ptr); |
380 } | 382 } |
381 | 383 |
382 // --- H a n d l e s --- | 384 // --- H a n d l e s --- |
383 | 385 |
384 | 386 |
385 HandleScope::HandleScope() : is_closed_(false) { | 387 HandleScope::HandleScope() : is_closed_(false) { |
386 API_ENTRY_CHECK("HandleScope::HandleScope"); | 388 API_ENTRY_CHECK("HandleScope::HandleScope"); |
387 i::HandleScope::Enter(&previous_); | 389 i::HandleScope::Enter(&previous_); |
388 } | 390 } |
389 | 391 |
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 | 2202 |
2201 | 2203 |
2202 Persistent<Context> v8::Context::New( | 2204 Persistent<Context> v8::Context::New( |
2203 v8::ExtensionConfiguration* extensions, | 2205 v8::ExtensionConfiguration* extensions, |
2204 v8::Handle<ObjectTemplate> global_template, | 2206 v8::Handle<ObjectTemplate> global_template, |
2205 v8::Handle<Value> global_object) { | 2207 v8::Handle<Value> global_object) { |
2206 EnsureInitialized("v8::Context::New()"); | 2208 EnsureInitialized("v8::Context::New()"); |
2207 LOG_API("Context::New"); | 2209 LOG_API("Context::New"); |
2208 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); | 2210 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); |
2209 | 2211 |
| 2212 // Give the heap a chance to cleanup if we've disposed contexts. |
| 2213 i::Heap::CollectAllGarbageIfContextDisposed(); |
| 2214 |
2210 v8::Handle<ObjectTemplate> proxy_template = global_template; | 2215 v8::Handle<ObjectTemplate> proxy_template = global_template; |
2211 i::Handle<i::FunctionTemplateInfo> proxy_constructor; | 2216 i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
2212 i::Handle<i::FunctionTemplateInfo> global_constructor; | 2217 i::Handle<i::FunctionTemplateInfo> global_constructor; |
2213 | 2218 |
2214 if (!global_template.IsEmpty()) { | 2219 if (!global_template.IsEmpty()) { |
2215 // Make sure that the global_template has a constructor. | 2220 // Make sure that the global_template has a constructor. |
2216 global_constructor = EnsureConstructor(Utils::OpenHandle(*global_template)); | 2221 global_constructor = EnsureConstructor(Utils::OpenHandle(*global_template)); |
2217 | 2222 |
2218 // Create a fresh template for the global proxy object. | 2223 // Create a fresh template for the global proxy object. |
2219 proxy_template = ObjectTemplate::New(); | 2224 proxy_template = ObjectTemplate::New(); |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 reinterpret_cast<HandleScopeImplementer*>(storage); | 3035 reinterpret_cast<HandleScopeImplementer*>(storage); |
3031 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3036 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
3032 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3037 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
3033 &thread_local->handle_scope_data_; | 3038 &thread_local->handle_scope_data_; |
3034 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3039 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
3035 | 3040 |
3036 return storage + ArchiveSpacePerThread(); | 3041 return storage + ArchiveSpacePerThread(); |
3037 } | 3042 } |
3038 | 3043 |
3039 } } // namespace v8::internal | 3044 } } // namespace v8::internal |
OLD | NEW |