OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4856 if (templ->constructor()->IsUndefined()) { | 4856 if (templ->constructor()->IsUndefined()) { |
4857 Local<FunctionTemplate> constructor = FunctionTemplate::New(); | 4857 Local<FunctionTemplate> constructor = FunctionTemplate::New(); |
4858 Utils::OpenHandle(*constructor)->set_instance_template(*templ); | 4858 Utils::OpenHandle(*constructor)->set_instance_template(*templ); |
4859 templ->set_constructor(*Utils::OpenHandle(*constructor)); | 4859 templ->set_constructor(*Utils::OpenHandle(*constructor)); |
4860 } | 4860 } |
4861 return i::Handle<i::FunctionTemplateInfo>( | 4861 return i::Handle<i::FunctionTemplateInfo>( |
4862 i::FunctionTemplateInfo::cast(templ->constructor())); | 4862 i::FunctionTemplateInfo::cast(templ->constructor())); |
4863 } | 4863 } |
4864 | 4864 |
4865 | 4865 |
4866 Persistent<Context> v8::Context::New( | 4866 static i::Handle<i::Context> CreateEnvironment( |
| 4867 i::Isolate* isolate, |
4867 v8::ExtensionConfiguration* extensions, | 4868 v8::ExtensionConfiguration* extensions, |
4868 v8::Handle<ObjectTemplate> global_template, | 4869 v8::Handle<ObjectTemplate> global_template, |
4869 v8::Handle<Value> global_object) { | 4870 v8::Handle<Value> global_object) { |
4870 i::Isolate::EnsureDefaultIsolate(); | 4871 i::Handle<i::Context> env; |
4871 i::Isolate* isolate = i::Isolate::Current(); | |
4872 EnsureInitializedForIsolate(isolate, "v8::Context::New()"); | |
4873 LOG_API(isolate, "Context::New"); | |
4874 ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>()); | |
4875 | 4872 |
4876 // Enter V8 via an ENTER_V8 scope. | 4873 // Enter V8 via an ENTER_V8 scope. |
4877 i::Handle<i::Context> env; | |
4878 { | 4874 { |
4879 ENTER_V8(isolate); | 4875 ENTER_V8(isolate); |
4880 v8::Handle<ObjectTemplate> proxy_template = global_template; | 4876 v8::Handle<ObjectTemplate> proxy_template = global_template; |
4881 i::Handle<i::FunctionTemplateInfo> proxy_constructor; | 4877 i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
4882 i::Handle<i::FunctionTemplateInfo> global_constructor; | 4878 i::Handle<i::FunctionTemplateInfo> global_constructor; |
4883 | 4879 |
4884 if (!global_template.IsEmpty()) { | 4880 if (!global_template.IsEmpty()) { |
4885 // Make sure that the global_template has a constructor. | 4881 // Make sure that the global_template has a constructor. |
4886 global_constructor = | 4882 global_constructor = |
4887 EnsureConstructor(Utils::OpenHandle(*global_template)); | 4883 EnsureConstructor(Utils::OpenHandle(*global_template)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4922 ASSERT(!proxy_constructor.is_null()); | 4918 ASSERT(!proxy_constructor.is_null()); |
4923 global_constructor->set_access_check_info( | 4919 global_constructor->set_access_check_info( |
4924 proxy_constructor->access_check_info()); | 4920 proxy_constructor->access_check_info()); |
4925 global_constructor->set_needs_access_check( | 4921 global_constructor->set_needs_access_check( |
4926 proxy_constructor->needs_access_check()); | 4922 proxy_constructor->needs_access_check()); |
4927 } | 4923 } |
4928 isolate->runtime_profiler()->Reset(); | 4924 isolate->runtime_profiler()->Reset(); |
4929 } | 4925 } |
4930 // Leave V8. | 4926 // Leave V8. |
4931 | 4927 |
4932 if (env.is_null()) { | 4928 return env; |
4933 return Persistent<Context>(); | |
4934 } | |
4935 return Persistent<Context>(Utils::ToLocal(env)); | |
4936 } | 4929 } |
4937 | 4930 |
4938 | 4931 |
| 4932 Persistent<Context> v8::Context::New( |
| 4933 v8::ExtensionConfiguration* extensions, |
| 4934 v8::Handle<ObjectTemplate> global_template, |
| 4935 v8::Handle<Value> global_object) { |
| 4936 i::Isolate::EnsureDefaultIsolate(); |
| 4937 i::Isolate* isolate = i::Isolate::Current(); |
| 4938 Isolate* external_isolate = reinterpret_cast<Isolate*>(isolate); |
| 4939 EnsureInitializedForIsolate(isolate, "v8::Context::New()"); |
| 4940 LOG_API(isolate, "Context::New"); |
| 4941 ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>()); |
| 4942 i::HandleScope scope(isolate); |
| 4943 i::Handle<i::Context> env = |
| 4944 CreateEnvironment(isolate, extensions, global_template, global_object); |
| 4945 if (env.is_null()) return Persistent<Context>(); |
| 4946 return Persistent<Context>::New(external_isolate, Utils::ToLocal(env)); |
| 4947 } |
| 4948 |
| 4949 |
| 4950 Local<Context> v8::Context::New( |
| 4951 v8::Isolate* external_isolate, |
| 4952 v8::ExtensionConfiguration* extensions, |
| 4953 v8::Handle<ObjectTemplate> global_template, |
| 4954 v8::Handle<Value> global_object) { |
| 4955 i::Isolate::EnsureDefaultIsolate(); |
| 4956 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
| 4957 EnsureInitializedForIsolate(isolate, "v8::Context::New()"); |
| 4958 LOG_API(isolate, "Context::New"); |
| 4959 ON_BAILOUT(isolate, "v8::Context::New()", return Local<Context>()); |
| 4960 i::HandleScope scope(isolate); |
| 4961 i::Handle<i::Context> env = |
| 4962 CreateEnvironment(isolate, extensions, global_template, global_object); |
| 4963 if (env.is_null()) return Local<Context>(); |
| 4964 return Utils::ToLocal(scope.CloseAndEscape(env)); |
| 4965 } |
| 4966 |
| 4967 |
4939 void v8::Context::SetSecurityToken(Handle<Value> token) { | 4968 void v8::Context::SetSecurityToken(Handle<Value> token) { |
4940 i::Isolate* isolate = i::Isolate::Current(); | 4969 i::Isolate* isolate = i::Isolate::Current(); |
4941 if (IsDeadCheck(isolate, "v8::Context::SetSecurityToken()")) { | 4970 if (IsDeadCheck(isolate, "v8::Context::SetSecurityToken()")) { |
4942 return; | 4971 return; |
4943 } | 4972 } |
4944 ENTER_V8(isolate); | 4973 ENTER_V8(isolate); |
4945 i::Handle<i::Context> env = Utils::OpenHandle(this); | 4974 i::Handle<i::Context> env = Utils::OpenHandle(this); |
4946 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); | 4975 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); |
4947 env->set_security_token(*token_handle); | 4976 env->set_security_token(*token_handle); |
4948 } | 4977 } |
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7225 | 7254 |
7226 v->VisitPointers(blocks_.first(), first_block_limit_); | 7255 v->VisitPointers(blocks_.first(), first_block_limit_); |
7227 | 7256 |
7228 for (int i = 1; i < blocks_.length(); i++) { | 7257 for (int i = 1; i < blocks_.length(); i++) { |
7229 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7258 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
7230 } | 7259 } |
7231 } | 7260 } |
7232 | 7261 |
7233 | 7262 |
7234 } } // namespace v8::internal | 7263 } } // namespace v8::internal |
OLD | NEW |