Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: src/bootstrapper.cc

Issue 1224623004: Make v8::Handle as "deprecated soon" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/bootstrapper.h ('k') | src/builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void Bootstrapper::TearDown() { 141 void Bootstrapper::TearDown() {
142 DeleteNativeSources(isolate_->heap()->natives_source_cache()); 142 DeleteNativeSources(isolate_->heap()->natives_source_cache());
143 DeleteNativeSources(isolate_->heap()->experimental_natives_source_cache()); 143 DeleteNativeSources(isolate_->heap()->experimental_natives_source_cache());
144 DeleteNativeSources(isolate_->heap()->extra_natives_source_cache()); 144 DeleteNativeSources(isolate_->heap()->extra_natives_source_cache());
145 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical 145 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical
146 } 146 }
147 147
148 148
149 class Genesis BASE_EMBEDDED { 149 class Genesis BASE_EMBEDDED {
150 public: 150 public:
151 Genesis(Isolate* isolate, 151 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
152 MaybeHandle<JSGlobalProxy> maybe_global_proxy, 152 v8::Local<v8::ObjectTemplate> global_proxy_template,
153 v8::Handle<v8::ObjectTemplate> global_proxy_template,
154 v8::ExtensionConfiguration* extensions); 153 v8::ExtensionConfiguration* extensions);
155 ~Genesis() { } 154 ~Genesis() { }
156 155
157 Isolate* isolate() const { return isolate_; } 156 Isolate* isolate() const { return isolate_; }
158 Factory* factory() const { return isolate_->factory(); } 157 Factory* factory() const { return isolate_->factory(); }
159 Heap* heap() const { return isolate_->heap(); } 158 Heap* heap() const { return isolate_->heap(); }
160 159
161 Handle<Context> result() { return result_; } 160 Handle<Context> result() { return result_; }
162 161
163 private: 162 private:
(...skipping 14 matching lines...) Expand all
178 // Make the "arguments" and "caller" properties throw a TypeError on access. 177 // Make the "arguments" and "caller" properties throw a TypeError on access.
179 void AddRestrictedFunctionProperties(Handle<Map> map); 178 void AddRestrictedFunctionProperties(Handle<Map> map);
180 179
181 // Creates the global objects using the global proxy and the template passed 180 // Creates the global objects using the global proxy and the template passed
182 // in through the API. We call this regardless of whether we are building a 181 // in through the API. We call this regardless of whether we are building a
183 // context from scratch or using a deserialized one from the partial snapshot 182 // context from scratch or using a deserialized one from the partial snapshot
184 // but in the latter case we don't use the objects it produces directly, as 183 // but in the latter case we don't use the objects it produces directly, as
185 // we have to used the deserialized ones that are linked together with the 184 // we have to used the deserialized ones that are linked together with the
186 // rest of the context snapshot. 185 // rest of the context snapshot.
187 Handle<GlobalObject> CreateNewGlobals( 186 Handle<GlobalObject> CreateNewGlobals(
188 v8::Handle<v8::ObjectTemplate> global_proxy_template, 187 v8::Local<v8::ObjectTemplate> global_proxy_template,
189 Handle<JSGlobalProxy> global_proxy); 188 Handle<JSGlobalProxy> global_proxy);
190 // Hooks the given global proxy into the context. If the context was created 189 // Hooks the given global proxy into the context. If the context was created
191 // by deserialization then this will unhook the global proxy that was 190 // by deserialization then this will unhook the global proxy that was
192 // deserialized, leaving the GC to pick it up. 191 // deserialized, leaving the GC to pick it up.
193 void HookUpGlobalProxy(Handle<GlobalObject> global_object, 192 void HookUpGlobalProxy(Handle<GlobalObject> global_object,
194 Handle<JSGlobalProxy> global_proxy); 193 Handle<JSGlobalProxy> global_proxy);
195 // Similarly, we want to use the global that has been created by the templates 194 // Similarly, we want to use the global that has been created by the templates
196 // passed through the API. The global from the snapshot is detached from the 195 // passed through the API. The global from the snapshot is detached from the
197 // other objects in the snapshot. 196 // other objects in the snapshot.
198 void HookUpGlobalObject(Handle<GlobalObject> global_object, 197 void HookUpGlobalObject(Handle<GlobalObject> global_object,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 const char* name, 266 const char* name,
268 ExtensionStates* extension_states); 267 ExtensionStates* extension_states);
269 static bool InstallExtension(Isolate* isolate, 268 static bool InstallExtension(Isolate* isolate,
270 v8::RegisteredExtension* current, 269 v8::RegisteredExtension* current,
271 ExtensionStates* extension_states); 270 ExtensionStates* extension_states);
272 static bool InstallSpecialObjects(Handle<Context> native_context); 271 static bool InstallSpecialObjects(Handle<Context> native_context);
273 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins); 272 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
274 bool ConfigureApiObject(Handle<JSObject> object, 273 bool ConfigureApiObject(Handle<JSObject> object,
275 Handle<ObjectTemplateInfo> object_template); 274 Handle<ObjectTemplateInfo> object_template);
276 bool ConfigureGlobalObjects( 275 bool ConfigureGlobalObjects(
277 v8::Handle<v8::ObjectTemplate> global_proxy_template); 276 v8::Local<v8::ObjectTemplate> global_proxy_template);
278 277
279 // Migrates all properties from the 'from' object to the 'to' 278 // Migrates all properties from the 'from' object to the 'to'
280 // object and overrides the prototype in 'to' with the one from 279 // object and overrides the prototype in 'to' with the one from
281 // 'from'. 280 // 'from'.
282 void TransferObject(Handle<JSObject> from, Handle<JSObject> to); 281 void TransferObject(Handle<JSObject> from, Handle<JSObject> to);
283 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to); 282 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to);
284 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to); 283 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
285 284
286 enum FunctionMode { 285 enum FunctionMode {
287 // With prototype. 286 // With prototype.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 342
344 343
345 void Bootstrapper::Iterate(ObjectVisitor* v) { 344 void Bootstrapper::Iterate(ObjectVisitor* v) {
346 extensions_cache_.Iterate(v); 345 extensions_cache_.Iterate(v);
347 v->Synchronize(VisitorSynchronization::kExtensions); 346 v->Synchronize(VisitorSynchronization::kExtensions);
348 } 347 }
349 348
350 349
351 Handle<Context> Bootstrapper::CreateEnvironment( 350 Handle<Context> Bootstrapper::CreateEnvironment(
352 MaybeHandle<JSGlobalProxy> maybe_global_proxy, 351 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
353 v8::Handle<v8::ObjectTemplate> global_proxy_template, 352 v8::Local<v8::ObjectTemplate> global_proxy_template,
354 v8::ExtensionConfiguration* extensions) { 353 v8::ExtensionConfiguration* extensions) {
355 HandleScope scope(isolate_); 354 HandleScope scope(isolate_);
356 Genesis genesis( 355 Genesis genesis(
357 isolate_, maybe_global_proxy, global_proxy_template, extensions); 356 isolate_, maybe_global_proxy, global_proxy_template, extensions);
358 Handle<Context> env = genesis.result(); 357 Handle<Context> env = genesis.result();
359 if (env.is_null() || !InstallExtensions(env, extensions)) { 358 if (env.is_null() || !InstallExtensions(env, extensions)) {
360 return Handle<Context>(); 359 return Handle<Context>();
361 } 360 }
362 return scope.CloseAndEscape(env); 361 return scope.CloseAndEscape(env);
363 } 362 }
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 if (slot >= 0) { 847 if (slot >= 0) {
849 DCHECK_EQ(slot, Context::MIN_CONTEXT_SLOTS); 848 DCHECK_EQ(slot, Context::MIN_CONTEXT_SLOTS);
850 context->set(slot, native_context()->global_proxy()); 849 context->set(slot, native_context()->global_proxy());
851 } 850 }
852 } 851 }
853 } 852 }
854 } 853 }
855 854
856 855
857 Handle<GlobalObject> Genesis::CreateNewGlobals( 856 Handle<GlobalObject> Genesis::CreateNewGlobals(
858 v8::Handle<v8::ObjectTemplate> global_proxy_template, 857 v8::Local<v8::ObjectTemplate> global_proxy_template,
859 Handle<JSGlobalProxy> global_proxy) { 858 Handle<JSGlobalProxy> global_proxy) {
860 // The argument global_proxy_template aka data is an ObjectTemplateInfo. 859 // The argument global_proxy_template aka data is an ObjectTemplateInfo.
861 // It has a constructor pointer that points at global_constructor which is a 860 // It has a constructor pointer that points at global_constructor which is a
862 // FunctionTemplateInfo. 861 // FunctionTemplateInfo.
863 // The global_proxy_constructor is used to (re)initialize the 862 // The global_proxy_constructor is used to (re)initialize the
864 // global_proxy. The global_proxy_constructor also has a prototype_template 863 // global_proxy. The global_proxy_constructor also has a prototype_template
865 // pointer that points at js_global_object_template which is an 864 // pointer that points at js_global_object_template which is an
866 // ObjectTemplateInfo. 865 // ObjectTemplateInfo.
867 // That in turn has a constructor pointer that points at 866 // That in turn has a constructor pointer that points at
868 // js_global_object_constructor which is a FunctionTemplateInfo. 867 // js_global_object_constructor which is a FunctionTemplateInfo.
(...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 Handle<Object> function_object = Object::GetProperty( 2850 Handle<Object> function_object = Object::GetProperty(
2852 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked(); 2851 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked();
2853 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2852 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2854 builtins->set_javascript_builtin(id, *function); 2853 builtins->set_javascript_builtin(id, *function);
2855 } 2854 }
2856 return true; 2855 return true;
2857 } 2856 }
2858 2857
2859 2858
2860 bool Genesis::ConfigureGlobalObjects( 2859 bool Genesis::ConfigureGlobalObjects(
2861 v8::Handle<v8::ObjectTemplate> global_proxy_template) { 2860 v8::Local<v8::ObjectTemplate> global_proxy_template) {
2862 Handle<JSObject> global_proxy( 2861 Handle<JSObject> global_proxy(
2863 JSObject::cast(native_context()->global_proxy())); 2862 JSObject::cast(native_context()->global_proxy()));
2864 Handle<JSObject> global_object( 2863 Handle<JSObject> global_object(
2865 JSObject::cast(native_context()->global_object())); 2864 JSObject::cast(native_context()->global_object()));
2866 2865
2867 if (!global_proxy_template.IsEmpty()) { 2866 if (!global_proxy_template.IsEmpty()) {
2868 // Configure the global proxy object. 2867 // Configure the global proxy object.
2869 Handle<ObjectTemplateInfo> global_proxy_data = 2868 Handle<ObjectTemplateInfo> global_proxy_data =
2870 v8::Utils::OpenHandle(*global_proxy_template); 2869 v8::Utils::OpenHandle(*global_proxy_template);
2871 if (!ConfigureApiObject(global_proxy, global_proxy_data)) return false; 2870 if (!ConfigureApiObject(global_proxy, global_proxy_data)) return false;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 } 3071 }
3073 3072
3074 private: 3073 private:
3075 bool flag_; 3074 bool flag_;
3076 bool enabled_; 3075 bool enabled_;
3077 }; 3076 };
3078 3077
3079 3078
3080 Genesis::Genesis(Isolate* isolate, 3079 Genesis::Genesis(Isolate* isolate,
3081 MaybeHandle<JSGlobalProxy> maybe_global_proxy, 3080 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
3082 v8::Handle<v8::ObjectTemplate> global_proxy_template, 3081 v8::Local<v8::ObjectTemplate> global_proxy_template,
3083 v8::ExtensionConfiguration* extensions) 3082 v8::ExtensionConfiguration* extensions)
3084 : isolate_(isolate), 3083 : isolate_(isolate), active_(isolate->bootstrapper()) {
3085 active_(isolate->bootstrapper()) {
3086 NoTrackDoubleFieldsForSerializerScope disable_scope(isolate); 3084 NoTrackDoubleFieldsForSerializerScope disable_scope(isolate);
3087 result_ = Handle<Context>::null(); 3085 result_ = Handle<Context>::null();
3088 // Before creating the roots we must save the context and restore it 3086 // Before creating the roots we must save the context and restore it
3089 // on all function exits. 3087 // on all function exits.
3090 SaveContext saved_context(isolate); 3088 SaveContext saved_context(isolate);
3091 3089
3092 // During genesis, the boilerplate for stack overflow won't work until the 3090 // During genesis, the boilerplate for stack overflow won't work until the
3093 // environment has been at least partially initialized. Add a stack check 3091 // environment has been at least partially initialized. Add a stack check
3094 // before entering JS code to catch overflow early. 3092 // before entering JS code to catch overflow early.
3095 StackLimitCheck check(isolate); 3093 StackLimitCheck check(isolate);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 } 3198 }
3201 3199
3202 3200
3203 // Called when the top-level V8 mutex is destroyed. 3201 // Called when the top-level V8 mutex is destroyed.
3204 void Bootstrapper::FreeThreadResources() { 3202 void Bootstrapper::FreeThreadResources() {
3205 DCHECK(!IsActive()); 3203 DCHECK(!IsActive());
3206 } 3204 }
3207 3205
3208 } // namespace internal 3206 } // namespace internal
3209 } // namespace v8 3207 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698