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

Side by Side Diff: src/bootstrapper.cc

Issue 10872084: Allocate block-scoped global bindings to global context. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 Factory* factory = object->GetIsolate()->factory(); 320 Factory* factory = object->GetIsolate()->factory();
321 Handle<Map> old_to_map = Handle<Map>(object->map()); 321 Handle<Map> old_to_map = Handle<Map>(object->map());
322 Handle<Map> new_to_map = factory->CopyMap(old_to_map); 322 Handle<Map> new_to_map = factory->CopyMap(old_to_map);
323 new_to_map->set_prototype(*proto); 323 new_to_map->set_prototype(*proto);
324 object->set_map(*new_to_map); 324 object->set_map(*new_to_map);
325 } 325 }
326 326
327 327
328 void Bootstrapper::DetachGlobal(Handle<Context> env) { 328 void Bootstrapper::DetachGlobal(Handle<Context> env) {
329 Factory* factory = env->GetIsolate()->factory(); 329 Factory* factory = env->GetIsolate()->factory();
330 JSGlobalProxy::cast(env->global_proxy())-> 330 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy()));
331 set_native_context(*factory->null_value()); 331 global_proxy->set_native_context(*factory->null_value());
332 SetObjectPrototype(Handle<JSObject>(env->global_proxy()), 332 SetObjectPrototype(global_proxy, factory->null_value());
333 factory->null_value());
334 env->set_global_proxy(env->global_object()); 333 env->set_global_proxy(env->global_object());
335 env->global_object()->set_global_receiver(env->global_object()); 334 env->global_object()->set_global_receiver(env->global_object());
336 } 335 }
337 336
338 337
339 void Bootstrapper::ReattachGlobal(Handle<Context> env, 338 void Bootstrapper::ReattachGlobal(Handle<Context> env,
340 Handle<Object> global_object) { 339 Handle<JSGlobalProxy> global_proxy) {
341 ASSERT(global_object->IsJSGlobalProxy()); 340 env->global_object()->set_global_receiver(*global_proxy);
342 Handle<JSGlobalProxy> global = Handle<JSGlobalProxy>::cast(global_object); 341 env->set_global_proxy(*global_proxy);
343 env->global_object()->set_global_receiver(*global); 342 SetObjectPrototype(global_proxy, Handle<JSObject>(env->global_object()));
344 env->set_global_proxy(*global); 343 global_proxy->set_native_context(*env);
345 SetObjectPrototype(global, Handle<JSObject>(env->global_object()));
346 global->set_native_context(*env);
347 } 344 }
348 345
349 346
350 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, 347 static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
351 const char* name, 348 const char* name,
352 InstanceType type, 349 InstanceType type,
353 int instance_size, 350 int instance_size,
354 Handle<JSObject> prototype, 351 Handle<JSObject> prototype,
355 Builtins::Name call, 352 Builtins::Name call,
356 bool is_ecma_native) { 353 bool is_ecma_native) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 return Handle<JSGlobalProxy>::cast( 787 return Handle<JSGlobalProxy>::cast(
791 factory()->NewJSObject(global_proxy_function, TENURED)); 788 factory()->NewJSObject(global_proxy_function, TENURED));
792 } 789 }
793 } 790 }
794 791
795 792
796 void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global, 793 void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global,
797 Handle<JSGlobalProxy> global_proxy) { 794 Handle<JSGlobalProxy> global_proxy) {
798 // Set the native context for the global object. 795 // Set the native context for the global object.
799 inner_global->set_native_context(*native_context()); 796 inner_global->set_native_context(*native_context());
797 inner_global->set_global_context(*native_context());
800 inner_global->set_global_receiver(*global_proxy); 798 inner_global->set_global_receiver(*global_proxy);
801 global_proxy->set_native_context(*native_context()); 799 global_proxy->set_native_context(*native_context());
802 native_context()->set_global_proxy(*global_proxy); 800 native_context()->set_global_proxy(*global_proxy);
803 } 801 }
804 802
805 803
806 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { 804 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
807 Handle<GlobalObject> inner_global_from_snapshot( 805 Handle<GlobalObject> inner_global_from_snapshot(
808 GlobalObject::cast(native_context_->extension())); 806 GlobalObject::cast(native_context_->extension()));
809 Handle<JSBuiltinsObject> builtins_global(native_context_->builtins()); 807 Handle<JSBuiltinsObject> builtins_global(native_context_->builtins());
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 Handle<String> name = factory()->LookupAsciiSymbol("builtins"); 1434 Handle<String> name = factory()->LookupAsciiSymbol("builtins");
1437 builtins_fun->shared()->set_instance_class_name(*name); 1435 builtins_fun->shared()->set_instance_class_name(*name);
1438 builtins_fun->initial_map()->set_dictionary_map(true); 1436 builtins_fun->initial_map()->set_dictionary_map(true);
1439 builtins_fun->initial_map()->set_prototype(heap()->null_value()); 1437 builtins_fun->initial_map()->set_prototype(heap()->null_value());
1440 1438
1441 // Allocate the builtins object. 1439 // Allocate the builtins object.
1442 Handle<JSBuiltinsObject> builtins = 1440 Handle<JSBuiltinsObject> builtins =
1443 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); 1441 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
1444 builtins->set_builtins(*builtins); 1442 builtins->set_builtins(*builtins);
1445 builtins->set_native_context(*native_context()); 1443 builtins->set_native_context(*native_context());
1444 builtins->set_global_context(*native_context());
1446 builtins->set_global_receiver(*builtins); 1445 builtins->set_global_receiver(*builtins);
1447 1446
1448 // Set up the 'global' properties of the builtins object. The 1447 // Set up the 'global' properties of the builtins object. The
1449 // 'global' property that refers to the global object is the only 1448 // 'global' property that refers to the global object is the only
1450 // way to get from code running in the builtins context to the 1449 // way to get from code running in the builtins context to the
1451 // global object. 1450 // global object.
1452 static const PropertyAttributes attributes = 1451 static const PropertyAttributes attributes =
1453 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 1452 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1454 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); 1453 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global");
1455 Handle<Object> global_obj(native_context()->global_object()); 1454 Handle<Object> global_obj(native_context()->global_object());
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 return from + sizeof(NestingCounterType); 2395 return from + sizeof(NestingCounterType);
2397 } 2396 }
2398 2397
2399 2398
2400 // Called when the top-level V8 mutex is destroyed. 2399 // Called when the top-level V8 mutex is destroyed.
2401 void Bootstrapper::FreeThreadResources() { 2400 void Bootstrapper::FreeThreadResources() {
2402 ASSERT(!IsActive()); 2401 ASSERT(!IsActive());
2403 } 2402 }
2404 2403
2405 } } // namespace v8::internal 2404 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/compiler.h » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698