| 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" |
| 11 #include "src/isolate-inl.h" |
| 11 #include "src/macro-assembler.h" | 12 #include "src/macro-assembler.h" |
| 12 | 13 |
| 13 namespace v8 { | 14 namespace v8 { |
| 14 namespace internal { | 15 namespace internal { |
| 15 | 16 |
| 16 | 17 |
| 17 template<typename T> | 18 template<typename T> |
| 18 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { | 19 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { |
| 19 CALL_HEAP_FUNCTION( | 20 CALL_HEAP_FUNCTION( |
| 20 isolate(), | 21 isolate(), |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 &exception) | 1130 &exception) |
| 1130 .ToHandle(&result)) { | 1131 .ToHandle(&result)) { |
| 1131 Handle<Object> exception_obj; | 1132 Handle<Object> exception_obj; |
| 1132 if (exception.ToHandle(&exception_obj)) return exception_obj; | 1133 if (exception.ToHandle(&exception_obj)) return exception_obj; |
| 1133 return undefined_value(); | 1134 return undefined_value(); |
| 1134 } | 1135 } |
| 1135 return result; | 1136 return result; |
| 1136 } | 1137 } |
| 1137 | 1138 |
| 1138 | 1139 |
| 1140 #define DEFINE_ERROR(NAME, name) \ |
| 1141 Handle<Object> Factory::New##NAME(MessageTemplate::Template template_index, \ |
| 1142 Handle<Object> arg0, Handle<Object> arg1, \ |
| 1143 Handle<Object> arg2) { \ |
| 1144 return NewError(isolate()->name##_function(), template_index, arg0, arg1, \ |
| 1145 arg2); \ |
| 1146 } |
| 1147 DEFINE_ERROR(Error, error) |
| 1148 DEFINE_ERROR(EvalError, eval_error) |
| 1149 DEFINE_ERROR(RangeError, range_error) |
| 1150 DEFINE_ERROR(ReferenceError, reference_error) |
| 1151 DEFINE_ERROR(SyntaxError, syntax_error) |
| 1152 DEFINE_ERROR(TypeError, type_error) |
| 1153 #undef DEFINE_ERROR |
| 1154 |
| 1155 |
| 1139 void Factory::InitializeFunction(Handle<JSFunction> function, | 1156 void Factory::InitializeFunction(Handle<JSFunction> function, |
| 1140 Handle<SharedFunctionInfo> info, | 1157 Handle<SharedFunctionInfo> info, |
| 1141 Handle<Context> context) { | 1158 Handle<Context> context) { |
| 1142 function->initialize_properties(); | 1159 function->initialize_properties(); |
| 1143 function->initialize_elements(); | 1160 function->initialize_elements(); |
| 1144 function->set_shared(*info); | 1161 function->set_shared(*info); |
| 1145 function->set_code(info->code()); | 1162 function->set_code(info->code()); |
| 1146 function->set_context(*context); | 1163 function->set_context(*context); |
| 1147 function->set_prototype_or_initial_map(*the_hole_value()); | 1164 function->set_prototype_or_initial_map(*the_hole_value()); |
| 1148 function->set_literals_or_bindings(*empty_fixed_array()); | 1165 function->set_literals_or_bindings(*empty_fixed_array()); |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 } | 2349 } |
| 2333 | 2350 |
| 2334 | 2351 |
| 2335 Handle<Object> Factory::ToBoolean(bool value) { | 2352 Handle<Object> Factory::ToBoolean(bool value) { |
| 2336 return value ? true_value() : false_value(); | 2353 return value ? true_value() : false_value(); |
| 2337 } | 2354 } |
| 2338 | 2355 |
| 2339 | 2356 |
| 2340 } // namespace internal | 2357 } // namespace internal |
| 2341 } // namespace v8 | 2358 } // namespace v8 |
| OLD | NEW |