| 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 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 Code); | 1474 Code); |
| 1475 } | 1475 } |
| 1476 | 1476 |
| 1477 | 1477 |
| 1478 Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) { | 1478 Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) { |
| 1479 CALL_HEAP_FUNCTION(isolate(), | 1479 CALL_HEAP_FUNCTION(isolate(), |
| 1480 isolate()->heap()->CopyCode(*code, reloc_info), | 1480 isolate()->heap()->CopyCode(*code, reloc_info), |
| 1481 Code); | 1481 Code); |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 Handle<BytecodeArray> Factory::CopyBytecodeArray( |
| 1485 Handle<BytecodeArray> bytecode_array) { |
| 1486 CALL_HEAP_FUNCTION(isolate(), |
| 1487 isolate()->heap()->CopyBytecodeArray(*bytecode_array), |
| 1488 BytecodeArray); |
| 1489 } |
| 1484 | 1490 |
| 1485 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, | 1491 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, |
| 1486 PretenureFlag pretenure) { | 1492 PretenureFlag pretenure) { |
| 1487 JSFunction::EnsureHasInitialMap(constructor); | 1493 JSFunction::EnsureHasInitialMap(constructor); |
| 1488 CALL_HEAP_FUNCTION( | 1494 CALL_HEAP_FUNCTION( |
| 1489 isolate(), | 1495 isolate(), |
| 1490 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); | 1496 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); |
| 1491 } | 1497 } |
| 1492 | 1498 |
| 1493 | 1499 |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 share->set_code(*code); | 2128 share->set_code(*code); |
| 2123 share->set_optimized_code_map(*cleared_optimized_code_map()); | 2129 share->set_optimized_code_map(*cleared_optimized_code_map()); |
| 2124 share->set_scope_info(ScopeInfo::Empty(isolate())); | 2130 share->set_scope_info(ScopeInfo::Empty(isolate())); |
| 2125 Handle<Code> construct_stub = | 2131 Handle<Code> construct_stub = |
| 2126 is_constructor ? isolate()->builtins()->JSConstructStubGeneric() | 2132 is_constructor ? isolate()->builtins()->JSConstructStubGeneric() |
| 2127 : isolate()->builtins()->ConstructedNonConstructable(); | 2133 : isolate()->builtins()->ConstructedNonConstructable(); |
| 2128 share->set_construct_stub(*construct_stub); | 2134 share->set_construct_stub(*construct_stub); |
| 2129 share->set_instance_class_name(*Object_string()); | 2135 share->set_instance_class_name(*Object_string()); |
| 2130 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); | 2136 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); |
| 2131 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); | 2137 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); |
| 2132 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); | 2138 share->set_debug_info(DebugInfo::uninitialized(), SKIP_WRITE_BARRIER); |
| 2133 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); | 2139 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); |
| 2134 StaticFeedbackVectorSpec empty_spec; | 2140 StaticFeedbackVectorSpec empty_spec; |
| 2135 Handle<TypeFeedbackMetadata> feedback_metadata = | 2141 Handle<TypeFeedbackMetadata> feedback_metadata = |
| 2136 TypeFeedbackMetadata::New(isolate(), &empty_spec); | 2142 TypeFeedbackMetadata::New(isolate(), &empty_spec); |
| 2137 Handle<TypeFeedbackVector> feedback_vector = | 2143 Handle<TypeFeedbackVector> feedback_vector = |
| 2138 TypeFeedbackVector::New(isolate(), feedback_metadata); | 2144 TypeFeedbackVector::New(isolate(), feedback_metadata); |
| 2139 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); | 2145 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); |
| 2140 #if TRACE_MAPS | 2146 #if TRACE_MAPS |
| 2141 share->set_unique_id(isolate()->GetNextUniqueSharedFunctionInfoId()); | 2147 share->set_unique_id(isolate()->GetNextUniqueSharedFunctionInfoId()); |
| 2142 #endif | 2148 #endif |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 Handle<FixedArray> break_points( | 2247 Handle<FixedArray> break_points( |
| 2242 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); | 2248 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); |
| 2243 | 2249 |
| 2244 // Create and set up the debug info object. Debug info contains function, a | 2250 // Create and set up the debug info object. Debug info contains function, a |
| 2245 // copy of the original code, the executing code and initial fixed array for | 2251 // copy of the original code, the executing code and initial fixed array for |
| 2246 // active break points. | 2252 // active break points. |
| 2247 Handle<DebugInfo> debug_info = | 2253 Handle<DebugInfo> debug_info = |
| 2248 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); | 2254 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); |
| 2249 debug_info->set_shared(*shared); | 2255 debug_info->set_shared(*shared); |
| 2250 if (shared->HasBytecodeArray()) { | 2256 if (shared->HasBytecodeArray()) { |
| 2251 debug_info->set_abstract_code(AbstractCode::cast(shared->bytecode_array())); | 2257 // Create a copy for debugging. |
| 2258 Handle<BytecodeArray> original(shared->bytecode_array(), isolate()); |
| 2259 Handle<BytecodeArray> copy = CopyBytecodeArray(original); |
| 2260 debug_info->set_abstract_code(AbstractCode::cast(*copy)); |
| 2252 } else { | 2261 } else { |
| 2253 debug_info->set_abstract_code(AbstractCode::cast(shared->code())); | 2262 debug_info->set_abstract_code(AbstractCode::cast(shared->code())); |
| 2254 } | 2263 } |
| 2255 debug_info->set_break_points(*break_points); | 2264 debug_info->set_break_points(*break_points); |
| 2256 | 2265 |
| 2257 // Link debug info to function. | 2266 // Link debug info to function. |
| 2258 shared->set_debug_info(*debug_info); | 2267 shared->set_debug_info(*debug_info); |
| 2259 | 2268 |
| 2260 return debug_info; | 2269 return debug_info; |
| 2261 } | 2270 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 } | 2397 } |
| 2389 | 2398 |
| 2390 | 2399 |
| 2391 Handle<Object> Factory::ToBoolean(bool value) { | 2400 Handle<Object> Factory::ToBoolean(bool value) { |
| 2392 return value ? true_value() : false_value(); | 2401 return value ? true_value() : false_value(); |
| 2393 } | 2402 } |
| 2394 | 2403 |
| 2395 | 2404 |
| 2396 } // namespace internal | 2405 } // namespace internal |
| 2397 } // namespace v8 | 2406 } // namespace v8 |
| OLD | NEW |