OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 pretenure), | 344 pretenure), |
345 JSFunction); | 345 JSFunction); |
346 } | 346 } |
347 | 347 |
348 | 348 |
349 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( | 349 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
350 Handle<SharedFunctionInfo> function_info, | 350 Handle<SharedFunctionInfo> function_info, |
351 Handle<Context> context, | 351 Handle<Context> context, |
352 PretenureFlag pretenure) { | 352 PretenureFlag pretenure) { |
353 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo( | 353 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo( |
354 function_info, Top::function_map(), pretenure); | 354 function_info, |
| 355 function_info->strict_mode() |
| 356 ? Top::strict_mode_function_map() |
| 357 : Top::function_map(), |
| 358 pretenure); |
| 359 |
355 result->set_context(*context); | 360 result->set_context(*context); |
356 int number_of_literals = function_info->num_literals(); | 361 int number_of_literals = function_info->num_literals(); |
357 Handle<FixedArray> literals = | 362 Handle<FixedArray> literals = |
358 Factory::NewFixedArray(number_of_literals, pretenure); | 363 Factory::NewFixedArray(number_of_literals, pretenure); |
359 if (number_of_literals > 0) { | 364 if (number_of_literals > 0) { |
360 // Store the object, regexp and array functions in the literals | 365 // Store the object, regexp and array functions in the literals |
361 // array prefix. These functions will be used when creating | 366 // array prefix. These functions will be used when creating |
362 // object, regexp and array literals in this function. | 367 // object, regexp and array literals in this function. |
363 literals->set(JSFunction::kLiteralGlobalContextIndex, | 368 literals->set(JSFunction::kLiteralGlobalContextIndex, |
364 context->global_context()); | 369 context->global_context()); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 SetPrototypeProperty(function, prototype); | 582 SetPrototypeProperty(function, prototype); |
578 // Currently safe because it is only invoked from Genesis. | 583 // Currently safe because it is only invoked from Genesis. |
579 SetLocalPropertyNoThrow( | 584 SetLocalPropertyNoThrow( |
580 prototype, Factory::constructor_symbol(), function, DONT_ENUM); | 585 prototype, Factory::constructor_symbol(), function, DONT_ENUM); |
581 return function; | 586 return function; |
582 } | 587 } |
583 | 588 |
584 | 589 |
585 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, | 590 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, |
586 Handle<Code> code) { | 591 Handle<Code> code) { |
587 Handle<JSFunction> function = NewFunctionWithoutPrototype(name); | 592 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, |
| 593 kNonStrictMode); |
588 function->shared()->set_code(*code); | 594 function->shared()->set_code(*code); |
589 function->set_code(*code); | 595 function->set_code(*code); |
590 ASSERT(!function->has_initial_map()); | 596 ASSERT(!function->has_initial_map()); |
591 ASSERT(!function->has_prototype()); | 597 ASSERT(!function->has_prototype()); |
592 return function; | 598 return function; |
593 } | 599 } |
594 | 600 |
595 | 601 |
596 Handle<Code> Factory::NewCode(const CodeDesc& desc, | 602 Handle<Code> Factory::NewCode(const CodeDesc& desc, |
597 Code::Flags flags, | 603 Code::Flags flags, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 | 808 |
803 Handle<JSFunction> Factory::NewFunction(Handle<String> name, | 809 Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
804 Handle<Object> prototype) { | 810 Handle<Object> prototype) { |
805 Handle<JSFunction> fun = NewFunctionHelper(name, prototype); | 811 Handle<JSFunction> fun = NewFunctionHelper(name, prototype); |
806 fun->set_context(Top::context()->global_context()); | 812 fun->set_context(Top::context()->global_context()); |
807 return fun; | 813 return fun; |
808 } | 814 } |
809 | 815 |
810 | 816 |
811 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper( | 817 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper( |
812 Handle<String> name) { | 818 Handle<String> name, |
| 819 StrictModeFlag strict_mode) { |
813 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); | 820 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); |
| 821 Handle<Map> map = strict_mode == kStrictMode |
| 822 ? Top::strict_mode_function_without_prototype_map() |
| 823 : Top::function_without_prototype_map(); |
814 CALL_HEAP_FUNCTION(Heap::AllocateFunction( | 824 CALL_HEAP_FUNCTION(Heap::AllocateFunction( |
815 *Top::function_without_prototype_map(), | 825 *map, |
816 *function_share, | 826 *function_share, |
817 *the_hole_value()), | 827 *the_hole_value()), |
818 JSFunction); | 828 JSFunction); |
819 } | 829 } |
820 | 830 |
821 | 831 |
822 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name) { | 832 Handle<JSFunction> Factory::NewFunctionWithoutPrototype( |
823 Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name); | 833 Handle<String> name, |
| 834 StrictModeFlag strict_mode) { |
| 835 Handle<JSFunction> fun = NewFunctionWithoutPrototypeHelper(name, strict_mode); |
824 fun->set_context(Top::context()->global_context()); | 836 fun->set_context(Top::context()->global_context()); |
825 return fun; | 837 return fun; |
826 } | 838 } |
827 | 839 |
828 | 840 |
829 Handle<Object> Factory::ToObject(Handle<Object> object) { | 841 Handle<Object> Factory::ToObject(Handle<Object> object) { |
830 CALL_HEAP_FUNCTION(object->ToObject(), Object); | 842 CALL_HEAP_FUNCTION(object->ToObject(), Object); |
831 } | 843 } |
832 | 844 |
833 | 845 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 Execution::ConfigureInstance(instance, | 1081 Execution::ConfigureInstance(instance, |
1070 instance_template, | 1082 instance_template, |
1071 pending_exception); | 1083 pending_exception); |
1072 } else { | 1084 } else { |
1073 *pending_exception = false; | 1085 *pending_exception = false; |
1074 } | 1086 } |
1075 } | 1087 } |
1076 | 1088 |
1077 | 1089 |
1078 } } // namespace v8::internal | 1090 } } // namespace v8::internal |
OLD | NEW |