| OLD | NEW |
| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 384 |
| 385 | 385 |
| 386 void Genesis::SetFunctionInstanceDescriptor( | 386 void Genesis::SetFunctionInstanceDescriptor( |
| 387 Handle<Map> map, PrototypePropertyMode prototypeMode) { | 387 Handle<Map> map, PrototypePropertyMode prototypeMode) { |
| 388 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; | 388 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; |
| 389 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); | 389 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); |
| 390 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 390 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 391 DONT_ENUM | DONT_DELETE | READ_ONLY); | 391 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 392 | 392 |
| 393 DescriptorArray::WhitenessWitness witness(*descriptors); | 393 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 394 map->set_instance_descriptors(*descriptors); |
| 394 | 395 |
| 395 { // Add length. | 396 { // Add length. |
| 396 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); | 397 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); |
| 397 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); | 398 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); |
| 398 descriptors->Append(&d, witness); | 399 map->AppendDescriptor(&d, witness); |
| 399 } | 400 } |
| 400 { // Add name. | 401 { // Add name. |
| 401 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); | 402 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); |
| 402 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); | 403 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); |
| 403 descriptors->Append(&d, witness); | 404 map->AppendDescriptor(&d, witness); |
| 404 } | 405 } |
| 405 { // Add arguments. | 406 { // Add arguments. |
| 406 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments)); | 407 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments)); |
| 407 CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs); | 408 CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs); |
| 408 descriptors->Append(&d, witness); | 409 map->AppendDescriptor(&d, witness); |
| 409 } | 410 } |
| 410 { // Add caller. | 411 { // Add caller. |
| 411 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller)); | 412 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller)); |
| 412 CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs); | 413 CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs); |
| 413 descriptors->Append(&d, witness); | 414 map->AppendDescriptor(&d, witness); |
| 414 } | 415 } |
| 415 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 416 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
| 416 // Add prototype. | 417 // Add prototype. |
| 417 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { | 418 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { |
| 418 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); | 419 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); |
| 419 } | 420 } |
| 420 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); | 421 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); |
| 421 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); | 422 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); |
| 422 descriptors->Append(&d, witness); | 423 map->AppendDescriptor(&d, witness); |
| 423 } | 424 } |
| 424 | |
| 425 map->set_instance_descriptors(*descriptors); | |
| 426 } | 425 } |
| 427 | 426 |
| 428 | 427 |
| 429 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { | 428 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { |
| 430 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 429 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
| 431 SetFunctionInstanceDescriptor(map, prototype_mode); | 430 SetFunctionInstanceDescriptor(map, prototype_mode); |
| 432 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); | 431 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); |
| 433 return map; | 432 return map; |
| 434 } | 433 } |
| 435 | 434 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 522 |
| 524 | 523 |
| 525 void Genesis::SetStrictFunctionInstanceDescriptor( | 524 void Genesis::SetStrictFunctionInstanceDescriptor( |
| 526 Handle<Map> map, PrototypePropertyMode prototypeMode) { | 525 Handle<Map> map, PrototypePropertyMode prototypeMode) { |
| 527 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; | 526 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; |
| 528 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); | 527 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); |
| 529 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 528 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 530 DONT_ENUM | DONT_DELETE); | 529 DONT_ENUM | DONT_DELETE); |
| 531 | 530 |
| 532 DescriptorArray::WhitenessWitness witness(*descriptors); | 531 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 532 map->set_instance_descriptors(*descriptors); |
| 533 | 533 |
| 534 { // Add length. | 534 { // Add length. |
| 535 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); | 535 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); |
| 536 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); | 536 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); |
| 537 descriptors->Append(&d, witness); | 537 map->AppendDescriptor(&d, witness); |
| 538 } | 538 } |
| 539 { // Add name. | 539 { // Add name. |
| 540 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); | 540 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); |
| 541 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); | 541 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); |
| 542 descriptors->Append(&d, witness); | 542 map->AppendDescriptor(&d, witness); |
| 543 } | 543 } |
| 544 { // Add arguments. | 544 { // Add arguments. |
| 545 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); | 545 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); |
| 546 CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs); | 546 CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs); |
| 547 descriptors->Append(&d, witness); | 547 map->AppendDescriptor(&d, witness); |
| 548 } | 548 } |
| 549 { // Add caller. | 549 { // Add caller. |
| 550 Handle<AccessorPair> caller(factory()->NewAccessorPair()); | 550 Handle<AccessorPair> caller(factory()->NewAccessorPair()); |
| 551 CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs); | 551 CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs); |
| 552 descriptors->Append(&d, witness); | 552 map->AppendDescriptor(&d, witness); |
| 553 } | 553 } |
| 554 | 554 |
| 555 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 555 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
| 556 // Add prototype. | 556 // Add prototype. |
| 557 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { | 557 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { |
| 558 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY); | 558 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY); |
| 559 } | 559 } |
| 560 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); | 560 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); |
| 561 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); | 561 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); |
| 562 descriptors->Append(&d, witness); | 562 map->AppendDescriptor(&d, witness); |
| 563 } | 563 } |
| 564 | |
| 565 map->set_instance_descriptors(*descriptors); | |
| 566 } | 564 } |
| 567 | 565 |
| 568 | 566 |
| 569 // ECMAScript 5th Edition, 13.2.3 | 567 // ECMAScript 5th Edition, 13.2.3 |
| 570 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { | 568 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
| 571 if (throw_type_error_function.is_null()) { | 569 if (throw_type_error_function.is_null()) { |
| 572 Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError"); | 570 Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError"); |
| 573 throw_type_error_function = | 571 throw_type_error_function = |
| 574 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); | 572 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); |
| 575 Handle<Code> code(isolate()->builtins()->builtin( | 573 Handle<Code> code(isolate()->builtins()->builtin( |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 | 861 |
| 864 // This seems a bit hackish, but we need to make sure Array.length | 862 // This seems a bit hackish, but we need to make sure Array.length |
| 865 // is 1. | 863 // is 1. |
| 866 array_function->shared()->set_length(1); | 864 array_function->shared()->set_length(1); |
| 867 | 865 |
| 868 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1)); | 866 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1)); |
| 869 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 867 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 870 DONT_ENUM | DONT_DELETE); | 868 DONT_ENUM | DONT_DELETE); |
| 871 | 869 |
| 872 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 870 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
| 871 array_function->initial_map()->set_instance_descriptors(*array_descriptors); |
| 873 | 872 |
| 874 { // Add length. | 873 { // Add length. |
| 875 Handle<Foreign> f(factory->NewForeign(&Accessors::ArrayLength)); | 874 Handle<Foreign> f(factory->NewForeign(&Accessors::ArrayLength)); |
| 876 CallbacksDescriptor d(*factory->length_symbol(), *f, attribs); | 875 CallbacksDescriptor d(*factory->length_symbol(), *f, attribs); |
| 877 array_descriptors->Append(&d, witness); | 876 array_function->initial_map()->AppendDescriptor(&d, witness); |
| 878 } | 877 } |
| 879 | 878 |
| 880 // array_function is used internally. JS code creating array object should | 879 // array_function is used internally. JS code creating array object should |
| 881 // search for the 'Array' property on the global object and use that one | 880 // search for the 'Array' property on the global object and use that one |
| 882 // as the constructor. 'Array' property on a global object can be | 881 // as the constructor. 'Array' property on a global object can be |
| 883 // overwritten by JS code. | 882 // overwritten by JS code. |
| 884 global_context()->set_array_function(*array_function); | 883 global_context()->set_array_function(*array_function); |
| 885 array_function->initial_map()->set_instance_descriptors(*array_descriptors); | |
| 886 } | 884 } |
| 887 | 885 |
| 888 { // --- N u m b e r --- | 886 { // --- N u m b e r --- |
| 889 Handle<JSFunction> number_fun = | 887 Handle<JSFunction> number_fun = |
| 890 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 888 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
| 891 isolate->initial_object_prototype(), | 889 isolate->initial_object_prototype(), |
| 892 Builtins::kIllegal, true); | 890 Builtins::kIllegal, true); |
| 893 global_context()->set_number_function(*number_fun); | 891 global_context()->set_number_function(*number_fun); |
| 894 } | 892 } |
| 895 | 893 |
| 896 { // --- B o o l e a n --- | 894 { // --- B o o l e a n --- |
| 897 Handle<JSFunction> boolean_fun = | 895 Handle<JSFunction> boolean_fun = |
| 898 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, | 896 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, |
| 899 isolate->initial_object_prototype(), | 897 isolate->initial_object_prototype(), |
| 900 Builtins::kIllegal, true); | 898 Builtins::kIllegal, true); |
| 901 global_context()->set_boolean_function(*boolean_fun); | 899 global_context()->set_boolean_function(*boolean_fun); |
| 902 } | 900 } |
| 903 | 901 |
| 904 { // --- S t r i n g --- | 902 { // --- S t r i n g --- |
| 905 Handle<JSFunction> string_fun = | 903 Handle<JSFunction> string_fun = |
| 906 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, | 904 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, |
| 907 isolate->initial_object_prototype(), | 905 isolate->initial_object_prototype(), |
| 908 Builtins::kIllegal, true); | 906 Builtins::kIllegal, true); |
| 909 string_fun->shared()->set_construct_stub( | 907 string_fun->shared()->set_construct_stub( |
| 910 isolate->builtins()->builtin(Builtins::kStringConstructCode)); | 908 isolate->builtins()->builtin(Builtins::kStringConstructCode)); |
| 911 global_context()->set_string_function(*string_fun); | 909 global_context()->set_string_function(*string_fun); |
| 912 | 910 |
| 911 Handle<Map> string_map = |
| 912 Handle<Map>(global_context()->string_function()->initial_map()); |
| 913 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1)); | 913 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1)); |
| 914 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 914 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 915 DONT_ENUM | DONT_DELETE | READ_ONLY); | 915 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 916 | 916 |
| 917 DescriptorArray::WhitenessWitness witness(*string_descriptors); | 917 DescriptorArray::WhitenessWitness witness(*string_descriptors); |
| 918 string_map->set_instance_descriptors(*string_descriptors); |
| 918 | 919 |
| 919 { // Add length. | 920 { // Add length. |
| 920 Handle<Foreign> f(factory->NewForeign(&Accessors::StringLength)); | 921 Handle<Foreign> f(factory->NewForeign(&Accessors::StringLength)); |
| 921 CallbacksDescriptor d(*factory->length_symbol(), *f, attribs); | 922 CallbacksDescriptor d(*factory->length_symbol(), *f, attribs); |
| 922 string_descriptors->Append(&d, witness); | 923 string_map->AppendDescriptor(&d, witness); |
| 923 } | 924 } |
| 924 | |
| 925 Handle<Map> string_map = | |
| 926 Handle<Map>(global_context()->string_function()->initial_map()); | |
| 927 string_map->set_instance_descriptors(*string_descriptors); | |
| 928 } | 925 } |
| 929 | 926 |
| 930 { // --- D a t e --- | 927 { // --- D a t e --- |
| 931 // Builtin functions for Date.prototype. | 928 // Builtin functions for Date.prototype. |
| 932 Handle<JSFunction> date_fun = | 929 Handle<JSFunction> date_fun = |
| 933 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, | 930 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, |
| 934 isolate->initial_object_prototype(), | 931 isolate->initial_object_prototype(), |
| 935 Builtins::kIllegal, true); | 932 Builtins::kIllegal, true); |
| 936 | 933 |
| 937 global_context()->set_date_function(*date_fun); | 934 global_context()->set_date_function(*date_fun); |
| 938 } | 935 } |
| 939 | 936 |
| 940 | 937 |
| 941 { // -- R e g E x p | 938 { // -- R e g E x p |
| 942 // Builtin functions for RegExp.prototype. | 939 // Builtin functions for RegExp.prototype. |
| 943 Handle<JSFunction> regexp_fun = | 940 Handle<JSFunction> regexp_fun = |
| 944 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 941 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
| 945 isolate->initial_object_prototype(), | 942 isolate->initial_object_prototype(), |
| 946 Builtins::kIllegal, true); | 943 Builtins::kIllegal, true); |
| 947 global_context()->set_regexp_function(*regexp_fun); | 944 global_context()->set_regexp_function(*regexp_fun); |
| 948 | 945 |
| 949 ASSERT(regexp_fun->has_initial_map()); | 946 ASSERT(regexp_fun->has_initial_map()); |
| 950 Handle<Map> initial_map(regexp_fun->initial_map()); | 947 Handle<Map> initial_map(regexp_fun->initial_map()); |
| 951 | 948 |
| 952 ASSERT_EQ(0, initial_map->inobject_properties()); | 949 ASSERT_EQ(0, initial_map->inobject_properties()); |
| 953 | 950 |
| 951 PropertyAttributes final = |
| 952 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 954 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); | 953 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); |
| 955 DescriptorArray::WhitenessWitness witness(*descriptors); | 954 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 956 PropertyAttributes final = | 955 initial_map->set_instance_descriptors(*descriptors); |
| 957 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 956 |
| 958 { | 957 { |
| 959 // ECMA-262, section 15.10.7.1. | 958 // ECMA-262, section 15.10.7.1. |
| 960 FieldDescriptor field(heap->source_symbol(), | 959 FieldDescriptor field(heap->source_symbol(), |
| 961 JSRegExp::kSourceFieldIndex, | 960 JSRegExp::kSourceFieldIndex, |
| 962 final); | 961 final); |
| 963 descriptors->Append(&field, witness); | 962 initial_map->AppendDescriptor(&field, witness); |
| 964 } | 963 } |
| 965 { | 964 { |
| 966 // ECMA-262, section 15.10.7.2. | 965 // ECMA-262, section 15.10.7.2. |
| 967 FieldDescriptor field(heap->global_symbol(), | 966 FieldDescriptor field(heap->global_symbol(), |
| 968 JSRegExp::kGlobalFieldIndex, | 967 JSRegExp::kGlobalFieldIndex, |
| 969 final); | 968 final); |
| 970 descriptors->Append(&field, witness); | 969 initial_map->AppendDescriptor(&field, witness); |
| 971 } | 970 } |
| 972 { | 971 { |
| 973 // ECMA-262, section 15.10.7.3. | 972 // ECMA-262, section 15.10.7.3. |
| 974 FieldDescriptor field(heap->ignore_case_symbol(), | 973 FieldDescriptor field(heap->ignore_case_symbol(), |
| 975 JSRegExp::kIgnoreCaseFieldIndex, | 974 JSRegExp::kIgnoreCaseFieldIndex, |
| 976 final); | 975 final); |
| 977 descriptors->Append(&field, witness); | 976 initial_map->AppendDescriptor(&field, witness); |
| 978 } | 977 } |
| 979 { | 978 { |
| 980 // ECMA-262, section 15.10.7.4. | 979 // ECMA-262, section 15.10.7.4. |
| 981 FieldDescriptor field(heap->multiline_symbol(), | 980 FieldDescriptor field(heap->multiline_symbol(), |
| 982 JSRegExp::kMultilineFieldIndex, | 981 JSRegExp::kMultilineFieldIndex, |
| 983 final); | 982 final); |
| 984 descriptors->Append(&field, witness); | 983 initial_map->AppendDescriptor(&field, witness); |
| 985 } | 984 } |
| 986 { | 985 { |
| 987 // ECMA-262, section 15.10.7.5. | 986 // ECMA-262, section 15.10.7.5. |
| 988 PropertyAttributes writable = | 987 PropertyAttributes writable = |
| 989 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 988 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 990 FieldDescriptor field(heap->last_index_symbol(), | 989 FieldDescriptor field(heap->last_index_symbol(), |
| 991 JSRegExp::kLastIndexFieldIndex, | 990 JSRegExp::kLastIndexFieldIndex, |
| 992 writable); | 991 writable); |
| 993 descriptors->Append(&field, witness); | 992 initial_map->AppendDescriptor(&field, witness); |
| 994 } | 993 } |
| 995 initial_map->set_instance_descriptors(*descriptors); | |
| 996 | 994 |
| 997 initial_map->set_inobject_properties(5); | 995 initial_map->set_inobject_properties(5); |
| 998 initial_map->set_pre_allocated_property_fields(5); | 996 initial_map->set_pre_allocated_property_fields(5); |
| 999 initial_map->set_unused_property_fields(0); | 997 initial_map->set_unused_property_fields(0); |
| 1000 initial_map->set_instance_size( | 998 initial_map->set_instance_size( |
| 1001 initial_map->instance_size() + 5 * kPointerSize); | 999 initial_map->instance_size() + 5 * kPointerSize); |
| 1002 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); | 1000 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); |
| 1003 | 1001 |
| 1004 // RegExp prototype object is itself a RegExp. | 1002 // RegExp prototype object is itself a RegExp. |
| 1005 Handle<Map> proto_map = factory->CopyMap(initial_map); | 1003 Handle<Map> proto_map = factory->CopyMap(initial_map); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 callee->set_setter(*throw_function); | 1129 callee->set_setter(*throw_function); |
| 1132 caller->set_getter(*throw_function); | 1130 caller->set_getter(*throw_function); |
| 1133 caller->set_setter(*throw_function); | 1131 caller->set_setter(*throw_function); |
| 1134 | 1132 |
| 1135 // Create the map. Allocate one in-object field for length. | 1133 // Create the map. Allocate one in-object field for length. |
| 1136 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, | 1134 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, |
| 1137 Heap::kArgumentsObjectSizeStrict); | 1135 Heap::kArgumentsObjectSizeStrict); |
| 1138 // Create the descriptor array for the arguments object. | 1136 // Create the descriptor array for the arguments object. |
| 1139 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 1137 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); |
| 1140 DescriptorArray::WhitenessWitness witness(*descriptors); | 1138 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 1139 map->set_instance_descriptors(*descriptors); |
| 1140 |
| 1141 { // length | 1141 { // length |
| 1142 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); | 1142 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); |
| 1143 descriptors->Append(&d, witness); | 1143 map->AppendDescriptor(&d, witness); |
| 1144 } | 1144 } |
| 1145 { // callee | 1145 { // callee |
| 1146 CallbacksDescriptor d(*factory->callee_symbol(), | 1146 CallbacksDescriptor d(*factory->callee_symbol(), |
| 1147 *callee, | 1147 *callee, |
| 1148 attributes); | 1148 attributes); |
| 1149 descriptors->Append(&d, witness); | 1149 map->AppendDescriptor(&d, witness); |
| 1150 } | 1150 } |
| 1151 { // caller | 1151 { // caller |
| 1152 CallbacksDescriptor d(*factory->caller_symbol(), | 1152 CallbacksDescriptor d(*factory->caller_symbol(), |
| 1153 *caller, | 1153 *caller, |
| 1154 attributes); | 1154 attributes); |
| 1155 descriptors->Append(&d, witness); | 1155 map->AppendDescriptor(&d, witness); |
| 1156 } | 1156 } |
| 1157 map->set_instance_descriptors(*descriptors); | |
| 1158 | 1157 |
| 1159 map->set_function_with_prototype(true); | 1158 map->set_function_with_prototype(true); |
| 1160 map->set_prototype(global_context()->object_function()->prototype()); | 1159 map->set_prototype(global_context()->object_function()->prototype()); |
| 1161 map->set_pre_allocated_property_fields(1); | 1160 map->set_pre_allocated_property_fields(1); |
| 1162 map->set_inobject_properties(1); | 1161 map->set_inobject_properties(1); |
| 1163 | 1162 |
| 1164 // Copy constructor from the non-strict arguments boilerplate. | 1163 // Copy constructor from the non-strict arguments boilerplate. |
| 1165 map->set_constructor( | 1164 map->set_constructor( |
| 1166 global_context()->arguments_boilerplate()->map()->constructor()); | 1165 global_context()->arguments_boilerplate()->map()->constructor()); |
| 1167 | 1166 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 | 1475 |
| 1477 PropertyAttributes attribs = | 1476 PropertyAttributes attribs = |
| 1478 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1477 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 1479 | 1478 |
| 1480 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); | 1479 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); |
| 1481 | 1480 |
| 1482 Handle<DescriptorArray> script_descriptors( | 1481 Handle<DescriptorArray> script_descriptors( |
| 1483 factory()->NewDescriptorArray(13)); | 1482 factory()->NewDescriptorArray(13)); |
| 1484 | 1483 |
| 1485 DescriptorArray::WhitenessWitness witness(*script_descriptors); | 1484 DescriptorArray::WhitenessWitness witness(*script_descriptors); |
| 1485 script_map->set_instance_descriptors(*script_descriptors); |
| 1486 | 1486 |
| 1487 { | 1487 { |
| 1488 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptSource)); | 1488 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptSource)); |
| 1489 CallbacksDescriptor d( | 1489 CallbacksDescriptor d( |
| 1490 *factory()->LookupAsciiSymbol("source"), *f, attribs); | 1490 *factory()->LookupAsciiSymbol("source"), *f, attribs); |
| 1491 script_descriptors->Append(&d, witness); | 1491 script_map->AppendDescriptor(&d, witness); |
| 1492 } | 1492 } |
| 1493 | 1493 |
| 1494 { | 1494 { |
| 1495 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptName)); | 1495 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptName)); |
| 1496 CallbacksDescriptor d( | 1496 CallbacksDescriptor d( |
| 1497 *factory()->LookupAsciiSymbol("name"), *f, attribs); | 1497 *factory()->LookupAsciiSymbol("name"), *f, attribs); |
| 1498 script_descriptors->Append(&d, witness); | 1498 script_map->AppendDescriptor(&d, witness); |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 { | 1501 { |
| 1502 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptId)); | 1502 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptId)); |
| 1503 CallbacksDescriptor d( | 1503 CallbacksDescriptor d( |
| 1504 *factory()->LookupAsciiSymbol("id"), *f, attribs); | 1504 *factory()->LookupAsciiSymbol("id"), *f, attribs); |
| 1505 script_descriptors->Append(&d, witness); | 1505 script_map->AppendDescriptor(&d, witness); |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 { | 1508 { |
| 1509 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptLineOffset)); | 1509 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptLineOffset)); |
| 1510 CallbacksDescriptor d( | 1510 CallbacksDescriptor d( |
| 1511 *factory()->LookupAsciiSymbol("line_offset"), *f, attribs); | 1511 *factory()->LookupAsciiSymbol("line_offset"), *f, attribs); |
| 1512 script_descriptors->Append(&d, witness); | 1512 script_map->AppendDescriptor(&d, witness); |
| 1513 } | 1513 } |
| 1514 | 1514 |
| 1515 { | 1515 { |
| 1516 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptColumnOffset)); | 1516 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptColumnOffset)); |
| 1517 CallbacksDescriptor d( | 1517 CallbacksDescriptor d( |
| 1518 *factory()->LookupAsciiSymbol("column_offset"), *f, attribs); | 1518 *factory()->LookupAsciiSymbol("column_offset"), *f, attribs); |
| 1519 script_descriptors->Append(&d, witness); | 1519 script_map->AppendDescriptor(&d, witness); |
| 1520 } | 1520 } |
| 1521 | 1521 |
| 1522 { | 1522 { |
| 1523 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptData)); | 1523 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptData)); |
| 1524 CallbacksDescriptor d( | 1524 CallbacksDescriptor d( |
| 1525 *factory()->LookupAsciiSymbol("data"), *f, attribs); | 1525 *factory()->LookupAsciiSymbol("data"), *f, attribs); |
| 1526 script_descriptors->Append(&d, witness); | 1526 script_map->AppendDescriptor(&d, witness); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 { | 1529 { |
| 1530 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptType)); | 1530 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptType)); |
| 1531 CallbacksDescriptor d( | 1531 CallbacksDescriptor d( |
| 1532 *factory()->LookupAsciiSymbol("type"), *f, attribs); | 1532 *factory()->LookupAsciiSymbol("type"), *f, attribs); |
| 1533 script_descriptors->Append(&d, witness); | 1533 script_map->AppendDescriptor(&d, witness); |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 { | 1536 { |
| 1537 Handle<Foreign> f(factory()->NewForeign( | 1537 Handle<Foreign> f(factory()->NewForeign( |
| 1538 &Accessors::ScriptCompilationType)); | 1538 &Accessors::ScriptCompilationType)); |
| 1539 CallbacksDescriptor d( | 1539 CallbacksDescriptor d( |
| 1540 *factory()->LookupAsciiSymbol("compilation_type"), *f, attribs); | 1540 *factory()->LookupAsciiSymbol("compilation_type"), *f, attribs); |
| 1541 script_descriptors->Append(&d, witness); | 1541 script_map->AppendDescriptor(&d, witness); |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 { | 1544 { |
| 1545 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptLineEnds)); | 1545 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptLineEnds)); |
| 1546 CallbacksDescriptor d( | 1546 CallbacksDescriptor d( |
| 1547 *factory()->LookupAsciiSymbol("line_ends"), *f, attribs); | 1547 *factory()->LookupAsciiSymbol("line_ends"), *f, attribs); |
| 1548 script_descriptors->Append(&d, witness); | 1548 script_map->AppendDescriptor(&d, witness); |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 { | 1551 { |
| 1552 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptContextData)); | 1552 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptContextData)); |
| 1553 CallbacksDescriptor d( | 1553 CallbacksDescriptor d( |
| 1554 *factory()->LookupAsciiSymbol("context_data"), *f, attribs); | 1554 *factory()->LookupAsciiSymbol("context_data"), *f, attribs); |
| 1555 script_descriptors->Append(&d, witness); | 1555 script_map->AppendDescriptor(&d, witness); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 { | 1558 { |
| 1559 Handle<Foreign> f(factory()->NewForeign( | 1559 Handle<Foreign> f(factory()->NewForeign( |
| 1560 &Accessors::ScriptEvalFromScript)); | 1560 &Accessors::ScriptEvalFromScript)); |
| 1561 CallbacksDescriptor d( | 1561 CallbacksDescriptor d( |
| 1562 *factory()->LookupAsciiSymbol("eval_from_script"), *f, attribs); | 1562 *factory()->LookupAsciiSymbol("eval_from_script"), *f, attribs); |
| 1563 script_descriptors->Append(&d, witness); | 1563 script_map->AppendDescriptor(&d, witness); |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 { | 1566 { |
| 1567 Handle<Foreign> f(factory()->NewForeign( | 1567 Handle<Foreign> f(factory()->NewForeign( |
| 1568 &Accessors::ScriptEvalFromScriptPosition)); | 1568 &Accessors::ScriptEvalFromScriptPosition)); |
| 1569 CallbacksDescriptor d( | 1569 CallbacksDescriptor d( |
| 1570 *factory()->LookupAsciiSymbol("eval_from_script_position"), | 1570 *factory()->LookupAsciiSymbol("eval_from_script_position"), |
| 1571 *f, | 1571 *f, |
| 1572 attribs); | 1572 attribs); |
| 1573 script_descriptors->Append(&d, witness); | 1573 script_map->AppendDescriptor(&d, witness); |
| 1574 } | 1574 } |
| 1575 | 1575 |
| 1576 { | 1576 { |
| 1577 Handle<Foreign> f(factory()->NewForeign( | 1577 Handle<Foreign> f(factory()->NewForeign( |
| 1578 &Accessors::ScriptEvalFromFunctionName)); | 1578 &Accessors::ScriptEvalFromFunctionName)); |
| 1579 CallbacksDescriptor d( | 1579 CallbacksDescriptor d( |
| 1580 *factory()->LookupAsciiSymbol("eval_from_function_name"), | 1580 *factory()->LookupAsciiSymbol("eval_from_function_name"), |
| 1581 *f, | 1581 *f, |
| 1582 attribs); | 1582 attribs); |
| 1583 script_descriptors->Append(&d, witness); | 1583 script_map->AppendDescriptor(&d, witness); |
| 1584 } | 1584 } |
| 1585 | 1585 |
| 1586 script_map->set_instance_descriptors(*script_descriptors); | |
| 1587 | |
| 1588 // Allocate the empty script. | 1586 // Allocate the empty script. |
| 1589 Handle<Script> script = factory()->NewScript(factory()->empty_string()); | 1587 Handle<Script> script = factory()->NewScript(factory()->empty_string()); |
| 1590 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 1588 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 1591 heap()->public_set_empty_script(*script); | 1589 heap()->public_set_empty_script(*script); |
| 1592 } | 1590 } |
| 1593 { | 1591 { |
| 1594 // Builtin function for OpaqueReference -- a JSValue-based object, | 1592 // Builtin function for OpaqueReference -- a JSValue-based object, |
| 1595 // that keeps its field isolated from JavaScript code. It may store | 1593 // that keeps its field isolated from JavaScript code. It may store |
| 1596 // objects, that JavaScript code may not access. | 1594 // objects, that JavaScript code may not access. |
| 1597 Handle<JSFunction> opaque_reference_fun = | 1595 Handle<JSFunction> opaque_reference_fun = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 if (!maybe_map->To(&new_map)) return false; | 1636 if (!maybe_map->To(&new_map)) return false; |
| 1639 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); | 1637 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); |
| 1640 array_function->set_initial_map(new_map); | 1638 array_function->set_initial_map(new_map); |
| 1641 | 1639 |
| 1642 // Make "length" magic on instances. | 1640 // Make "length" magic on instances. |
| 1643 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1)); | 1641 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1)); |
| 1644 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 1642 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 1645 DONT_ENUM | DONT_DELETE); | 1643 DONT_ENUM | DONT_DELETE); |
| 1646 | 1644 |
| 1647 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 1645 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
| 1646 array_function->initial_map()->set_instance_descriptors(*array_descriptors); |
| 1648 | 1647 |
| 1649 { // Add length. | 1648 { // Add length. |
| 1650 Handle<Foreign> f(factory()->NewForeign(&Accessors::ArrayLength)); | 1649 Handle<Foreign> f(factory()->NewForeign(&Accessors::ArrayLength)); |
| 1651 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); | 1650 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); |
| 1652 array_descriptors->Append(&d, witness); | 1651 array_function->initial_map()->AppendDescriptor(&d, witness); |
| 1653 } | 1652 } |
| 1654 | 1653 |
| 1655 array_function->initial_map()->set_instance_descriptors(*array_descriptors); | |
| 1656 | |
| 1657 global_context()->set_internal_array_function(*array_function); | 1654 global_context()->set_internal_array_function(*array_function); |
| 1658 } | 1655 } |
| 1659 | 1656 |
| 1660 if (FLAG_disable_native_files) { | 1657 if (FLAG_disable_native_files) { |
| 1661 PrintF("Warning: Running without installed natives!\n"); | 1658 PrintF("Warning: Running without installed natives!\n"); |
| 1662 return true; | 1659 return true; |
| 1663 } | 1660 } |
| 1664 | 1661 |
| 1665 // Install natives. | 1662 // Install natives. |
| 1666 for (int i = Natives::GetDebuggerCount(); | 1663 for (int i = Natives::GetDebuggerCount(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 initial_map->set_constructor(*array_constructor); | 1731 initial_map->set_constructor(*array_constructor); |
| 1735 | 1732 |
| 1736 // Set prototype on map. | 1733 // Set prototype on map. |
| 1737 initial_map->set_non_instance_prototype(false); | 1734 initial_map->set_non_instance_prototype(false); |
| 1738 initial_map->set_prototype(*array_prototype); | 1735 initial_map->set_prototype(*array_prototype); |
| 1739 | 1736 |
| 1740 // Update map with length accessor from Array and add "index" and "input". | 1737 // Update map with length accessor from Array and add "index" and "input". |
| 1741 Handle<DescriptorArray> reresult_descriptors = | 1738 Handle<DescriptorArray> reresult_descriptors = |
| 1742 factory()->NewDescriptorArray(3); | 1739 factory()->NewDescriptorArray(3); |
| 1743 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); | 1740 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); |
| 1741 initial_map->set_instance_descriptors(*reresult_descriptors); |
| 1744 | 1742 |
| 1745 JSFunction* array_function = global_context()->array_function(); | 1743 { |
| 1746 Handle<DescriptorArray> array_descriptors( | 1744 JSFunction* array_function = global_context()->array_function(); |
| 1747 array_function->initial_map()->instance_descriptors()); | 1745 Handle<DescriptorArray> array_descriptors( |
| 1748 int old = array_descriptors->SearchWithCache(heap()->length_symbol()); | 1746 array_function->initial_map()->instance_descriptors()); |
| 1749 reresult_descriptors->CopyFrom(0, *array_descriptors, old, witness); | 1747 String* length = heap()->length_symbol(); |
| 1750 | 1748 int old = array_descriptors->SearchWithCache(length); |
| 1751 reresult_descriptors->SetLastAdded(0); | 1749 ASSERT(old != DescriptorArray::kNotFound); |
| 1752 | 1750 CallbacksDescriptor desc(length, |
| 1751 array_descriptors->GetValue(old), |
| 1752 array_descriptors->GetDetails(old).attributes()); |
| 1753 initial_map->AppendDescriptor(&desc, witness); |
| 1754 } |
| 1753 { | 1755 { |
| 1754 FieldDescriptor index_field(heap()->index_symbol(), | 1756 FieldDescriptor index_field(heap()->index_symbol(), |
| 1755 JSRegExpResult::kIndexIndex, | 1757 JSRegExpResult::kIndexIndex, |
| 1756 NONE); | 1758 NONE); |
| 1757 reresult_descriptors->Append(&index_field, witness); | 1759 initial_map->AppendDescriptor(&index_field, witness); |
| 1758 } | 1760 } |
| 1759 | 1761 |
| 1760 { | 1762 { |
| 1761 FieldDescriptor input_field(heap()->input_symbol(), | 1763 FieldDescriptor input_field(heap()->input_symbol(), |
| 1762 JSRegExpResult::kInputIndex, | 1764 JSRegExpResult::kInputIndex, |
| 1763 NONE); | 1765 NONE); |
| 1764 reresult_descriptors->Append(&input_field, witness); | 1766 initial_map->AppendDescriptor(&input_field, witness); |
| 1765 } | 1767 } |
| 1766 initial_map->set_instance_descriptors(*reresult_descriptors); | |
| 1767 | 1768 |
| 1768 initial_map->set_inobject_properties(2); | 1769 initial_map->set_inobject_properties(2); |
| 1769 initial_map->set_pre_allocated_property_fields(2); | 1770 initial_map->set_pre_allocated_property_fields(2); |
| 1770 initial_map->set_unused_property_fields(0); | 1771 initial_map->set_unused_property_fields(0); |
| 1771 | 1772 |
| 1772 global_context()->set_regexp_result_map(*initial_map); | 1773 global_context()->set_regexp_result_map(*initial_map); |
| 1773 } | 1774 } |
| 1774 | 1775 |
| 1775 #ifdef DEBUG | 1776 #ifdef DEBUG |
| 1776 builtins->Verify(); | 1777 builtins->Verify(); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 return from + sizeof(NestingCounterType); | 2363 return from + sizeof(NestingCounterType); |
| 2363 } | 2364 } |
| 2364 | 2365 |
| 2365 | 2366 |
| 2366 // Called when the top-level V8 mutex is destroyed. | 2367 // Called when the top-level V8 mutex is destroyed. |
| 2367 void Bootstrapper::FreeThreadResources() { | 2368 void Bootstrapper::FreeThreadResources() { |
| 2368 ASSERT(!IsActive()); | 2369 ASSERT(!IsActive()); |
| 2369 } | 2370 } |
| 2370 | 2371 |
| 2371 } } // namespace v8::internal | 2372 } } // namespace v8::internal |
| OLD | NEW |