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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2215 } | 2215 } |
2216 | 2216 |
2217 | 2217 |
2218 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) { | 2218 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) { |
2219 // Allocate initial fixed array for active break points before allocating the | 2219 // Allocate initial fixed array for active break points before allocating the |
2220 // debug info object to avoid allocation while setting up the debug info | 2220 // debug info object to avoid allocation while setting up the debug info |
2221 // object. | 2221 // object. |
2222 Handle<FixedArray> break_points( | 2222 Handle<FixedArray> break_points( |
2223 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); | 2223 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); |
2224 | 2224 |
| 2225 // Make a copy of the bytecode array if available. |
| 2226 Handle<Object> maybe_debug_bytecode_array = undefined_value(); |
| 2227 if (shared->HasBytecodeArray()) { |
| 2228 Handle<BytecodeArray> original(shared->bytecode_array()); |
| 2229 maybe_debug_bytecode_array = CopyBytecodeArray(original); |
| 2230 } |
| 2231 |
2225 // Create and set up the debug info object. Debug info contains function, a | 2232 // Create and set up the debug info object. Debug info contains function, a |
2226 // copy of the original code, the executing code and initial fixed array for | 2233 // copy of the original code, the executing code and initial fixed array for |
2227 // active break points. | 2234 // active break points. |
2228 Handle<DebugInfo> debug_info = | 2235 Handle<DebugInfo> debug_info = |
2229 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); | 2236 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); |
2230 debug_info->set_shared(*shared); | 2237 debug_info->set_shared(*shared); |
2231 if (shared->HasBytecodeArray()) { | 2238 debug_info->set_debug_bytecode_array(*maybe_debug_bytecode_array); |
2232 // We need to create a copy, but delay since this may cause heap | |
2233 // verification. | |
2234 debug_info->set_abstract_code(AbstractCode::cast(shared->bytecode_array())); | |
2235 } else { | |
2236 debug_info->set_abstract_code(AbstractCode::cast(shared->code())); | |
2237 } | |
2238 debug_info->set_break_points(*break_points); | 2239 debug_info->set_break_points(*break_points); |
2239 if (shared->HasBytecodeArray()) { | |
2240 // Create a copy for debugging. | |
2241 Handle<BytecodeArray> original(shared->bytecode_array()); | |
2242 Handle<BytecodeArray> copy = CopyBytecodeArray(original); | |
2243 debug_info->set_abstract_code(AbstractCode::cast(*copy)); | |
2244 } | |
2245 | 2240 |
2246 // Link debug info to function. | 2241 // Link debug info to function. |
2247 shared->set_debug_info(*debug_info); | 2242 shared->set_debug_info(*debug_info); |
2248 | 2243 |
2249 return debug_info; | 2244 return debug_info; |
2250 } | 2245 } |
2251 | 2246 |
2252 | 2247 |
2253 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee, | 2248 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee, |
2254 int length) { | 2249 int length) { |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 Handle<AccessorInfo> prototype = | 2491 Handle<AccessorInfo> prototype = |
2497 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2492 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2498 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2493 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2499 prototype, attribs); | 2494 prototype, attribs); |
2500 map->AppendDescriptor(&d); | 2495 map->AppendDescriptor(&d); |
2501 } | 2496 } |
2502 } | 2497 } |
2503 | 2498 |
2504 } // namespace internal | 2499 } // namespace internal |
2505 } // namespace v8 | 2500 } // namespace v8 |
OLD | NEW |