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

Side by Side Diff: src/bootstrapper.cc

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

Powered by Google App Engine
This is Rietveld 408576698