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 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2996 reinterpret_cast<HandleScopeImplementer*>(storage); | 3009 reinterpret_cast<HandleScopeImplementer*>(storage); |
2997 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3010 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
2998 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3011 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
2999 &thread_local->handle_scope_data_; | 3012 &thread_local->handle_scope_data_; |
3000 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3013 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
3001 | 3014 |
3002 return storage + ArchiveSpacePerThread(); | 3015 return storage + ArchiveSpacePerThread(); |
3003 } | 3016 } |
3004 | 3017 |
3005 } } // namespace v8::internal | 3018 } } // namespace v8::internal |
OLD | NEW |