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 "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 Handle<SharedFunctionInfo> info, | 1224 Handle<SharedFunctionInfo> info, |
1225 Handle<Context> context) { | 1225 Handle<Context> context) { |
1226 function->initialize_properties(); | 1226 function->initialize_properties(); |
1227 function->initialize_elements(); | 1227 function->initialize_elements(); |
1228 function->set_shared(*info); | 1228 function->set_shared(*info); |
1229 function->set_code(info->code()); | 1229 function->set_code(info->code()); |
1230 function->set_context(*context); | 1230 function->set_context(*context); |
1231 function->set_prototype_or_initial_map(*the_hole_value()); | 1231 function->set_prototype_or_initial_map(*the_hole_value()); |
1232 function->set_literals_or_bindings(*empty_fixed_array()); | 1232 function->set_literals_or_bindings(*empty_fixed_array()); |
1233 function->set_next_function_link(*undefined_value()); | 1233 function->set_next_function_link(*undefined_value()); |
| 1234 |
| 1235 // TODO(arv): This does not look correct. We need to make sure we use |
| 1236 // a Map that has no prototype property. |
1234 if (info->is_arrow()) function->RemovePrototype(); | 1237 if (info->is_arrow()) function->RemovePrototype(); |
1235 } | 1238 } |
1236 | 1239 |
1237 | 1240 |
1238 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, | 1241 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
1239 Handle<SharedFunctionInfo> info, | 1242 Handle<SharedFunctionInfo> info, |
1240 Handle<Context> context, | 1243 Handle<Context> context, |
1241 PretenureFlag pretenure) { | 1244 PretenureFlag pretenure) { |
1242 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE; | 1245 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE; |
1243 Handle<JSFunction> result = New<JSFunction>(map, space); | 1246 Handle<JSFunction> result = New<JSFunction>(map, space); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 } | 1346 } |
1344 | 1347 |
1345 return prototype; | 1348 return prototype; |
1346 } | 1349 } |
1347 | 1350 |
1348 | 1351 |
1349 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( | 1352 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
1350 Handle<SharedFunctionInfo> info, | 1353 Handle<SharedFunctionInfo> info, |
1351 Handle<Context> context, | 1354 Handle<Context> context, |
1352 PretenureFlag pretenure) { | 1355 PretenureFlag pretenure) { |
1353 int map_index = Context::FunctionMapIndex(info->strict_mode(), | 1356 int map_index = Context::FunctionMapIndex( |
1354 info->is_generator()); | 1357 info->strict_mode(), info->is_generator(), info->is_concise_method()); |
1355 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); | 1358 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); |
1356 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); | 1359 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); |
1357 | 1360 |
1358 if (info->ic_age() != isolate()->heap()->global_ic_age()) { | 1361 if (info->ic_age() != isolate()->heap()->global_ic_age()) { |
1359 info->ResetForNewContext(isolate()->heap()->global_ic_age()); | 1362 info->ResetForNewContext(isolate()->heap()->global_ic_age()); |
1360 } | 1363 } |
1361 | 1364 |
1362 int index = info->SearchOptimizedCodeMap(context->native_context(), | 1365 int index = info->SearchOptimizedCodeMap(context->native_context(), |
1363 BailoutId::None()); | 1366 BailoutId::None()); |
1364 if (!info->bound() && index < 0) { | 1367 if (!info->bound() && index < 0) { |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 isolate()->heap()->AllocateFixedArrayWithFiller( | 1889 isolate()->heap()->AllocateFixedArrayWithFiller( |
1887 slot_count, | 1890 slot_count, |
1888 TENURED, | 1891 TENURED, |
1889 *TypeFeedbackInfo::UninitializedSentinel(isolate())), | 1892 *TypeFeedbackInfo::UninitializedSentinel(isolate())), |
1890 FixedArray); | 1893 FixedArray); |
1891 } | 1894 } |
1892 | 1895 |
1893 | 1896 |
1894 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 1897 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
1895 Handle<String> name, int number_of_literals, bool is_generator, | 1898 Handle<String> name, int number_of_literals, bool is_generator, |
1896 bool is_arrow, Handle<Code> code, Handle<ScopeInfo> scope_info, | 1899 bool is_arrow, bool is_concise_method, Handle<Code> code, |
1897 Handle<FixedArray> feedback_vector) { | 1900 Handle<ScopeInfo> scope_info, Handle<FixedArray> feedback_vector) { |
1898 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); | 1901 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); |
1899 shared->set_scope_info(*scope_info); | 1902 shared->set_scope_info(*scope_info); |
1900 shared->set_feedback_vector(*feedback_vector); | 1903 shared->set_feedback_vector(*feedback_vector); |
1901 shared->set_is_arrow(is_arrow); | 1904 shared->set_is_arrow(is_arrow); |
| 1905 shared->set_is_concise_method(is_concise_method); |
1902 int literals_array_size = number_of_literals; | 1906 int literals_array_size = number_of_literals; |
1903 // If the function contains object, regexp or array literals, | 1907 // If the function contains object, regexp or array literals, |
1904 // allocate extra space for a literals array prefix containing the | 1908 // allocate extra space for a literals array prefix containing the |
1905 // context. | 1909 // context. |
1906 if (number_of_literals > 0) { | 1910 if (number_of_literals > 0) { |
1907 literals_array_size += JSFunction::kLiteralsPrefixSize; | 1911 literals_array_size += JSFunction::kLiteralsPrefixSize; |
1908 } | 1912 } |
1909 shared->set_num_literals(literals_array_size); | 1913 shared->set_num_literals(literals_array_size); |
1910 if (is_generator) { | 1914 if (is_generator) { |
1911 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 1915 shared->set_instance_class_name(isolate()->heap()->Generator_string()); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 return Handle<Object>::null(); | 2383 return Handle<Object>::null(); |
2380 } | 2384 } |
2381 | 2385 |
2382 | 2386 |
2383 Handle<Object> Factory::ToBoolean(bool value) { | 2387 Handle<Object> Factory::ToBoolean(bool value) { |
2384 return value ? true_value() : false_value(); | 2388 return value ? true_value() : false_value(); |
2385 } | 2389 } |
2386 | 2390 |
2387 | 2391 |
2388 } } // namespace v8::internal | 2392 } } // namespace v8::internal |
OLD | NEW |