| 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 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2168 obj->SetInternalField(index, *val); | 2170 obj->SetInternalField(index, *val); |
| 2169 } | 2171 } |
| 2170 | 2172 |
| 2171 | 2173 |
| 2172 // --- E n v i r o n m e n t --- | 2174 // --- E n v i r o n m e n t --- |
| 2173 | 2175 |
| 2174 bool v8::V8::Initialize() { | 2176 bool v8::V8::Initialize() { |
| 2175 if (i::V8::HasBeenSetup()) return true; | 2177 if (i::V8::HasBeenSetup()) return true; |
| 2176 HandleScope scope; | 2178 HandleScope scope; |
| 2177 if (i::Snapshot::Initialize()) { | 2179 if (i::Snapshot::Initialize()) { |
| 2178 i::Serializer::disable(); | |
| 2179 return true; | 2180 return true; |
| 2180 } else { | 2181 } else { |
| 2181 return i::V8::Initialize(NULL); | 2182 return i::V8::Initialize(NULL); |
| 2182 } | 2183 } |
| 2183 } | 2184 } |
| 2184 | 2185 |
| 2185 | 2186 |
| 2186 const char* v8::V8::GetVersion() { | 2187 const char* v8::V8::GetVersion() { |
| 2187 return "1.0.2 (candidate)"; | 2188 return "1.0.3 (candidate)"; |
| 2188 } | 2189 } |
| 2189 | 2190 |
| 2190 | 2191 |
| 2191 static i::Handle<i::FunctionTemplateInfo> | 2192 static i::Handle<i::FunctionTemplateInfo> |
| 2192 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) { | 2193 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) { |
| 2193 if (templ->constructor()->IsUndefined()) { | 2194 if (templ->constructor()->IsUndefined()) { |
| 2194 Local<FunctionTemplate> constructor = FunctionTemplate::New(); | 2195 Local<FunctionTemplate> constructor = FunctionTemplate::New(); |
| 2195 Utils::OpenHandle(*constructor)->set_instance_template(*templ); | 2196 Utils::OpenHandle(*constructor)->set_instance_template(*templ); |
| 2196 templ->set_constructor(*Utils::OpenHandle(*constructor)); | 2197 templ->set_constructor(*Utils::OpenHandle(*constructor)); |
| 2197 } | 2198 } |
| 2198 return i::Handle<i::FunctionTemplateInfo>( | 2199 return i::Handle<i::FunctionTemplateInfo>( |
| 2199 i::FunctionTemplateInfo::cast(templ->constructor())); | 2200 i::FunctionTemplateInfo::cast(templ->constructor())); |
| 2200 } | 2201 } |
| 2201 | 2202 |
| 2202 | 2203 |
| 2203 Persistent<Context> v8::Context::New( | 2204 Persistent<Context> v8::Context::New( |
| 2204 v8::ExtensionConfiguration* extensions, | 2205 v8::ExtensionConfiguration* extensions, |
| 2205 v8::Handle<ObjectTemplate> global_template, | 2206 v8::Handle<ObjectTemplate> global_template, |
| 2206 v8::Handle<Value> global_object) { | 2207 v8::Handle<Value> global_object) { |
| 2207 EnsureInitialized("v8::Context::New()"); | 2208 EnsureInitialized("v8::Context::New()"); |
| 2208 LOG_API("Context::New"); | 2209 LOG_API("Context::New"); |
| 2209 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); | 2210 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); |
| 2210 | 2211 |
| 2212 // Give the heap a chance to cleanup if we've disposed contexts. |
| 2213 i::Heap::CollectAllGarbageIfContextDisposed(); |
| 2214 |
| 2211 v8::Handle<ObjectTemplate> proxy_template = global_template; | 2215 v8::Handle<ObjectTemplate> proxy_template = global_template; |
| 2212 i::Handle<i::FunctionTemplateInfo> proxy_constructor; | 2216 i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
| 2213 i::Handle<i::FunctionTemplateInfo> global_constructor; | 2217 i::Handle<i::FunctionTemplateInfo> global_constructor; |
| 2214 | 2218 |
| 2215 if (!global_template.IsEmpty()) { | 2219 if (!global_template.IsEmpty()) { |
| 2216 // Make sure that the global_template has a constructor. | 2220 // Make sure that the global_template has a constructor. |
| 2217 global_constructor = EnsureConstructor(Utils::OpenHandle(*global_template)); | 2221 global_constructor = EnsureConstructor(Utils::OpenHandle(*global_template)); |
| 2218 | 2222 |
| 2219 // Create a fresh template for the global proxy object. | 2223 // Create a fresh template for the global proxy object. |
| 2220 proxy_template = ObjectTemplate::New(); | 2224 proxy_template = ObjectTemplate::New(); |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3031 reinterpret_cast<HandleScopeImplementer*>(storage); | 3035 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 3032 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3036 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
| 3033 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3037 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
| 3034 &thread_local->handle_scope_data_; | 3038 &thread_local->handle_scope_data_; |
| 3035 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3039 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
| 3036 | 3040 |
| 3037 return storage + ArchiveSpacePerThread(); | 3041 return storage + ArchiveSpacePerThread(); |
| 3038 } | 3042 } |
| 3039 | 3043 |
| 3040 } } // namespace v8::internal | 3044 } } // namespace v8::internal |
| OLD | NEW |