OLD | NEW |
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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 ADD_READONLY_PROTOTYPE, | 293 ADD_READONLY_PROTOTYPE, |
294 ADD_WRITEABLE_PROTOTYPE | 294 ADD_WRITEABLE_PROTOTYPE |
295 }; | 295 }; |
296 | 296 |
297 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode); | 297 Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode); |
298 | 298 |
299 void SetFunctionInstanceDescriptor(Handle<Map> map, | 299 void SetFunctionInstanceDescriptor(Handle<Map> map, |
300 PrototypePropertyMode prototypeMode); | 300 PrototypePropertyMode prototypeMode); |
301 void MakeFunctionInstancePrototypeWritable(); | 301 void MakeFunctionInstancePrototypeWritable(); |
302 | 302 |
303 Handle<Map> CreateStrictModeFunctionMap( | 303 Handle<Map> CreateStrictFunctionMap( |
304 PrototypePropertyMode prototype_mode, | 304 PrototypePropertyMode prototype_mode, |
305 Handle<JSFunction> empty_function); | 305 Handle<JSFunction> empty_function); |
306 | 306 |
307 void SetStrictFunctionInstanceDescriptor(Handle<Map> map, | 307 void SetStrictFunctionInstanceDescriptor(Handle<Map> map, |
308 PrototypePropertyMode propertyMode); | 308 PrototypePropertyMode propertyMode); |
309 | 309 |
310 static bool CompileBuiltin(Isolate* isolate, int index); | 310 static bool CompileBuiltin(Isolate* isolate, int index); |
311 static bool CompileExperimentalBuiltin(Isolate* isolate, int index); | 311 static bool CompileExperimentalBuiltin(Isolate* isolate, int index); |
312 static bool CompileNative(Isolate* isolate, | 312 static bool CompileNative(Isolate* isolate, |
313 Vector<const char> name, | 313 Vector<const char> name, |
314 Handle<String> source); | 314 Handle<String> source); |
315 static bool CompileScriptCached(Isolate* isolate, | 315 static bool CompileScriptCached(Isolate* isolate, |
316 Vector<const char> name, | 316 Vector<const char> name, |
317 Handle<String> source, | 317 Handle<String> source, |
318 SourceCodeCache* cache, | 318 SourceCodeCache* cache, |
319 v8::Extension* extension, | 319 v8::Extension* extension, |
320 Handle<Context> top_context, | 320 Handle<Context> top_context, |
321 bool use_runtime_context); | 321 bool use_runtime_context); |
322 | 322 |
323 Isolate* isolate_; | 323 Isolate* isolate_; |
324 Handle<Context> result_; | 324 Handle<Context> result_; |
325 Handle<Context> native_context_; | 325 Handle<Context> native_context_; |
326 | 326 |
327 // Function maps. Function maps are created initially with a read only | 327 // Function maps. Function maps are created initially with a read only |
328 // prototype for the processing of JS builtins. Later the function maps are | 328 // prototype for the processing of JS builtins. Later the function maps are |
329 // replaced in order to make prototype writable. These are the final, writable | 329 // replaced in order to make prototype writable. These are the final, writable |
330 // prototype, maps. | 330 // prototype, maps. |
331 Handle<Map> function_map_writable_prototype_; | 331 Handle<Map> sloppy_function_map_writable_prototype_; |
332 Handle<Map> strict_mode_function_map_writable_prototype_; | 332 Handle<Map> strict_function_map_writable_prototype_; |
333 Handle<JSFunction> throw_type_error_function; | 333 Handle<JSFunction> throw_type_error_function; |
334 | 334 |
335 BootstrapperActive active_; | 335 BootstrapperActive active_; |
336 friend class Bootstrapper; | 336 friend class Bootstrapper; |
337 }; | 337 }; |
338 | 338 |
339 | 339 |
340 void Bootstrapper::Iterate(ObjectVisitor* v) { | 340 void Bootstrapper::Iterate(ObjectVisitor* v) { |
341 extensions_cache_.Iterate(v); | 341 extensions_cache_.Iterate(v); |
342 v->Synchronize(VisitorSynchronization::kExtensions); | 342 v->Synchronize(VisitorSynchronization::kExtensions); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 | 467 |
468 | 468 |
469 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { | 469 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { |
470 // Allocate the map for function instances. Maps are allocated first and their | 470 // Allocate the map for function instances. Maps are allocated first and their |
471 // prototypes patched later, once empty function is created. | 471 // prototypes patched later, once empty function is created. |
472 | 472 |
473 // Functions with this map will not have a 'prototype' property, and | 473 // Functions with this map will not have a 'prototype' property, and |
474 // can not be used as constructors. | 474 // can not be used as constructors. |
475 Handle<Map> function_without_prototype_map = | 475 Handle<Map> function_without_prototype_map = |
476 CreateFunctionMap(DONT_ADD_PROTOTYPE); | 476 CreateFunctionMap(DONT_ADD_PROTOTYPE); |
477 native_context()->set_function_without_prototype_map( | 477 native_context()->set_sloppy_function_without_prototype_map( |
478 *function_without_prototype_map); | 478 *function_without_prototype_map); |
479 | 479 |
480 // Allocate the function map. This map is temporary, used only for processing | 480 // Allocate the function map. This map is temporary, used only for processing |
481 // of builtins. | 481 // of builtins. |
482 // Later the map is replaced with writable prototype map, allocated below. | 482 // Later the map is replaced with writable prototype map, allocated below. |
483 Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE); | 483 Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE); |
484 native_context()->set_function_map(*function_map); | 484 native_context()->set_sloppy_function_map(*function_map); |
485 | 485 |
486 // The final map for functions. Writeable prototype. | 486 // The final map for functions. Writeable prototype. |
487 // This map is installed in MakeFunctionInstancePrototypeWritable. | 487 // This map is installed in MakeFunctionInstancePrototypeWritable. |
488 function_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); | 488 sloppy_function_map_writable_prototype_ = |
| 489 CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); |
489 | 490 |
490 Factory* factory = isolate->factory(); | 491 Factory* factory = isolate->factory(); |
491 | 492 |
492 Handle<String> object_name = factory->Object_string(); | 493 Handle<String> object_name = factory->Object_string(); |
493 | 494 |
494 { // --- O b j e c t --- | 495 { // --- O b j e c t --- |
495 Handle<JSFunction> object_fun = | 496 Handle<JSFunction> object_fun = |
496 factory->NewFunction(object_name, factory->null_value()); | 497 factory->NewFunction(object_name, factory->null_value()); |
497 Handle<Map> object_function_map = | 498 Handle<Map> object_function_map = |
498 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 499 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
(...skipping 13 matching lines...) Expand all Loading... |
512 // assertions during startup. | 513 // assertions during startup. |
513 native_context()->set_initial_array_prototype(*prototype); | 514 native_context()->set_initial_array_prototype(*prototype); |
514 Accessors::FunctionSetPrototype(object_fun, prototype); | 515 Accessors::FunctionSetPrototype(object_fun, prototype); |
515 } | 516 } |
516 | 517 |
517 // Allocate the empty function as the prototype for function ECMAScript | 518 // Allocate the empty function as the prototype for function ECMAScript |
518 // 262 15.3.4. | 519 // 262 15.3.4. |
519 Handle<String> empty_string = | 520 Handle<String> empty_string = |
520 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); | 521 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); |
521 Handle<JSFunction> empty_function = | 522 Handle<JSFunction> empty_function = |
522 factory->NewFunctionWithoutPrototype(empty_string, SLOPPY_MODE); | 523 factory->NewFunctionWithoutPrototype(empty_string, SLOPPY); |
523 | 524 |
524 // --- E m p t y --- | 525 // --- E m p t y --- |
525 Handle<Code> code = | 526 Handle<Code> code = |
526 Handle<Code>(isolate->builtins()->builtin( | 527 Handle<Code>(isolate->builtins()->builtin( |
527 Builtins::kEmptyFunction)); | 528 Builtins::kEmptyFunction)); |
528 empty_function->set_code(*code); | 529 empty_function->set_code(*code); |
529 empty_function->shared()->set_code(*code); | 530 empty_function->shared()->set_code(*code); |
530 Handle<String> source = | 531 Handle<String> source = |
531 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); | 532 factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}")); |
532 Handle<Script> script = factory->NewScript(source); | 533 Handle<Script> script = factory->NewScript(source); |
533 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 534 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
534 empty_function->shared()->set_script(*script); | 535 empty_function->shared()->set_script(*script); |
535 empty_function->shared()->set_start_position(0); | 536 empty_function->shared()->set_start_position(0); |
536 empty_function->shared()->set_end_position(source->length()); | 537 empty_function->shared()->set_end_position(source->length()); |
537 empty_function->shared()->DontAdaptArguments(); | 538 empty_function->shared()->DontAdaptArguments(); |
538 | 539 |
539 // Set prototypes for the function maps. | 540 // Set prototypes for the function maps. |
540 native_context()->function_map()->set_prototype(*empty_function); | 541 native_context()->sloppy_function_map()->set_prototype(*empty_function); |
541 native_context()->function_without_prototype_map()-> | 542 native_context()->sloppy_function_without_prototype_map()-> |
542 set_prototype(*empty_function); | 543 set_prototype(*empty_function); |
543 function_map_writable_prototype_->set_prototype(*empty_function); | 544 sloppy_function_map_writable_prototype_->set_prototype(*empty_function); |
544 | 545 |
545 // Allocate the function map first and then patch the prototype later | 546 // Allocate the function map first and then patch the prototype later |
546 Handle<Map> empty_function_map = CreateFunctionMap(DONT_ADD_PROTOTYPE); | 547 Handle<Map> empty_function_map = CreateFunctionMap(DONT_ADD_PROTOTYPE); |
547 empty_function_map->set_prototype( | 548 empty_function_map->set_prototype( |
548 native_context()->object_function()->prototype()); | 549 native_context()->object_function()->prototype()); |
549 empty_function->set_map(*empty_function_map); | 550 empty_function->set_map(*empty_function_map); |
550 return empty_function; | 551 return empty_function; |
551 } | 552 } |
552 | 553 |
553 | 554 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 } | 598 } |
598 } | 599 } |
599 | 600 |
600 | 601 |
601 // ECMAScript 5th Edition, 13.2.3 | 602 // ECMAScript 5th Edition, 13.2.3 |
602 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { | 603 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
603 if (throw_type_error_function.is_null()) { | 604 if (throw_type_error_function.is_null()) { |
604 Handle<String> name = factory()->InternalizeOneByteString( | 605 Handle<String> name = factory()->InternalizeOneByteString( |
605 STATIC_ASCII_VECTOR("ThrowTypeError")); | 606 STATIC_ASCII_VECTOR("ThrowTypeError")); |
606 throw_type_error_function = | 607 throw_type_error_function = |
607 factory()->NewFunctionWithoutPrototype(name, SLOPPY_MODE); | 608 factory()->NewFunctionWithoutPrototype(name, SLOPPY); |
608 Handle<Code> code(isolate()->builtins()->builtin( | 609 Handle<Code> code(isolate()->builtins()->builtin( |
609 Builtins::kStrictModePoisonPill)); | 610 Builtins::kStrictModePoisonPill)); |
610 throw_type_error_function->set_map( | 611 throw_type_error_function->set_map(native_context()->sloppy_function_map()); |
611 native_context()->function_map()); | |
612 throw_type_error_function->set_code(*code); | 612 throw_type_error_function->set_code(*code); |
613 throw_type_error_function->shared()->set_code(*code); | 613 throw_type_error_function->shared()->set_code(*code); |
614 throw_type_error_function->shared()->DontAdaptArguments(); | 614 throw_type_error_function->shared()->DontAdaptArguments(); |
615 | 615 |
616 JSObject::PreventExtensions(throw_type_error_function); | 616 JSObject::PreventExtensions(throw_type_error_function); |
617 } | 617 } |
618 return throw_type_error_function; | 618 return throw_type_error_function; |
619 } | 619 } |
620 | 620 |
621 | 621 |
622 Handle<Map> Genesis::CreateStrictModeFunctionMap( | 622 Handle<Map> Genesis::CreateStrictFunctionMap( |
623 PrototypePropertyMode prototype_mode, | 623 PrototypePropertyMode prototype_mode, |
624 Handle<JSFunction> empty_function) { | 624 Handle<JSFunction> empty_function) { |
625 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 625 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
626 SetStrictFunctionInstanceDescriptor(map, prototype_mode); | 626 SetStrictFunctionInstanceDescriptor(map, prototype_mode); |
627 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); | 627 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); |
628 map->set_prototype(*empty_function); | 628 map->set_prototype(*empty_function); |
629 return map; | 629 return map; |
630 } | 630 } |
631 | 631 |
632 | 632 |
633 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { | 633 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { |
634 // Allocate map for the prototype-less strict mode instances. | 634 // Allocate map for the prototype-less strict mode instances. |
635 Handle<Map> strict_mode_function_without_prototype_map = | 635 Handle<Map> strict_function_without_prototype_map = |
636 CreateStrictModeFunctionMap(DONT_ADD_PROTOTYPE, empty); | 636 CreateStrictFunctionMap(DONT_ADD_PROTOTYPE, empty); |
637 native_context()->set_strict_mode_function_without_prototype_map( | 637 native_context()->set_strict_function_without_prototype_map( |
638 *strict_mode_function_without_prototype_map); | 638 *strict_function_without_prototype_map); |
639 | 639 |
640 // Allocate map for the strict mode functions. This map is temporary, used | 640 // Allocate map for the strict mode functions. This map is temporary, used |
641 // only for processing of builtins. | 641 // only for processing of builtins. |
642 // Later the map is replaced with writable prototype map, allocated below. | 642 // Later the map is replaced with writable prototype map, allocated below. |
643 Handle<Map> strict_mode_function_map = | 643 Handle<Map> strict_function_map = |
644 CreateStrictModeFunctionMap(ADD_READONLY_PROTOTYPE, empty); | 644 CreateStrictFunctionMap(ADD_READONLY_PROTOTYPE, empty); |
645 native_context()->set_strict_mode_function_map( | 645 native_context()->set_strict_function_map(*strict_function_map); |
646 *strict_mode_function_map); | |
647 | 646 |
648 // The final map for the strict mode functions. Writeable prototype. | 647 // The final map for the strict mode functions. Writeable prototype. |
649 // This map is installed in MakeFunctionInstancePrototypeWritable. | 648 // This map is installed in MakeFunctionInstancePrototypeWritable. |
650 strict_mode_function_map_writable_prototype_ = | 649 strict_function_map_writable_prototype_ = |
651 CreateStrictModeFunctionMap(ADD_WRITEABLE_PROTOTYPE, empty); | 650 CreateStrictFunctionMap(ADD_WRITEABLE_PROTOTYPE, empty); |
652 | 651 |
653 // Complete the callbacks. | 652 // Complete the callbacks. |
654 PoisonArgumentsAndCaller(strict_mode_function_without_prototype_map); | 653 PoisonArgumentsAndCaller(strict_function_without_prototype_map); |
655 PoisonArgumentsAndCaller(strict_mode_function_map); | 654 PoisonArgumentsAndCaller(strict_function_map); |
656 PoisonArgumentsAndCaller(strict_mode_function_map_writable_prototype_); | 655 PoisonArgumentsAndCaller(strict_function_map_writable_prototype_); |
657 } | 656 } |
658 | 657 |
659 | 658 |
660 static void SetAccessors(Handle<Map> map, | 659 static void SetAccessors(Handle<Map> map, |
661 Handle<String> name, | 660 Handle<String> name, |
662 Handle<JSFunction> func) { | 661 Handle<JSFunction> func) { |
663 DescriptorArray* descs = map->instance_descriptors(); | 662 DescriptorArray* descs = map->instance_descriptors(); |
664 int number = descs->SearchWithCache(*name, *map); | 663 int number = descs->SearchWithCache(*name, *map); |
665 AccessorPair* accessors = AccessorPair::cast(descs->GetValue(number)); | 664 AccessorPair* accessors = AccessorPair::cast(descs->GetValue(number)); |
666 accessors->set_getter(*func); | 665 accessors->set_getter(*func); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 JS_OBJECT_TYPE, | 1129 JS_OBJECT_TYPE, |
1131 JSObject::kHeaderSize, | 1130 JSObject::kHeaderSize, |
1132 prototype, | 1131 prototype, |
1133 code, | 1132 code, |
1134 false); | 1133 false); |
1135 ASSERT(!function->has_initial_map()); | 1134 ASSERT(!function->has_initial_map()); |
1136 function->shared()->set_instance_class_name(*arguments_string); | 1135 function->shared()->set_instance_class_name(*arguments_string); |
1137 function->shared()->set_expected_nof_properties(2); | 1136 function->shared()->set_expected_nof_properties(2); |
1138 Handle<JSObject> result = factory->NewJSObject(function); | 1137 Handle<JSObject> result = factory->NewJSObject(function); |
1139 | 1138 |
1140 native_context()->set_arguments_boilerplate(*result); | 1139 native_context()->set_sloppy_arguments_boilerplate(*result); |
1141 // Note: length must be added as the first property and | 1140 // Note: length must be added as the first property and |
1142 // callee must be added as the second property. | 1141 // callee must be added as the second property. |
1143 CHECK_NOT_EMPTY_HANDLE(isolate, | 1142 CHECK_NOT_EMPTY_HANDLE(isolate, |
1144 JSObject::SetLocalPropertyIgnoreAttributes( | 1143 JSObject::SetLocalPropertyIgnoreAttributes( |
1145 result, factory->length_string(), | 1144 result, factory->length_string(), |
1146 factory->undefined_value(), DONT_ENUM, | 1145 factory->undefined_value(), DONT_ENUM, |
1147 Object::FORCE_TAGGED, FORCE_FIELD)); | 1146 Object::FORCE_TAGGED, FORCE_FIELD)); |
1148 CHECK_NOT_EMPTY_HANDLE(isolate, | 1147 CHECK_NOT_EMPTY_HANDLE(isolate, |
1149 JSObject::SetLocalPropertyIgnoreAttributes( | 1148 JSObject::SetLocalPropertyIgnoreAttributes( |
1150 result, factory->callee_string(), | 1149 result, factory->callee_string(), |
(...skipping 22 matching lines...) Expand all Loading... |
1173 { // --- aliased_arguments_boilerplate_ | 1172 { // --- aliased_arguments_boilerplate_ |
1174 // Set up a well-formed parameter map to make assertions happy. | 1173 // Set up a well-formed parameter map to make assertions happy. |
1175 Handle<FixedArray> elements = factory->NewFixedArray(2); | 1174 Handle<FixedArray> elements = factory->NewFixedArray(2); |
1176 elements->set_map(heap->sloppy_arguments_elements_map()); | 1175 elements->set_map(heap->sloppy_arguments_elements_map()); |
1177 Handle<FixedArray> array; | 1176 Handle<FixedArray> array; |
1178 array = factory->NewFixedArray(0); | 1177 array = factory->NewFixedArray(0); |
1179 elements->set(0, *array); | 1178 elements->set(0, *array); |
1180 array = factory->NewFixedArray(0); | 1179 array = factory->NewFixedArray(0); |
1181 elements->set(1, *array); | 1180 elements->set(1, *array); |
1182 | 1181 |
1183 Handle<Map> old_map(native_context()->arguments_boilerplate()->map()); | 1182 Handle<Map> old_map( |
| 1183 native_context()->sloppy_arguments_boilerplate()->map()); |
1184 Handle<Map> new_map = factory->CopyMap(old_map); | 1184 Handle<Map> new_map = factory->CopyMap(old_map); |
1185 new_map->set_pre_allocated_property_fields(2); | 1185 new_map->set_pre_allocated_property_fields(2); |
1186 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map); | 1186 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map); |
1187 // Set elements kind after allocating the object because | 1187 // Set elements kind after allocating the object because |
1188 // NewJSObjectFromMap assumes a fast elements map. | 1188 // NewJSObjectFromMap assumes a fast elements map. |
1189 new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS); | 1189 new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS); |
1190 result->set_elements(*elements); | 1190 result->set_elements(*elements); |
1191 ASSERT(result->HasSloppyArgumentsElements()); | 1191 ASSERT(result->HasSloppyArgumentsElements()); |
1192 native_context()->set_aliased_arguments_boilerplate(*result); | 1192 native_context()->set_aliased_arguments_boilerplate(*result); |
1193 } | 1193 } |
(...skipping 10 matching lines...) Expand all Loading... |
1204 GetThrowTypeErrorFunction(); | 1204 GetThrowTypeErrorFunction(); |
1205 | 1205 |
1206 // Install the ThrowTypeError functions. | 1206 // Install the ThrowTypeError functions. |
1207 callee->set_getter(*throw_function); | 1207 callee->set_getter(*throw_function); |
1208 callee->set_setter(*throw_function); | 1208 callee->set_setter(*throw_function); |
1209 caller->set_getter(*throw_function); | 1209 caller->set_getter(*throw_function); |
1210 caller->set_setter(*throw_function); | 1210 caller->set_setter(*throw_function); |
1211 | 1211 |
1212 // Create the map. Allocate one in-object field for length. | 1212 // Create the map. Allocate one in-object field for length. |
1213 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, | 1213 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, |
1214 Heap::kArgumentsObjectSizeStrict); | 1214 Heap::kStrictArgumentsObjectSize); |
1215 // Create the descriptor array for the arguments object. | 1215 // Create the descriptor array for the arguments object. |
1216 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3); | 1216 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3); |
1217 DescriptorArray::WhitenessWitness witness(*descriptors); | 1217 DescriptorArray::WhitenessWitness witness(*descriptors); |
1218 map->set_instance_descriptors(*descriptors); | 1218 map->set_instance_descriptors(*descriptors); |
1219 | 1219 |
1220 { // length | 1220 { // length |
1221 FieldDescriptor d( | 1221 FieldDescriptor d( |
1222 *factory->length_string(), 0, DONT_ENUM, Representation::Tagged()); | 1222 *factory->length_string(), 0, DONT_ENUM, Representation::Tagged()); |
1223 map->AppendDescriptor(&d, witness); | 1223 map->AppendDescriptor(&d, witness); |
1224 } | 1224 } |
(...skipping 10 matching lines...) Expand all Loading... |
1235 map->AppendDescriptor(&d, witness); | 1235 map->AppendDescriptor(&d, witness); |
1236 } | 1236 } |
1237 | 1237 |
1238 map->set_function_with_prototype(true); | 1238 map->set_function_with_prototype(true); |
1239 map->set_prototype(native_context()->object_function()->prototype()); | 1239 map->set_prototype(native_context()->object_function()->prototype()); |
1240 map->set_pre_allocated_property_fields(1); | 1240 map->set_pre_allocated_property_fields(1); |
1241 map->set_inobject_properties(1); | 1241 map->set_inobject_properties(1); |
1242 | 1242 |
1243 // Copy constructor from the sloppy arguments boilerplate. | 1243 // Copy constructor from the sloppy arguments boilerplate. |
1244 map->set_constructor( | 1244 map->set_constructor( |
1245 native_context()->arguments_boilerplate()->map()->constructor()); | 1245 native_context()->sloppy_arguments_boilerplate()->map()->constructor()); |
1246 | 1246 |
1247 // Allocate the arguments boilerplate object. | 1247 // Allocate the arguments boilerplate object. |
1248 Handle<JSObject> result = factory->NewJSObjectFromMap(map); | 1248 Handle<JSObject> result = factory->NewJSObjectFromMap(map); |
1249 native_context()->set_strict_mode_arguments_boilerplate(*result); | 1249 native_context()->set_strict_arguments_boilerplate(*result); |
1250 | 1250 |
1251 // Add length property only for strict mode boilerplate. | 1251 // Add length property only for strict mode boilerplate. |
1252 CHECK_NOT_EMPTY_HANDLE(isolate, | 1252 CHECK_NOT_EMPTY_HANDLE(isolate, |
1253 JSObject::SetLocalPropertyIgnoreAttributes( | 1253 JSObject::SetLocalPropertyIgnoreAttributes( |
1254 result, factory->length_string(), | 1254 result, factory->length_string(), |
1255 factory->undefined_value(), DONT_ENUM)); | 1255 factory->undefined_value(), DONT_ENUM)); |
1256 | 1256 |
1257 #ifdef DEBUG | 1257 #ifdef DEBUG |
1258 LookupResult lookup(isolate); | 1258 LookupResult lookup(isolate); |
1259 result->LocalLookup(heap->length_string(), &lookup); | 1259 result->LocalLookup(heap->length_string(), &lookup); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, | 1382 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, |
1383 generator_object_prototype, Builtins::kIllegal, | 1383 generator_object_prototype, Builtins::kIllegal, |
1384 false, false); | 1384 false, false); |
1385 InstallFunction(builtins, "GeneratorFunction", | 1385 InstallFunction(builtins, "GeneratorFunction", |
1386 JS_FUNCTION_TYPE, JSFunction::kSize, | 1386 JS_FUNCTION_TYPE, JSFunction::kSize, |
1387 generator_function_prototype, Builtins::kIllegal, | 1387 generator_function_prototype, Builtins::kIllegal, |
1388 false, false); | 1388 false, false); |
1389 | 1389 |
1390 // Create maps for generator functions and their prototypes. Store those | 1390 // Create maps for generator functions and their prototypes. Store those |
1391 // maps in the native context. | 1391 // maps in the native context. |
1392 Handle<Map> function_map(native_context()->function_map()); | 1392 Handle<Map> function_map(native_context()->sloppy_function_map()); |
1393 Handle<Map> generator_function_map = factory()->CopyMap(function_map); | 1393 Handle<Map> generator_function_map = factory()->CopyMap(function_map); |
1394 generator_function_map->set_prototype(*generator_function_prototype); | 1394 generator_function_map->set_prototype(*generator_function_prototype); |
1395 native_context()->set_generator_function_map(*generator_function_map); | 1395 native_context()->set_sloppy_generator_function_map( |
| 1396 *generator_function_map); |
1396 | 1397 |
1397 Handle<Map> strict_mode_function_map( | 1398 Handle<Map> strict_mode_function_map( |
1398 native_context()->strict_mode_function_map()); | 1399 native_context()->strict_function_map()); |
1399 Handle<Map> strict_mode_generator_function_map = factory()->CopyMap( | 1400 Handle<Map> strict_mode_generator_function_map = factory()->CopyMap( |
1400 strict_mode_function_map); | 1401 strict_mode_function_map); |
1401 strict_mode_generator_function_map->set_prototype( | 1402 strict_mode_generator_function_map->set_prototype( |
1402 *generator_function_prototype); | 1403 *generator_function_prototype); |
1403 native_context()->set_strict_mode_generator_function_map( | 1404 native_context()->set_strict_generator_function_map( |
1404 *strict_mode_generator_function_map); | 1405 *strict_mode_generator_function_map); |
1405 | 1406 |
1406 Handle<Map> object_map(native_context()->object_function()->initial_map()); | 1407 Handle<Map> object_map(native_context()->object_function()->initial_map()); |
1407 Handle<Map> generator_object_prototype_map = factory()->CopyMap( | 1408 Handle<Map> generator_object_prototype_map = factory()->CopyMap( |
1408 object_map, 0); | 1409 object_map, 0); |
1409 generator_object_prototype_map->set_prototype( | 1410 generator_object_prototype_map->set_prototype( |
1410 *generator_object_prototype); | 1411 *generator_object_prototype); |
1411 native_context()->set_generator_object_prototype_map( | 1412 native_context()->set_generator_object_prototype_map( |
1412 *generator_object_prototype_map); | 1413 *generator_object_prototype_map); |
1413 | 1414 |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2552 Handle<Map> new_to_map = factory()->CopyMap(old_to_map); | 2553 Handle<Map> new_to_map = factory()->CopyMap(old_to_map); |
2553 new_to_map->set_prototype(from->map()->prototype()); | 2554 new_to_map->set_prototype(from->map()->prototype()); |
2554 to->set_map(*new_to_map); | 2555 to->set_map(*new_to_map); |
2555 } | 2556 } |
2556 | 2557 |
2557 | 2558 |
2558 void Genesis::MakeFunctionInstancePrototypeWritable() { | 2559 void Genesis::MakeFunctionInstancePrototypeWritable() { |
2559 // The maps with writable prototype are created in CreateEmptyFunction | 2560 // The maps with writable prototype are created in CreateEmptyFunction |
2560 // and CreateStrictModeFunctionMaps respectively. Initially the maps are | 2561 // and CreateStrictModeFunctionMaps respectively. Initially the maps are |
2561 // created with read-only prototype for JS builtins processing. | 2562 // created with read-only prototype for JS builtins processing. |
2562 ASSERT(!function_map_writable_prototype_.is_null()); | 2563 ASSERT(!sloppy_function_map_writable_prototype_.is_null()); |
2563 ASSERT(!strict_mode_function_map_writable_prototype_.is_null()); | 2564 ASSERT(!strict_function_map_writable_prototype_.is_null()); |
2564 | 2565 |
2565 // Replace function instance maps to make prototype writable. | 2566 // Replace function instance maps to make prototype writable. |
2566 native_context()->set_function_map(*function_map_writable_prototype_); | 2567 native_context()->set_sloppy_function_map( |
2567 native_context()->set_strict_mode_function_map( | 2568 *sloppy_function_map_writable_prototype_); |
2568 *strict_mode_function_map_writable_prototype_); | 2569 native_context()->set_strict_function_map( |
| 2570 *strict_function_map_writable_prototype_); |
2569 } | 2571 } |
2570 | 2572 |
2571 | 2573 |
2572 class NoTrackDoubleFieldsForSerializerScope { | 2574 class NoTrackDoubleFieldsForSerializerScope { |
2573 public: | 2575 public: |
2574 NoTrackDoubleFieldsForSerializerScope() : flag_(FLAG_track_double_fields) { | 2576 NoTrackDoubleFieldsForSerializerScope() : flag_(FLAG_track_double_fields) { |
2575 if (Serializer::enabled()) { | 2577 if (Serializer::enabled()) { |
2576 // Disable tracking double fields because heap numbers treated as | 2578 // Disable tracking double fields because heap numbers treated as |
2577 // immutable by the serializer. | 2579 // immutable by the serializer. |
2578 FLAG_track_double_fields = false; | 2580 FLAG_track_double_fields = false; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 return from + sizeof(NestingCounterType); | 2748 return from + sizeof(NestingCounterType); |
2747 } | 2749 } |
2748 | 2750 |
2749 | 2751 |
2750 // Called when the top-level V8 mutex is destroyed. | 2752 // Called when the top-level V8 mutex is destroyed. |
2751 void Bootstrapper::FreeThreadResources() { | 2753 void Bootstrapper::FreeThreadResources() { |
2752 ASSERT(!IsActive()); | 2754 ASSERT(!IsActive()); |
2753 } | 2755 } |
2754 | 2756 |
2755 } } // namespace v8::internal | 2757 } } // namespace v8::internal |
OLD | NEW |