OLD | NEW |
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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 // Allocate the empty function as the prototype for function ECMAScript | 439 // Allocate the empty function as the prototype for function ECMAScript |
440 // 262 15.3.4. | 440 // 262 15.3.4. |
441 Handle<String> symbol = FACTORY->LookupAsciiSymbol("Empty"); | 441 Handle<String> symbol = FACTORY->LookupAsciiSymbol("Empty"); |
442 Handle<JSFunction> empty_function = | 442 Handle<JSFunction> empty_function = |
443 FACTORY->NewFunctionWithoutPrototype(symbol, kNonStrictMode); | 443 FACTORY->NewFunctionWithoutPrototype(symbol, kNonStrictMode); |
444 | 444 |
445 // --- E m p t y --- | 445 // --- E m p t y --- |
446 Handle<Code> code = | 446 Handle<Code> code = |
447 Handle<Code>(Isolate::Current()->builtins()->builtin( | 447 Handle<Code>(Isolate::Current()->builtins()->builtin( |
448 Builtins::EmptyFunction)); | 448 Builtins::kEmptyFunction)); |
449 empty_function->set_code(*code); | 449 empty_function->set_code(*code); |
450 empty_function->shared()->set_code(*code); | 450 empty_function->shared()->set_code(*code); |
451 Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("() {}")); | 451 Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("() {}")); |
452 Handle<Script> script = FACTORY->NewScript(source); | 452 Handle<Script> script = FACTORY->NewScript(source); |
453 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 453 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
454 empty_function->shared()->set_script(*script); | 454 empty_function->shared()->set_script(*script); |
455 empty_function->shared()->set_start_position(0); | 455 empty_function->shared()->set_start_position(0); |
456 empty_function->shared()->set_end_position(source->length()); | 456 empty_function->shared()->set_end_position(source->length()); |
457 empty_function->shared()->DontAdaptArguments(); | 457 empty_function->shared()->DontAdaptArguments(); |
458 | 458 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 ADD_READONLY_PROTOTYPE, empty, arguments, caller)); | 580 ADD_READONLY_PROTOTYPE, empty, arguments, caller)); |
581 | 581 |
582 // The final map for the strict mode functions. Writeable prototype. | 582 // The final map for the strict mode functions. Writeable prototype. |
583 // This map is installed in MakeFunctionInstancePrototypeWritable. | 583 // This map is installed in MakeFunctionInstancePrototypeWritable. |
584 strict_mode_function_instance_map_writable_prototype_ = | 584 strict_mode_function_instance_map_writable_prototype_ = |
585 CreateStrictModeFunctionMap( | 585 CreateStrictModeFunctionMap( |
586 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); | 586 ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller); |
587 | 587 |
588 // Create the ThrowTypeError function instances. | 588 // Create the ThrowTypeError function instances. |
589 Handle<JSFunction> arguments_throw = | 589 Handle<JSFunction> arguments_throw = |
590 CreateThrowTypeErrorFunction(Builtins::StrictFunctionArguments); | 590 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionArguments); |
591 Handle<JSFunction> caller_throw = | 591 Handle<JSFunction> caller_throw = |
592 CreateThrowTypeErrorFunction(Builtins::StrictFunctionCaller); | 592 CreateThrowTypeErrorFunction(Builtins::kStrictFunctionCaller); |
593 | 593 |
594 // Complete the callback fixed arrays. | 594 // Complete the callback fixed arrays. |
595 arguments->set(0, *arguments_throw); | 595 arguments->set(0, *arguments_throw); |
596 arguments->set(1, *arguments_throw); | 596 arguments->set(1, *arguments_throw); |
597 caller->set(0, *caller_throw); | 597 caller->set(0, *caller_throw); |
598 caller->set(1, *caller_throw); | 598 caller->set(1, *caller_throw); |
599 } | 599 } |
600 | 600 |
601 | 601 |
602 static void AddToWeakGlobalContextList(Context* context) { | 602 static void AddToWeakGlobalContextList(Context* context) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 Handle<Object> proto_template(global_constructor->prototype_template()); | 666 Handle<Object> proto_template(global_constructor->prototype_template()); |
667 if (!proto_template->IsUndefined()) { | 667 if (!proto_template->IsUndefined()) { |
668 js_global_template = | 668 js_global_template = |
669 Handle<ObjectTemplateInfo>::cast(proto_template); | 669 Handle<ObjectTemplateInfo>::cast(proto_template); |
670 } | 670 } |
671 } | 671 } |
672 | 672 |
673 if (js_global_template.is_null()) { | 673 if (js_global_template.is_null()) { |
674 Handle<String> name = Handle<String>(HEAP->empty_symbol()); | 674 Handle<String> name = Handle<String>(HEAP->empty_symbol()); |
675 Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin( | 675 Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin( |
676 Builtins::Illegal)); | 676 Builtins::kIllegal)); |
677 js_global_function = | 677 js_global_function = |
678 FACTORY->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, | 678 FACTORY->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, |
679 JSGlobalObject::kSize, code, true); | 679 JSGlobalObject::kSize, code, true); |
680 // Change the constructor property of the prototype of the | 680 // Change the constructor property of the prototype of the |
681 // hidden global function to refer to the Object function. | 681 // hidden global function to refer to the Object function. |
682 Handle<JSObject> prototype = | 682 Handle<JSObject> prototype = |
683 Handle<JSObject>( | 683 Handle<JSObject>( |
684 JSObject::cast(js_global_function->instance_prototype())); | 684 JSObject::cast(js_global_function->instance_prototype())); |
685 SetLocalPropertyNoThrow( | 685 SetLocalPropertyNoThrow( |
686 prototype, | 686 prototype, |
(...skipping 13 matching lines...) Expand all Loading... |
700 FACTORY->NewGlobalObject(js_global_function); | 700 FACTORY->NewGlobalObject(js_global_function); |
701 if (inner_global_out != NULL) { | 701 if (inner_global_out != NULL) { |
702 *inner_global_out = inner_global; | 702 *inner_global_out = inner_global; |
703 } | 703 } |
704 | 704 |
705 // Step 2: create or re-initialize the global proxy object. | 705 // Step 2: create or re-initialize the global proxy object. |
706 Handle<JSFunction> global_proxy_function; | 706 Handle<JSFunction> global_proxy_function; |
707 if (global_template.IsEmpty()) { | 707 if (global_template.IsEmpty()) { |
708 Handle<String> name = Handle<String>(HEAP->empty_symbol()); | 708 Handle<String> name = Handle<String>(HEAP->empty_symbol()); |
709 Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin( | 709 Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin( |
710 Builtins::Illegal)); | 710 Builtins::kIllegal)); |
711 global_proxy_function = | 711 global_proxy_function = |
712 FACTORY->NewFunction(name, JS_GLOBAL_PROXY_TYPE, | 712 FACTORY->NewFunction(name, JS_GLOBAL_PROXY_TYPE, |
713 JSGlobalProxy::kSize, code, true); | 713 JSGlobalProxy::kSize, code, true); |
714 } else { | 714 } else { |
715 Handle<ObjectTemplateInfo> data = | 715 Handle<ObjectTemplateInfo> data = |
716 v8::Utils::OpenHandle(*global_template); | 716 v8::Utils::OpenHandle(*global_template); |
717 Handle<FunctionTemplateInfo> global_constructor( | 717 Handle<FunctionTemplateInfo> global_constructor( |
718 FunctionTemplateInfo::cast(data->constructor())); | 718 FunctionTemplateInfo::cast(data->constructor())); |
719 global_proxy_function = | 719 global_proxy_function = |
720 FACTORY->CreateApiFunction(global_constructor, | 720 FACTORY->CreateApiFunction(global_constructor, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 global_context()->set_security_token(*inner_global); | 789 global_context()->set_security_token(*inner_global); |
790 | 790 |
791 Handle<String> object_name = Handle<String>(HEAP->Object_symbol()); | 791 Handle<String> object_name = Handle<String>(HEAP->Object_symbol()); |
792 SetLocalPropertyNoThrow(inner_global, object_name, | 792 SetLocalPropertyNoThrow(inner_global, object_name, |
793 Isolate::Current()->object_function(), DONT_ENUM); | 793 Isolate::Current()->object_function(), DONT_ENUM); |
794 | 794 |
795 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); | 795 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); |
796 | 796 |
797 // Install global Function object | 797 // Install global Function object |
798 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 798 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
799 empty_function, Builtins::Illegal, true); // ECMA native. | 799 empty_function, Builtins::kIllegal, true); // ECMA native. |
800 | 800 |
801 { // --- A r r a y --- | 801 { // --- A r r a y --- |
802 Handle<JSFunction> array_function = | 802 Handle<JSFunction> array_function = |
803 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 803 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
804 Isolate::Current()->initial_object_prototype(), | 804 Isolate::Current()->initial_object_prototype(), |
805 Builtins::ArrayCode, true); | 805 Builtins::kArrayCode, true); |
806 array_function->shared()->set_construct_stub( | 806 array_function->shared()->set_construct_stub( |
807 Isolate::Current()->builtins()->builtin(Builtins::ArrayConstructCode)); | 807 Isolate::Current()->builtins()->builtin(Builtins::kArrayConstructCode)); |
808 array_function->shared()->DontAdaptArguments(); | 808 array_function->shared()->DontAdaptArguments(); |
809 | 809 |
810 // This seems a bit hackish, but we need to make sure Array.length | 810 // This seems a bit hackish, but we need to make sure Array.length |
811 // is 1. | 811 // is 1. |
812 array_function->shared()->set_length(1); | 812 array_function->shared()->set_length(1); |
813 Handle<DescriptorArray> array_descriptors = | 813 Handle<DescriptorArray> array_descriptors = |
814 FACTORY->CopyAppendProxyDescriptor( | 814 FACTORY->CopyAppendProxyDescriptor( |
815 FACTORY->empty_descriptor_array(), | 815 FACTORY->empty_descriptor_array(), |
816 FACTORY->length_symbol(), | 816 FACTORY->length_symbol(), |
817 FACTORY->NewProxy(&Accessors::ArrayLength), | 817 FACTORY->NewProxy(&Accessors::ArrayLength), |
818 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); | 818 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); |
819 | 819 |
820 // Cache the fast JavaScript array map | 820 // Cache the fast JavaScript array map |
821 global_context()->set_js_array_map(array_function->initial_map()); | 821 global_context()->set_js_array_map(array_function->initial_map()); |
822 global_context()->js_array_map()->set_instance_descriptors( | 822 global_context()->js_array_map()->set_instance_descriptors( |
823 *array_descriptors); | 823 *array_descriptors); |
824 // array_function is used internally. JS code creating array object should | 824 // array_function is used internally. JS code creating array object should |
825 // search for the 'Array' property on the global object and use that one | 825 // search for the 'Array' property on the global object and use that one |
826 // as the constructor. 'Array' property on a global object can be | 826 // as the constructor. 'Array' property on a global object can be |
827 // overwritten by JS code. | 827 // overwritten by JS code. |
828 global_context()->set_array_function(*array_function); | 828 global_context()->set_array_function(*array_function); |
829 } | 829 } |
830 | 830 |
831 { // --- N u m b e r --- | 831 { // --- N u m b e r --- |
832 Handle<JSFunction> number_fun = | 832 Handle<JSFunction> number_fun = |
833 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 833 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
834 Isolate::Current()->initial_object_prototype(), | 834 Isolate::Current()->initial_object_prototype(), |
835 Builtins::Illegal, true); | 835 Builtins::kIllegal, true); |
836 global_context()->set_number_function(*number_fun); | 836 global_context()->set_number_function(*number_fun); |
837 } | 837 } |
838 | 838 |
839 { // --- B o o l e a n --- | 839 { // --- B o o l e a n --- |
840 Handle<JSFunction> boolean_fun = | 840 Handle<JSFunction> boolean_fun = |
841 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, | 841 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, |
842 Isolate::Current()->initial_object_prototype(), | 842 Isolate::Current()->initial_object_prototype(), |
843 Builtins::Illegal, true); | 843 Builtins::kIllegal, true); |
844 global_context()->set_boolean_function(*boolean_fun); | 844 global_context()->set_boolean_function(*boolean_fun); |
845 } | 845 } |
846 | 846 |
847 { // --- S t r i n g --- | 847 { // --- S t r i n g --- |
848 Handle<JSFunction> string_fun = | 848 Handle<JSFunction> string_fun = |
849 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, | 849 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, |
850 Isolate::Current()->initial_object_prototype(), | 850 Isolate::Current()->initial_object_prototype(), |
851 Builtins::Illegal, true); | 851 Builtins::kIllegal, true); |
852 string_fun->shared()->set_construct_stub( | 852 string_fun->shared()->set_construct_stub( |
853 Isolate::Current()->builtins()->builtin(Builtins::StringConstructCode)); | 853 Isolate::Current()->builtins()->builtin( |
| 854 Builtins::kStringConstructCode)); |
854 global_context()->set_string_function(*string_fun); | 855 global_context()->set_string_function(*string_fun); |
855 // Add 'length' property to strings. | 856 // Add 'length' property to strings. |
856 Handle<DescriptorArray> string_descriptors = | 857 Handle<DescriptorArray> string_descriptors = |
857 FACTORY->CopyAppendProxyDescriptor( | 858 FACTORY->CopyAppendProxyDescriptor( |
858 FACTORY->empty_descriptor_array(), | 859 FACTORY->empty_descriptor_array(), |
859 FACTORY->length_symbol(), | 860 FACTORY->length_symbol(), |
860 FACTORY->NewProxy(&Accessors::StringLength), | 861 FACTORY->NewProxy(&Accessors::StringLength), |
861 static_cast<PropertyAttributes>(DONT_ENUM | | 862 static_cast<PropertyAttributes>(DONT_ENUM | |
862 DONT_DELETE | | 863 DONT_DELETE | |
863 READ_ONLY)); | 864 READ_ONLY)); |
864 | 865 |
865 Handle<Map> string_map = | 866 Handle<Map> string_map = |
866 Handle<Map>(global_context()->string_function()->initial_map()); | 867 Handle<Map>(global_context()->string_function()->initial_map()); |
867 string_map->set_instance_descriptors(*string_descriptors); | 868 string_map->set_instance_descriptors(*string_descriptors); |
868 } | 869 } |
869 | 870 |
870 { // --- D a t e --- | 871 { // --- D a t e --- |
871 // Builtin functions for Date.prototype. | 872 // Builtin functions for Date.prototype. |
872 Handle<JSFunction> date_fun = | 873 Handle<JSFunction> date_fun = |
873 InstallFunction(global, "Date", JS_VALUE_TYPE, JSValue::kSize, | 874 InstallFunction(global, "Date", JS_VALUE_TYPE, JSValue::kSize, |
874 Isolate::Current()->initial_object_prototype(), | 875 Isolate::Current()->initial_object_prototype(), |
875 Builtins::Illegal, true); | 876 Builtins::kIllegal, true); |
876 | 877 |
877 global_context()->set_date_function(*date_fun); | 878 global_context()->set_date_function(*date_fun); |
878 } | 879 } |
879 | 880 |
880 | 881 |
881 { // -- R e g E x p | 882 { // -- R e g E x p |
882 // Builtin functions for RegExp.prototype. | 883 // Builtin functions for RegExp.prototype. |
883 Handle<JSFunction> regexp_fun = | 884 Handle<JSFunction> regexp_fun = |
884 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 885 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
885 Isolate::Current()->initial_object_prototype(), | 886 Isolate::Current()->initial_object_prototype(), |
886 Builtins::Illegal, true); | 887 Builtins::kIllegal, true); |
887 global_context()->set_regexp_function(*regexp_fun); | 888 global_context()->set_regexp_function(*regexp_fun); |
888 | 889 |
889 ASSERT(regexp_fun->has_initial_map()); | 890 ASSERT(regexp_fun->has_initial_map()); |
890 Handle<Map> initial_map(regexp_fun->initial_map()); | 891 Handle<Map> initial_map(regexp_fun->initial_map()); |
891 | 892 |
892 ASSERT_EQ(0, initial_map->inobject_properties()); | 893 ASSERT_EQ(0, initial_map->inobject_properties()); |
893 | 894 |
894 Handle<DescriptorArray> descriptors = FACTORY->NewDescriptorArray(5); | 895 Handle<DescriptorArray> descriptors = FACTORY->NewDescriptorArray(5); |
895 PropertyAttributes final = | 896 PropertyAttributes final = |
896 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 897 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM); | 962 SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM); |
962 global_context()->set_json_object(*json_object); | 963 global_context()->set_json_object(*json_object); |
963 } | 964 } |
964 | 965 |
965 { // --- arguments_boilerplate_ | 966 { // --- arguments_boilerplate_ |
966 // Make sure we can recognize argument objects at runtime. | 967 // Make sure we can recognize argument objects at runtime. |
967 // This is done by introducing an anonymous function with | 968 // This is done by introducing an anonymous function with |
968 // class_name equals 'Arguments'. | 969 // class_name equals 'Arguments'. |
969 Handle<String> symbol = FACTORY->LookupAsciiSymbol("Arguments"); | 970 Handle<String> symbol = FACTORY->LookupAsciiSymbol("Arguments"); |
970 Handle<Code> code = Handle<Code>( | 971 Handle<Code> code = Handle<Code>( |
971 Isolate::Current()->builtins()->builtin(Builtins::Illegal)); | 972 Isolate::Current()->builtins()->builtin(Builtins::kIllegal)); |
972 Handle<JSObject> prototype = | 973 Handle<JSObject> prototype = |
973 Handle<JSObject>( | 974 Handle<JSObject>( |
974 JSObject::cast(global_context()->object_function()->prototype())); | 975 JSObject::cast(global_context()->object_function()->prototype())); |
975 | 976 |
976 Handle<JSFunction> function = | 977 Handle<JSFunction> function = |
977 FACTORY->NewFunctionWithPrototype(symbol, | 978 FACTORY->NewFunctionWithPrototype(symbol, |
978 JS_OBJECT_TYPE, | 979 JS_OBJECT_TYPE, |
979 JSObject::kHeaderSize, | 980 JSObject::kHeaderSize, |
980 prototype, | 981 prototype, |
981 code, | 982 code, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 | 1017 |
1017 { // --- strict mode arguments boilerplate | 1018 { // --- strict mode arguments boilerplate |
1018 const PropertyAttributes attributes = | 1019 const PropertyAttributes attributes = |
1019 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1020 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
1020 | 1021 |
1021 // Create the ThrowTypeError functions. | 1022 // Create the ThrowTypeError functions. |
1022 Handle<FixedArray> callee = FACTORY->NewFixedArray(2, TENURED); | 1023 Handle<FixedArray> callee = FACTORY->NewFixedArray(2, TENURED); |
1023 Handle<FixedArray> caller = FACTORY->NewFixedArray(2, TENURED); | 1024 Handle<FixedArray> caller = FACTORY->NewFixedArray(2, TENURED); |
1024 | 1025 |
1025 Handle<JSFunction> callee_throw = | 1026 Handle<JSFunction> callee_throw = |
1026 CreateThrowTypeErrorFunction(Builtins::StrictArgumentsCallee); | 1027 CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCallee); |
1027 Handle<JSFunction> caller_throw = | 1028 Handle<JSFunction> caller_throw = |
1028 CreateThrowTypeErrorFunction(Builtins::StrictArgumentsCaller); | 1029 CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCaller); |
1029 | 1030 |
1030 // Install the ThrowTypeError functions. | 1031 // Install the ThrowTypeError functions. |
1031 callee->set(0, *callee_throw); | 1032 callee->set(0, *callee_throw); |
1032 callee->set(1, *callee_throw); | 1033 callee->set(1, *callee_throw); |
1033 caller->set(0, *caller_throw); | 1034 caller->set(0, *caller_throw); |
1034 caller->set(1, *caller_throw); | 1035 caller->set(1, *caller_throw); |
1035 | 1036 |
1036 // Create the descriptor array for the arguments object. | 1037 // Create the descriptor array for the arguments object. |
1037 Handle<DescriptorArray> descriptors = FACTORY->NewDescriptorArray(3); | 1038 Handle<DescriptorArray> descriptors = FACTORY->NewDescriptorArray(3); |
1038 { // length | 1039 { // length |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 | 1082 |
1082 // Check the state of the object. | 1083 // Check the state of the object. |
1083 ASSERT(result->HasFastProperties()); | 1084 ASSERT(result->HasFastProperties()); |
1084 ASSERT(result->HasFastElements()); | 1085 ASSERT(result->HasFastElements()); |
1085 #endif | 1086 #endif |
1086 } | 1087 } |
1087 | 1088 |
1088 { // --- context extension | 1089 { // --- context extension |
1089 // Create a function for the context extension objects. | 1090 // Create a function for the context extension objects. |
1090 Handle<Code> code = Handle<Code>( | 1091 Handle<Code> code = Handle<Code>( |
1091 Isolate::Current()->builtins()->builtin(Builtins::Illegal)); | 1092 Isolate::Current()->builtins()->builtin(Builtins::kIllegal)); |
1092 Handle<JSFunction> context_extension_fun = | 1093 Handle<JSFunction> context_extension_fun = |
1093 FACTORY->NewFunction(FACTORY->empty_symbol(), | 1094 FACTORY->NewFunction(FACTORY->empty_symbol(), |
1094 JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 1095 JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
1095 JSObject::kHeaderSize, | 1096 JSObject::kHeaderSize, |
1096 code, | 1097 code, |
1097 true); | 1098 true); |
1098 | 1099 |
1099 Handle<String> name = FACTORY->LookupAsciiSymbol("context_extension"); | 1100 Handle<String> name = FACTORY->LookupAsciiSymbol("context_extension"); |
1100 context_extension_fun->shared()->set_instance_class_name(*name); | 1101 context_extension_fun->shared()->set_instance_class_name(*name); |
1101 global_context()->set_context_extension_function(*context_extension_fun); | 1102 global_context()->set_context_extension_function(*context_extension_fun); |
1102 } | 1103 } |
1103 | 1104 |
1104 | 1105 |
1105 { | 1106 { |
1106 // Setup the call-as-function delegate. | 1107 // Setup the call-as-function delegate. |
1107 Handle<Code> code = | 1108 Handle<Code> code = |
1108 Handle<Code>(Isolate::Current()->builtins()->builtin( | 1109 Handle<Code>(Isolate::Current()->builtins()->builtin( |
1109 Builtins::HandleApiCallAsFunction)); | 1110 Builtins::kHandleApiCallAsFunction)); |
1110 Handle<JSFunction> delegate = | 1111 Handle<JSFunction> delegate = |
1111 FACTORY->NewFunction(FACTORY->empty_symbol(), JS_OBJECT_TYPE, | 1112 FACTORY->NewFunction(FACTORY->empty_symbol(), JS_OBJECT_TYPE, |
1112 JSObject::kHeaderSize, code, true); | 1113 JSObject::kHeaderSize, code, true); |
1113 global_context()->set_call_as_function_delegate(*delegate); | 1114 global_context()->set_call_as_function_delegate(*delegate); |
1114 delegate->shared()->DontAdaptArguments(); | 1115 delegate->shared()->DontAdaptArguments(); |
1115 } | 1116 } |
1116 | 1117 |
1117 { | 1118 { |
1118 // Setup the call-as-constructor delegate. | 1119 // Setup the call-as-constructor delegate. |
1119 Handle<Code> code = | 1120 Handle<Code> code = |
1120 Handle<Code>(Isolate::Current()->builtins()->builtin( | 1121 Handle<Code>(Isolate::Current()->builtins()->builtin( |
1121 Builtins::HandleApiCallAsConstructor)); | 1122 Builtins::kHandleApiCallAsConstructor)); |
1122 Handle<JSFunction> delegate = | 1123 Handle<JSFunction> delegate = |
1123 FACTORY->NewFunction(FACTORY->empty_symbol(), JS_OBJECT_TYPE, | 1124 FACTORY->NewFunction(FACTORY->empty_symbol(), JS_OBJECT_TYPE, |
1124 JSObject::kHeaderSize, code, true); | 1125 JSObject::kHeaderSize, code, true); |
1125 global_context()->set_call_as_constructor_delegate(*delegate); | 1126 global_context()->set_call_as_constructor_delegate(*delegate); |
1126 delegate->shared()->DontAdaptArguments(); | 1127 delegate->shared()->DontAdaptArguments(); |
1127 } | 1128 } |
1128 | 1129 |
1129 // Initialize the out of memory slot. | 1130 // Initialize the out of memory slot. |
1130 global_context()->set_out_of_memory(HEAP->false_value()); | 1131 global_context()->set_out_of_memory(HEAP->false_value()); |
1131 | 1132 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 | 1245 |
1245 bool Genesis::InstallNatives() { | 1246 bool Genesis::InstallNatives() { |
1246 HandleScope scope; | 1247 HandleScope scope; |
1247 Isolate* isolate = Isolate::Current(); | 1248 Isolate* isolate = Isolate::Current(); |
1248 Factory* factory = isolate->factory(); | 1249 Factory* factory = isolate->factory(); |
1249 | 1250 |
1250 // Create a function for the builtins object. Allocate space for the | 1251 // Create a function for the builtins object. Allocate space for the |
1251 // JavaScript builtins, a reference to the builtins object | 1252 // JavaScript builtins, a reference to the builtins object |
1252 // (itself) and a reference to the global_context directly in the object. | 1253 // (itself) and a reference to the global_context directly in the object. |
1253 Handle<Code> code = Handle<Code>( | 1254 Handle<Code> code = Handle<Code>( |
1254 isolate->builtins()->builtin(Builtins::Illegal)); | 1255 isolate->builtins()->builtin(Builtins::kIllegal)); |
1255 Handle<JSFunction> builtins_fun = | 1256 Handle<JSFunction> builtins_fun = |
1256 factory->NewFunction(factory->empty_symbol(), JS_BUILTINS_OBJECT_TYPE, | 1257 factory->NewFunction(factory->empty_symbol(), JS_BUILTINS_OBJECT_TYPE, |
1257 JSBuiltinsObject::kSize, code, true); | 1258 JSBuiltinsObject::kSize, code, true); |
1258 | 1259 |
1259 Handle<String> name = factory->LookupAsciiSymbol("builtins"); | 1260 Handle<String> name = factory->LookupAsciiSymbol("builtins"); |
1260 builtins_fun->shared()->set_instance_class_name(*name); | 1261 builtins_fun->shared()->set_instance_class_name(*name); |
1261 | 1262 |
1262 // Allocate the builtins object. | 1263 // Allocate the builtins object. |
1263 Handle<JSBuiltinsObject> builtins = | 1264 Handle<JSBuiltinsObject> builtins = |
1264 Handle<JSBuiltinsObject>::cast(factory->NewGlobalObject(builtins_fun)); | 1265 Handle<JSBuiltinsObject>::cast(factory->NewGlobalObject(builtins_fun)); |
(...skipping 24 matching lines...) Expand all Loading... |
1289 factory->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); | 1290 factory->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); |
1290 context->set_global(*builtins); // override builtins global object | 1291 context->set_global(*builtins); // override builtins global object |
1291 | 1292 |
1292 global_context()->set_runtime_context(*context); | 1293 global_context()->set_runtime_context(*context); |
1293 | 1294 |
1294 { // -- S c r i p t | 1295 { // -- S c r i p t |
1295 // Builtin functions for Script. | 1296 // Builtin functions for Script. |
1296 Handle<JSFunction> script_fun = | 1297 Handle<JSFunction> script_fun = |
1297 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, | 1298 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, |
1298 isolate->initial_object_prototype(), | 1299 isolate->initial_object_prototype(), |
1299 Builtins::Illegal, false); | 1300 Builtins::kIllegal, false); |
1300 Handle<JSObject> prototype = | 1301 Handle<JSObject> prototype = |
1301 factory->NewJSObject(isolate->object_function(), TENURED); | 1302 factory->NewJSObject(isolate->object_function(), TENURED); |
1302 SetPrototype(script_fun, prototype); | 1303 SetPrototype(script_fun, prototype); |
1303 global_context()->set_script_function(*script_fun); | 1304 global_context()->set_script_function(*script_fun); |
1304 | 1305 |
1305 // Add 'source' and 'data' property to scripts. | 1306 // Add 'source' and 'data' property to scripts. |
1306 PropertyAttributes common_attributes = | 1307 PropertyAttributes common_attributes = |
1307 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1308 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
1308 Handle<Proxy> proxy_source = factory->NewProxy(&Accessors::ScriptSource); | 1309 Handle<Proxy> proxy_source = factory->NewProxy(&Accessors::ScriptSource); |
1309 Handle<DescriptorArray> script_descriptors = | 1310 Handle<DescriptorArray> script_descriptors = |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 HEAP->public_set_empty_script(*script); | 1415 HEAP->public_set_empty_script(*script); |
1415 } | 1416 } |
1416 { | 1417 { |
1417 // Builtin function for OpaqueReference -- a JSValue-based object, | 1418 // Builtin function for OpaqueReference -- a JSValue-based object, |
1418 // that keeps its field isolated from JavaScript code. It may store | 1419 // that keeps its field isolated from JavaScript code. It may store |
1419 // objects, that JavaScript code may not access. | 1420 // objects, that JavaScript code may not access. |
1420 Handle<JSFunction> opaque_reference_fun = | 1421 Handle<JSFunction> opaque_reference_fun = |
1421 InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE, | 1422 InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE, |
1422 JSValue::kSize, | 1423 JSValue::kSize, |
1423 isolate->initial_object_prototype(), | 1424 isolate->initial_object_prototype(), |
1424 Builtins::Illegal, false); | 1425 Builtins::kIllegal, false); |
1425 Handle<JSObject> prototype = | 1426 Handle<JSObject> prototype = |
1426 factory->NewJSObject(isolate->object_function(), TENURED); | 1427 factory->NewJSObject(isolate->object_function(), TENURED); |
1427 SetPrototype(opaque_reference_fun, prototype); | 1428 SetPrototype(opaque_reference_fun, prototype); |
1428 global_context()->set_opaque_reference_function(*opaque_reference_fun); | 1429 global_context()->set_opaque_reference_function(*opaque_reference_fun); |
1429 } | 1430 } |
1430 | 1431 |
1431 { // --- I n t e r n a l A r r a y --- | 1432 { // --- I n t e r n a l A r r a y --- |
1432 // An array constructor on the builtins object that works like | 1433 // An array constructor on the builtins object that works like |
1433 // the public Array constructor, except that its prototype | 1434 // the public Array constructor, except that its prototype |
1434 // doesn't inherit from Object.prototype. | 1435 // doesn't inherit from Object.prototype. |
1435 // To be used only for internal work by builtins. Instances | 1436 // To be used only for internal work by builtins. Instances |
1436 // must not be leaked to user code. | 1437 // must not be leaked to user code. |
1437 // Only works correctly when called as a constructor. The normal | 1438 // Only works correctly when called as a constructor. The normal |
1438 // Array code uses Array.prototype as prototype when called as | 1439 // Array code uses Array.prototype as prototype when called as |
1439 // a function. | 1440 // a function. |
1440 Handle<JSFunction> array_function = | 1441 Handle<JSFunction> array_function = |
1441 InstallFunction(builtins, | 1442 InstallFunction(builtins, |
1442 "InternalArray", | 1443 "InternalArray", |
1443 JS_ARRAY_TYPE, | 1444 JS_ARRAY_TYPE, |
1444 JSArray::kSize, | 1445 JSArray::kSize, |
1445 isolate->initial_object_prototype(), | 1446 isolate->initial_object_prototype(), |
1446 Builtins::ArrayCode, | 1447 Builtins::kArrayCode, |
1447 true); | 1448 true); |
1448 Handle<JSObject> prototype = | 1449 Handle<JSObject> prototype = |
1449 factory->NewJSObject(isolate->object_function(), TENURED); | 1450 factory->NewJSObject(isolate->object_function(), TENURED); |
1450 SetPrototype(array_function, prototype); | 1451 SetPrototype(array_function, prototype); |
1451 | 1452 |
1452 array_function->shared()->set_construct_stub( | 1453 array_function->shared()->set_construct_stub( |
1453 isolate->builtins()->builtin(Builtins::ArrayConstructCode)); | 1454 isolate->builtins()->builtin(Builtins::kArrayConstructCode)); |
1454 array_function->shared()->DontAdaptArguments(); | 1455 array_function->shared()->DontAdaptArguments(); |
1455 | 1456 |
1456 // Make "length" magic on instances. | 1457 // Make "length" magic on instances. |
1457 Handle<DescriptorArray> array_descriptors = | 1458 Handle<DescriptorArray> array_descriptors = |
1458 factory->CopyAppendProxyDescriptor( | 1459 factory->CopyAppendProxyDescriptor( |
1459 factory->empty_descriptor_array(), | 1460 factory->empty_descriptor_array(), |
1460 factory->length_symbol(), | 1461 factory->length_symbol(), |
1461 factory->NewProxy(&Accessors::ArrayLength), | 1462 factory->NewProxy(&Accessors::ArrayLength), |
1462 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); | 1463 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); |
1463 | 1464 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 { Handle<String> key = factory->function_class_symbol(); | 1499 { Handle<String> key = factory->function_class_symbol(); |
1499 Handle<JSFunction> function = | 1500 Handle<JSFunction> function = |
1500 Handle<JSFunction>::cast(GetProperty(isolate->global(), key)); | 1501 Handle<JSFunction>::cast(GetProperty(isolate->global(), key)); |
1501 Handle<JSObject> proto = | 1502 Handle<JSObject> proto = |
1502 Handle<JSObject>(JSObject::cast(function->instance_prototype())); | 1503 Handle<JSObject>(JSObject::cast(function->instance_prototype())); |
1503 | 1504 |
1504 // Install the call and the apply functions. | 1505 // Install the call and the apply functions. |
1505 Handle<JSFunction> call = | 1506 Handle<JSFunction> call = |
1506 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1507 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
1507 Handle<JSObject>::null(), | 1508 Handle<JSObject>::null(), |
1508 Builtins::FunctionCall, | 1509 Builtins::kFunctionCall, |
1509 false); | 1510 false); |
1510 Handle<JSFunction> apply = | 1511 Handle<JSFunction> apply = |
1511 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1512 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
1512 Handle<JSObject>::null(), | 1513 Handle<JSObject>::null(), |
1513 Builtins::FunctionApply, | 1514 Builtins::kFunctionApply, |
1514 false); | 1515 false); |
1515 | 1516 |
1516 // Make sure that Function.prototype.call appears to be compiled. | 1517 // Make sure that Function.prototype.call appears to be compiled. |
1517 // The code will never be called, but inline caching for call will | 1518 // The code will never be called, but inline caching for call will |
1518 // only work if it appears to be compiled. | 1519 // only work if it appears to be compiled. |
1519 call->shared()->DontAdaptArguments(); | 1520 call->shared()->DontAdaptArguments(); |
1520 ASSERT(call->is_compiled()); | 1521 ASSERT(call->is_compiled()); |
1521 | 1522 |
1522 // Set the expected parameters for apply to 2; required by builtin. | 1523 // Set the expected parameters for apply to 2; required by builtin. |
1523 apply->shared()->set_formal_parameter_count(2); | 1524 apply->shared()->set_formal_parameter_count(2); |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 return from + sizeof(NestingCounterType); | 2094 return from + sizeof(NestingCounterType); |
2094 } | 2095 } |
2095 | 2096 |
2096 | 2097 |
2097 // Called when the top-level V8 mutex is destroyed. | 2098 // Called when the top-level V8 mutex is destroyed. |
2098 void Bootstrapper::FreeThreadResources() { | 2099 void Bootstrapper::FreeThreadResources() { |
2099 ASSERT(!IsActive()); | 2100 ASSERT(!IsActive()); |
2100 } | 2101 } |
2101 | 2102 |
2102 } } // namespace v8::internal | 2103 } } // namespace v8::internal |
OLD | NEW |