| 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 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 if (i::Snapshot::Initialize()) { | 2196 if (i::Snapshot::Initialize()) { |
| 2197 i::Serializer::disable(); | 2197 i::Serializer::disable(); |
| 2198 return true; | 2198 return true; |
| 2199 } else { | 2199 } else { |
| 2200 return i::V8::Initialize(NULL); | 2200 return i::V8::Initialize(NULL); |
| 2201 } | 2201 } |
| 2202 } | 2202 } |
| 2203 | 2203 |
| 2204 | 2204 |
| 2205 const char* v8::V8::GetVersion() { | 2205 const char* v8::V8::GetVersion() { |
| 2206 return "0.4.6 (candidate)"; | 2206 return "0.4.7 (candidate)"; |
| 2207 } | 2207 } |
| 2208 | 2208 |
| 2209 | 2209 |
| 2210 static i::Handle<i::FunctionTemplateInfo> | 2210 static i::Handle<i::FunctionTemplateInfo> |
| 2211 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) { | 2211 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) { |
| 2212 if (templ->constructor()->IsUndefined()) { | 2212 if (templ->constructor()->IsUndefined()) { |
| 2213 Local<FunctionTemplate> constructor = FunctionTemplate::New(); | 2213 Local<FunctionTemplate> constructor = FunctionTemplate::New(); |
| 2214 Utils::OpenHandle(*constructor)->set_instance_template(*templ); | 2214 Utils::OpenHandle(*constructor)->set_instance_template(*templ); |
| 2215 templ->set_constructor(*Utils::OpenHandle(*constructor)); | 2215 templ->set_constructor(*Utils::OpenHandle(*constructor)); |
| 2216 } | 2216 } |
| 2217 return i::Handle<i::FunctionTemplateInfo>( | 2217 return i::Handle<i::FunctionTemplateInfo>( |
| 2218 i::FunctionTemplateInfo::cast(templ->constructor())); | 2218 i::FunctionTemplateInfo::cast(templ->constructor())); |
| 2219 } | 2219 } |
| 2220 | 2220 |
| 2221 | 2221 |
| 2222 Persistent<Context> v8::Context::New( | 2222 Persistent<Context> v8::Context::New( |
| 2223 v8::ExtensionConfiguration* extensions, | 2223 v8::ExtensionConfiguration* extensions, |
| 2224 v8::Handle<ObjectTemplate> global_template, | 2224 v8::Handle<ObjectTemplate> global_template, |
| 2225 v8::Handle<Value> global_object) { | 2225 v8::Handle<Value> global_object) { |
| 2226 EnsureInitialized("v8::Context::New()"); | 2226 EnsureInitialized("v8::Context::New()"); |
| 2227 LOG_API("Context::New"); | 2227 LOG_API("Context::New"); |
| 2228 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); | 2228 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); |
| 2229 | 2229 |
| 2230 // Make sure that the global_template has a constructor. | 2230 v8::Handle<ObjectTemplate> proxy_template = global_template; |
| 2231 i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
| 2232 i::Handle<i::FunctionTemplateInfo> global_constructor; |
| 2233 |
| 2231 if (!global_template.IsEmpty()) { | 2234 if (!global_template.IsEmpty()) { |
| 2232 i::Handle<i::FunctionTemplateInfo> constructor = | 2235 // Make sure that the global_template has a constructor. |
| 2233 EnsureConstructor(Utils::OpenHandle(*global_template)); | 2236 global_constructor = EnsureConstructor(Utils::OpenHandle(*global_template)); |
| 2234 | 2237 |
| 2235 // Create a fresh template for global proxy object. | 2238 // Create a fresh template for the global proxy object. |
| 2236 Local<ObjectTemplate> proxy_template = ObjectTemplate::New(); | 2239 proxy_template = ObjectTemplate::New(); |
| 2240 proxy_constructor = EnsureConstructor(Utils::OpenHandle(*proxy_template)); |
| 2237 | 2241 |
| 2238 i::Handle<i::FunctionTemplateInfo> proxy_constructor = | 2242 // Set the global template to be the prototype template of global |
| 2239 EnsureConstructor(Utils::OpenHandle(*proxy_template)); | 2243 // proxy template. |
| 2240 | |
| 2241 // Set the global template to be the prototype template | |
| 2242 // of global proxy template. | |
| 2243 proxy_constructor->set_prototype_template( | 2244 proxy_constructor->set_prototype_template( |
| 2244 *Utils::OpenHandle(*global_template)); | 2245 *Utils::OpenHandle(*global_template)); |
| 2245 | 2246 |
| 2246 // Migrate security handlers from global_template to proxy_template. | 2247 // Migrate security handlers from global_template to |
| 2247 if (!constructor->access_check_info()->IsUndefined()) { | 2248 // proxy_template. Temporarily removing access check information |
| 2248 proxy_constructor->set_access_check_info( | 2249 // from the global template. |
| 2249 constructor->access_check_info()); | 2250 if (!global_constructor->access_check_info()->IsUndefined()) { |
| 2250 proxy_constructor->set_needs_access_check(true); | 2251 proxy_constructor->set_access_check_info( |
| 2251 | 2252 global_constructor->access_check_info()); |
| 2252 // Remove access check info from global_template. | 2253 proxy_constructor->set_needs_access_check( |
| 2253 constructor->set_needs_access_check(false); | 2254 global_constructor->needs_access_check()); |
| 2254 constructor->set_access_check_info(i::Heap::undefined_value()); | 2255 global_constructor->set_needs_access_check(false); |
| 2256 global_constructor->set_access_check_info(i::Heap::undefined_value()); |
| 2255 } | 2257 } |
| 2256 | |
| 2257 global_template = proxy_template; | |
| 2258 } | 2258 } |
| 2259 | 2259 |
| 2260 // Create the environment. |
| 2260 i::Handle<i::Context> env = i::Bootstrapper::CreateEnvironment( | 2261 i::Handle<i::Context> env = i::Bootstrapper::CreateEnvironment( |
| 2261 Utils::OpenHandle(*global_object), | 2262 Utils::OpenHandle(*global_object), |
| 2262 global_template, extensions); | 2263 proxy_template, |
| 2264 extensions); |
| 2265 |
| 2266 // Restore the access check info on the global template. |
| 2267 if (!global_template.IsEmpty()) { |
| 2268 ASSERT(!global_constructor.is_null()); |
| 2269 ASSERT(!proxy_constructor.is_null()); |
| 2270 global_constructor->set_access_check_info( |
| 2271 proxy_constructor->access_check_info()); |
| 2272 global_constructor->set_needs_access_check( |
| 2273 proxy_constructor->needs_access_check()); |
| 2274 } |
| 2275 |
| 2263 if (!ApiCheck(!env.is_null(), | 2276 if (!ApiCheck(!env.is_null(), |
| 2264 "v8::Context::New()", | 2277 "v8::Context::New()", |
| 2265 "Could not initialize environment")) | 2278 "Could not initialize environment")) |
| 2266 return Persistent<Context>(); | 2279 return Persistent<Context>(); |
| 2267 return Persistent<Context>(Utils::ToLocal(env)); | 2280 return Persistent<Context>(Utils::ToLocal(env)); |
| 2268 } | 2281 } |
| 2269 | 2282 |
| 2270 | 2283 |
| 2271 void v8::Context::SetSecurityToken(Handle<Value> token) { | 2284 void v8::Context::SetSecurityToken(Handle<Value> token) { |
| 2272 if (IsDeadCheck("v8::Context::SetSecurityToken()")) return; | 2285 if (IsDeadCheck("v8::Context::SetSecurityToken()")) return; |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 } | 2634 } |
| 2622 | 2635 |
| 2623 | 2636 |
| 2624 void V8::SetFailedAccessCheckCallbackFunction( | 2637 void V8::SetFailedAccessCheckCallbackFunction( |
| 2625 FailedAccessCheckCallback callback) { | 2638 FailedAccessCheckCallback callback) { |
| 2626 if (IsDeadCheck("v8::V8::SetFailedAccessCheckCallbackFunction()")) return; | 2639 if (IsDeadCheck("v8::V8::SetFailedAccessCheckCallbackFunction()")) return; |
| 2627 i::Top::SetFailedAccessCheckCallback(callback); | 2640 i::Top::SetFailedAccessCheckCallback(callback); |
| 2628 } | 2641 } |
| 2629 | 2642 |
| 2630 | 2643 |
| 2631 void V8::AddObjectToGroup(void* group_id, Persistent<Object> obj) { | 2644 void V8::AddObjectGroup(Persistent<Value>* objects, size_t length) { |
| 2632 if (IsDeadCheck("v8::V8::AddObjectToGroup()")) return; | 2645 if (IsDeadCheck("v8::V8::AddObjectGroup()")) return; |
| 2633 i::GlobalHandles::AddToGroup(group_id, reinterpret_cast<i::Object**>(*obj)); | 2646 STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**)); |
| 2647 i::GlobalHandles::AddGroup(reinterpret_cast<i::Object***>(objects), length); |
| 2634 } | 2648 } |
| 2635 | 2649 |
| 2636 | 2650 |
| 2637 int V8::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) { | 2651 int V8::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) { |
| 2638 if (IsDeadCheck("v8::V8::AdjustAmountOfExternalAllocatedMemory()")) return 0; | 2652 if (IsDeadCheck("v8::V8::AdjustAmountOfExternalAllocatedMemory()")) return 0; |
| 2639 return i::Heap::AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 2653 return i::Heap::AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
| 2640 } | 2654 } |
| 2641 | 2655 |
| 2642 | 2656 |
| 2643 void V8::SetGlobalGCPrologueCallback(GCCallback callback) { | 2657 void V8::SetGlobalGCPrologueCallback(GCCallback callback) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 reinterpret_cast<HandleScopeImplementer*>(storage); | 3010 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 2997 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3011 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
| 2998 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3012 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
| 2999 &thread_local->handle_scope_data_; | 3013 &thread_local->handle_scope_data_; |
| 3000 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3014 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
| 3001 | 3015 |
| 3002 return storage + ArchiveSpacePerThread(); | 3016 return storage + ArchiveSpacePerThread(); |
| 3003 } | 3017 } |
| 3004 | 3018 |
| 3005 } } // namespace v8::internal | 3019 } } // namespace v8::internal |
| OLD | NEW |