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

Side by Side Diff: src/bootstrapper.cc

Issue 151146: Treat the builtins object like other global objects (with... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/factory.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 // Allocate the function map first and then patch the prototype later 533 // Allocate the function map first and then patch the prototype later
534 Handle<Map> empty_fm = Factory::CopyMapDropDescriptors(fm); 534 Handle<Map> empty_fm = Factory::CopyMapDropDescriptors(fm);
535 empty_fm->set_instance_descriptors(*function_map_descriptors); 535 empty_fm->set_instance_descriptors(*function_map_descriptors);
536 empty_fm->set_prototype(global_context()->object_function()->prototype()); 536 empty_fm->set_prototype(global_context()->object_function()->prototype());
537 empty_function->set_map(*empty_fm); 537 empty_function->set_map(*empty_fm);
538 } 538 }
539 539
540 { // --- G l o b a l --- 540 { // --- G l o b a l ---
541 // Step 1: create a fresh inner JSGlobalObject 541 // Step 1: create a fresh inner JSGlobalObject
542 Handle<JSGlobalObject> object; 542 Handle<GlobalObject> object;
543 { 543 {
544 Handle<JSFunction> js_global_function; 544 Handle<JSFunction> js_global_function;
545 Handle<ObjectTemplateInfo> js_global_template; 545 Handle<ObjectTemplateInfo> js_global_template;
546 if (!global_template.IsEmpty()) { 546 if (!global_template.IsEmpty()) {
547 // Get prototype template of the global_template 547 // Get prototype template of the global_template
548 Handle<ObjectTemplateInfo> data = 548 Handle<ObjectTemplateInfo> data =
549 v8::Utils::OpenHandle(*global_template); 549 v8::Utils::OpenHandle(*global_template);
550 Handle<FunctionTemplateInfo> global_constructor = 550 Handle<FunctionTemplateInfo> global_constructor =
551 Handle<FunctionTemplateInfo>( 551 Handle<FunctionTemplateInfo>(
552 FunctionTemplateInfo::cast(data->constructor())); 552 FunctionTemplateInfo::cast(data->constructor()));
(...skipping 19 matching lines...) Expand all
572 Top::object_function(), NONE); 572 Top::object_function(), NONE);
573 } else { 573 } else {
574 Handle<FunctionTemplateInfo> js_global_constructor( 574 Handle<FunctionTemplateInfo> js_global_constructor(
575 FunctionTemplateInfo::cast(js_global_template->constructor())); 575 FunctionTemplateInfo::cast(js_global_template->constructor()));
576 js_global_function = 576 js_global_function =
577 Factory::CreateApiFunction(js_global_constructor, 577 Factory::CreateApiFunction(js_global_constructor,
578 Factory::InnerGlobalObject); 578 Factory::InnerGlobalObject);
579 } 579 }
580 580
581 js_global_function->initial_map()->set_is_hidden_prototype(); 581 js_global_function->initial_map()->set_is_hidden_prototype();
582 SetExpectedNofProperties(js_global_function, 100); 582 object = Factory::NewGlobalObject(js_global_function);
583 object = Factory::NewJSGlobalObject(js_global_function);
584 } 583 }
585 584
586 // Set the global context for the global object. 585 // Set the global context for the global object.
587 object->set_global_context(*global_context()); 586 object->set_global_context(*global_context());
588 587
589 // Step 2: create or re-initialize the global proxy object. 588 // Step 2: create or re-initialize the global proxy object.
590 Handle<JSGlobalProxy> global_proxy; 589 Handle<JSGlobalProxy> global_proxy;
591 { 590 {
592 Handle<JSFunction> global_proxy_function; 591 Handle<JSFunction> global_proxy_function;
593 if (global_template.IsEmpty()) { 592 if (global_template.IsEmpty()) {
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 // Create a function for the builtins object. Allocate space for the 954 // Create a function for the builtins object. Allocate space for the
956 // JavaScript builtins, a reference to the builtins object 955 // JavaScript builtins, a reference to the builtins object
957 // (itself) and a reference to the global_context directly in the object. 956 // (itself) and a reference to the global_context directly in the object.
958 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 957 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal));
959 Handle<JSFunction> builtins_fun = 958 Handle<JSFunction> builtins_fun =
960 Factory::NewFunction(Factory::empty_symbol(), JS_BUILTINS_OBJECT_TYPE, 959 Factory::NewFunction(Factory::empty_symbol(), JS_BUILTINS_OBJECT_TYPE,
961 JSBuiltinsObject::kSize, code, true); 960 JSBuiltinsObject::kSize, code, true);
962 961
963 Handle<String> name = Factory::LookupAsciiSymbol("builtins"); 962 Handle<String> name = Factory::LookupAsciiSymbol("builtins");
964 builtins_fun->shared()->set_instance_class_name(*name); 963 builtins_fun->shared()->set_instance_class_name(*name);
965 SetExpectedNofProperties(builtins_fun, 100);
966 964
967 // Allocate the builtins object. 965 // Allocate the builtins object.
968 Handle<JSBuiltinsObject> builtins = 966 Handle<JSBuiltinsObject> builtins =
969 Handle<JSBuiltinsObject>::cast(Factory::NewJSObject(builtins_fun, 967 Handle<JSBuiltinsObject>::cast(Factory::NewGlobalObject(builtins_fun));
970 TENURED));
971 builtins->set_builtins(*builtins); 968 builtins->set_builtins(*builtins);
972 builtins->set_global_context(*global_context()); 969 builtins->set_global_context(*global_context());
973 builtins->set_global_receiver(*builtins); 970 builtins->set_global_receiver(*builtins);
974 971
975 // Setup the 'global' properties of the builtins object. The 972 // Setup the 'global' properties of the builtins object. The
976 // 'global' property that refers to the global object is the only 973 // 'global' property that refers to the global object is the only
977 // way to get from code running in the builtins context to the 974 // way to get from code running in the builtins context to the
978 // global object. 975 // global object.
979 static const PropertyAttributes attributes = 976 static const PropertyAttributes attributes =
980 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 977 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 ASSERT(call->is_compiled()); 1180 ASSERT(call->is_compiled());
1184 1181
1185 // Set the expected parameters for apply to 2; required by builtin. 1182 // Set the expected parameters for apply to 2; required by builtin.
1186 apply->shared()->set_formal_parameter_count(2); 1183 apply->shared()->set_formal_parameter_count(2);
1187 1184
1188 // Set the lengths for the functions to satisfy ECMA-262. 1185 // Set the lengths for the functions to satisfy ECMA-262.
1189 call->shared()->set_length(1); 1186 call->shared()->set_length(1);
1190 apply->shared()->set_length(2); 1187 apply->shared()->set_length(2);
1191 } 1188 }
1192 1189
1193 // Make sure that the builtins object has fast properties.
1194 // If the ASSERT below fails, please increase the expected number of
1195 // properties for the builtins object.
1196 ASSERT(builtins->HasFastProperties());
1197 #ifdef DEBUG 1190 #ifdef DEBUG
1198 builtins->Verify(); 1191 builtins->Verify();
1199 #endif 1192 #endif
1200 return true; 1193 return true;
1201 } 1194 }
1202 1195
1203 1196
1204 bool Genesis::InstallSpecialObjects() { 1197 bool Genesis::InstallSpecialObjects() {
1205 HandleScope scope; 1198 HandleScope scope;
1206 Handle<JSGlobalObject> js_global( 1199 Handle<JSGlobalObject> js_global(
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 } 1619 }
1627 1620
1628 1621
1629 // Restore statics that are thread local. 1622 // Restore statics that are thread local.
1630 char* Genesis::RestoreState(char* from) { 1623 char* Genesis::RestoreState(char* from) {
1631 current_ = *reinterpret_cast<Genesis**>(from); 1624 current_ = *reinterpret_cast<Genesis**>(from);
1632 return from + sizeof(current_); 1625 return from + sizeof(current_);
1633 } 1626 }
1634 1627
1635 } } // namespace v8::internal 1628 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698