| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); | 387 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); |
| 388 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 388 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 389 DONT_ENUM | DONT_DELETE | READ_ONLY); | 389 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 390 | 390 |
| 391 DescriptorArray::WhitenessWitness witness(*descriptors); | 391 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 392 | 392 |
| 393 int index = 0; | 393 int index = 0; |
| 394 | 394 |
| 395 { // Add length. | 395 { // Add length. |
| 396 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); | 396 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); |
| 397 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs, index + 1); | 397 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); |
| 398 descriptors->Set(index, &d, witness); | 398 descriptors->Append(index++, &d, witness); |
| 399 ++index; | |
| 400 } | 399 } |
| 401 { // Add name. | 400 { // Add name. |
| 402 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); | 401 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); |
| 403 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs, index + 1); | 402 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); |
| 404 descriptors->Set(index, &d, witness); | 403 descriptors->Append(index++, &d, witness); |
| 405 ++index; | |
| 406 } | 404 } |
| 407 { // Add arguments. | 405 { // Add arguments. |
| 408 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments)); | 406 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments)); |
| 409 CallbacksDescriptor d( | 407 CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs); |
| 410 *factory()->arguments_symbol(), *f, attribs, index + 1); | 408 descriptors->Append(index++, &d, witness); |
| 411 descriptors->Set(index, &d, witness); | |
| 412 ++index; | |
| 413 } | 409 } |
| 414 { // Add caller. | 410 { // Add caller. |
| 415 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller)); | 411 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller)); |
| 416 CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs, index + 1); | 412 CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs); |
| 417 descriptors->Set(index, &d, witness); | 413 descriptors->Append(index++, &d, witness); |
| 418 ++index; | |
| 419 } | 414 } |
| 420 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 415 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
| 421 // Add prototype. | 416 // Add prototype. |
| 422 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { | 417 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { |
| 423 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); | 418 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); |
| 424 } | 419 } |
| 425 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); | 420 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); |
| 426 CallbacksDescriptor d( | 421 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); |
| 427 *factory()->prototype_symbol(), *f, attribs, index + 1); | 422 descriptors->Append(index, &d, witness); |
| 428 descriptors->Set(index, &d, witness); | |
| 429 } | 423 } |
| 430 | 424 |
| 431 descriptors->Sort(witness); | 425 descriptors->Sort(witness); |
| 432 return descriptors; | 426 return descriptors; |
| 433 } | 427 } |
| 434 | 428 |
| 435 | 429 |
| 436 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { | 430 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { |
| 437 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 431 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
| 438 Handle<DescriptorArray> descriptors = | 432 Handle<DescriptorArray> descriptors = |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; | 532 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; |
| 539 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); | 533 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); |
| 540 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 534 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 541 DONT_ENUM | DONT_DELETE); | 535 DONT_ENUM | DONT_DELETE); |
| 542 | 536 |
| 543 DescriptorArray::WhitenessWitness witness(*descriptors); | 537 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 544 | 538 |
| 545 int index = 0; | 539 int index = 0; |
| 546 { // Add length. | 540 { // Add length. |
| 547 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); | 541 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); |
| 548 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs, index + 1); | 542 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); |
| 549 descriptors->Set(index, &d, witness); | 543 descriptors->Append(index++, &d, witness); |
| 550 ++index; | |
| 551 } | 544 } |
| 552 { // Add name. | 545 { // Add name. |
| 553 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); | 546 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); |
| 554 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs, index + 1); | 547 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); |
| 555 descriptors->Set(index, &d, witness); | 548 descriptors->Append(index++, &d, witness); |
| 556 ++index; | |
| 557 } | 549 } |
| 558 { // Add arguments. | 550 { // Add arguments. |
| 559 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); | 551 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); |
| 560 CallbacksDescriptor d( | 552 CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs); |
| 561 *factory()->arguments_symbol(), *arguments, attribs, index + 1); | 553 descriptors->Append(index++, &d, witness); |
| 562 descriptors->Set(index, &d, witness); | |
| 563 ++index; | |
| 564 } | 554 } |
| 565 { // Add caller. | 555 { // Add caller. |
| 566 Handle<AccessorPair> caller(factory()->NewAccessorPair()); | 556 Handle<AccessorPair> caller(factory()->NewAccessorPair()); |
| 567 CallbacksDescriptor d( | 557 CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs); |
| 568 *factory()->caller_symbol(), *caller, attribs, index + 1); | 558 descriptors->Append(index++, &d, witness); |
| 569 descriptors->Set(index, &d, witness); | |
| 570 ++index; | |
| 571 } | 559 } |
| 572 | 560 |
| 573 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 561 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
| 574 // Add prototype. | 562 // Add prototype. |
| 575 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { | 563 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { |
| 576 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY); | 564 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY); |
| 577 } | 565 } |
| 578 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); | 566 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); |
| 579 CallbacksDescriptor d( | 567 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); |
| 580 *factory()->prototype_symbol(), *f, attribs, index + 1); | 568 descriptors->Append(index, &d, witness); |
| 581 descriptors->Set(index, &d, witness); | |
| 582 } | 569 } |
| 583 | 570 |
| 584 descriptors->Sort(witness); | 571 descriptors->Sort(witness); |
| 585 return descriptors; | 572 return descriptors; |
| 586 } | 573 } |
| 587 | 574 |
| 588 | 575 |
| 589 // ECMAScript 5th Edition, 13.2.3 | 576 // ECMAScript 5th Edition, 13.2.3 |
| 590 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { | 577 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
| 591 if (throw_type_error_function.is_null()) { | 578 if (throw_type_error_function.is_null()) { |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 952 |
| 966 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); | 953 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); |
| 967 DescriptorArray::WhitenessWitness witness(*descriptors); | 954 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 968 PropertyAttributes final = | 955 PropertyAttributes final = |
| 969 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 956 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 970 int index = 0; | 957 int index = 0; |
| 971 { | 958 { |
| 972 // ECMA-262, section 15.10.7.1. | 959 // ECMA-262, section 15.10.7.1. |
| 973 FieldDescriptor field(heap->source_symbol(), | 960 FieldDescriptor field(heap->source_symbol(), |
| 974 JSRegExp::kSourceFieldIndex, | 961 JSRegExp::kSourceFieldIndex, |
| 975 final, | 962 final); |
| 976 index + 1); | 963 descriptors->Append(index++, &field, witness); |
| 977 descriptors->Set(index, &field, witness); | |
| 978 ++index; | |
| 979 } | 964 } |
| 980 { | 965 { |
| 981 // ECMA-262, section 15.10.7.2. | 966 // ECMA-262, section 15.10.7.2. |
| 982 FieldDescriptor field(heap->global_symbol(), | 967 FieldDescriptor field(heap->global_symbol(), |
| 983 JSRegExp::kGlobalFieldIndex, | 968 JSRegExp::kGlobalFieldIndex, |
| 984 final, | 969 final); |
| 985 index + 1); | 970 descriptors->Append(index++, &field, witness); |
| 986 descriptors->Set(index, &field, witness); | |
| 987 ++index; | |
| 988 } | 971 } |
| 989 { | 972 { |
| 990 // ECMA-262, section 15.10.7.3. | 973 // ECMA-262, section 15.10.7.3. |
| 991 FieldDescriptor field(heap->ignore_case_symbol(), | 974 FieldDescriptor field(heap->ignore_case_symbol(), |
| 992 JSRegExp::kIgnoreCaseFieldIndex, | 975 JSRegExp::kIgnoreCaseFieldIndex, |
| 993 final, | 976 final); |
| 994 index + 1); | 977 descriptors->Append(index++, &field, witness); |
| 995 descriptors->Set(index, &field, witness); | |
| 996 ++index; | |
| 997 } | 978 } |
| 998 { | 979 { |
| 999 // ECMA-262, section 15.10.7.4. | 980 // ECMA-262, section 15.10.7.4. |
| 1000 FieldDescriptor field(heap->multiline_symbol(), | 981 FieldDescriptor field(heap->multiline_symbol(), |
| 1001 JSRegExp::kMultilineFieldIndex, | 982 JSRegExp::kMultilineFieldIndex, |
| 1002 final, | 983 final); |
| 1003 index + 1); | 984 descriptors->Append(index++, &field, witness); |
| 1004 descriptors->Set(index, &field, witness); | |
| 1005 ++index; | |
| 1006 } | 985 } |
| 1007 { | 986 { |
| 1008 // ECMA-262, section 15.10.7.5. | 987 // ECMA-262, section 15.10.7.5. |
| 1009 PropertyAttributes writable = | 988 PropertyAttributes writable = |
| 1010 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 989 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 1011 FieldDescriptor field(heap->last_index_symbol(), | 990 FieldDescriptor field(heap->last_index_symbol(), |
| 1012 JSRegExp::kLastIndexFieldIndex, | 991 JSRegExp::kLastIndexFieldIndex, |
| 1013 writable, | 992 writable); |
| 1014 index + 1); | 993 descriptors->Append(index, &field, witness); |
| 1015 descriptors->Set(index, &field, witness); | |
| 1016 } | 994 } |
| 1017 descriptors->Sort(witness); | 995 descriptors->Sort(witness); |
| 1018 | 996 |
| 1019 initial_map->set_inobject_properties(5); | 997 initial_map->set_inobject_properties(5); |
| 1020 initial_map->set_pre_allocated_property_fields(5); | 998 initial_map->set_pre_allocated_property_fields(5); |
| 1021 initial_map->set_unused_property_fields(0); | 999 initial_map->set_unused_property_fields(0); |
| 1022 initial_map->set_instance_size( | 1000 initial_map->set_instance_size( |
| 1023 initial_map->instance_size() + 5 * kPointerSize); | 1001 initial_map->instance_size() + 5 * kPointerSize); |
| 1024 initial_map->set_instance_descriptors(*descriptors); | 1002 initial_map->set_instance_descriptors(*descriptors); |
| 1025 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); | 1003 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 callee->set_getter(*throw_function); | 1131 callee->set_getter(*throw_function); |
| 1154 callee->set_setter(*throw_function); | 1132 callee->set_setter(*throw_function); |
| 1155 caller->set_getter(*throw_function); | 1133 caller->set_getter(*throw_function); |
| 1156 caller->set_setter(*throw_function); | 1134 caller->set_setter(*throw_function); |
| 1157 | 1135 |
| 1158 // Create the descriptor array for the arguments object. | 1136 // Create the descriptor array for the arguments object. |
| 1159 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 1137 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); |
| 1160 DescriptorArray::WhitenessWitness witness(*descriptors); | 1138 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 1161 int index = 0; | 1139 int index = 0; |
| 1162 { // length | 1140 { // length |
| 1163 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM, index + 1); | 1141 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); |
| 1164 descriptors->Set(index, &d, witness); | 1142 descriptors->Append(index++, &d, witness); |
| 1165 ++index; | |
| 1166 } | 1143 } |
| 1167 { // callee | 1144 { // callee |
| 1168 CallbacksDescriptor d(*factory->callee_symbol(), | 1145 CallbacksDescriptor d(*factory->callee_symbol(), |
| 1169 *callee, | 1146 *callee, |
| 1170 attributes, | 1147 attributes); |
| 1171 index + 1); | 1148 descriptors->Append(index++, &d, witness); |
| 1172 descriptors->Set(index, &d, witness); | |
| 1173 ++index; | |
| 1174 } | 1149 } |
| 1175 { // caller | 1150 { // caller |
| 1176 CallbacksDescriptor d(*factory->caller_symbol(), | 1151 CallbacksDescriptor d(*factory->caller_symbol(), |
| 1177 *caller, | 1152 *caller, |
| 1178 attributes, | 1153 attributes); |
| 1179 index + 1); | 1154 descriptors->Append(index++, &d, witness); |
| 1180 descriptors->Set(index, &d, witness); | |
| 1181 } | 1155 } |
| 1182 descriptors->Sort(witness); | 1156 descriptors->Sort(witness); |
| 1183 | 1157 |
| 1184 // Create the map. Allocate one in-object field for length. | 1158 // Create the map. Allocate one in-object field for length. |
| 1185 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, | 1159 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, |
| 1186 Heap::kArgumentsObjectSizeStrict); | 1160 Heap::kArgumentsObjectSizeStrict); |
| 1187 map->set_instance_descriptors(*descriptors); | 1161 map->set_instance_descriptors(*descriptors); |
| 1188 map->set_function_with_prototype(true); | 1162 map->set_function_with_prototype(true); |
| 1189 map->set_prototype(global_context()->object_function()->prototype()); | 1163 map->set_prototype(global_context()->object_function()->prototype()); |
| 1190 map->set_pre_allocated_property_fields(1); | 1164 map->set_pre_allocated_property_fields(1); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1772 array_function->initial_map()->instance_descriptors()); | 1746 array_function->initial_map()->instance_descriptors()); |
| 1773 int old = array_descriptors->SearchWithCache(heap()->length_symbol()); | 1747 int old = array_descriptors->SearchWithCache(heap()->length_symbol()); |
| 1774 MaybeObject* copy_result = | 1748 MaybeObject* copy_result = |
| 1775 reresult_descriptors->CopyFrom(0, *array_descriptors, old, witness); | 1749 reresult_descriptors->CopyFrom(0, *array_descriptors, old, witness); |
| 1776 if (copy_result->IsFailure()) return false; | 1750 if (copy_result->IsFailure()) return false; |
| 1777 | 1751 |
| 1778 int index = 1; | 1752 int index = 1; |
| 1779 { | 1753 { |
| 1780 FieldDescriptor index_field(heap()->index_symbol(), | 1754 FieldDescriptor index_field(heap()->index_symbol(), |
| 1781 JSRegExpResult::kIndexIndex, | 1755 JSRegExpResult::kIndexIndex, |
| 1782 NONE, | 1756 NONE); |
| 1783 index + 1); | 1757 reresult_descriptors->Append(index++, &index_field, witness); |
| 1784 reresult_descriptors->Set(index, &index_field, witness); | |
| 1785 ++index; | |
| 1786 } | 1758 } |
| 1787 | 1759 |
| 1788 { | 1760 { |
| 1789 FieldDescriptor input_field(heap()->input_symbol(), | 1761 FieldDescriptor input_field(heap()->input_symbol(), |
| 1790 JSRegExpResult::kInputIndex, | 1762 JSRegExpResult::kInputIndex, |
| 1791 NONE, | 1763 NONE); |
| 1792 index + 1); | 1764 reresult_descriptors->Append(index, &input_field, witness); |
| 1793 reresult_descriptors->Set(index, &input_field, witness); | |
| 1794 } | 1765 } |
| 1795 reresult_descriptors->Sort(witness); | 1766 reresult_descriptors->Sort(witness); |
| 1796 | 1767 |
| 1797 initial_map->set_inobject_properties(2); | 1768 initial_map->set_inobject_properties(2); |
| 1798 initial_map->set_pre_allocated_property_fields(2); | 1769 initial_map->set_pre_allocated_property_fields(2); |
| 1799 initial_map->set_unused_property_fields(0); | 1770 initial_map->set_unused_property_fields(0); |
| 1800 initial_map->set_instance_descriptors(*reresult_descriptors); | 1771 initial_map->set_instance_descriptors(*reresult_descriptors); |
| 1801 | 1772 |
| 1802 global_context()->set_regexp_result_map(*initial_map); | 1773 global_context()->set_regexp_result_map(*initial_map); |
| 1803 } | 1774 } |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 return from + sizeof(NestingCounterType); | 2360 return from + sizeof(NestingCounterType); |
| 2390 } | 2361 } |
| 2391 | 2362 |
| 2392 | 2363 |
| 2393 // Called when the top-level V8 mutex is destroyed. | 2364 // Called when the top-level V8 mutex is destroyed. |
| 2394 void Bootstrapper::FreeThreadResources() { | 2365 void Bootstrapper::FreeThreadResources() { |
| 2395 ASSERT(!IsActive()); | 2366 ASSERT(!IsActive()); |
| 2396 } | 2367 } |
| 2397 | 2368 |
| 2398 } } // namespace v8::internal | 2369 } } // namespace v8::internal |
| OLD | NEW |