OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 bool V8::IsGlobalWeak(i::Object** obj) { | 431 bool V8::IsGlobalWeak(i::Object** obj) { |
432 LOG_API("IsGlobalWeak"); | 432 LOG_API("IsGlobalWeak"); |
433 if (!i::V8::IsRunning()) return false; | 433 if (!i::V8::IsRunning()) return false; |
434 return i::GlobalHandles::IsWeak(obj); | 434 return i::GlobalHandles::IsWeak(obj); |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 void V8::DisposeGlobal(i::Object** obj) { | 438 void V8::DisposeGlobal(i::Object** obj) { |
439 LOG_API("DisposeGlobal"); | 439 LOG_API("DisposeGlobal"); |
440 if (!i::V8::IsRunning()) return; | 440 if (!i::V8::IsRunning()) return; |
| 441 if ((*obj)->IsGlobalContext()) i::Heap::NotifyContextDisposedDeprecated(); |
441 i::GlobalHandles::Destroy(obj); | 442 i::GlobalHandles::Destroy(obj); |
442 } | 443 } |
443 | 444 |
444 // --- H a n d l e s --- | 445 // --- H a n d l e s --- |
445 | 446 |
446 | 447 |
447 HandleScope::HandleScope() : is_closed_(false) { | 448 HandleScope::HandleScope() : is_closed_(false) { |
448 API_ENTRY_CHECK("HandleScope::HandleScope"); | 449 API_ENTRY_CHECK("HandleScope::HandleScope"); |
449 i::HandleScope::Enter(&previous_); | 450 i::HandleScope::Enter(&previous_); |
450 } | 451 } |
(...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2850 v8::Handle<ObjectTemplate> global_template, | 2851 v8::Handle<ObjectTemplate> global_template, |
2851 v8::Handle<Value> global_object) { | 2852 v8::Handle<Value> global_object) { |
2852 EnsureInitialized("v8::Context::New()"); | 2853 EnsureInitialized("v8::Context::New()"); |
2853 LOG_API("Context::New"); | 2854 LOG_API("Context::New"); |
2854 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); | 2855 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); |
2855 | 2856 |
2856 // Enter V8 via an ENTER_V8 scope. | 2857 // Enter V8 via an ENTER_V8 scope. |
2857 i::Handle<i::Context> env; | 2858 i::Handle<i::Context> env; |
2858 { | 2859 { |
2859 ENTER_V8; | 2860 ENTER_V8; |
| 2861 #if defined(ANDROID) |
| 2862 // On mobile device, full GC is expensive, leave it to the system to |
| 2863 // decide when should make a full GC. |
| 2864 #else |
| 2865 // Give the heap a chance to cleanup if we've disposed contexts. |
| 2866 i::Heap::CollectAllGarbageIfContextDisposedDeprecated(); |
| 2867 #endif |
2860 v8::Handle<ObjectTemplate> proxy_template = global_template; | 2868 v8::Handle<ObjectTemplate> proxy_template = global_template; |
2861 i::Handle<i::FunctionTemplateInfo> proxy_constructor; | 2869 i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
2862 i::Handle<i::FunctionTemplateInfo> global_constructor; | 2870 i::Handle<i::FunctionTemplateInfo> global_constructor; |
2863 | 2871 |
2864 if (!global_template.IsEmpty()) { | 2872 if (!global_template.IsEmpty()) { |
2865 // Make sure that the global_template has a constructor. | 2873 // Make sure that the global_template has a constructor. |
2866 global_constructor = | 2874 global_constructor = |
2867 EnsureConstructor(Utils::OpenHandle(*global_template)); | 2875 EnsureConstructor(Utils::OpenHandle(*global_template)); |
2868 | 2876 |
2869 // Create a fresh template for the global proxy object. | 2877 // Create a fresh template for the global proxy object. |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3552 } | 3560 } |
3553 } | 3561 } |
3554 | 3562 |
3555 | 3563 |
3556 void V8::TerminateExecution() { | 3564 void V8::TerminateExecution() { |
3557 if (!i::V8::IsRunning()) return; | 3565 if (!i::V8::IsRunning()) return; |
3558 i::StackGuard::TerminateExecution(); | 3566 i::StackGuard::TerminateExecution(); |
3559 } | 3567 } |
3560 | 3568 |
3561 | 3569 |
3562 bool V8::IsExecutionTerminating() { | |
3563 if (!i::V8::IsRunning()) return false; | |
3564 if (i::Top::has_scheduled_exception()) { | |
3565 return i::Top::scheduled_exception() == i::Heap::termination_exception(); | |
3566 } | |
3567 return false; | |
3568 } | |
3569 | |
3570 | |
3571 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { | 3570 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { |
3572 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); | 3571 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); |
3573 if (obj.IsEmpty()) { | 3572 if (obj.IsEmpty()) { |
3574 str_ = NULL; | 3573 str_ = NULL; |
3575 length_ = 0; | 3574 length_ = 0; |
3576 return; | 3575 return; |
3577 } | 3576 } |
3578 ENTER_V8; | 3577 ENTER_V8; |
3579 HandleScope scope; | 3578 HandleScope scope; |
3580 TryCatch try_catch; | 3579 TryCatch try_catch; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3945 | 3944 |
3946 | 3945 |
3947 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 3946 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
3948 HandleScopeImplementer* thread_local = | 3947 HandleScopeImplementer* thread_local = |
3949 reinterpret_cast<HandleScopeImplementer*>(storage); | 3948 reinterpret_cast<HandleScopeImplementer*>(storage); |
3950 thread_local->IterateThis(v); | 3949 thread_local->IterateThis(v); |
3951 return storage + ArchiveSpacePerThread(); | 3950 return storage + ArchiveSpacePerThread(); |
3952 } | 3951 } |
3953 | 3952 |
3954 } } // namespace v8::internal | 3953 } } // namespace v8::internal |
OLD | NEW |