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

Side by Side Diff: src/bootstrapper.cc

Issue 10692185: Couple the enumeration index of a property to the size of the descriptor array where it first appea… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use the enumeration index of the LastAdded descriptor for appending. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( 384 Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor(
385 PrototypePropertyMode prototypeMode) { 385 PrototypePropertyMode prototypeMode) {
386 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 386 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
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;
394
395 { // Add length. 393 { // Add length.
396 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); 394 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength));
397 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs, index + 1); 395 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs);
398 descriptors->Set(index, &d, witness); 396 descriptors->Append(&d, witness);
399 ++index;
400 } 397 }
401 { // Add name. 398 { // Add name.
402 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); 399 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName));
403 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs, index + 1); 400 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs);
404 descriptors->Set(index, &d, witness); 401 descriptors->Append(&d, witness);
405 ++index;
406 } 402 }
407 { // Add arguments. 403 { // Add arguments.
408 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments)); 404 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments));
409 CallbacksDescriptor d( 405 CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs);
410 *factory()->arguments_symbol(), *f, attribs, index + 1); 406 descriptors->Append(&d, witness);
411 descriptors->Set(index, &d, witness);
412 ++index;
413 } 407 }
414 { // Add caller. 408 { // Add caller.
415 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller)); 409 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller));
416 CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs, index + 1); 410 CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs);
417 descriptors->Set(index, &d, witness); 411 descriptors->Append(&d, witness);
418 ++index;
419 } 412 }
420 if (prototypeMode != DONT_ADD_PROTOTYPE) { 413 if (prototypeMode != DONT_ADD_PROTOTYPE) {
421 // Add prototype. 414 // Add prototype.
422 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { 415 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
423 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); 416 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY);
424 } 417 }
425 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); 418 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype));
426 CallbacksDescriptor d( 419 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs);
427 *factory()->prototype_symbol(), *f, attribs, index + 1); 420 descriptors->Append(&d, witness);
428 descriptors->Set(index, &d, witness);
429 } 421 }
430 422
431 descriptors->Sort(witness); 423 descriptors->Sort(witness);
432 return descriptors; 424 return descriptors;
433 } 425 }
434 426
435 427
436 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { 428 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
437 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 429 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
438 Handle<DescriptorArray> descriptors = 430 Handle<DescriptorArray> descriptors =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 527
536 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( 528 Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
537 PrototypePropertyMode prototypeMode) { 529 PrototypePropertyMode prototypeMode) {
538 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 530 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
539 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); 531 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size));
540 PropertyAttributes attribs = static_cast<PropertyAttributes>( 532 PropertyAttributes attribs = static_cast<PropertyAttributes>(
541 DONT_ENUM | DONT_DELETE); 533 DONT_ENUM | DONT_DELETE);
542 534
543 DescriptorArray::WhitenessWitness witness(*descriptors); 535 DescriptorArray::WhitenessWitness witness(*descriptors);
544 536
545 int index = 0;
546 { // Add length. 537 { // Add length.
547 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength)); 538 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength));
548 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs, index + 1); 539 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs);
549 descriptors->Set(index, &d, witness); 540 descriptors->Append(&d, witness);
550 ++index;
551 } 541 }
552 { // Add name. 542 { // Add name.
553 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName)); 543 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName));
554 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs, index + 1); 544 CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs);
555 descriptors->Set(index, &d, witness); 545 descriptors->Append(&d, witness);
556 ++index;
557 } 546 }
558 { // Add arguments. 547 { // Add arguments.
559 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); 548 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
560 CallbacksDescriptor d( 549 CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs);
561 *factory()->arguments_symbol(), *arguments, attribs, index + 1); 550 descriptors->Append(&d, witness);
562 descriptors->Set(index, &d, witness);
563 ++index;
564 } 551 }
565 { // Add caller. 552 { // Add caller.
566 Handle<AccessorPair> caller(factory()->NewAccessorPair()); 553 Handle<AccessorPair> caller(factory()->NewAccessorPair());
567 CallbacksDescriptor d( 554 CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs);
568 *factory()->caller_symbol(), *caller, attribs, index + 1); 555 descriptors->Append(&d, witness);
569 descriptors->Set(index, &d, witness);
570 ++index;
571 } 556 }
572 557
573 if (prototypeMode != DONT_ADD_PROTOTYPE) { 558 if (prototypeMode != DONT_ADD_PROTOTYPE) {
574 // Add prototype. 559 // Add prototype.
575 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { 560 if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) {
576 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY); 561 attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY);
577 } 562 }
578 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype)); 563 Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype));
579 CallbacksDescriptor d( 564 CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs);
580 *factory()->prototype_symbol(), *f, attribs, index + 1); 565 descriptors->Append(&d, witness);
581 descriptors->Set(index, &d, witness);
582 } 566 }
583 567
584 descriptors->Sort(witness); 568 descriptors->Sort(witness);
585 return descriptors; 569 return descriptors;
586 } 570 }
587 571
588 572
589 // ECMAScript 5th Edition, 13.2.3 573 // ECMAScript 5th Edition, 13.2.3
590 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 574 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
591 if (throw_type_error_function.is_null()) { 575 if (throw_type_error_function.is_null()) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 944
961 ASSERT(regexp_fun->has_initial_map()); 945 ASSERT(regexp_fun->has_initial_map());
962 Handle<Map> initial_map(regexp_fun->initial_map()); 946 Handle<Map> initial_map(regexp_fun->initial_map());
963 947
964 ASSERT_EQ(0, initial_map->inobject_properties()); 948 ASSERT_EQ(0, initial_map->inobject_properties());
965 949
966 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); 950 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5);
967 DescriptorArray::WhitenessWitness witness(*descriptors); 951 DescriptorArray::WhitenessWitness witness(*descriptors);
968 PropertyAttributes final = 952 PropertyAttributes final =
969 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 953 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
970 int index = 0;
971 { 954 {
972 // ECMA-262, section 15.10.7.1. 955 // ECMA-262, section 15.10.7.1.
973 FieldDescriptor field(heap->source_symbol(), 956 FieldDescriptor field(heap->source_symbol(),
974 JSRegExp::kSourceFieldIndex, 957 JSRegExp::kSourceFieldIndex,
975 final, 958 final);
976 index + 1); 959 descriptors->Append(&field, witness);
977 descriptors->Set(index, &field, witness);
978 ++index;
979 } 960 }
980 { 961 {
981 // ECMA-262, section 15.10.7.2. 962 // ECMA-262, section 15.10.7.2.
982 FieldDescriptor field(heap->global_symbol(), 963 FieldDescriptor field(heap->global_symbol(),
983 JSRegExp::kGlobalFieldIndex, 964 JSRegExp::kGlobalFieldIndex,
984 final, 965 final);
985 index + 1); 966 descriptors->Append(&field, witness);
986 descriptors->Set(index, &field, witness);
987 ++index;
988 } 967 }
989 { 968 {
990 // ECMA-262, section 15.10.7.3. 969 // ECMA-262, section 15.10.7.3.
991 FieldDescriptor field(heap->ignore_case_symbol(), 970 FieldDescriptor field(heap->ignore_case_symbol(),
992 JSRegExp::kIgnoreCaseFieldIndex, 971 JSRegExp::kIgnoreCaseFieldIndex,
993 final, 972 final);
994 index + 1); 973 descriptors->Append(&field, witness);
995 descriptors->Set(index, &field, witness);
996 ++index;
997 } 974 }
998 { 975 {
999 // ECMA-262, section 15.10.7.4. 976 // ECMA-262, section 15.10.7.4.
1000 FieldDescriptor field(heap->multiline_symbol(), 977 FieldDescriptor field(heap->multiline_symbol(),
1001 JSRegExp::kMultilineFieldIndex, 978 JSRegExp::kMultilineFieldIndex,
1002 final, 979 final);
1003 index + 1); 980 descriptors->Append(&field, witness);
1004 descriptors->Set(index, &field, witness);
1005 ++index;
1006 } 981 }
1007 { 982 {
1008 // ECMA-262, section 15.10.7.5. 983 // ECMA-262, section 15.10.7.5.
1009 PropertyAttributes writable = 984 PropertyAttributes writable =
1010 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 985 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1011 FieldDescriptor field(heap->last_index_symbol(), 986 FieldDescriptor field(heap->last_index_symbol(),
1012 JSRegExp::kLastIndexFieldIndex, 987 JSRegExp::kLastIndexFieldIndex,
1013 writable, 988 writable);
1014 index + 1); 989 descriptors->Append(&field, witness);
1015 descriptors->Set(index, &field, witness);
1016 } 990 }
1017 descriptors->Sort(witness); 991 descriptors->Sort(witness);
1018 992
1019 initial_map->set_inobject_properties(5); 993 initial_map->set_inobject_properties(5);
1020 initial_map->set_pre_allocated_property_fields(5); 994 initial_map->set_pre_allocated_property_fields(5);
1021 initial_map->set_unused_property_fields(0); 995 initial_map->set_unused_property_fields(0);
1022 initial_map->set_instance_size( 996 initial_map->set_instance_size(
1023 initial_map->instance_size() + 5 * kPointerSize); 997 initial_map->instance_size() + 5 * kPointerSize);
1024 initial_map->set_instance_descriptors(*descriptors); 998 initial_map->set_instance_descriptors(*descriptors);
1025 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); 999 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 1125
1152 // Install the ThrowTypeError functions. 1126 // Install the ThrowTypeError functions.
1153 callee->set_getter(*throw_function); 1127 callee->set_getter(*throw_function);
1154 callee->set_setter(*throw_function); 1128 callee->set_setter(*throw_function);
1155 caller->set_getter(*throw_function); 1129 caller->set_getter(*throw_function);
1156 caller->set_setter(*throw_function); 1130 caller->set_setter(*throw_function);
1157 1131
1158 // Create the descriptor array for the arguments object. 1132 // Create the descriptor array for the arguments object.
1159 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); 1133 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
1160 DescriptorArray::WhitenessWitness witness(*descriptors); 1134 DescriptorArray::WhitenessWitness witness(*descriptors);
1161 int index = 0;
1162 { // length 1135 { // length
1163 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM, index + 1); 1136 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
1164 descriptors->Set(index, &d, witness); 1137 descriptors->Append(&d, witness);
1165 ++index;
1166 } 1138 }
1167 { // callee 1139 { // callee
1168 CallbacksDescriptor d(*factory->callee_symbol(), 1140 CallbacksDescriptor d(*factory->callee_symbol(),
1169 *callee, 1141 *callee,
1170 attributes, 1142 attributes);
1171 index + 1); 1143 descriptors->Append(&d, witness);
1172 descriptors->Set(index, &d, witness);
1173 ++index;
1174 } 1144 }
1175 { // caller 1145 { // caller
1176 CallbacksDescriptor d(*factory->caller_symbol(), 1146 CallbacksDescriptor d(*factory->caller_symbol(),
1177 *caller, 1147 *caller,
1178 attributes, 1148 attributes);
1179 index + 1); 1149 descriptors->Append(&d, witness);
1180 descriptors->Set(index, &d, witness);
1181 } 1150 }
1182 descriptors->Sort(witness); 1151 descriptors->Sort(witness);
1183 1152
1184 // Create the map. Allocate one in-object field for length. 1153 // Create the map. Allocate one in-object field for length.
1185 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, 1154 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1186 Heap::kArgumentsObjectSizeStrict); 1155 Heap::kArgumentsObjectSizeStrict);
1187 map->set_instance_descriptors(*descriptors); 1156 map->set_instance_descriptors(*descriptors);
1188 map->set_function_with_prototype(true); 1157 map->set_function_with_prototype(true);
1189 map->set_prototype(global_context()->object_function()->prototype()); 1158 map->set_prototype(global_context()->object_function()->prototype());
1190 map->set_pre_allocated_property_fields(1); 1159 map->set_pre_allocated_property_fields(1);
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); 1737 DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
1769 1738
1770 JSFunction* array_function = global_context()->array_function(); 1739 JSFunction* array_function = global_context()->array_function();
1771 Handle<DescriptorArray> array_descriptors( 1740 Handle<DescriptorArray> array_descriptors(
1772 array_function->initial_map()->instance_descriptors()); 1741 array_function->initial_map()->instance_descriptors());
1773 int old = array_descriptors->SearchWithCache(heap()->length_symbol()); 1742 int old = array_descriptors->SearchWithCache(heap()->length_symbol());
1774 MaybeObject* copy_result = 1743 MaybeObject* copy_result =
1775 reresult_descriptors->CopyFrom(0, *array_descriptors, old, witness); 1744 reresult_descriptors->CopyFrom(0, *array_descriptors, old, witness);
1776 if (copy_result->IsFailure()) return false; 1745 if (copy_result->IsFailure()) return false;
1777 1746
1778 int index = 1; 1747 reresult_descriptors->SetLastAdded(0);
1748
1779 { 1749 {
1780 FieldDescriptor index_field(heap()->index_symbol(), 1750 FieldDescriptor index_field(heap()->index_symbol(),
1781 JSRegExpResult::kIndexIndex, 1751 JSRegExpResult::kIndexIndex,
1782 NONE, 1752 NONE);
1783 index + 1); 1753 reresult_descriptors->Append(&index_field, witness);
1784 reresult_descriptors->Set(index, &index_field, witness);
1785 ++index;
1786 } 1754 }
1787 1755
1788 { 1756 {
1789 FieldDescriptor input_field(heap()->input_symbol(), 1757 FieldDescriptor input_field(heap()->input_symbol(),
1790 JSRegExpResult::kInputIndex, 1758 JSRegExpResult::kInputIndex,
1791 NONE, 1759 NONE);
1792 index + 1); 1760 reresult_descriptors->Append(&input_field, witness);
1793 reresult_descriptors->Set(index, &input_field, witness);
1794 } 1761 }
1795 reresult_descriptors->Sort(witness); 1762 reresult_descriptors->Sort(witness);
1796 1763
1797 initial_map->set_inobject_properties(2); 1764 initial_map->set_inobject_properties(2);
1798 initial_map->set_pre_allocated_property_fields(2); 1765 initial_map->set_pre_allocated_property_fields(2);
1799 initial_map->set_unused_property_fields(0); 1766 initial_map->set_unused_property_fields(0);
1800 initial_map->set_instance_descriptors(*reresult_descriptors); 1767 initial_map->set_instance_descriptors(*reresult_descriptors);
1801 1768
1802 global_context()->set_regexp_result_map(*initial_map); 1769 global_context()->set_regexp_result_map(*initial_map);
1803 } 1770 }
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 return from + sizeof(NestingCounterType); 2356 return from + sizeof(NestingCounterType);
2390 } 2357 }
2391 2358
2392 2359
2393 // Called when the top-level V8 mutex is destroyed. 2360 // Called when the top-level V8 mutex is destroyed.
2394 void Bootstrapper::FreeThreadResources() { 2361 void Bootstrapper::FreeThreadResources() {
2395 ASSERT(!IsActive()); 2362 ASSERT(!IsActive());
2396 } 2363 }
2397 2364
2398 } } // namespace v8::internal 2365 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698