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

Side by Side Diff: src/bootstrapper.cc

Issue 2840018: [Isolates] Moved more compilation-related globals (builtins, runtime, &c.)... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: rebase Created 10 years, 6 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/ast.cc ('k') | src/builtins.h » ('j') | src/runtime.h » ('J')
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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 334
335 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, 335 static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
336 const char* name, 336 const char* name,
337 InstanceType type, 337 InstanceType type,
338 int instance_size, 338 int instance_size,
339 Handle<JSObject> prototype, 339 Handle<JSObject> prototype,
340 Builtins::Name call, 340 Builtins::Name call,
341 bool is_ecma_native) { 341 bool is_ecma_native) {
342 Handle<String> symbol = Factory::LookupAsciiSymbol(name); 342 Handle<String> symbol = Factory::LookupAsciiSymbol(name);
343 Handle<Code> call_code = Handle<Code>(Builtins::builtin(call)); 343 Handle<Code> call_code = Handle<Code>(
344 Isolate::Current()->builtins()->builtin(call));
344 Handle<JSFunction> function = prototype.is_null() ? 345 Handle<JSFunction> function = prototype.is_null() ?
345 Factory::NewFunctionWithoutPrototype(symbol, call_code) : 346 Factory::NewFunctionWithoutPrototype(symbol, call_code) :
346 Factory::NewFunctionWithPrototype(symbol, 347 Factory::NewFunctionWithPrototype(symbol,
347 type, 348 type,
348 instance_size, 349 instance_size,
349 prototype, 350 prototype,
350 call_code, 351 call_code,
351 is_ecma_native); 352 is_ecma_native);
352 SetProperty(target, symbol, function, DONT_ENUM); 353 SetProperty(target, symbol, function, DONT_ENUM);
353 if (is_ecma_native) { 354 if (is_ecma_native) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 468 }
468 469
469 // Allocate the empty function as the prototype for function ECMAScript 470 // Allocate the empty function as the prototype for function ECMAScript
470 // 262 15.3.4. 471 // 262 15.3.4.
471 Handle<String> symbol = Factory::LookupAsciiSymbol("Empty"); 472 Handle<String> symbol = Factory::LookupAsciiSymbol("Empty");
472 Handle<JSFunction> empty_function = 473 Handle<JSFunction> empty_function =
473 Factory::NewFunctionWithoutPrototype(symbol); 474 Factory::NewFunctionWithoutPrototype(symbol);
474 475
475 // --- E m p t y --- 476 // --- E m p t y ---
476 Handle<Code> code = 477 Handle<Code> code =
477 Handle<Code>(Builtins::builtin(Builtins::EmptyFunction)); 478 Handle<Code>(Isolate::Current()->builtins()->builtin(
479 Builtins::EmptyFunction));
478 empty_function->set_code(*code); 480 empty_function->set_code(*code);
479 Handle<String> source = Factory::NewStringFromAscii(CStrVector("() {}")); 481 Handle<String> source = Factory::NewStringFromAscii(CStrVector("() {}"));
480 Handle<Script> script = Factory::NewScript(source); 482 Handle<Script> script = Factory::NewScript(source);
481 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 483 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
482 empty_function->shared()->set_script(*script); 484 empty_function->shared()->set_script(*script);
483 empty_function->shared()->set_start_position(0); 485 empty_function->shared()->set_start_position(0);
484 empty_function->shared()->set_end_position(source->length()); 486 empty_function->shared()->set_end_position(source->length());
485 empty_function->shared()->DontAdaptArguments(); 487 empty_function->shared()->DontAdaptArguments();
486 global_context()->function_map()->set_prototype(*empty_function); 488 global_context()->function_map()->set_prototype(*empty_function);
487 global_context()->function_instance_map()->set_prototype(*empty_function); 489 global_context()->function_instance_map()->set_prototype(*empty_function);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 FunctionTemplateInfo::cast(data->constructor())); 548 FunctionTemplateInfo::cast(data->constructor()));
547 Handle<Object> proto_template(global_constructor->prototype_template()); 549 Handle<Object> proto_template(global_constructor->prototype_template());
548 if (!proto_template->IsUndefined()) { 550 if (!proto_template->IsUndefined()) {
549 js_global_template = 551 js_global_template =
550 Handle<ObjectTemplateInfo>::cast(proto_template); 552 Handle<ObjectTemplateInfo>::cast(proto_template);
551 } 553 }
552 } 554 }
553 555
554 if (js_global_template.is_null()) { 556 if (js_global_template.is_null()) {
555 Handle<String> name = Handle<String>(HEAP->empty_symbol()); 557 Handle<String> name = Handle<String>(HEAP->empty_symbol());
556 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 558 Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin(
559 Builtins::Illegal));
557 js_global_function = 560 js_global_function =
558 Factory::NewFunction(name, JS_GLOBAL_OBJECT_TYPE, 561 Factory::NewFunction(name, JS_GLOBAL_OBJECT_TYPE,
559 JSGlobalObject::kSize, code, true); 562 JSGlobalObject::kSize, code, true);
560 // Change the constructor property of the prototype of the 563 // Change the constructor property of the prototype of the
561 // hidden global function to refer to the Object function. 564 // hidden global function to refer to the Object function.
562 Handle<JSObject> prototype = 565 Handle<JSObject> prototype =
563 Handle<JSObject>( 566 Handle<JSObject>(
564 JSObject::cast(js_global_function->instance_prototype())); 567 JSObject::cast(js_global_function->instance_prototype()));
565 SetProperty(prototype, Factory::constructor_symbol(), 568 SetProperty(prototype, Factory::constructor_symbol(),
566 Isolate::Current()->object_function(), NONE); 569 Isolate::Current()->object_function(), NONE);
567 } else { 570 } else {
568 Handle<FunctionTemplateInfo> js_global_constructor( 571 Handle<FunctionTemplateInfo> js_global_constructor(
569 FunctionTemplateInfo::cast(js_global_template->constructor())); 572 FunctionTemplateInfo::cast(js_global_template->constructor()));
570 js_global_function = 573 js_global_function =
571 Factory::CreateApiFunction(js_global_constructor, 574 Factory::CreateApiFunction(js_global_constructor,
572 Factory::InnerGlobalObject); 575 Factory::InnerGlobalObject);
573 } 576 }
574 577
575 js_global_function->initial_map()->set_is_hidden_prototype(); 578 js_global_function->initial_map()->set_is_hidden_prototype();
576 Handle<GlobalObject> inner_global = 579 Handle<GlobalObject> inner_global =
577 Factory::NewGlobalObject(js_global_function); 580 Factory::NewGlobalObject(js_global_function);
578 if (inner_global_out != NULL) { 581 if (inner_global_out != NULL) {
579 *inner_global_out = inner_global; 582 *inner_global_out = inner_global;
580 } 583 }
581 584
582 // Step 2: create or re-initialize the global proxy object. 585 // Step 2: create or re-initialize the global proxy object.
583 Handle<JSFunction> global_proxy_function; 586 Handle<JSFunction> global_proxy_function;
584 if (global_template.IsEmpty()) { 587 if (global_template.IsEmpty()) {
585 Handle<String> name = Handle<String>(HEAP->empty_symbol()); 588 Handle<String> name = Handle<String>(HEAP->empty_symbol());
586 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 589 Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin(
590 Builtins::Illegal));
587 global_proxy_function = 591 global_proxy_function =
588 Factory::NewFunction(name, JS_GLOBAL_PROXY_TYPE, 592 Factory::NewFunction(name, JS_GLOBAL_PROXY_TYPE,
589 JSGlobalProxy::kSize, code, true); 593 JSGlobalProxy::kSize, code, true);
590 } else { 594 } else {
591 Handle<ObjectTemplateInfo> data = 595 Handle<ObjectTemplateInfo> data =
592 v8::Utils::OpenHandle(*global_template); 596 v8::Utils::OpenHandle(*global_template);
593 Handle<FunctionTemplateInfo> global_constructor( 597 Handle<FunctionTemplateInfo> global_constructor(
594 FunctionTemplateInfo::cast(data->constructor())); 598 FunctionTemplateInfo::cast(data->constructor()));
595 global_proxy_function = 599 global_proxy_function =
596 Factory::CreateApiFunction(global_constructor, 600 Factory::CreateApiFunction(global_constructor,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 // Install global Function object 677 // Install global Function object
674 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, 678 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
675 empty_function, Builtins::Illegal, true); // ECMA native. 679 empty_function, Builtins::Illegal, true); // ECMA native.
676 680
677 { // --- A r r a y --- 681 { // --- A r r a y ---
678 Handle<JSFunction> array_function = 682 Handle<JSFunction> array_function =
679 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 683 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
680 Isolate::Current()->initial_object_prototype(), 684 Isolate::Current()->initial_object_prototype(),
681 Builtins::ArrayCode, true); 685 Builtins::ArrayCode, true);
682 array_function->shared()->set_construct_stub( 686 array_function->shared()->set_construct_stub(
683 Builtins::builtin(Builtins::ArrayConstructCode)); 687 Isolate::Current()->builtins()->builtin(Builtins::ArrayConstructCode));
684 array_function->shared()->DontAdaptArguments(); 688 array_function->shared()->DontAdaptArguments();
685 689
686 // This seems a bit hackish, but we need to make sure Array.length 690 // This seems a bit hackish, but we need to make sure Array.length
687 // is 1. 691 // is 1.
688 array_function->shared()->set_length(1); 692 array_function->shared()->set_length(1);
689 Handle<DescriptorArray> array_descriptors = 693 Handle<DescriptorArray> array_descriptors =
690 Factory::CopyAppendProxyDescriptor( 694 Factory::CopyAppendProxyDescriptor(
691 Factory::empty_descriptor_array(), 695 Factory::empty_descriptor_array(),
692 Factory::length_symbol(), 696 Factory::length_symbol(),
693 Factory::NewProxy(&Accessors::ArrayLength), 697 Factory::NewProxy(&Accessors::ArrayLength),
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 ASSERT(json_object->IsJSObject()); 837 ASSERT(json_object->IsJSObject());
834 SetProperty(global, name, json_object, DONT_ENUM); 838 SetProperty(global, name, json_object, DONT_ENUM);
835 global_context()->set_json_object(*json_object); 839 global_context()->set_json_object(*json_object);
836 } 840 }
837 841
838 { // --- arguments_boilerplate_ 842 { // --- arguments_boilerplate_
839 // Make sure we can recognize argument objects at runtime. 843 // Make sure we can recognize argument objects at runtime.
840 // This is done by introducing an anonymous function with 844 // This is done by introducing an anonymous function with
841 // class_name equals 'Arguments'. 845 // class_name equals 'Arguments'.
842 Handle<String> symbol = Factory::LookupAsciiSymbol("Arguments"); 846 Handle<String> symbol = Factory::LookupAsciiSymbol("Arguments");
843 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 847 Handle<Code> code = Handle<Code>(
848 Isolate::Current()->builtins()->builtin(Builtins::Illegal));
844 Handle<JSObject> prototype = 849 Handle<JSObject> prototype =
845 Handle<JSObject>( 850 Handle<JSObject>(
846 JSObject::cast(global_context()->object_function()->prototype())); 851 JSObject::cast(global_context()->object_function()->prototype()));
847 852
848 Handle<JSFunction> function = 853 Handle<JSFunction> function =
849 Factory::NewFunctionWithPrototype(symbol, 854 Factory::NewFunctionWithPrototype(symbol,
850 JS_OBJECT_TYPE, 855 JS_OBJECT_TYPE,
851 JSObject::kHeaderSize, 856 JSObject::kHeaderSize,
852 prototype, 857 prototype,
853 code, 858 code,
(...skipping 27 matching lines...) Expand all
881 ASSERT(result->map()->inobject_properties() > Heap::arguments_length_index); 886 ASSERT(result->map()->inobject_properties() > Heap::arguments_length_index);
882 887
883 // Check the state of the object. 888 // Check the state of the object.
884 ASSERT(result->HasFastProperties()); 889 ASSERT(result->HasFastProperties());
885 ASSERT(result->HasFastElements()); 890 ASSERT(result->HasFastElements());
886 #endif 891 #endif
887 } 892 }
888 893
889 { // --- context extension 894 { // --- context extension
890 // Create a function for the context extension objects. 895 // Create a function for the context extension objects.
891 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 896 Handle<Code> code = Handle<Code>(
897 Isolate::Current()->builtins()->builtin(Builtins::Illegal));
892 Handle<JSFunction> context_extension_fun = 898 Handle<JSFunction> context_extension_fun =
893 Factory::NewFunction(Factory::empty_symbol(), 899 Factory::NewFunction(Factory::empty_symbol(),
894 JS_CONTEXT_EXTENSION_OBJECT_TYPE, 900 JS_CONTEXT_EXTENSION_OBJECT_TYPE,
895 JSObject::kHeaderSize, 901 JSObject::kHeaderSize,
896 code, 902 code,
897 true); 903 true);
898 904
899 Handle<String> name = Factory::LookupAsciiSymbol("context_extension"); 905 Handle<String> name = Factory::LookupAsciiSymbol("context_extension");
900 context_extension_fun->shared()->set_instance_class_name(*name); 906 context_extension_fun->shared()->set_instance_class_name(*name);
901 global_context()->set_context_extension_function(*context_extension_fun); 907 global_context()->set_context_extension_function(*context_extension_fun);
902 } 908 }
903 909
904 910
905 { 911 {
906 // Setup the call-as-function delegate. 912 // Setup the call-as-function delegate.
907 Handle<Code> code = 913 Handle<Code> code =
908 Handle<Code>(Builtins::builtin(Builtins::HandleApiCallAsFunction)); 914 Handle<Code>(Isolate::Current()->builtins()->builtin(
915 Builtins::HandleApiCallAsFunction));
909 Handle<JSFunction> delegate = 916 Handle<JSFunction> delegate =
910 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE, 917 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE,
911 JSObject::kHeaderSize, code, true); 918 JSObject::kHeaderSize, code, true);
912 global_context()->set_call_as_function_delegate(*delegate); 919 global_context()->set_call_as_function_delegate(*delegate);
913 delegate->shared()->DontAdaptArguments(); 920 delegate->shared()->DontAdaptArguments();
914 } 921 }
915 922
916 { 923 {
917 // Setup the call-as-constructor delegate. 924 // Setup the call-as-constructor delegate.
918 Handle<Code> code = 925 Handle<Code> code =
919 Handle<Code>(Builtins::builtin(Builtins::HandleApiCallAsConstructor)); 926 Handle<Code>(Isolate::Current()->builtins()->builtin(
927 Builtins::HandleApiCallAsConstructor));
920 Handle<JSFunction> delegate = 928 Handle<JSFunction> delegate =
921 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE, 929 Factory::NewFunction(Factory::empty_symbol(), JS_OBJECT_TYPE,
922 JSObject::kHeaderSize, code, true); 930 JSObject::kHeaderSize, code, true);
923 global_context()->set_call_as_constructor_delegate(*delegate); 931 global_context()->set_call_as_constructor_delegate(*delegate);
924 delegate->shared()->DontAdaptArguments(); 932 delegate->shared()->DontAdaptArguments();
925 } 933 }
926 934
927 // Initialize the out of memory slot. 935 // Initialize the out of memory slot.
928 global_context()->set_out_of_memory(HEAP->false_value()); 936 global_context()->set_out_of_memory(HEAP->false_value());
929 937
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 1047
1040 #undef INSTALL_NATIVE 1048 #undef INSTALL_NATIVE
1041 1049
1042 1050
1043 bool Genesis::InstallNatives() { 1051 bool Genesis::InstallNatives() {
1044 HandleScope scope; 1052 HandleScope scope;
1045 1053
1046 // Create a function for the builtins object. Allocate space for the 1054 // Create a function for the builtins object. Allocate space for the
1047 // JavaScript builtins, a reference to the builtins object 1055 // JavaScript builtins, a reference to the builtins object
1048 // (itself) and a reference to the global_context directly in the object. 1056 // (itself) and a reference to the global_context directly in the object.
1049 Handle<Code> code = Handle<Code>(Builtins::builtin(Builtins::Illegal)); 1057 Handle<Code> code = Handle<Code>(
1058 Isolate::Current()->builtins()->builtin(Builtins::Illegal));
1050 Handle<JSFunction> builtins_fun = 1059 Handle<JSFunction> builtins_fun =
1051 Factory::NewFunction(Factory::empty_symbol(), JS_BUILTINS_OBJECT_TYPE, 1060 Factory::NewFunction(Factory::empty_symbol(), JS_BUILTINS_OBJECT_TYPE,
1052 JSBuiltinsObject::kSize, code, true); 1061 JSBuiltinsObject::kSize, code, true);
1053 1062
1054 Handle<String> name = Factory::LookupAsciiSymbol("builtins"); 1063 Handle<String> name = Factory::LookupAsciiSymbol("builtins");
1055 builtins_fun->shared()->set_instance_class_name(*name); 1064 builtins_fun->shared()->set_instance_class_name(*name);
1056 1065
1057 // Allocate the builtins object. 1066 // Allocate the builtins object.
1058 Handle<JSBuiltinsObject> builtins = 1067 Handle<JSBuiltinsObject> builtins =
1059 Handle<JSBuiltinsObject>::cast(Factory::NewGlobalObject(builtins_fun)); 1068 Handle<JSBuiltinsObject>::cast(Factory::NewGlobalObject(builtins_fun));
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 return from + sizeof(NestingCounterType); 1812 return from + sizeof(NestingCounterType);
1804 } 1813 }
1805 1814
1806 1815
1807 // Called when the top-level V8 mutex is destroyed. 1816 // Called when the top-level V8 mutex is destroyed.
1808 void Bootstrapper::FreeThreadResources() { 1817 void Bootstrapper::FreeThreadResources() {
1809 ASSERT(!IsActive()); 1818 ASSERT(!IsActive());
1810 } 1819 }
1811 1820
1812 } } // namespace v8::internal 1821 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/builtins.h » ('j') | src/runtime.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698