| 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/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 } | 1166 } |
| 1167 DEFINE_ERROR(Error, error) | 1167 DEFINE_ERROR(Error, error) |
| 1168 DEFINE_ERROR(EvalError, eval_error) | 1168 DEFINE_ERROR(EvalError, eval_error) |
| 1169 DEFINE_ERROR(RangeError, range_error) | 1169 DEFINE_ERROR(RangeError, range_error) |
| 1170 DEFINE_ERROR(ReferenceError, reference_error) | 1170 DEFINE_ERROR(ReferenceError, reference_error) |
| 1171 DEFINE_ERROR(SyntaxError, syntax_error) | 1171 DEFINE_ERROR(SyntaxError, syntax_error) |
| 1172 DEFINE_ERROR(TypeError, type_error) | 1172 DEFINE_ERROR(TypeError, type_error) |
| 1173 #undef DEFINE_ERROR | 1173 #undef DEFINE_ERROR |
| 1174 | 1174 |
| 1175 | 1175 |
| 1176 void Factory::InitializeFunction(Handle<JSFunction> function, | 1176 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
| 1177 Handle<SharedFunctionInfo> info, | 1177 Handle<SharedFunctionInfo> info, |
| 1178 Handle<Context> context) { | 1178 Handle<Context> context, |
| 1179 PretenureFlag pretenure) { |
| 1180 AllocationSpace space = pretenure == TENURED ? OLD_SPACE : NEW_SPACE; |
| 1181 Handle<JSFunction> function = New<JSFunction>(map, space); |
| 1182 |
| 1179 function->initialize_properties(); | 1183 function->initialize_properties(); |
| 1180 function->initialize_elements(); | 1184 function->initialize_elements(); |
| 1181 function->set_shared(*info); | 1185 function->set_shared(*info); |
| 1182 function->set_code(info->code()); | 1186 function->set_code(info->code()); |
| 1183 function->set_context(*context); | 1187 function->set_context(*context); |
| 1184 function->set_prototype_or_initial_map(*the_hole_value()); | 1188 function->set_prototype_or_initial_map(*the_hole_value()); |
| 1185 function->set_literals_or_bindings(*empty_fixed_array()); | 1189 function->set_literals_or_bindings(*empty_fixed_array()); |
| 1186 function->set_next_function_link(*undefined_value(), SKIP_WRITE_BARRIER); | 1190 function->set_next_function_link(*undefined_value(), SKIP_WRITE_BARRIER); |
| 1191 isolate()->heap()->InitializeJSObjectBody(*function, *map, JSFunction::kSize); |
| 1192 return function; |
| 1187 } | 1193 } |
| 1188 | 1194 |
| 1189 | 1195 |
| 1190 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, | |
| 1191 Handle<SharedFunctionInfo> info, | |
| 1192 Handle<Context> context, | |
| 1193 PretenureFlag pretenure) { | |
| 1194 AllocationSpace space = pretenure == TENURED ? OLD_SPACE : NEW_SPACE; | |
| 1195 Handle<JSFunction> result = New<JSFunction>(map, space); | |
| 1196 InitializeFunction(result, info, context); | |
| 1197 return result; | |
| 1198 } | |
| 1199 | |
| 1200 | |
| 1201 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, | 1196 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
| 1202 Handle<String> name, | 1197 Handle<String> name, |
| 1203 MaybeHandle<Code> code) { | 1198 MaybeHandle<Code> code) { |
| 1204 Handle<Context> context(isolate()->native_context()); | 1199 Handle<Context> context(isolate()->native_context()); |
| 1205 Handle<SharedFunctionInfo> info = | 1200 Handle<SharedFunctionInfo> info = |
| 1206 NewSharedFunctionInfo(name, code, map->is_constructor()); | 1201 NewSharedFunctionInfo(name, code, map->is_constructor()); |
| 1207 DCHECK(is_sloppy(info->language_mode()) && | 1202 DCHECK(is_sloppy(info->language_mode()) && |
| 1208 (map.is_identical_to(isolate()->sloppy_function_map()) || | 1203 (map.is_identical_to(isolate()->sloppy_function_map()) || |
| 1209 map.is_identical_to( | 1204 map.is_identical_to( |
| 1210 isolate()->sloppy_function_without_prototype_map()) || | 1205 isolate()->sloppy_function_without_prototype_map()) || |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 } | 2327 } |
| 2333 | 2328 |
| 2334 | 2329 |
| 2335 Handle<Object> Factory::ToBoolean(bool value) { | 2330 Handle<Object> Factory::ToBoolean(bool value) { |
| 2336 return value ? true_value() : false_value(); | 2331 return value ? true_value() : false_value(); |
| 2337 } | 2332 } |
| 2338 | 2333 |
| 2339 | 2334 |
| 2340 } // namespace internal | 2335 } // namespace internal |
| 2341 } // namespace v8 | 2336 } // namespace v8 |
| OLD | NEW |