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

Side by Side Diff: src/bootstrapper.cc

Issue 234783002: Handlify Map::CopyDropDescriptors(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Made WhitenessWitness private. Created 6 years, 8 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/objects.h » ('j') | src/objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bootstrapper.h" 5 #include "bootstrapper.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "natives.h" 9 #include "natives.h"
10 #include "snapshot.h" 10 #include "snapshot.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 377 }
378 function->shared()->set_native(true); 378 function->shared()->set_native(true);
379 return function; 379 return function;
380 } 380 }
381 381
382 382
383 void Genesis::SetFunctionInstanceDescriptor( 383 void Genesis::SetFunctionInstanceDescriptor(
384 Handle<Map> map, PrototypePropertyMode prototypeMode) { 384 Handle<Map> map, PrototypePropertyMode prototypeMode) {
385 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 385 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
386 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size)); 386 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size));
387 DescriptorArray::WhitenessWitness witness(*descriptors);
388 387
389 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 388 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
390 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 389 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
391 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); 390 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments));
392 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); 391 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller));
393 Handle<Foreign> prototype; 392 Handle<Foreign> prototype;
394 if (prototypeMode != DONT_ADD_PROTOTYPE) { 393 if (prototypeMode != DONT_ADD_PROTOTYPE) {
395 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 394 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
396 } 395 }
397 PropertyAttributes attribs = static_cast<PropertyAttributes>( 396 PropertyAttributes attribs = static_cast<PropertyAttributes>(
398 DONT_ENUM | DONT_DELETE | READ_ONLY); 397 DONT_ENUM | DONT_DELETE | READ_ONLY);
399 map->set_instance_descriptors(*descriptors); 398 map->set_instance_descriptors(*descriptors);
Toon Verwaest 2014/04/11 10:34:32 What about Map::EnsureDescriptorSlack(map, size);
mvstanton 2014/04/11 11:25:20 Done.
400 399
401 { // Add length. 400 { // Add length.
402 CallbacksDescriptor d(factory()->length_string(), length, attribs); 401 CallbacksDescriptor d(factory()->length_string(), length, attribs);
403 map->AppendDescriptor(&d, witness); 402 map->AppendDescriptor(&d);
404 } 403 }
405 { // Add name. 404 { // Add name.
406 CallbacksDescriptor d(factory()->name_string(), name, attribs); 405 CallbacksDescriptor d(factory()->name_string(), name, attribs);
407 map->AppendDescriptor(&d, witness); 406 map->AppendDescriptor(&d);
408 } 407 }
409 { // Add arguments. 408 { // Add arguments.
410 CallbacksDescriptor d(factory()->arguments_string(), args, attribs); 409 CallbacksDescriptor d(factory()->arguments_string(), args, attribs);
411 map->AppendDescriptor(&d, witness); 410 map->AppendDescriptor(&d);
412 } 411 }
413 { // Add caller. 412 { // Add caller.
414 CallbacksDescriptor d(factory()->caller_string(), caller, attribs); 413 CallbacksDescriptor d(factory()->caller_string(), caller, attribs);
415 map->AppendDescriptor(&d, witness); 414 map->AppendDescriptor(&d);
416 } 415 }
417 if (prototypeMode != DONT_ADD_PROTOTYPE) { 416 if (prototypeMode != DONT_ADD_PROTOTYPE) {
418 // Add prototype. 417 // Add prototype.
419 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { 418 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
420 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); 419 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY);
421 } 420 }
422 CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs); 421 CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs);
423 map->AppendDescriptor(&d, witness); 422 map->AppendDescriptor(&d);
424 } 423 }
425 } 424 }
426 425
427 426
428 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { 427 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
429 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 428 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
430 SetFunctionInstanceDescriptor(map, prototype_mode); 429 SetFunctionInstanceDescriptor(map, prototype_mode);
431 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); 430 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
432 return map; 431 return map;
433 } 432 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 native_context()->object_function()->prototype()); 515 native_context()->object_function()->prototype());
517 empty_function->set_map(*empty_function_map); 516 empty_function->set_map(*empty_function_map);
518 return empty_function; 517 return empty_function;
519 } 518 }
520 519
521 520
522 void Genesis::SetStrictFunctionInstanceDescriptor( 521 void Genesis::SetStrictFunctionInstanceDescriptor(
523 Handle<Map> map, PrototypePropertyMode prototypeMode) { 522 Handle<Map> map, PrototypePropertyMode prototypeMode) {
524 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 523 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
525 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size)); 524 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size));
526 DescriptorArray::WhitenessWitness witness(*descriptors);
527 525
528 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 526 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
529 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 527 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
530 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); 528 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
531 Handle<AccessorPair> caller(factory()->NewAccessorPair()); 529 Handle<AccessorPair> caller(factory()->NewAccessorPair());
532 Handle<Foreign> prototype; 530 Handle<Foreign> prototype;
533 if (prototypeMode != DONT_ADD_PROTOTYPE) { 531 if (prototypeMode != DONT_ADD_PROTOTYPE) {
534 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); 532 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
535 } 533 }
536 PropertyAttributes rw_attribs = 534 PropertyAttributes rw_attribs =
537 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 535 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
538 PropertyAttributes ro_attribs = 536 PropertyAttributes ro_attribs =
539 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 537 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
540 map->set_instance_descriptors(*descriptors); 538 map->set_instance_descriptors(*descriptors);
541 539
542 { // Add length. 540 { // Add length.
543 CallbacksDescriptor d(factory()->length_string(), length, ro_attribs); 541 CallbacksDescriptor d(factory()->length_string(), length, ro_attribs);
544 map->AppendDescriptor(&d, witness); 542 map->AppendDescriptor(&d);
545 } 543 }
546 { // Add name. 544 { // Add name.
547 CallbacksDescriptor d(factory()->name_string(), name, ro_attribs); 545 CallbacksDescriptor d(factory()->name_string(), name, ro_attribs);
548 map->AppendDescriptor(&d, witness); 546 map->AppendDescriptor(&d);
549 } 547 }
550 { // Add arguments. 548 { // Add arguments.
551 CallbacksDescriptor d(factory()->arguments_string(), arguments, 549 CallbacksDescriptor d(factory()->arguments_string(), arguments,
552 rw_attribs); 550 rw_attribs);
553 map->AppendDescriptor(&d, witness); 551 map->AppendDescriptor(&d);
554 } 552 }
555 { // Add caller. 553 { // Add caller.
556 CallbacksDescriptor d(factory()->caller_string(), caller, rw_attribs); 554 CallbacksDescriptor d(factory()->caller_string(), caller, rw_attribs);
557 map->AppendDescriptor(&d, witness); 555 map->AppendDescriptor(&d);
558 } 556 }
559 if (prototypeMode != DONT_ADD_PROTOTYPE) { 557 if (prototypeMode != DONT_ADD_PROTOTYPE) {
560 // Add prototype. 558 // Add prototype.
561 PropertyAttributes attribs = 559 PropertyAttributes attribs =
562 prototypeMode == ADD_WRITEABLE_PROTOTYPE ? rw_attribs : ro_attribs; 560 prototypeMode == ADD_WRITEABLE_PROTOTYPE ? rw_attribs : ro_attribs;
563 CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs); 561 CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs);
564 map->AppendDescriptor(&d, witness); 562 map->AppendDescriptor(&d);
565 } 563 }
566 } 564 }
567 565
568 566
569 // ECMAScript 5th Edition, 13.2.3 567 // ECMAScript 5th Edition, 13.2.3
570 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 568 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
571 if (throw_type_error_function.is_null()) { 569 if (throw_type_error_function.is_null()) {
572 Handle<String> name = factory()->InternalizeOneByteString( 570 Handle<String> name = factory()->InternalizeOneByteString(
573 STATIC_ASCII_VECTOR("ThrowTypeError")); 571 STATIC_ASCII_VECTOR("ThrowTypeError"));
574 throw_type_error_function = 572 throw_type_error_function =
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 array_function->shared()->set_length(1); 855 array_function->shared()->set_length(1);
858 856
859 Handle<Map> initial_map(array_function->initial_map()); 857 Handle<Map> initial_map(array_function->initial_map());
860 858
861 // This assert protects an optimization in 859 // This assert protects an optimization in
862 // HGraphBuilder::JSArrayBuilder::EmitMapCode() 860 // HGraphBuilder::JSArrayBuilder::EmitMapCode()
863 ASSERT(initial_map->elements_kind() == GetInitialFastElementsKind()); 861 ASSERT(initial_map->elements_kind() == GetInitialFastElementsKind());
864 862
865 Handle<DescriptorArray> array_descriptors( 863 Handle<DescriptorArray> array_descriptors(
866 factory->NewDescriptorArray(0, 1)); 864 factory->NewDescriptorArray(0, 1));
867 DescriptorArray::WhitenessWitness witness(*array_descriptors);
868 865
869 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); 866 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength));
870 PropertyAttributes attribs = static_cast<PropertyAttributes>( 867 PropertyAttributes attribs = static_cast<PropertyAttributes>(
871 DONT_ENUM | DONT_DELETE); 868 DONT_ENUM | DONT_DELETE);
872 initial_map->set_instance_descriptors(*array_descriptors); 869 initial_map->set_instance_descriptors(*array_descriptors);
873 870
874 { // Add length. 871 { // Add length.
875 CallbacksDescriptor d(factory->length_string(), array_length, attribs); 872 CallbacksDescriptor d(factory->length_string(), array_length, attribs);
876 array_function->initial_map()->AppendDescriptor(&d, witness); 873 array_function->initial_map()->AppendDescriptor(&d);
877 } 874 }
878 875
879 // array_function is used internally. JS code creating array object should 876 // array_function is used internally. JS code creating array object should
880 // search for the 'Array' property on the global object and use that one 877 // search for the 'Array' property on the global object and use that one
881 // as the constructor. 'Array' property on a global object can be 878 // as the constructor. 'Array' property on a global object can be
882 // overwritten by JS code. 879 // overwritten by JS code.
883 native_context()->set_array_function(*array_function); 880 native_context()->set_array_function(*array_function);
884 881
885 // Cache the array maps, needed by ArrayConstructorStub 882 // Cache the array maps, needed by ArrayConstructorStub
886 CacheInitialJSArrayMaps(native_context(), initial_map); 883 CacheInitialJSArrayMaps(native_context(), initial_map);
(...skipping 24 matching lines...) Expand all
911 isolate->initial_object_prototype(), 908 isolate->initial_object_prototype(),
912 Builtins::kIllegal, true, true); 909 Builtins::kIllegal, true, true);
913 string_fun->shared()->set_construct_stub( 910 string_fun->shared()->set_construct_stub(
914 isolate->builtins()->builtin(Builtins::kStringConstructCode)); 911 isolate->builtins()->builtin(Builtins::kStringConstructCode));
915 native_context()->set_string_function(*string_fun); 912 native_context()->set_string_function(*string_fun);
916 913
917 Handle<Map> string_map = 914 Handle<Map> string_map =
918 Handle<Map>(native_context()->string_function()->initial_map()); 915 Handle<Map>(native_context()->string_function()->initial_map());
919 Handle<DescriptorArray> string_descriptors( 916 Handle<DescriptorArray> string_descriptors(
920 factory->NewDescriptorArray(0, 1)); 917 factory->NewDescriptorArray(0, 1));
921 DescriptorArray::WhitenessWitness witness(*string_descriptors);
922 918
923 Handle<Foreign> string_length( 919 Handle<Foreign> string_length(
924 factory->NewForeign(&Accessors::StringLength)); 920 factory->NewForeign(&Accessors::StringLength));
925 PropertyAttributes attribs = static_cast<PropertyAttributes>( 921 PropertyAttributes attribs = static_cast<PropertyAttributes>(
926 DONT_ENUM | DONT_DELETE | READ_ONLY); 922 DONT_ENUM | DONT_DELETE | READ_ONLY);
927 string_map->set_instance_descriptors(*string_descriptors); 923 string_map->set_instance_descriptors(*string_descriptors);
928 924
929 { // Add length. 925 { // Add length.
930 CallbacksDescriptor d(factory->length_string(), string_length, attribs); 926 CallbacksDescriptor d(factory->length_string(), string_length, attribs);
931 string_map->AppendDescriptor(&d, witness); 927 string_map->AppendDescriptor(&d);
932 } 928 }
933 } 929 }
934 930
935 { // --- D a t e --- 931 { // --- D a t e ---
936 // Builtin functions for Date.prototype. 932 // Builtin functions for Date.prototype.
937 Handle<JSFunction> date_fun = 933 Handle<JSFunction> date_fun =
938 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, 934 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize,
939 isolate->initial_object_prototype(), 935 isolate->initial_object_prototype(),
940 Builtins::kIllegal, true, true); 936 Builtins::kIllegal, true, true);
941 937
(...skipping 10 matching lines...) Expand all
952 native_context()->set_regexp_function(*regexp_fun); 948 native_context()->set_regexp_function(*regexp_fun);
953 949
954 ASSERT(regexp_fun->has_initial_map()); 950 ASSERT(regexp_fun->has_initial_map());
955 Handle<Map> initial_map(regexp_fun->initial_map()); 951 Handle<Map> initial_map(regexp_fun->initial_map());
956 952
957 ASSERT_EQ(0, initial_map->inobject_properties()); 953 ASSERT_EQ(0, initial_map->inobject_properties());
958 954
959 PropertyAttributes final = 955 PropertyAttributes final =
960 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 956 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
961 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5); 957 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5);
962 DescriptorArray::WhitenessWitness witness(*descriptors);
963 initial_map->set_instance_descriptors(*descriptors); 958 initial_map->set_instance_descriptors(*descriptors);
964 959
965 { 960 {
966 // ECMA-262, section 15.10.7.1. 961 // ECMA-262, section 15.10.7.1.
967 FieldDescriptor field(factory->source_string(), 962 FieldDescriptor field(factory->source_string(),
968 JSRegExp::kSourceFieldIndex, 963 JSRegExp::kSourceFieldIndex,
969 final, 964 final,
970 Representation::Tagged()); 965 Representation::Tagged());
971 initial_map->AppendDescriptor(&field, witness); 966 initial_map->AppendDescriptor(&field);
972 } 967 }
973 { 968 {
974 // ECMA-262, section 15.10.7.2. 969 // ECMA-262, section 15.10.7.2.
975 FieldDescriptor field(factory->global_string(), 970 FieldDescriptor field(factory->global_string(),
976 JSRegExp::kGlobalFieldIndex, 971 JSRegExp::kGlobalFieldIndex,
977 final, 972 final,
978 Representation::Tagged()); 973 Representation::Tagged());
979 initial_map->AppendDescriptor(&field, witness); 974 initial_map->AppendDescriptor(&field);
980 } 975 }
981 { 976 {
982 // ECMA-262, section 15.10.7.3. 977 // ECMA-262, section 15.10.7.3.
983 FieldDescriptor field(factory->ignore_case_string(), 978 FieldDescriptor field(factory->ignore_case_string(),
984 JSRegExp::kIgnoreCaseFieldIndex, 979 JSRegExp::kIgnoreCaseFieldIndex,
985 final, 980 final,
986 Representation::Tagged()); 981 Representation::Tagged());
987 initial_map->AppendDescriptor(&field, witness); 982 initial_map->AppendDescriptor(&field);
988 } 983 }
989 { 984 {
990 // ECMA-262, section 15.10.7.4. 985 // ECMA-262, section 15.10.7.4.
991 FieldDescriptor field(factory->multiline_string(), 986 FieldDescriptor field(factory->multiline_string(),
992 JSRegExp::kMultilineFieldIndex, 987 JSRegExp::kMultilineFieldIndex,
993 final, 988 final,
994 Representation::Tagged()); 989 Representation::Tagged());
995 initial_map->AppendDescriptor(&field, witness); 990 initial_map->AppendDescriptor(&field);
996 } 991 }
997 { 992 {
998 // ECMA-262, section 15.10.7.5. 993 // ECMA-262, section 15.10.7.5.
999 PropertyAttributes writable = 994 PropertyAttributes writable =
1000 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 995 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1001 FieldDescriptor field(factory->last_index_string(), 996 FieldDescriptor field(factory->last_index_string(),
1002 JSRegExp::kLastIndexFieldIndex, 997 JSRegExp::kLastIndexFieldIndex,
1003 writable, 998 writable,
1004 Representation::Tagged()); 999 Representation::Tagged());
1005 initial_map->AppendDescriptor(&field, witness); 1000 initial_map->AppendDescriptor(&field);
1006 } 1001 }
1007 1002
1008 initial_map->set_inobject_properties(5); 1003 initial_map->set_inobject_properties(5);
1009 initial_map->set_pre_allocated_property_fields(5); 1004 initial_map->set_pre_allocated_property_fields(5);
1010 initial_map->set_unused_property_fields(0); 1005 initial_map->set_unused_property_fields(0);
1011 initial_map->set_instance_size( 1006 initial_map->set_instance_size(
1012 initial_map->instance_size() + 5 * kPointerSize); 1007 initial_map->instance_size() + 5 * kPointerSize);
1013 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); 1008 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
1014 1009
1015 // RegExp prototype object is itself a RegExp. 1010 // RegExp prototype object is itself a RegExp.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 callee->set_getter(*throw_function); 1164 callee->set_getter(*throw_function);
1170 callee->set_setter(*throw_function); 1165 callee->set_setter(*throw_function);
1171 caller->set_getter(*throw_function); 1166 caller->set_getter(*throw_function);
1172 caller->set_setter(*throw_function); 1167 caller->set_setter(*throw_function);
1173 1168
1174 // Create the map. Allocate one in-object field for length. 1169 // Create the map. Allocate one in-object field for length.
1175 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, 1170 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1176 Heap::kStrictArgumentsObjectSize); 1171 Heap::kStrictArgumentsObjectSize);
1177 // Create the descriptor array for the arguments object. 1172 // Create the descriptor array for the arguments object.
1178 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3); 1173 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3);
1179 DescriptorArray::WhitenessWitness witness(*descriptors);
1180 map->set_instance_descriptors(*descriptors); 1174 map->set_instance_descriptors(*descriptors);
1181 1175
1182 { // length 1176 { // length
1183 FieldDescriptor d( 1177 FieldDescriptor d(
1184 factory->length_string(), 0, DONT_ENUM, Representation::Tagged()); 1178 factory->length_string(), 0, DONT_ENUM, Representation::Tagged());
1185 map->AppendDescriptor(&d, witness); 1179 map->AppendDescriptor(&d);
1186 } 1180 }
1187 { // callee 1181 { // callee
1188 CallbacksDescriptor d(factory->callee_string(), 1182 CallbacksDescriptor d(factory->callee_string(),
1189 callee, 1183 callee,
1190 attributes); 1184 attributes);
1191 map->AppendDescriptor(&d, witness); 1185 map->AppendDescriptor(&d);
1192 } 1186 }
1193 { // caller 1187 { // caller
1194 CallbacksDescriptor d(factory->caller_string(), 1188 CallbacksDescriptor d(factory->caller_string(),
1195 caller, 1189 caller,
1196 attributes); 1190 attributes);
1197 map->AppendDescriptor(&d, witness); 1191 map->AppendDescriptor(&d);
1198 } 1192 }
1199 1193
1200 map->set_function_with_prototype(true); 1194 map->set_function_with_prototype(true);
1201 map->set_prototype(native_context()->object_function()->prototype()); 1195 map->set_prototype(native_context()->object_function()->prototype());
1202 map->set_pre_allocated_property_fields(1); 1196 map->set_pre_allocated_property_fields(1);
1203 map->set_inobject_properties(1); 1197 map->set_inobject_properties(1);
1204 1198
1205 // Copy constructor from the sloppy arguments boilerplate. 1199 // Copy constructor from the sloppy arguments boilerplate.
1206 map->set_constructor( 1200 map->set_constructor(
1207 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); 1201 native_context()->sloppy_arguments_boilerplate()->map()->constructor());
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 // Create a map for generator result objects. 1370 // Create a map for generator result objects.
1377 ASSERT(object_function->initial_map()->inobject_properties() == 0); 1371 ASSERT(object_function->initial_map()->inobject_properties() == 0);
1378 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); 1372 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
1379 Handle<Map> generator_result_map = Map::Create( 1373 Handle<Map> generator_result_map = Map::Create(
1380 object_function, JSGeneratorObject::kResultPropertyCount); 1374 object_function, JSGeneratorObject::kResultPropertyCount);
1381 ASSERT(generator_result_map->inobject_properties() == 1375 ASSERT(generator_result_map->inobject_properties() ==
1382 JSGeneratorObject::kResultPropertyCount); 1376 JSGeneratorObject::kResultPropertyCount);
1383 1377
1384 Handle<DescriptorArray> descriptors = factory()->NewDescriptorArray(0, 1378 Handle<DescriptorArray> descriptors = factory()->NewDescriptorArray(0,
1385 JSGeneratorObject::kResultPropertyCount); 1379 JSGeneratorObject::kResultPropertyCount);
1386 DescriptorArray::WhitenessWitness witness(*descriptors);
1387 generator_result_map->set_instance_descriptors(*descriptors); 1380 generator_result_map->set_instance_descriptors(*descriptors);
1388 1381
1389 Handle<String> value_string = factory()->InternalizeOneByteString( 1382 Handle<String> value_string = factory()->InternalizeOneByteString(
1390 STATIC_ASCII_VECTOR("value")); 1383 STATIC_ASCII_VECTOR("value"));
1391 FieldDescriptor value_descr(value_string, 1384 FieldDescriptor value_descr(value_string,
1392 JSGeneratorObject::kResultValuePropertyIndex, 1385 JSGeneratorObject::kResultValuePropertyIndex,
1393 NONE, 1386 NONE,
1394 Representation::Tagged()); 1387 Representation::Tagged());
1395 generator_result_map->AppendDescriptor(&value_descr, witness); 1388 generator_result_map->AppendDescriptor(&value_descr);
1396 1389
1397 Handle<String> done_string = factory()->InternalizeOneByteString( 1390 Handle<String> done_string = factory()->InternalizeOneByteString(
1398 STATIC_ASCII_VECTOR("done")); 1391 STATIC_ASCII_VECTOR("done"));
1399 FieldDescriptor done_descr(done_string, 1392 FieldDescriptor done_descr(done_string,
1400 JSGeneratorObject::kResultDonePropertyIndex, 1393 JSGeneratorObject::kResultDonePropertyIndex,
1401 NONE, 1394 NONE,
1402 Representation::Tagged()); 1395 Representation::Tagged());
1403 generator_result_map->AppendDescriptor(&done_descr, witness); 1396 generator_result_map->AppendDescriptor(&done_descr);
1404 1397
1405 generator_result_map->set_unused_property_fields(0); 1398 generator_result_map->set_unused_property_fields(0);
1406 ASSERT_EQ(JSGeneratorObject::kResultSize, 1399 ASSERT_EQ(JSGeneratorObject::kResultSize,
1407 generator_result_map->instance_size()); 1400 generator_result_map->instance_size());
1408 native_context()->set_generator_result_map(*generator_result_map); 1401 native_context()->set_generator_result_map(*generator_result_map);
1409 } 1402 }
1410 } 1403 }
1411 1404
1412 1405
1413 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { 1406 bool Genesis::CompileBuiltin(Isolate* isolate, int index) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 array_function->shared()->DontAdaptArguments(); 1596 array_function->shared()->DontAdaptArguments();
1604 1597
1605 Handle<Map> original_map(array_function->initial_map()); 1598 Handle<Map> original_map(array_function->initial_map());
1606 Handle<Map> initial_map = Map::Copy(original_map); 1599 Handle<Map> initial_map = Map::Copy(original_map);
1607 initial_map->set_elements_kind(elements_kind); 1600 initial_map->set_elements_kind(elements_kind);
1608 array_function->set_initial_map(*initial_map); 1601 array_function->set_initial_map(*initial_map);
1609 1602
1610 // Make "length" magic on instances. 1603 // Make "length" magic on instances.
1611 Handle<DescriptorArray> array_descriptors( 1604 Handle<DescriptorArray> array_descriptors(
1612 factory()->NewDescriptorArray(0, 1)); 1605 factory()->NewDescriptorArray(0, 1));
1613 DescriptorArray::WhitenessWitness witness(*array_descriptors);
1614 1606
1615 Handle<Foreign> array_length(factory()->NewForeign( 1607 Handle<Foreign> array_length(factory()->NewForeign(
1616 &Accessors::ArrayLength)); 1608 &Accessors::ArrayLength));
1617 PropertyAttributes attribs = static_cast<PropertyAttributes>( 1609 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1618 DONT_ENUM | DONT_DELETE); 1610 DONT_ENUM | DONT_DELETE);
1619 initial_map->set_instance_descriptors(*array_descriptors); 1611 initial_map->set_instance_descriptors(*array_descriptors);
1620 1612
1621 { // Add length. 1613 { // Add length.
1622 CallbacksDescriptor d( 1614 CallbacksDescriptor d(
1623 factory()->length_string(), array_length, attribs); 1615 factory()->length_string(), array_length, attribs);
1624 array_function->initial_map()->AppendDescriptor(&d, witness); 1616 array_function->initial_map()->AppendDescriptor(&d);
1625 } 1617 }
1626 1618
1627 return array_function; 1619 return array_function;
1628 } 1620 }
1629 1621
1630 1622
1631 bool Genesis::InstallNatives() { 1623 bool Genesis::InstallNatives() {
1632 HandleScope scope(isolate()); 1624 HandleScope scope(isolate());
1633 1625
1634 // Create a function for the builtins object. Allocate space for the 1626 // Create a function for the builtins object. Allocate space for the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 Builtins::kIllegal, false, false); 1690 Builtins::kIllegal, false, false);
1699 Handle<JSObject> prototype = 1691 Handle<JSObject> prototype =
1700 factory()->NewJSObject(isolate()->object_function(), TENURED); 1692 factory()->NewJSObject(isolate()->object_function(), TENURED);
1701 Accessors::FunctionSetPrototype(script_fun, prototype); 1693 Accessors::FunctionSetPrototype(script_fun, prototype);
1702 native_context()->set_script_function(*script_fun); 1694 native_context()->set_script_function(*script_fun);
1703 1695
1704 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); 1696 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1705 1697
1706 Handle<DescriptorArray> script_descriptors( 1698 Handle<DescriptorArray> script_descriptors(
1707 factory()->NewDescriptorArray(0, 13)); 1699 factory()->NewDescriptorArray(0, 13));
1708 DescriptorArray::WhitenessWitness witness(*script_descriptors);
1709 1700
1710 Handle<Foreign> script_source( 1701 Handle<Foreign> script_source(
1711 factory()->NewForeign(&Accessors::ScriptSource)); 1702 factory()->NewForeign(&Accessors::ScriptSource));
1712 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName)); 1703 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName));
1713 Handle<String> id_string(factory()->InternalizeOneByteString( 1704 Handle<String> id_string(factory()->InternalizeOneByteString(
1714 STATIC_ASCII_VECTOR("id"))); 1705 STATIC_ASCII_VECTOR("id")));
1715 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId)); 1706 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId));
1716 Handle<String> line_offset_string( 1707 Handle<String> line_offset_string(
1717 factory()->InternalizeOneByteString( 1708 factory()->InternalizeOneByteString(
1718 STATIC_ASCII_VECTOR("line_offset"))); 1709 STATIC_ASCII_VECTOR("line_offset")));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 STATIC_ASCII_VECTOR("eval_from_function_name"))); 1746 STATIC_ASCII_VECTOR("eval_from_function_name")));
1756 Handle<Foreign> script_eval_from_function_name( 1747 Handle<Foreign> script_eval_from_function_name(
1757 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); 1748 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName));
1758 PropertyAttributes attribs = 1749 PropertyAttributes attribs =
1759 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1750 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1760 script_map->set_instance_descriptors(*script_descriptors); 1751 script_map->set_instance_descriptors(*script_descriptors);
1761 1752
1762 { 1753 {
1763 CallbacksDescriptor d( 1754 CallbacksDescriptor d(
1764 factory()->source_string(), script_source, attribs); 1755 factory()->source_string(), script_source, attribs);
1765 script_map->AppendDescriptor(&d, witness); 1756 script_map->AppendDescriptor(&d);
1766 } 1757 }
1767 1758
1768 { 1759 {
1769 CallbacksDescriptor d(factory()->name_string(), script_name, attribs); 1760 CallbacksDescriptor d(factory()->name_string(), script_name, attribs);
1770 script_map->AppendDescriptor(&d, witness); 1761 script_map->AppendDescriptor(&d);
1771 } 1762 }
1772 1763
1773 { 1764 {
1774 CallbacksDescriptor d(id_string, script_id, attribs); 1765 CallbacksDescriptor d(id_string, script_id, attribs);
1775 script_map->AppendDescriptor(&d, witness); 1766 script_map->AppendDescriptor(&d);
1776 } 1767 }
1777 1768
1778 { 1769 {
1779 CallbacksDescriptor d(line_offset_string, script_line_offset, attribs); 1770 CallbacksDescriptor d(line_offset_string, script_line_offset, attribs);
1780 script_map->AppendDescriptor(&d, witness); 1771 script_map->AppendDescriptor(&d);
1781 } 1772 }
1782 1773
1783 { 1774 {
1784 CallbacksDescriptor d( 1775 CallbacksDescriptor d(
1785 column_offset_string, script_column_offset, attribs); 1776 column_offset_string, script_column_offset, attribs);
1786 script_map->AppendDescriptor(&d, witness); 1777 script_map->AppendDescriptor(&d);
1787 } 1778 }
1788 1779
1789 { 1780 {
1790 CallbacksDescriptor d(type_string, script_type, attribs); 1781 CallbacksDescriptor d(type_string, script_type, attribs);
1791 script_map->AppendDescriptor(&d, witness); 1782 script_map->AppendDescriptor(&d);
1792 } 1783 }
1793 1784
1794 { 1785 {
1795 CallbacksDescriptor d( 1786 CallbacksDescriptor d(
1796 compilation_type_string, script_compilation_type, attribs); 1787 compilation_type_string, script_compilation_type, attribs);
1797 script_map->AppendDescriptor(&d, witness); 1788 script_map->AppendDescriptor(&d);
1798 } 1789 }
1799 1790
1800 { 1791 {
1801 CallbacksDescriptor d(line_ends_string, script_line_ends, attribs); 1792 CallbacksDescriptor d(line_ends_string, script_line_ends, attribs);
1802 script_map->AppendDescriptor(&d, witness); 1793 script_map->AppendDescriptor(&d);
1803 } 1794 }
1804 1795
1805 { 1796 {
1806 CallbacksDescriptor d( 1797 CallbacksDescriptor d(
1807 context_data_string, script_context_data, attribs); 1798 context_data_string, script_context_data, attribs);
1808 script_map->AppendDescriptor(&d, witness); 1799 script_map->AppendDescriptor(&d);
1809 } 1800 }
1810 1801
1811 { 1802 {
1812 CallbacksDescriptor d( 1803 CallbacksDescriptor d(
1813 eval_from_script_string, script_eval_from_script, attribs); 1804 eval_from_script_string, script_eval_from_script, attribs);
1814 script_map->AppendDescriptor(&d, witness); 1805 script_map->AppendDescriptor(&d);
1815 } 1806 }
1816 1807
1817 { 1808 {
1818 CallbacksDescriptor d( 1809 CallbacksDescriptor d(
1819 eval_from_script_position_string, 1810 eval_from_script_position_string,
1820 script_eval_from_script_position, 1811 script_eval_from_script_position,
1821 attribs); 1812 attribs);
1822 script_map->AppendDescriptor(&d, witness); 1813 script_map->AppendDescriptor(&d);
1823 } 1814 }
1824 1815
1825 { 1816 {
1826 CallbacksDescriptor d( 1817 CallbacksDescriptor d(
1827 eval_from_function_name_string, 1818 eval_from_function_name_string,
1828 script_eval_from_function_name, 1819 script_eval_from_function_name,
1829 attribs); 1820 attribs);
1830 script_map->AppendDescriptor(&d, witness); 1821 script_map->AppendDescriptor(&d);
1831 } 1822 }
1832 1823
1833 // Allocate the empty script. 1824 // Allocate the empty script.
1834 Handle<Script> script = factory()->NewScript(factory()->empty_string()); 1825 Handle<Script> script = factory()->NewScript(factory()->empty_string());
1835 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 1826 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1836 heap()->public_set_empty_script(*script); 1827 heap()->public_set_empty_script(*script);
1837 } 1828 }
1838 { 1829 {
1839 // Builtin function for OpaqueReference -- a JSValue-based object, 1830 // Builtin function for OpaqueReference -- a JSValue-based object,
1840 // that keeps its field isolated from JavaScript code. It may store 1831 // that keeps its field isolated from JavaScript code. It may store
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 factory()->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize); 1933 factory()->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize);
1943 initial_map->set_constructor(*array_constructor); 1934 initial_map->set_constructor(*array_constructor);
1944 1935
1945 // Set prototype on map. 1936 // Set prototype on map.
1946 initial_map->set_non_instance_prototype(false); 1937 initial_map->set_non_instance_prototype(false);
1947 initial_map->set_prototype(*array_prototype); 1938 initial_map->set_prototype(*array_prototype);
1948 1939
1949 // Update map with length accessor from Array and add "index" and "input". 1940 // Update map with length accessor from Array and add "index" and "input".
1950 Handle<DescriptorArray> reresult_descriptors = 1941 Handle<DescriptorArray> reresult_descriptors =
1951 factory()->NewDescriptorArray(0, 3); 1942 factory()->NewDescriptorArray(0, 3);
1952 DescriptorArray::WhitenessWitness witness(*reresult_descriptors);
1953 initial_map->set_instance_descriptors(*reresult_descriptors); 1943 initial_map->set_instance_descriptors(*reresult_descriptors);
1954 1944
1955 { 1945 {
1956 JSFunction* array_function = native_context()->array_function(); 1946 JSFunction* array_function = native_context()->array_function();
1957 Handle<DescriptorArray> array_descriptors( 1947 Handle<DescriptorArray> array_descriptors(
1958 array_function->initial_map()->instance_descriptors()); 1948 array_function->initial_map()->instance_descriptors());
1959 Handle<String> length = factory()->length_string(); 1949 Handle<String> length = factory()->length_string();
1960 int old = array_descriptors->SearchWithCache( 1950 int old = array_descriptors->SearchWithCache(
1961 *length, array_function->initial_map()); 1951 *length, array_function->initial_map());
1962 ASSERT(old != DescriptorArray::kNotFound); 1952 ASSERT(old != DescriptorArray::kNotFound);
1963 CallbacksDescriptor desc(length, 1953 CallbacksDescriptor desc(length,
1964 handle(array_descriptors->GetValue(old), 1954 handle(array_descriptors->GetValue(old),
1965 isolate()), 1955 isolate()),
1966 array_descriptors->GetDetails(old).attributes()); 1956 array_descriptors->GetDetails(old).attributes());
1967 initial_map->AppendDescriptor(&desc, witness); 1957 initial_map->AppendDescriptor(&desc);
1968 } 1958 }
1969 { 1959 {
1970 FieldDescriptor index_field(factory()->index_string(), 1960 FieldDescriptor index_field(factory()->index_string(),
1971 JSRegExpResult::kIndexIndex, 1961 JSRegExpResult::kIndexIndex,
1972 NONE, 1962 NONE,
1973 Representation::Tagged()); 1963 Representation::Tagged());
1974 initial_map->AppendDescriptor(&index_field, witness); 1964 initial_map->AppendDescriptor(&index_field);
1975 } 1965 }
1976 1966
1977 { 1967 {
1978 FieldDescriptor input_field(factory()->input_string(), 1968 FieldDescriptor input_field(factory()->input_string(),
1979 JSRegExpResult::kInputIndex, 1969 JSRegExpResult::kInputIndex,
1980 NONE, 1970 NONE,
1981 Representation::Tagged()); 1971 Representation::Tagged());
1982 initial_map->AppendDescriptor(&input_field, witness); 1972 initial_map->AppendDescriptor(&input_field);
1983 } 1973 }
1984 1974
1985 initial_map->set_inobject_properties(2); 1975 initial_map->set_inobject_properties(2);
1986 initial_map->set_pre_allocated_property_fields(2); 1976 initial_map->set_pre_allocated_property_fields(2);
1987 initial_map->set_unused_property_fields(0); 1977 initial_map->set_unused_property_fields(0);
1988 1978
1989 native_context()->set_regexp_result_map(*initial_map); 1979 native_context()->set_regexp_result_map(*initial_map);
1990 } 1980 }
1991 1981
1992 #ifdef VERIFY_HEAP 1982 #ifdef VERIFY_HEAP
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 return from + sizeof(NestingCounterType); 2708 return from + sizeof(NestingCounterType);
2719 } 2709 }
2720 2710
2721 2711
2722 // Called when the top-level V8 mutex is destroyed. 2712 // Called when the top-level V8 mutex is destroyed.
2723 void Bootstrapper::FreeThreadResources() { 2713 void Bootstrapper::FreeThreadResources() {
2724 ASSERT(!IsActive()); 2714 ASSERT(!IsActive());
2725 } 2715 }
2726 2716
2727 } } // namespace v8::internal 2717 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698