| OLD | NEW |
| 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/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { | 363 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { |
| 364 // object.__proto__ = proto; | 364 // object.__proto__ = proto; |
| 365 Handle<Map> old_map = Handle<Map>(object->map()); | 365 Handle<Map> old_map = Handle<Map>(object->map()); |
| 366 Handle<Map> new_map = Map::Copy(old_map, "SetObjectPrototype"); | 366 Handle<Map> new_map = Map::Copy(old_map, "SetObjectPrototype"); |
| 367 Map::SetPrototype(new_map, proto, FAST_PROTOTYPE); | 367 Map::SetPrototype(new_map, proto, FAST_PROTOTYPE); |
| 368 JSObject::MigrateToMap(object, new_map); | 368 JSObject::MigrateToMap(object, new_map); |
| 369 } | 369 } |
| 370 | 370 |
| 371 | 371 |
| 372 void Bootstrapper::DetachGlobal(Handle<Context> env) { | 372 void Bootstrapper::DetachGlobal(Handle<Context> env) { |
| 373 env->GetIsolate()->counters()->errors_thrown_per_context()->AddSample( |
| 374 env->GetErrorsThrown()); |
| 375 |
| 373 Factory* factory = env->GetIsolate()->factory(); | 376 Factory* factory = env->GetIsolate()->factory(); |
| 374 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); | 377 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); |
| 375 global_proxy->set_native_context(*factory->null_value()); | 378 global_proxy->set_native_context(*factory->null_value()); |
| 376 SetObjectPrototype(global_proxy, factory->null_value()); | 379 SetObjectPrototype(global_proxy, factory->null_value()); |
| 377 global_proxy->map()->SetConstructor(*factory->null_value()); | 380 global_proxy->map()->SetConstructor(*factory->null_value()); |
| 378 if (FLAG_track_detached_contexts) { | 381 if (FLAG_track_detached_contexts) { |
| 379 env->GetIsolate()->AddDetachedContext(env); | 382 env->GetIsolate()->AddDetachedContext(env); |
| 380 } | 383 } |
| 381 } | 384 } |
| 382 | 385 |
| (...skipping 2815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3198 | 3201 |
| 3199 if (!InstallNatives(context_type)) return; | 3202 if (!InstallNatives(context_type)) return; |
| 3200 | 3203 |
| 3201 MakeFunctionInstancePrototypeWritable(); | 3204 MakeFunctionInstancePrototypeWritable(); |
| 3202 | 3205 |
| 3203 if (context_type != THIN_CONTEXT) { | 3206 if (context_type != THIN_CONTEXT) { |
| 3204 if (!InstallExtraNatives()) return; | 3207 if (!InstallExtraNatives()) return; |
| 3205 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 3208 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
| 3206 } | 3209 } |
| 3207 isolate->counters()->contexts_created_from_scratch()->Increment(); | 3210 isolate->counters()->contexts_created_from_scratch()->Increment(); |
| 3211 // Re-initialize the counter because it got incremented during snapshot |
| 3212 // creation. |
| 3213 isolate->native_context()->set_errors_thrown(Smi::FromInt(0)); |
| 3208 } | 3214 } |
| 3209 | 3215 |
| 3210 // Install experimental natives. Do not include them into the | 3216 // Install experimental natives. Do not include them into the |
| 3211 // snapshot as we should be able to turn them off at runtime. Re-installing | 3217 // snapshot as we should be able to turn them off at runtime. Re-installing |
| 3212 // them after they have already been deserialized would also fail. | 3218 // them after they have already been deserialized would also fail. |
| 3213 if (context_type == FULL_CONTEXT) { | 3219 if (context_type == FULL_CONTEXT) { |
| 3214 if (!isolate->serializer_enabled()) { | 3220 if (!isolate->serializer_enabled()) { |
| 3215 InitializeExperimentalGlobal(); | 3221 InitializeExperimentalGlobal(); |
| 3216 if (!InstallExperimentalNatives()) return; | 3222 if (!InstallExperimentalNatives()) return; |
| 3217 | 3223 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3262 } | 3268 } |
| 3263 | 3269 |
| 3264 | 3270 |
| 3265 // Called when the top-level V8 mutex is destroyed. | 3271 // Called when the top-level V8 mutex is destroyed. |
| 3266 void Bootstrapper::FreeThreadResources() { | 3272 void Bootstrapper::FreeThreadResources() { |
| 3267 DCHECK(!IsActive()); | 3273 DCHECK(!IsActive()); |
| 3268 } | 3274 } |
| 3269 | 3275 |
| 3270 } // namespace internal | 3276 } // namespace internal |
| 3271 } // namespace v8 | 3277 } // namespace v8 |
| OLD | NEW |