| 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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 Code); | 1487 Code); |
| 1488 } | 1488 } |
| 1489 | 1489 |
| 1490 | 1490 |
| 1491 Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) { | 1491 Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) { |
| 1492 CALL_HEAP_FUNCTION(isolate(), | 1492 CALL_HEAP_FUNCTION(isolate(), |
| 1493 isolate()->heap()->CopyCode(*code, reloc_info), | 1493 isolate()->heap()->CopyCode(*code, reloc_info), |
| 1494 Code); | 1494 Code); |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 Handle<BytecodeArray> Factory::CopyBytecodeArray( |
| 1498 Handle<BytecodeArray> bytecode_array) { |
| 1499 CALL_HEAP_FUNCTION(isolate(), |
| 1500 isolate()->heap()->CopyBytecodeArray(*bytecode_array), |
| 1501 BytecodeArray); |
| 1502 } |
| 1497 | 1503 |
| 1498 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, | 1504 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, |
| 1499 PretenureFlag pretenure) { | 1505 PretenureFlag pretenure) { |
| 1500 JSFunction::EnsureHasInitialMap(constructor); | 1506 JSFunction::EnsureHasInitialMap(constructor); |
| 1501 CALL_HEAP_FUNCTION( | 1507 CALL_HEAP_FUNCTION( |
| 1502 isolate(), | 1508 isolate(), |
| 1503 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); | 1509 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); |
| 1504 } | 1510 } |
| 1505 | 1511 |
| 1506 | 1512 |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 share->set_code(*code); | 2141 share->set_code(*code); |
| 2136 share->set_optimized_code_map(*cleared_optimized_code_map()); | 2142 share->set_optimized_code_map(*cleared_optimized_code_map()); |
| 2137 share->set_scope_info(ScopeInfo::Empty(isolate())); | 2143 share->set_scope_info(ScopeInfo::Empty(isolate())); |
| 2138 Handle<Code> construct_stub = | 2144 Handle<Code> construct_stub = |
| 2139 is_constructor ? isolate()->builtins()->JSConstructStubGeneric() | 2145 is_constructor ? isolate()->builtins()->JSConstructStubGeneric() |
| 2140 : isolate()->builtins()->ConstructedNonConstructable(); | 2146 : isolate()->builtins()->ConstructedNonConstructable(); |
| 2141 share->set_construct_stub(*construct_stub); | 2147 share->set_construct_stub(*construct_stub); |
| 2142 share->set_instance_class_name(*Object_string()); | 2148 share->set_instance_class_name(*Object_string()); |
| 2143 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); | 2149 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); |
| 2144 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); | 2150 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); |
| 2145 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); | 2151 share->set_debug_info(DebugInfo::uninitialized(), SKIP_WRITE_BARRIER); |
| 2146 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); | 2152 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); |
| 2147 StaticFeedbackVectorSpec empty_spec; | 2153 StaticFeedbackVectorSpec empty_spec; |
| 2148 Handle<TypeFeedbackMetadata> feedback_metadata = | 2154 Handle<TypeFeedbackMetadata> feedback_metadata = |
| 2149 TypeFeedbackMetadata::New(isolate(), &empty_spec); | 2155 TypeFeedbackMetadata::New(isolate(), &empty_spec); |
| 2150 Handle<TypeFeedbackVector> feedback_vector = | 2156 Handle<TypeFeedbackVector> feedback_vector = |
| 2151 TypeFeedbackVector::New(isolate(), feedback_metadata); | 2157 TypeFeedbackVector::New(isolate(), feedback_metadata); |
| 2152 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); | 2158 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); |
| 2153 #if TRACE_MAPS | 2159 #if TRACE_MAPS |
| 2154 share->set_unique_id(isolate()->GetNextUniqueSharedFunctionInfoId()); | 2160 share->set_unique_id(isolate()->GetNextUniqueSharedFunctionInfoId()); |
| 2155 #endif | 2161 #endif |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 Handle<FixedArray> break_points( | 2260 Handle<FixedArray> break_points( |
| 2255 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); | 2261 NewFixedArray(DebugInfo::kEstimatedNofBreakPointsInFunction)); |
| 2256 | 2262 |
| 2257 // Create and set up the debug info object. Debug info contains function, a | 2263 // Create and set up the debug info object. Debug info contains function, a |
| 2258 // copy of the original code, the executing code and initial fixed array for | 2264 // copy of the original code, the executing code and initial fixed array for |
| 2259 // active break points. | 2265 // active break points. |
| 2260 Handle<DebugInfo> debug_info = | 2266 Handle<DebugInfo> debug_info = |
| 2261 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); | 2267 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE)); |
| 2262 debug_info->set_shared(*shared); | 2268 debug_info->set_shared(*shared); |
| 2263 if (shared->HasBytecodeArray()) { | 2269 if (shared->HasBytecodeArray()) { |
| 2264 debug_info->set_abstract_code(AbstractCode::cast(shared->bytecode_array())); | 2270 // Create a copy for debugging. |
| 2271 Handle<BytecodeArray> original(shared->bytecode_array(), isolate()); |
| 2272 Handle<BytecodeArray> copy = CopyBytecodeArray(original); |
| 2273 debug_info->set_abstract_code(AbstractCode::cast(*copy)); |
| 2265 } else { | 2274 } else { |
| 2266 debug_info->set_abstract_code(AbstractCode::cast(shared->code())); | 2275 debug_info->set_abstract_code(AbstractCode::cast(shared->code())); |
| 2267 } | 2276 } |
| 2268 debug_info->set_break_points(*break_points); | 2277 debug_info->set_break_points(*break_points); |
| 2269 | 2278 |
| 2270 // Link debug info to function. | 2279 // Link debug info to function. |
| 2271 shared->set_debug_info(*debug_info); | 2280 shared->set_debug_info(*debug_info); |
| 2272 | 2281 |
| 2273 return debug_info; | 2282 return debug_info; |
| 2274 } | 2283 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 } | 2410 } |
| 2402 | 2411 |
| 2403 | 2412 |
| 2404 Handle<Object> Factory::ToBoolean(bool value) { | 2413 Handle<Object> Factory::ToBoolean(bool value) { |
| 2405 return value ? true_value() : false_value(); | 2414 return value ? true_value() : false_value(); |
| 2406 } | 2415 } |
| 2407 | 2416 |
| 2408 | 2417 |
| 2409 } // namespace internal | 2418 } // namespace internal |
| 2410 } // namespace v8 | 2419 } // namespace v8 |
| OLD | NEW |