| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 | 406 |
| 407 | 407 |
| 408 void Context::Enter() { | 408 void Context::Enter() { |
| 409 if (IsDeadCheck("v8::Context::Enter()")) return; | 409 if (IsDeadCheck("v8::Context::Enter()")) return; |
| 410 i::Handle<i::Context> env = Utils::OpenHandle(this); | 410 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 411 thread_local.EnterContext(env); | 411 thread_local.EnterContext(env); |
| 412 | 412 |
| 413 thread_local.SaveContext(i::GlobalHandles::Create(i::Top::context())); | 413 thread_local.SaveContext(i::GlobalHandles::Create(i::Top::context())); |
| 414 i::Top::set_context(*env); | 414 i::Top::set_context(*env); |
| 415 | |
| 416 thread_local.SaveSecurityContext( | |
| 417 i::GlobalHandles::Create(i::Top::security_context())); | |
| 418 i::Top::set_security_context(*env); | |
| 419 } | 415 } |
| 420 | 416 |
| 421 | 417 |
| 422 void Context::Exit() { | 418 void Context::Exit() { |
| 423 if (has_shut_down) return; | 419 if (has_shut_down) return; |
| 424 if (!ApiCheck(thread_local.LeaveLastContext(), | 420 if (!ApiCheck(thread_local.LeaveLastContext(), |
| 425 "v8::Context::Exit()", | 421 "v8::Context::Exit()", |
| 426 "Cannot exit non-entered context")) { | 422 "Cannot exit non-entered context")) { |
| 427 return; | 423 return; |
| 428 } | 424 } |
| 429 | 425 |
| 430 // Content of 'last_context' and 'last_security_context' could be NULL. | 426 // Content of 'last_context' could be NULL. |
| 431 i::Handle<i::Object> last_context = thread_local.RestoreContext(); | 427 i::Handle<i::Object> last_context = thread_local.RestoreContext(); |
| 432 i::Top::set_context(static_cast<i::Context*>(*last_context)); | 428 i::Top::set_context(static_cast<i::Context*>(*last_context)); |
| 433 i::GlobalHandles::Destroy(last_context.location()); | 429 i::GlobalHandles::Destroy(last_context.location()); |
| 434 | |
| 435 i::Handle<i::Object> last_security_context = | |
| 436 thread_local.RestoreSecurityContext(); | |
| 437 i::Top::set_security_context( | |
| 438 static_cast<i::Context*>(*last_security_context)); | |
| 439 i::GlobalHandles::Destroy(last_security_context.location()); | |
| 440 } | 430 } |
| 441 | 431 |
| 442 | 432 |
| 443 void v8::HandleScope::DeleteExtensions() { | 433 void v8::HandleScope::DeleteExtensions() { |
| 444 ASSERT(current_.extensions != 0); | 434 ASSERT(current_.extensions != 0); |
| 445 thread_local.DeleteExtensions(current_.extensions); | 435 thread_local.DeleteExtensions(current_.extensions); |
| 446 } | 436 } |
| 447 | 437 |
| 448 | 438 |
| 449 void HandleScope::ZapRange(void** start, void** end) { | 439 void HandleScope::ZapRange(void** start, void** end) { |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 i::FunctionTemplateInfo* constructor = | 891 i::FunctionTemplateInfo* constructor = |
| 902 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 892 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
| 903 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 893 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 904 cons->set_undetectable(true); | 894 cons->set_undetectable(true); |
| 905 } | 895 } |
| 906 | 896 |
| 907 | 897 |
| 908 void ObjectTemplate::SetAccessCheckCallbacks( | 898 void ObjectTemplate::SetAccessCheckCallbacks( |
| 909 NamedSecurityCallback named_callback, | 899 NamedSecurityCallback named_callback, |
| 910 IndexedSecurityCallback indexed_callback, | 900 IndexedSecurityCallback indexed_callback, |
| 911 Handle<Value> data) { | 901 Handle<Value> data, |
| 902 bool turned_on_by_default) { |
| 912 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return; | 903 if (IsDeadCheck("v8::ObjectTemplate::SetAccessCheckCallbacks()")) return; |
| 913 HandleScope scope; | 904 HandleScope scope; |
| 914 EnsureConstructor(this); | 905 EnsureConstructor(this); |
| 915 | 906 |
| 916 i::Handle<i::Struct> struct_info = | 907 i::Handle<i::Struct> struct_info = |
| 917 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 908 i::Factory::NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
| 918 i::Handle<i::AccessCheckInfo> info = | 909 i::Handle<i::AccessCheckInfo> info = |
| 919 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 910 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
| 920 info->set_named_callback(*FromCData(named_callback)); | 911 info->set_named_callback(*FromCData(named_callback)); |
| 921 info->set_indexed_callback(*FromCData(indexed_callback)); | 912 info->set_indexed_callback(*FromCData(indexed_callback)); |
| 922 if (data.IsEmpty()) data = v8::Undefined(); | 913 if (data.IsEmpty()) data = v8::Undefined(); |
| 923 info->set_data(*Utils::OpenHandle(*data)); | 914 info->set_data(*Utils::OpenHandle(*data)); |
| 924 | 915 |
| 925 i::FunctionTemplateInfo* constructor = | 916 i::FunctionTemplateInfo* constructor = |
| 926 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 917 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
| 927 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 918 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 928 cons->set_needs_access_check(true); | |
| 929 cons->set_access_check_info(*info); | 919 cons->set_access_check_info(*info); |
| 920 cons->set_needs_access_check(turned_on_by_default); |
| 930 } | 921 } |
| 931 | 922 |
| 932 | 923 |
| 933 void ObjectTemplate::SetIndexedPropertyHandler( | 924 void ObjectTemplate::SetIndexedPropertyHandler( |
| 934 IndexedPropertyGetter getter, | 925 IndexedPropertyGetter getter, |
| 935 IndexedPropertySetter setter, | 926 IndexedPropertySetter setter, |
| 936 IndexedPropertyQuery query, | 927 IndexedPropertyQuery query, |
| 937 IndexedPropertyDeleter remover, | 928 IndexedPropertyDeleter remover, |
| 938 IndexedPropertyEnumerator enumerator, | 929 IndexedPropertyEnumerator enumerator, |
| 939 Handle<Value> data) { | 930 Handle<Value> data) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 | 1048 |
| 1058 | 1049 |
| 1059 Local<Value> Script::Run() { | 1050 Local<Value> Script::Run() { |
| 1060 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); | 1051 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); |
| 1061 LOG_API("Script::Run"); | 1052 LOG_API("Script::Run"); |
| 1062 i::Object* raw_result = NULL; | 1053 i::Object* raw_result = NULL; |
| 1063 { | 1054 { |
| 1064 HandleScope scope; | 1055 HandleScope scope; |
| 1065 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 1056 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
| 1066 EXCEPTION_PREAMBLE(); | 1057 EXCEPTION_PREAMBLE(); |
| 1067 i::Handle<i::Object> global(i::Top::context()->global()); | 1058 i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); |
| 1068 i::Handle<i::Object> result = | 1059 i::Handle<i::Object> result = |
| 1069 i::Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 1060 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
| 1070 EXCEPTION_BAILOUT_CHECK(Local<Value>()); | 1061 EXCEPTION_BAILOUT_CHECK(Local<Value>()); |
| 1071 raw_result = *result; | 1062 raw_result = *result; |
| 1072 } | 1063 } |
| 1073 i::Handle<i::Object> result(raw_result); | 1064 i::Handle<i::Object> result(raw_result); |
| 1074 return Utils::ToLocal(result); | 1065 return Utils::ToLocal(result); |
| 1075 } | 1066 } |
| 1076 | 1067 |
| 1077 | 1068 |
| 1078 // --- E x c e p t i o n s --- | 1069 // --- E x c e p t i o n s --- |
| 1079 | 1070 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 if (num->IsSmi()) { | 1748 if (num->IsSmi()) { |
| 1758 return i::Smi::cast(*num)->value(); | 1749 return i::Smi::cast(*num)->value(); |
| 1759 } else { | 1750 } else { |
| 1760 return static_cast<uint32_t>(num->Number()); | 1751 return static_cast<uint32_t>(num->Number()); |
| 1761 } | 1752 } |
| 1762 } | 1753 } |
| 1763 } | 1754 } |
| 1764 | 1755 |
| 1765 | 1756 |
| 1766 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, | 1757 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, |
| 1767 v8::PropertyAttribute attribs) { | 1758 v8::PropertyAttribute attribs) { |
| 1768 ON_BAILOUT("v8::Object::Set()", return false); | 1759 ON_BAILOUT("v8::Object::Set()", return false); |
| 1769 i::Handle<i::Object> self = Utils::OpenHandle(this); | 1760 i::Handle<i::Object> self = Utils::OpenHandle(this); |
| 1770 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 1761 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
| 1771 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 1762 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 1772 EXCEPTION_PREAMBLE(); | 1763 EXCEPTION_PREAMBLE(); |
| 1773 i::Handle<i::Object> obj = i::SetProperty( | 1764 i::Handle<i::Object> obj = i::SetProperty( |
| 1774 self, | 1765 self, |
| 1775 key_obj, | 1766 key_obj, |
| 1776 value_obj, | 1767 value_obj, |
| 1777 static_cast<PropertyAttributes>(attribs)); | 1768 static_cast<PropertyAttributes>(attribs)); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, | 1921 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, |
| 1931 &lookup, | 1922 &lookup, |
| 1932 *key_obj, | 1923 *key_obj, |
| 1933 &attributes)); | 1924 &attributes)); |
| 1934 return Utils::ToLocal(result); | 1925 return Utils::ToLocal(result); |
| 1935 } | 1926 } |
| 1936 return Local<Value>(); // No real property was found in prototype chain. | 1927 return Local<Value>(); // No real property was found in prototype chain. |
| 1937 } | 1928 } |
| 1938 | 1929 |
| 1939 | 1930 |
| 1931 // Turns on access checks by copying the map and setting the check flag. |
| 1932 // Because the object gets a new map, existing inline cache caching |
| 1933 // the old map of this object will fail. |
| 1934 void v8::Object::TurnOnAccessCheck() { |
| 1935 ON_BAILOUT("v8::Object::TurnOnAccessCheck()", return); |
| 1936 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 1937 |
| 1938 i::Handle<i::Map> new_map = |
| 1939 i::Factory::CopyMapDropTransitions(i::Handle<i::Map>(obj->map())); |
| 1940 new_map->set_is_access_check_needed(); |
| 1941 obj->set_map(*new_map); |
| 1942 } |
| 1943 |
| 1944 |
| 1940 Local<v8::Object> Function::NewInstance() { | 1945 Local<v8::Object> Function::NewInstance() { |
| 1941 return NewInstance(0, NULL); | 1946 return NewInstance(0, NULL); |
| 1942 } | 1947 } |
| 1943 | 1948 |
| 1944 | 1949 |
| 1945 Local<v8::Object> Function::NewInstance(int argc, | 1950 Local<v8::Object> Function::NewInstance(int argc, |
| 1946 v8::Handle<v8::Value> argv[]) { | 1951 v8::Handle<v8::Value> argv[]) { |
| 1947 ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>()); | 1952 ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>()); |
| 1948 LOG_API("Function::NewInstance"); | 1953 LOG_API("Function::NewInstance"); |
| 1949 HandleScope scope; | 1954 HandleScope scope; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 return i::V8::Initialize(NULL); | 2218 return i::V8::Initialize(NULL); |
| 2214 } | 2219 } |
| 2215 } | 2220 } |
| 2216 | 2221 |
| 2217 | 2222 |
| 2218 const char* v8::V8::GetVersion() { | 2223 const char* v8::V8::GetVersion() { |
| 2219 return "0.4.0 (internal)"; | 2224 return "0.4.0 (internal)"; |
| 2220 } | 2225 } |
| 2221 | 2226 |
| 2222 | 2227 |
| 2223 Persistent<Context> v8::Context::New(v8::ExtensionConfiguration* extensions, | 2228 static i::Handle<i::FunctionTemplateInfo> |
| 2224 v8::Handle<ObjectTemplate> global_template, | 2229 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) { |
| 2225 v8::Handle<Value> global_object) { | 2230 if (templ->constructor()->IsUndefined()) { |
| 2231 Local<FunctionTemplate> constructor = FunctionTemplate::New(); |
| 2232 Utils::OpenHandle(*constructor)->set_instance_template(*templ); |
| 2233 templ->set_constructor(*Utils::OpenHandle(*constructor)); |
| 2234 } |
| 2235 return i::Handle<i::FunctionTemplateInfo>( |
| 2236 i::FunctionTemplateInfo::cast(templ->constructor())); |
| 2237 } |
| 2238 |
| 2239 |
| 2240 Persistent<Context> v8::Context::New( |
| 2241 v8::ExtensionConfiguration* extensions, |
| 2242 v8::Handle<ObjectTemplate> global_template, |
| 2243 v8::Handle<Value> global_object) { |
| 2226 EnsureInitialized("v8::Context::New()"); | 2244 EnsureInitialized("v8::Context::New()"); |
| 2227 LOG_API("Context::New"); | 2245 LOG_API("Context::New"); |
| 2228 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); | 2246 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); |
| 2247 |
| 2229 // Make sure that the global_template has a constructor. | 2248 // Make sure that the global_template has a constructor. |
| 2230 if (!global_template.IsEmpty() && | 2249 if (!global_template.IsEmpty()) { |
| 2231 Utils::OpenHandle(*global_template)->constructor()->IsUndefined()) { | 2250 i::Handle<i::FunctionTemplateInfo> constructor = |
| 2232 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 2251 EnsureConstructor(Utils::OpenHandle(*global_template)); |
| 2233 Utils::OpenHandle(*templ)->set_instance_template( | 2252 |
| 2253 // Create a fresh template for outer global object. |
| 2254 Local<ObjectTemplate> outer_template = ObjectTemplate::New(); |
| 2255 |
| 2256 i::Handle<i::FunctionTemplateInfo> outer_constructor = |
| 2257 EnsureConstructor(Utils::OpenHandle(*outer_template)); |
| 2258 |
| 2259 // Set the global template to be the prototype template |
| 2260 // of outer global template. |
| 2261 outer_constructor->set_prototype_template( |
| 2234 *Utils::OpenHandle(*global_template)); | 2262 *Utils::OpenHandle(*global_template)); |
| 2235 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); | 2263 |
| 2236 Utils::OpenHandle(*global_template)->set_constructor(*constructor); | 2264 // Migrate security handlers from global_template to outer_template. |
| 2265 if (!constructor->access_check_info()->IsUndefined()) { |
| 2266 outer_constructor->set_access_check_info( |
| 2267 constructor->access_check_info()); |
| 2268 outer_constructor->set_needs_access_check(true); |
| 2269 |
| 2270 // Remove access check info from global_template. |
| 2271 constructor->set_needs_access_check(false); |
| 2272 constructor->set_access_check_info(i::Heap::undefined_value()); |
| 2273 } |
| 2274 |
| 2275 global_template = outer_template; |
| 2237 } | 2276 } |
| 2238 | 2277 |
| 2239 i::Handle<i::Context> env = i::Bootstrapper::CreateEnvironment( | 2278 i::Handle<i::Context> env = i::Bootstrapper::CreateEnvironment( |
| 2240 Utils::OpenHandle(*global_object), | 2279 Utils::OpenHandle(*global_object), |
| 2241 global_template, extensions); | 2280 global_template, extensions); |
| 2242 if (!ApiCheck(!env.is_null(), | 2281 if (!ApiCheck(!env.is_null(), |
| 2243 "v8::Context::New()", | 2282 "v8::Context::New()", |
| 2244 "Could not initialize environment")) | 2283 "Could not initialize environment")) |
| 2245 return Persistent<Context>(); | 2284 return Persistent<Context>(); |
| 2246 return Persistent<Context>(Utils::ToLocal(env)); | 2285 return Persistent<Context>(Utils::ToLocal(env)); |
| 2247 } | 2286 } |
| 2248 | 2287 |
| 2249 | 2288 |
| 2250 void v8::Context::SetSecurityToken(Handle<Value> token) { | 2289 void v8::Context::SetSecurityToken(Handle<Value> token) { |
| 2290 if (IsDeadCheck("v8::Context::SetSecurityToken()")) return; |
| 2251 i::Handle<i::Context> env = Utils::OpenHandle(this); | 2291 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 2252 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); | 2292 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); |
| 2253 // The global object of an environment is always a real global | 2293 env->set_security_token(*token_handle); |
| 2254 // object with security token and reference to the builtins object. | 2294 } |
| 2255 i::JSGlobalObject::cast(env->global())->set_security_token(*token_handle); | 2295 |
| 2296 |
| 2297 void v8::Context::UseDefaultSecurityToken() { |
| 2298 if (IsDeadCheck("v8::Context::UseDefaultSecurityToken()")) return; |
| 2299 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 2300 // The default security token of an environment is the inner global object |
| 2301 // of the environment. The security tokens of outer and inner global objects |
| 2302 // are always the same. |
| 2303 env->set_security_token(env->global()); |
| 2256 } | 2304 } |
| 2257 | 2305 |
| 2258 | 2306 |
| 2259 Handle<Value> v8::Context::GetSecurityToken() { | 2307 Handle<Value> v8::Context::GetSecurityToken() { |
| 2308 if (IsDeadCheck("v8::Context::GetSecurityToken()")) return Handle<Value>(); |
| 2260 i::Handle<i::Context> env = Utils::OpenHandle(this); | 2309 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 2261 i::Object* security_token = | 2310 i::Object* security_token = env->security_token(); |
| 2262 i::JSGlobalObject::cast(env->global())->security_token(); | |
| 2263 i::Handle<i::Object> token_handle(security_token); | 2311 i::Handle<i::Object> token_handle(security_token); |
| 2264 return Utils::ToLocal(token_handle); | 2312 return Utils::ToLocal(token_handle); |
| 2265 } | 2313 } |
| 2266 | 2314 |
| 2267 | 2315 |
| 2268 bool Context::HasOutOfMemoryException() { | 2316 bool Context::HasOutOfMemoryException() { |
| 2269 i::Handle<i::Context> env = Utils::OpenHandle(this); | 2317 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 2270 return env->has_out_of_memory(); | 2318 return env->has_out_of_memory(); |
| 2271 } | 2319 } |
| 2272 | 2320 |
| 2273 | 2321 |
| 2274 bool Context::InContext() { | 2322 bool Context::InContext() { |
| 2275 return i::Top::context() != NULL; | 2323 return i::Top::context() != NULL; |
| 2276 } | 2324 } |
| 2277 | 2325 |
| 2278 | 2326 |
| 2279 bool Context::InSecurityContext() { | |
| 2280 return i::Top::security_context() != NULL; | |
| 2281 } | |
| 2282 | |
| 2283 | |
| 2284 v8::Local<v8::Context> Context::GetEntered() { | 2327 v8::Local<v8::Context> Context::GetEntered() { |
| 2285 if (IsDeadCheck("v8::Context::GetEntered()")) return Local<Context>(); | 2328 if (IsDeadCheck("v8::Context::GetEntered()")) return Local<Context>(); |
| 2286 i::Handle<i::Object> last = thread_local.LastEnteredContext(); | 2329 i::Handle<i::Object> last = thread_local.LastEnteredContext(); |
| 2287 if (last.is_null()) return Local<Context>(); | 2330 if (last.is_null()) return Local<Context>(); |
| 2288 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); | 2331 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); |
| 2289 return Utils::ToLocal(context); | 2332 return Utils::ToLocal(context); |
| 2290 } | 2333 } |
| 2291 | 2334 |
| 2292 | 2335 |
| 2293 v8::Local<v8::Context> Context::GetCurrent() { | 2336 v8::Local<v8::Context> Context::GetCurrent() { |
| 2294 if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>(); | 2337 if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>(); |
| 2295 i::Handle<i::Context> context(i::Top::global_context()); | 2338 i::Handle<i::Context> context(i::Top::global_context()); |
| 2296 return Utils::ToLocal(context); | 2339 return Utils::ToLocal(context); |
| 2297 } | 2340 } |
| 2298 | 2341 |
| 2299 | 2342 |
| 2300 v8::Local<v8::Context> Context::GetCurrentSecurityContext() { | |
| 2301 if (IsDeadCheck("v8::Context::GetCurrentSecurityContext()")) { | |
| 2302 return Local<Context>(); | |
| 2303 } | |
| 2304 i::Handle<i::Context> context(i::Top::security_context()); | |
| 2305 return Utils::ToLocal(context); | |
| 2306 } | |
| 2307 | |
| 2308 | |
| 2309 v8::Local<v8::Object> Context::Global() { | 2343 v8::Local<v8::Object> Context::Global() { |
| 2310 if (IsDeadCheck("v8::Context::Global()")) return Local<v8::Object>(); | 2344 if (IsDeadCheck("v8::Context::Global()")) return Local<v8::Object>(); |
| 2311 i::Object** ctx = reinterpret_cast<i::Object**>(this); | 2345 i::Object** ctx = reinterpret_cast<i::Object**>(this); |
| 2312 i::Handle<i::Context> context = | 2346 i::Handle<i::Context> context = |
| 2313 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); | 2347 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); |
| 2314 i::Handle<i::JSObject> global(context->global()); | 2348 i::Handle<i::Object> global(context->global_proxy()); |
| 2315 return Utils::ToLocal(global); | 2349 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); |
| 2316 } | 2350 } |
| 2317 | 2351 |
| 2318 | 2352 |
| 2353 void Context::DetachGlobal() { |
| 2354 if (IsDeadCheck("v8::Context::DetachGlobal()")) return; |
| 2355 i::Object** ctx = reinterpret_cast<i::Object**>(this); |
| 2356 i::Handle<i::Context> context = |
| 2357 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); |
| 2358 i::Bootstrapper::DetachGlobal(context); |
| 2359 } |
| 2360 |
| 2361 |
| 2319 Local<v8::Object> ObjectTemplate::NewInstance() { | 2362 Local<v8::Object> ObjectTemplate::NewInstance() { |
| 2320 ON_BAILOUT("v8::ObjectTemplate::NewInstance()", return Local<v8::Object>()); | 2363 ON_BAILOUT("v8::ObjectTemplate::NewInstance()", return Local<v8::Object>()); |
| 2321 LOG_API("ObjectTemplate::NewInstance"); | 2364 LOG_API("ObjectTemplate::NewInstance"); |
| 2322 EXCEPTION_PREAMBLE(); | 2365 EXCEPTION_PREAMBLE(); |
| 2323 i::Handle<i::Object> obj = | 2366 i::Handle<i::Object> obj = |
| 2324 i::Execution::InstantiateObject(Utils::OpenHandle(this), | 2367 i::Execution::InstantiateObject(Utils::OpenHandle(this), |
| 2325 &has_pending_exception); | 2368 &has_pending_exception); |
| 2326 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); | 2369 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); |
| 2327 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj)); | 2370 return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj)); |
| 2328 } | 2371 } |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2926 reinterpret_cast<HandleScopeImplementer*>(storage); | 2969 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 2927 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 2970 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
| 2928 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 2971 ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
| 2929 &thread_local->handle_scope_data_; | 2972 &thread_local->handle_scope_data_; |
| 2930 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 2973 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
| 2931 | 2974 |
| 2932 return storage + ArchiveSpacePerThread(); | 2975 return storage + ArchiveSpacePerThread(); |
| 2933 } | 2976 } |
| 2934 | 2977 |
| 2935 } } // namespace v8::internal | 2978 } } // namespace v8::internal |
| OLD | NEW |