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

Side by Side Diff: src/bootstrapper.cc

Issue 11188031: Move DescriptorArray into the map (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove padding area Created 8 years, 2 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/heap.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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 390 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
391 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 391 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
392 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); 392 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments));
393 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); 393 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller));
394 Handle<Foreign> prototype; 394 Handle<Foreign> prototype;
395 if (prototypeMode != DONT_ADD_PROTOTYPE) { 395 if (prototypeMode != DONT_ADD_PROTOTYPE) {
396 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 396 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
397 } 397 }
398 PropertyAttributes attribs = static_cast<PropertyAttributes>( 398 PropertyAttributes attribs = static_cast<PropertyAttributes>(
399 DONT_ENUM | DONT_DELETE | READ_ONLY); 399 DONT_ENUM | DONT_DELETE | READ_ONLY);
400 Map::SetDescriptors(map, descriptors); 400 map->set_instance_descriptors(*descriptors);
401 401
402 { // Add length. 402 { // Add length.
403 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); 403 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs);
404 map->AppendDescriptor(&d, witness); 404 map->AppendDescriptor(&d, witness);
405 } 405 }
406 { // Add name. 406 { // Add name.
407 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); 407 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs);
408 map->AppendDescriptor(&d, witness); 408 map->AppendDescriptor(&d, witness);
409 } 409 }
410 { // Add arguments. 410 { // Add arguments.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 531 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
532 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 532 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
533 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); 533 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
534 Handle<AccessorPair> caller(factory()->NewAccessorPair()); 534 Handle<AccessorPair> caller(factory()->NewAccessorPair());
535 Handle<Foreign> prototype; 535 Handle<Foreign> prototype;
536 if (prototypeMode != DONT_ADD_PROTOTYPE) { 536 if (prototypeMode != DONT_ADD_PROTOTYPE) {
537 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 537 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
538 } 538 }
539 PropertyAttributes attribs = static_cast<PropertyAttributes>( 539 PropertyAttributes attribs = static_cast<PropertyAttributes>(
540 DONT_ENUM | DONT_DELETE); 540 DONT_ENUM | DONT_DELETE);
541 Map::SetDescriptors(map, descriptors); 541 map->set_instance_descriptors(*descriptors);
542 542
543 { // Add length. 543 { // Add length.
544 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); 544 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs);
545 map->AppendDescriptor(&d, witness); 545 map->AppendDescriptor(&d, witness);
546 } 546 }
547 { // Add name. 547 { // Add name.
548 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); 548 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs);
549 map->AppendDescriptor(&d, witness); 549 map->AppendDescriptor(&d, witness);
550 } 550 }
551 { // Add arguments. 551 { // Add arguments.
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 array_function->shared()->set_length(1); 868 array_function->shared()->set_length(1);
869 869
870 Handle<Map> initial_map(array_function->initial_map()); 870 Handle<Map> initial_map(array_function->initial_map());
871 Handle<DescriptorArray> array_descriptors( 871 Handle<DescriptorArray> array_descriptors(
872 factory->NewDescriptorArray(0, 1)); 872 factory->NewDescriptorArray(0, 1));
873 DescriptorArray::WhitenessWitness witness(*array_descriptors); 873 DescriptorArray::WhitenessWitness witness(*array_descriptors);
874 874
875 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); 875 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength));
876 PropertyAttributes attribs = static_cast<PropertyAttributes>( 876 PropertyAttributes attribs = static_cast<PropertyAttributes>(
877 DONT_ENUM | DONT_DELETE); 877 DONT_ENUM | DONT_DELETE);
878 Map::SetDescriptors(initial_map, array_descriptors); 878 initial_map->set_instance_descriptors(*array_descriptors);
879 879
880 { // Add length. 880 { // Add length.
881 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); 881 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs);
882 array_function->initial_map()->AppendDescriptor(&d, witness); 882 array_function->initial_map()->AppendDescriptor(&d, witness);
883 } 883 }
884 884
885 // array_function is used internally. JS code creating array object should 885 // array_function is used internally. JS code creating array object should
886 // search for the 'Array' property on the global object and use that one 886 // search for the 'Array' property on the global object and use that one
887 // as the constructor. 'Array' property on a global object can be 887 // as the constructor. 'Array' property on a global object can be
888 // overwritten by JS code. 888 // overwritten by JS code.
(...skipping 28 matching lines...) Expand all
917 Handle<Map> string_map = 917 Handle<Map> string_map =
918 Handle<Map>(native_context()->string_function()->initial_map()); 918 Handle<Map>(native_context()->string_function()->initial_map());
919 Handle<DescriptorArray> string_descriptors( 919 Handle<DescriptorArray> string_descriptors(
920 factory->NewDescriptorArray(0, 1)); 920 factory->NewDescriptorArray(0, 1));
921 DescriptorArray::WhitenessWitness witness(*string_descriptors); 921 DescriptorArray::WhitenessWitness witness(*string_descriptors);
922 922
923 Handle<Foreign> string_length( 923 Handle<Foreign> string_length(
924 factory->NewForeign(&Accessors::StringLength)); 924 factory->NewForeign(&Accessors::StringLength));
925 PropertyAttributes attribs = static_cast<PropertyAttributes>( 925 PropertyAttributes attribs = static_cast<PropertyAttributes>(
926 DONT_ENUM | DONT_DELETE | READ_ONLY); 926 DONT_ENUM | DONT_DELETE | READ_ONLY);
927 Map::SetDescriptors(string_map, string_descriptors); 927 string_map->set_instance_descriptors(*string_descriptors);
928 928
929 { // Add length. 929 { // Add length.
930 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); 930 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs);
931 string_map->AppendDescriptor(&d, witness); 931 string_map->AppendDescriptor(&d, witness);
932 } 932 }
933 } 933 }
934 934
935 { // --- D a t e --- 935 { // --- D a t e ---
936 // Builtin functions for Date.prototype. 936 // Builtin functions for Date.prototype.
937 Handle<JSFunction> date_fun = 937 Handle<JSFunction> date_fun =
(...skipping 15 matching lines...) Expand all
953 953
954 ASSERT(regexp_fun->has_initial_map()); 954 ASSERT(regexp_fun->has_initial_map());
955 Handle<Map> initial_map(regexp_fun->initial_map()); 955 Handle<Map> initial_map(regexp_fun->initial_map());
956 956
957 ASSERT_EQ(0, initial_map->inobject_properties()); 957 ASSERT_EQ(0, initial_map->inobject_properties());
958 958
959 PropertyAttributes final = 959 PropertyAttributes final =
960 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 960 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
961 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5); 961 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5);
962 DescriptorArray::WhitenessWitness witness(*descriptors); 962 DescriptorArray::WhitenessWitness witness(*descriptors);
963 Map::SetDescriptors(initial_map, descriptors); 963 initial_map->set_instance_descriptors(*descriptors);
964 964
965 { 965 {
966 // ECMA-262, section 15.10.7.1. 966 // ECMA-262, section 15.10.7.1.
967 FieldDescriptor field(heap->source_symbol(), 967 FieldDescriptor field(heap->source_symbol(),
968 JSRegExp::kSourceFieldIndex, 968 JSRegExp::kSourceFieldIndex,
969 final); 969 final);
970 initial_map->AppendDescriptor(&field, witness); 970 initial_map->AppendDescriptor(&field, witness);
971 } 971 }
972 { 972 {
973 // 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
1137 callee->set_setter(*throw_function); 1137 callee->set_setter(*throw_function);
1138 caller->set_getter(*throw_function); 1138 caller->set_getter(*throw_function);
1139 caller->set_setter(*throw_function); 1139 caller->set_setter(*throw_function);
1140 1140
1141 // Create the map. Allocate one in-object field for length. 1141 // Create the map. Allocate one in-object field for length.
1142 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, 1142 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1143 Heap::kArgumentsObjectSizeStrict); 1143 Heap::kArgumentsObjectSizeStrict);
1144 // Create the descriptor array for the arguments object. 1144 // Create the descriptor array for the arguments object.
1145 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3); 1145 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3);
1146 DescriptorArray::WhitenessWitness witness(*descriptors); 1146 DescriptorArray::WhitenessWitness witness(*descriptors);
1147 Map::SetDescriptors(map, descriptors); 1147 map->set_instance_descriptors(*descriptors);
1148 1148
1149 { // length 1149 { // length
1150 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); 1150 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
1151 map->AppendDescriptor(&d, witness); 1151 map->AppendDescriptor(&d, witness);
1152 } 1152 }
1153 { // callee 1153 { // callee
1154 CallbacksDescriptor d(*factory->callee_symbol(), 1154 CallbacksDescriptor d(*factory->callee_symbol(),
1155 *callee, 1155 *callee,
1156 attributes); 1156 attributes);
1157 map->AppendDescriptor(&d, witness); 1157 map->AppendDescriptor(&d, witness);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 Handle<String> eval_from_script_position_symbol( 1527 Handle<String> eval_from_script_position_symbol(
1528 factory()->LookupAsciiSymbol("eval_from_script_position")); 1528 factory()->LookupAsciiSymbol("eval_from_script_position"));
1529 Handle<Foreign> script_eval_from_script_position( 1529 Handle<Foreign> script_eval_from_script_position(
1530 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); 1530 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition));
1531 Handle<String> eval_from_function_name_symbol( 1531 Handle<String> eval_from_function_name_symbol(
1532 factory()->LookupAsciiSymbol("eval_from_function_name")); 1532 factory()->LookupAsciiSymbol("eval_from_function_name"));
1533 Handle<Foreign> script_eval_from_function_name( 1533 Handle<Foreign> script_eval_from_function_name(
1534 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); 1534 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName));
1535 PropertyAttributes attribs = 1535 PropertyAttributes attribs =
1536 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1536 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1537 Map::SetDescriptors(script_map, script_descriptors); 1537 script_map->set_instance_descriptors(*script_descriptors);
1538 1538
1539 { 1539 {
1540 CallbacksDescriptor d( 1540 CallbacksDescriptor d(
1541 *factory()->source_symbol(), *script_source, attribs); 1541 *factory()->source_symbol(), *script_source, attribs);
1542 script_map->AppendDescriptor(&d, witness); 1542 script_map->AppendDescriptor(&d, witness);
1543 } 1543 }
1544 1544
1545 { 1545 {
1546 CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs); 1546 CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs);
1547 script_map->AppendDescriptor(&d, witness); 1547 script_map->AppendDescriptor(&d, witness);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 // Make "length" magic on instances. 1668 // Make "length" magic on instances.
1669 Handle<Map> initial_map(array_function->initial_map()); 1669 Handle<Map> initial_map(array_function->initial_map());
1670 Handle<DescriptorArray> array_descriptors( 1670 Handle<DescriptorArray> array_descriptors(
1671 factory()->NewDescriptorArray(0, 1)); 1671 factory()->NewDescriptorArray(0, 1));
1672 DescriptorArray::WhitenessWitness witness(*array_descriptors); 1672 DescriptorArray::WhitenessWitness witness(*array_descriptors);
1673 1673
1674 Handle<Foreign> array_length(factory()->NewForeign( 1674 Handle<Foreign> array_length(factory()->NewForeign(
1675 &Accessors::ArrayLength)); 1675 &Accessors::ArrayLength));
1676 PropertyAttributes attribs = static_cast<PropertyAttributes>( 1676 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1677 DONT_ENUM | DONT_DELETE); 1677 DONT_ENUM | DONT_DELETE);
1678 Map::SetDescriptors(initial_map, array_descriptors); 1678 initial_map->set_instance_descriptors(*array_descriptors);
1679 1679
1680 { // Add length. 1680 { // Add length.
1681 CallbacksDescriptor d( 1681 CallbacksDescriptor d(
1682 *factory()->length_symbol(), *array_length, attribs); 1682 *factory()->length_symbol(), *array_length, attribs);
1683 array_function->initial_map()->AppendDescriptor(&d, witness); 1683 array_function->initial_map()->AppendDescriptor(&d, witness);
1684 } 1684 }
1685 1685
1686 native_context()->set_internal_array_function(*array_function); 1686 native_context()->set_internal_array_function(*array_function);
1687 } 1687 }
1688 1688
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 initial_map->set_constructor(*array_constructor); 1763 initial_map->set_constructor(*array_constructor);
1764 1764
1765 // Set prototype on map. 1765 // Set prototype on map.
1766 initial_map->set_non_instance_prototype(false); 1766 initial_map->set_non_instance_prototype(false);
1767 initial_map->set_prototype(*array_prototype); 1767 initial_map->set_prototype(*array_prototype);
1768 1768
1769 // Update map with length accessor from Array and add "index" and "input". 1769 // Update map with length accessor from Array and add "index" and "input".
1770 Handle<DescriptorArray> reresult_descriptors = 1770 Handle<DescriptorArray> reresult_descriptors =
1771 factory()->NewDescriptorArray(0, 3); 1771 factory()->NewDescriptorArray(0, 3);
1772 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); 1772 DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
1773 Map::SetDescriptors(initial_map, reresult_descriptors); 1773 initial_map->set_instance_descriptors(*reresult_descriptors);
1774 1774
1775 { 1775 {
1776 JSFunction* array_function = native_context()->array_function(); 1776 JSFunction* array_function = native_context()->array_function();
1777 Handle<DescriptorArray> array_descriptors( 1777 Handle<DescriptorArray> array_descriptors(
1778 array_function->initial_map()->instance_descriptors()); 1778 array_function->initial_map()->instance_descriptors());
1779 String* length = heap()->length_symbol(); 1779 String* length = heap()->length_symbol();
1780 int old = array_descriptors->SearchWithCache( 1780 int old = array_descriptors->SearchWithCache(
1781 length, array_function->initial_map()); 1781 length, array_function->initial_map());
1782 ASSERT(old != DescriptorArray::kNotFound); 1782 ASSERT(old != DescriptorArray::kNotFound);
1783 CallbacksDescriptor desc(length, 1783 CallbacksDescriptor desc(length,
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 return from + sizeof(NestingCounterType); 2399 return from + sizeof(NestingCounterType);
2400 } 2400 }
2401 2401
2402 2402
2403 // Called when the top-level V8 mutex is destroyed. 2403 // Called when the top-level V8 mutex is destroyed.
2404 void Bootstrapper::FreeThreadResources() { 2404 void Bootstrapper::FreeThreadResources() {
2405 ASSERT(!IsActive()); 2405 ASSERT(!IsActive());
2406 } 2406 }
2407 2407
2408 } } // namespace v8::internal 2408 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698