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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 source_shared->set_dont_flush(true); | 180 source_shared->set_dont_flush(true); |
181 | 181 |
182 // Set the code, scope info, formal parameter count, and the length | 182 // Set the code, scope info, formal parameter count, and the length |
183 // of the target shared function info. | 183 // of the target shared function info. |
184 target_shared->ReplaceCode(source_shared->code()); | 184 target_shared->ReplaceCode(source_shared->code()); |
185 if (source_shared->HasBytecodeArray()) { | 185 if (source_shared->HasBytecodeArray()) { |
186 target_shared->set_bytecode_array(source_shared->bytecode_array()); | 186 target_shared->set_bytecode_array(source_shared->bytecode_array()); |
187 } | 187 } |
188 target_shared->set_scope_info(source_shared->scope_info()); | 188 target_shared->set_scope_info(source_shared->scope_info()); |
189 target_shared->set_length(source_shared->length()); | 189 target_shared->set_length(source_shared->length()); |
| 190 target_shared->set_num_literals(source_shared->num_literals()); |
190 target_shared->set_feedback_vector(source_shared->feedback_vector()); | 191 target_shared->set_feedback_vector(source_shared->feedback_vector()); |
191 target_shared->set_internal_formal_parameter_count( | 192 target_shared->set_internal_formal_parameter_count( |
192 source_shared->internal_formal_parameter_count()); | 193 source_shared->internal_formal_parameter_count()); |
193 target_shared->set_start_position_and_type( | 194 target_shared->set_start_position_and_type( |
194 source_shared->start_position_and_type()); | 195 source_shared->start_position_and_type()); |
195 target_shared->set_end_position(source_shared->end_position()); | 196 target_shared->set_end_position(source_shared->end_position()); |
196 bool was_native = target_shared->native(); | 197 bool was_native = target_shared->native(); |
197 target_shared->set_compiler_hints(source_shared->compiler_hints()); | 198 target_shared->set_compiler_hints(source_shared->compiler_hints()); |
198 target_shared->set_opt_count_and_bailout_reason( | 199 target_shared->set_opt_count_and_bailout_reason( |
199 source_shared->opt_count_and_bailout_reason()); | 200 source_shared->opt_count_and_bailout_reason()); |
200 target_shared->set_native(was_native); | 201 target_shared->set_native(was_native); |
201 target_shared->set_profiler_ticks(source_shared->profiler_ticks()); | 202 target_shared->set_profiler_ticks(source_shared->profiler_ticks()); |
202 SharedFunctionInfo::SetScript( | 203 SharedFunctionInfo::SetScript( |
203 target_shared, Handle<Object>(source_shared->script(), isolate)); | 204 target_shared, Handle<Object>(source_shared->script(), isolate)); |
204 | 205 |
205 // Set the code of the target function. | 206 // Set the code of the target function. |
206 target->ReplaceCode(source_shared->code()); | 207 target->ReplaceCode(source_shared->code()); |
207 DCHECK(target->next_function_link()->IsUndefined()); | 208 DCHECK(target->next_function_link()->IsUndefined()); |
208 | 209 |
209 // Make sure we get a fresh copy of the literal vector to avoid cross | 210 // Make sure we get a fresh copy of the literal vector to avoid cross |
210 // context contamination. | 211 // context contamination. |
211 Handle<Context> context(source->context()); | 212 Handle<Context> context(source->context()); |
212 target->set_context(*context); | 213 target->set_context(*context); |
213 | 214 |
214 int number_of_literals = source->NumberOfLiterals(); | |
215 Handle<LiteralsArray> literals = | 215 Handle<LiteralsArray> literals = |
216 LiteralsArray::New(isolate, handle(target_shared->feedback_vector()), | 216 LiteralsArray::New(isolate, handle(target_shared->feedback_vector()), |
217 number_of_literals, TENURED); | 217 target_shared->num_literals(), TENURED); |
218 target->set_literals(*literals); | 218 target->set_literals(*literals); |
219 | 219 |
220 if (isolate->logger()->is_logging_code_events() || | 220 if (isolate->logger()->is_logging_code_events() || |
221 isolate->cpu_profiler()->is_profiling()) { | 221 isolate->cpu_profiler()->is_profiling()) { |
222 isolate->logger()->LogExistingFunction( | 222 isolate->logger()->LogExistingFunction( |
223 source_shared, Handle<AbstractCode>(source_shared->abstract_code())); | 223 source_shared, Handle<AbstractCode>(source_shared->abstract_code())); |
224 } | 224 } |
225 | 225 |
226 return *target; | 226 return *target; |
227 } | 227 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 DCHECK_EQ(1, args.length()); | 301 DCHECK_EQ(1, args.length()); |
302 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 302 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
303 return function->IsJSBoundFunction() | 303 return function->IsJSBoundFunction() |
304 ? *JSBoundFunction::ToString( | 304 ? *JSBoundFunction::ToString( |
305 Handle<JSBoundFunction>::cast(function)) | 305 Handle<JSBoundFunction>::cast(function)) |
306 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); | 306 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); |
307 } | 307 } |
308 | 308 |
309 } // namespace internal | 309 } // namespace internal |
310 } // namespace v8 | 310 } // namespace v8 |
OLD | NEW |