| OLD | NEW |
| 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 "factory.h" | 5 #include "factory.h" |
| 6 | 6 |
| 7 #include "macro-assembler.h" | 7 #include "macro-assembler.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "v8conversions.h" | 9 #include "v8conversions.h" |
| 10 | 10 |
| (...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 | 1781 |
| 1782 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { | 1782 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { |
| 1783 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize); | 1783 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize); |
| 1784 } | 1784 } |
| 1785 | 1785 |
| 1786 | 1786 |
| 1787 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 1787 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
| 1788 Handle<String> name, | 1788 Handle<String> name, |
| 1789 int number_of_literals, | 1789 int number_of_literals, |
| 1790 bool is_generator, | 1790 bool is_generator, |
| 1791 bool is_arrow, |
| 1791 Handle<Code> code, | 1792 Handle<Code> code, |
| 1792 Handle<ScopeInfo> scope_info) { | 1793 Handle<ScopeInfo> scope_info) { |
| 1793 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); | 1794 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); |
| 1794 shared->set_code(*code); | 1795 shared->set_code(*code); |
| 1795 shared->set_scope_info(*scope_info); | 1796 shared->set_scope_info(*scope_info); |
| 1797 shared->set_is_arrow(is_arrow); |
| 1796 int literals_array_size = number_of_literals; | 1798 int literals_array_size = number_of_literals; |
| 1797 // If the function contains object, regexp or array literals, | 1799 // If the function contains object, regexp or array literals, |
| 1798 // allocate extra space for a literals array prefix containing the | 1800 // allocate extra space for a literals array prefix containing the |
| 1799 // context. | 1801 // context. |
| 1800 if (number_of_literals > 0) { | 1802 if (number_of_literals > 0) { |
| 1801 literals_array_size += JSFunction::kLiteralsPrefixSize; | 1803 literals_array_size += JSFunction::kLiteralsPrefixSize; |
| 1802 } | 1804 } |
| 1803 shared->set_num_literals(literals_array_size); | 1805 shared->set_num_literals(literals_array_size); |
| 1804 if (is_generator) { | 1806 if (is_generator) { |
| 1805 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 1807 shared->set_instance_class_name(isolate()->heap()->Generator_string()); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 } | 1985 } |
| 1984 function->set_prototype_or_initial_map(*prototype); | 1986 function->set_prototype_or_initial_map(*prototype); |
| 1985 function->set_literals_or_bindings(*empty_fixed_array()); | 1987 function->set_literals_or_bindings(*empty_fixed_array()); |
| 1986 function->set_next_function_link(*undefined_value()); | 1988 function->set_next_function_link(*undefined_value()); |
| 1987 } | 1989 } |
| 1988 | 1990 |
| 1989 | 1991 |
| 1990 static Handle<Map> MapForNewFunction(Isolate* isolate, | 1992 static Handle<Map> MapForNewFunction(Isolate* isolate, |
| 1991 Handle<SharedFunctionInfo> function_info, | 1993 Handle<SharedFunctionInfo> function_info, |
| 1992 MaybeHandle<Object> maybe_prototype) { | 1994 MaybeHandle<Object> maybe_prototype) { |
| 1993 if (maybe_prototype.is_null()) { | 1995 if (maybe_prototype.is_null() || function_info->is_arrow()) { |
| 1994 return function_info->strict_mode() == SLOPPY | 1996 return function_info->strict_mode() == SLOPPY |
| 1995 ? isolate->sloppy_function_without_prototype_map() | 1997 ? isolate->sloppy_function_without_prototype_map() |
| 1996 : isolate->strict_function_without_prototype_map(); | 1998 : isolate->strict_function_without_prototype_map(); |
| 1997 } | 1999 } |
| 1998 | 2000 |
| 1999 Context* context = isolate->context()->native_context(); | 2001 Context* context = isolate->context()->native_context(); |
| 2000 int map_index = Context::FunctionMapIndex(function_info->strict_mode(), | 2002 int map_index = Context::FunctionMapIndex(function_info->strict_mode(), |
| 2001 function_info->is_generator()); | 2003 function_info->is_generator()); |
| 2002 return Handle<Map>(Map::cast(context->get(map_index))); | 2004 return Handle<Map>(Map::cast(context->get(map_index))); |
| 2003 } | 2005 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 return Handle<Object>::null(); | 2330 return Handle<Object>::null(); |
| 2329 } | 2331 } |
| 2330 | 2332 |
| 2331 | 2333 |
| 2332 Handle<Object> Factory::ToBoolean(bool value) { | 2334 Handle<Object> Factory::ToBoolean(bool value) { |
| 2333 return value ? true_value() : false_value(); | 2335 return value ? true_value() : false_value(); |
| 2334 } | 2336 } |
| 2335 | 2337 |
| 2336 | 2338 |
| 2337 } } // namespace v8::internal | 2339 } } // namespace v8::internal |
| OLD | NEW |