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 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 | 2262 |
2263 // We tenure the allocated string since it is referenced from the | 2263 // We tenure the allocated string since it is referenced from the |
2264 // number-string cache which lives in the old space. | 2264 // number-string cache which lives in the old space. |
2265 Handle<String> js_string = NewStringFromAsciiChecked(str, TENURED); | 2265 Handle<String> js_string = NewStringFromAsciiChecked(str, TENURED); |
2266 SetNumberStringCache(number, js_string); | 2266 SetNumberStringCache(number, js_string); |
2267 return js_string; | 2267 return js_string; |
2268 } | 2268 } |
2269 | 2269 |
2270 | 2270 |
2271 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) { | 2271 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) { |
2272 // Get the original code of the function. | |
2273 Handle<Code> code(shared->code()); | |
2274 | |
2275 // Create a copy of the code before allocating the debug info object to avoid | |
2276 // allocation while setting up the debug info object. | |
2277 Handle<Code> original_code(*Factory::CopyCode(code)); | |
2278 | |
2279 // Allocate initial fixed array for active break points before allocating the | 2272 // Allocate initial fixed array for active break points before allocating the |
2280 // debug info object to avoid allocation while setting up the debug info | 2273 // debug info object to avoid allocation while setting up the debug info |
2281 // object. | 2274 // object. |
2282 Handle<FixedArray> break_points( | 2275 Handle<FixedArray> break_points( |
2283 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); | 2276 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); |
2284 | 2277 |
2285 // Create and set up the debug info object. Debug info contains function, a | 2278 // Create and set up the debug info object. Debug info contains function, a |
2286 // copy of the original code, the executing code and initial fixed array for | 2279 // copy of the original code, the executing code and initial fixed array for |
2287 // active break points. | 2280 // active break points. |
2288 Handle<DebugInfo> debug_info = | 2281 Handle<DebugInfo> debug_info = |
2289 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); | 2282 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); |
2290 debug_info->set_shared(*shared); | 2283 debug_info->set_shared(*shared); |
2291 debug_info->set_original_code(*original_code); | 2284 debug_info->set_code(shared->code()); |
2292 debug_info->set_code(*code); | |
2293 debug_info->set_break_points(*break_points); | 2285 debug_info->set_break_points(*break_points); |
2294 | 2286 |
2295 // Link debug info to function. | 2287 // Link debug info to function. |
2296 shared->set_debug_info(*debug_info); | 2288 shared->set_debug_info(*debug_info); |
2297 | 2289 |
2298 return debug_info; | 2290 return debug_info; |
2299 } | 2291 } |
2300 | 2292 |
2301 | 2293 |
2302 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee, | 2294 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 } | 2419 } |
2428 | 2420 |
2429 | 2421 |
2430 Handle<Object> Factory::ToBoolean(bool value) { | 2422 Handle<Object> Factory::ToBoolean(bool value) { |
2431 return value ? true_value() : false_value(); | 2423 return value ? true_value() : false_value(); |
2432 } | 2424 } |
2433 | 2425 |
2434 | 2426 |
2435 } // namespace internal | 2427 } // namespace internal |
2436 } // namespace v8 | 2428 } // namespace v8 |
OLD | NEW |