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

Side by Side Diff: src/bootstrapper.cc

Issue 10816005: Swapped transition array and descriptor array. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 8 years, 4 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
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 392 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
393 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 393 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
394 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); 394 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments));
395 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); 395 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller));
396 Handle<Foreign> prototype; 396 Handle<Foreign> prototype;
397 if (prototypeMode != DONT_ADD_PROTOTYPE) { 397 if (prototypeMode != DONT_ADD_PROTOTYPE) {
398 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 398 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
399 } 399 }
400 PropertyAttributes attribs = static_cast<PropertyAttributes>( 400 PropertyAttributes attribs = static_cast<PropertyAttributes>(
401 DONT_ENUM | DONT_DELETE | READ_ONLY); 401 DONT_ENUM | DONT_DELETE | READ_ONLY);
402 map->set_instance_descriptors(*descriptors); 402
Michael Starzinger 2012/08/07 13:55:04 Drop the empty newline.
403 Map::SetDescriptors(map, descriptors);
403 404
404 { // Add length. 405 { // Add length.
405 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); 406 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs);
406 map->AppendDescriptor(&d, witness); 407 map->AppendDescriptor(&d, witness);
407 } 408 }
408 { // Add name. 409 { // Add name.
409 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); 410 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs);
410 map->AppendDescriptor(&d, witness); 411 map->AppendDescriptor(&d, witness);
411 } 412 }
412 { // Add arguments. 413 { // Add arguments.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 534 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
534 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 535 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
535 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); 536 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
536 Handle<AccessorPair> caller(factory()->NewAccessorPair()); 537 Handle<AccessorPair> caller(factory()->NewAccessorPair());
537 Handle<Foreign> prototype; 538 Handle<Foreign> prototype;
538 if (prototypeMode != DONT_ADD_PROTOTYPE) { 539 if (prototypeMode != DONT_ADD_PROTOTYPE) {
539 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 540 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
540 } 541 }
541 PropertyAttributes attribs = static_cast<PropertyAttributes>( 542 PropertyAttributes attribs = static_cast<PropertyAttributes>(
542 DONT_ENUM | DONT_DELETE); 543 DONT_ENUM | DONT_DELETE);
543 map->set_instance_descriptors(*descriptors); 544
Michael Starzinger 2012/08/07 13:55:04 Drop the empty newline.
Toon Verwaest 2012/08/10 12:32:52 Done.
545 Map::SetDescriptors(map, descriptors);
544 546
545 { // Add length. 547 { // Add length.
546 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); 548 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs);
547 map->AppendDescriptor(&d, witness); 549 map->AppendDescriptor(&d, witness);
548 } 550 }
549 { // Add name. 551 { // Add name.
550 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); 552 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs);
551 map->AppendDescriptor(&d, witness); 553 map->AppendDescriptor(&d, witness);
552 } 554 }
553 { // Add arguments. 555 { // Add arguments.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 isolate->initial_object_prototype(), 862 isolate->initial_object_prototype(),
861 Builtins::kArrayCode, true); 863 Builtins::kArrayCode, true);
862 array_function->shared()->set_construct_stub( 864 array_function->shared()->set_construct_stub(
863 isolate->builtins()->builtin(Builtins::kArrayConstructCode)); 865 isolate->builtins()->builtin(Builtins::kArrayConstructCode));
864 array_function->shared()->DontAdaptArguments(); 866 array_function->shared()->DontAdaptArguments();
865 867
866 // This seems a bit hackish, but we need to make sure Array.length 868 // This seems a bit hackish, but we need to make sure Array.length
867 // is 1. 869 // is 1.
868 array_function->shared()->set_length(1); 870 array_function->shared()->set_length(1);
869 871
872 Handle<Map> initial_map(array_function->initial_map());
870 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1)); 873 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1));
871 DescriptorArray::WhitenessWitness witness(*array_descriptors); 874 DescriptorArray::WhitenessWitness witness(*array_descriptors);
872 875
873 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); 876 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength));
874 PropertyAttributes attribs = static_cast<PropertyAttributes>( 877 PropertyAttributes attribs = static_cast<PropertyAttributes>(
875 DONT_ENUM | DONT_DELETE); 878 DONT_ENUM | DONT_DELETE);
876 array_function->initial_map()->set_instance_descriptors(*array_descriptors); 879 Map::SetDescriptors(initial_map, array_descriptors);
877 880
878 { // Add length. 881 { // Add length.
879 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); 882 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs);
880 array_function->initial_map()->AppendDescriptor(&d, witness); 883 array_function->initial_map()->AppendDescriptor(&d, witness);
881 } 884 }
882 885
883 // array_function is used internally. JS code creating array object should 886 // array_function is used internally. JS code creating array object should
884 // search for the 'Array' property on the global object and use that one 887 // search for the 'Array' property on the global object and use that one
885 // as the constructor. 'Array' property on a global object can be 888 // as the constructor. 'Array' property on a global object can be
886 // overwritten by JS code. 889 // overwritten by JS code.
(...skipping 27 matching lines...) Expand all
914 917
915 Handle<Map> string_map = 918 Handle<Map> string_map =
916 Handle<Map>(global_context()->string_function()->initial_map()); 919 Handle<Map>(global_context()->string_function()->initial_map());
917 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1)); 920 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1));
918 DescriptorArray::WhitenessWitness witness(*string_descriptors); 921 DescriptorArray::WhitenessWitness witness(*string_descriptors);
919 922
920 Handle<Foreign> string_length( 923 Handle<Foreign> string_length(
921 factory->NewForeign(&Accessors::StringLength)); 924 factory->NewForeign(&Accessors::StringLength));
922 PropertyAttributes attribs = static_cast<PropertyAttributes>( 925 PropertyAttributes attribs = static_cast<PropertyAttributes>(
923 DONT_ENUM | DONT_DELETE | READ_ONLY); 926 DONT_ENUM | DONT_DELETE | READ_ONLY);
924 string_map->set_instance_descriptors(*string_descriptors); 927 Map::SetDescriptors(string_map, string_descriptors);
925 928
926 { // Add length. 929 { // Add length.
927 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); 930 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs);
928 string_map->AppendDescriptor(&d, witness); 931 string_map->AppendDescriptor(&d, witness);
929 } 932 }
930 } 933 }
931 934
932 { // --- D a t e --- 935 { // --- D a t e ---
933 // Builtin functions for Date.prototype. 936 // Builtin functions for Date.prototype.
934 Handle<JSFunction> date_fun = 937 Handle<JSFunction> date_fun =
(...skipping 15 matching lines...) Expand all
950 953
951 ASSERT(regexp_fun->has_initial_map()); 954 ASSERT(regexp_fun->has_initial_map());
952 Handle<Map> initial_map(regexp_fun->initial_map()); 955 Handle<Map> initial_map(regexp_fun->initial_map());
953 956
954 ASSERT_EQ(0, initial_map->inobject_properties()); 957 ASSERT_EQ(0, initial_map->inobject_properties());
955 958
956 PropertyAttributes final = 959 PropertyAttributes final =
957 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 960 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
958 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); 961 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5);
959 DescriptorArray::WhitenessWitness witness(*descriptors); 962 DescriptorArray::WhitenessWitness witness(*descriptors);
960 initial_map->set_instance_descriptors(*descriptors); 963 Map::SetDescriptors(initial_map, descriptors);
961 964
962 { 965 {
963 // ECMA-262, section 15.10.7.1. 966 // ECMA-262, section 15.10.7.1.
964 FieldDescriptor field(heap->source_symbol(), 967 FieldDescriptor field(heap->source_symbol(),
965 JSRegExp::kSourceFieldIndex, 968 JSRegExp::kSourceFieldIndex,
966 final); 969 final);
967 initial_map->AppendDescriptor(&field, witness); 970 initial_map->AppendDescriptor(&field, witness);
968 } 971 }
969 { 972 {
970 // ECMA-262, section 15.10.7.2. 973 // ECMA-262, section 15.10.7.2.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 callee->set_setter(*throw_function); 1137 callee->set_setter(*throw_function);
1135 caller->set_getter(*throw_function); 1138 caller->set_getter(*throw_function);
1136 caller->set_setter(*throw_function); 1139 caller->set_setter(*throw_function);
1137 1140
1138 // Create the map. Allocate one in-object field for length. 1141 // Create the map. Allocate one in-object field for length.
1139 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, 1142 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1140 Heap::kArgumentsObjectSizeStrict); 1143 Heap::kArgumentsObjectSizeStrict);
1141 // Create the descriptor array for the arguments object. 1144 // Create the descriptor array for the arguments object.
1142 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); 1145 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
1143 DescriptorArray::WhitenessWitness witness(*descriptors); 1146 DescriptorArray::WhitenessWitness witness(*descriptors);
1144 map->set_instance_descriptors(*descriptors); 1147 Map::SetDescriptors(map, descriptors);
1145 1148
1146 { // length 1149 { // length
1147 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); 1150 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
1148 map->AppendDescriptor(&d, witness); 1151 map->AppendDescriptor(&d, witness);
1149 } 1152 }
1150 { // callee 1153 { // callee
1151 CallbacksDescriptor d(*factory->callee_symbol(), 1154 CallbacksDescriptor d(*factory->callee_symbol(),
1152 *callee, 1155 *callee,
1153 attributes); 1156 attributes);
1154 map->AppendDescriptor(&d, witness); 1157 map->AppendDescriptor(&d, witness);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 Handle<String> eval_from_script_position_symbol( 1522 Handle<String> eval_from_script_position_symbol(
1520 factory()->LookupAsciiSymbol("eval_from_script_position")); 1523 factory()->LookupAsciiSymbol("eval_from_script_position"));
1521 Handle<Foreign> script_eval_from_script_position( 1524 Handle<Foreign> script_eval_from_script_position(
1522 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); 1525 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition));
1523 Handle<String> eval_from_function_name_symbol( 1526 Handle<String> eval_from_function_name_symbol(
1524 factory()->LookupAsciiSymbol("eval_from_function_name")); 1527 factory()->LookupAsciiSymbol("eval_from_function_name"));
1525 Handle<Foreign> script_eval_from_function_name( 1528 Handle<Foreign> script_eval_from_function_name(
1526 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); 1529 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName));
1527 PropertyAttributes attribs = 1530 PropertyAttributes attribs =
1528 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1531 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1529 script_map->set_instance_descriptors(*script_descriptors); 1532 Map::SetDescriptors(script_map, script_descriptors);
1530 1533
1531 { 1534 {
1532 CallbacksDescriptor d( 1535 CallbacksDescriptor d(
1533 *factory()->source_symbol(), *script_source, attribs); 1536 *factory()->source_symbol(), *script_source, attribs);
1534 script_map->AppendDescriptor(&d, witness); 1537 script_map->AppendDescriptor(&d, witness);
1535 } 1538 }
1536 1539
1537 { 1540 {
1538 CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs); 1541 CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs);
1539 script_map->AppendDescriptor(&d, witness); 1542 script_map->AppendDescriptor(&d, witness);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 1647
1645 array_function->shared()->set_construct_stub( 1648 array_function->shared()->set_construct_stub(
1646 isolate()->builtins()->builtin(Builtins::kArrayConstructCode)); 1649 isolate()->builtins()->builtin(Builtins::kArrayConstructCode));
1647 array_function->shared()->DontAdaptArguments(); 1650 array_function->shared()->DontAdaptArguments();
1648 1651
1649 // InternalArrays should not use Smi-Only array optimizations. There are too 1652 // InternalArrays should not use Smi-Only array optimizations. There are too
1650 // many places in the C++ runtime code (e.g. RegEx) that assume that 1653 // many places in the C++ runtime code (e.g. RegEx) that assume that
1651 // elements in InternalArrays can be set to non-Smi values without going 1654 // elements in InternalArrays can be set to non-Smi values without going
1652 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT 1655 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT
1653 // transition easy to trap. Moreover, they rarely are smi-only. 1656 // transition easy to trap. Moreover, they rarely are smi-only.
1654 MaybeObject* maybe_map = 1657 MaybeObject* maybe_map = array_function->initial_map()->Copy();
1655 array_function->initial_map()->Copy(DescriptorArray::MAY_BE_SHARED);
1656 Map* new_map; 1658 Map* new_map;
1657 if (!maybe_map->To(&new_map)) return false; 1659 if (!maybe_map->To(&new_map)) return false;
1658 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); 1660 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS);
1659 array_function->set_initial_map(new_map); 1661 array_function->set_initial_map(new_map);
1660 1662
1661 // Make "length" magic on instances. 1663 // Make "length" magic on instances.
1664 Handle<Map> initial_map(array_function->initial_map());
1662 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1)); 1665 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1));
1663 DescriptorArray::WhitenessWitness witness(*array_descriptors); 1666 DescriptorArray::WhitenessWitness witness(*array_descriptors);
1664 1667
1665 Handle<Foreign> array_length(factory()->NewForeign( 1668 Handle<Foreign> array_length(factory()->NewForeign(
1666 &Accessors::ArrayLength)); 1669 &Accessors::ArrayLength));
1667 PropertyAttributes attribs = static_cast<PropertyAttributes>( 1670 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1668 DONT_ENUM | DONT_DELETE); 1671 DONT_ENUM | DONT_DELETE);
1669 array_function->initial_map()->set_instance_descriptors(*array_descriptors); 1672 Map::SetDescriptors(initial_map, array_descriptors);
1670 1673
1671 { // Add length. 1674 { // Add length.
1672 CallbacksDescriptor d( 1675 CallbacksDescriptor d(
1673 *factory()->length_symbol(), *array_length, attribs); 1676 *factory()->length_symbol(), *array_length, attribs);
1674 array_function->initial_map()->AppendDescriptor(&d, witness); 1677 array_function->initial_map()->AppendDescriptor(&d, witness);
1675 } 1678 }
1676 1679
1677 global_context()->set_internal_array_function(*array_function); 1680 global_context()->set_internal_array_function(*array_function);
1678 } 1681 }
1679 1682
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 initial_map->set_constructor(*array_constructor); 1757 initial_map->set_constructor(*array_constructor);
1755 1758
1756 // Set prototype on map. 1759 // Set prototype on map.
1757 initial_map->set_non_instance_prototype(false); 1760 initial_map->set_non_instance_prototype(false);
1758 initial_map->set_prototype(*array_prototype); 1761 initial_map->set_prototype(*array_prototype);
1759 1762
1760 // Update map with length accessor from Array and add "index" and "input". 1763 // Update map with length accessor from Array and add "index" and "input".
1761 Handle<DescriptorArray> reresult_descriptors = 1764 Handle<DescriptorArray> reresult_descriptors =
1762 factory()->NewDescriptorArray(3); 1765 factory()->NewDescriptorArray(3);
1763 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); 1766 DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
1764 initial_map->set_instance_descriptors(*reresult_descriptors); 1767 Map::SetDescriptors(initial_map, reresult_descriptors);
1765 1768
1766 { 1769 {
1767 JSFunction* array_function = global_context()->array_function(); 1770 JSFunction* array_function = global_context()->array_function();
1768 Handle<DescriptorArray> array_descriptors( 1771 Handle<DescriptorArray> array_descriptors(
1769 array_function->initial_map()->instance_descriptors()); 1772 array_function->initial_map()->instance_descriptors());
1770 String* length = heap()->length_symbol(); 1773 String* length = heap()->length_symbol();
1771 int old = array_descriptors->SearchWithCache(length); 1774 int old = array_descriptors->SearchWithCache(length);
1772 ASSERT(old != DescriptorArray::kNotFound); 1775 ASSERT(old != DescriptorArray::kNotFound);
1773 CallbacksDescriptor desc(length, 1776 CallbacksDescriptor desc(length,
1774 array_descriptors->GetValue(old), 1777 array_descriptors->GetValue(old),
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 return from + sizeof(NestingCounterType); 2389 return from + sizeof(NestingCounterType);
2387 } 2390 }
2388 2391
2389 2392
2390 // Called when the top-level V8 mutex is destroyed. 2393 // Called when the top-level V8 mutex is destroyed.
2391 void Bootstrapper::FreeThreadResources() { 2394 void Bootstrapper::FreeThreadResources() {
2392 ASSERT(!IsActive()); 2395 ASSERT(!IsActive());
2393 } 2396 }
2394 2397
2395 } } // namespace v8::internal 2398 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/factory.cc » ('j') | src/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698