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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 source_shared->set_dont_flush(true); | 165 source_shared->set_dont_flush(true); |
166 | 166 |
167 // Set the code, scope info, formal parameter count, and the length | 167 // Set the code, scope info, formal parameter count, and the length |
168 // of the target shared function info. | 168 // of the target shared function info. |
169 target_shared->ReplaceCode(source_shared->code()); | 169 target_shared->ReplaceCode(source_shared->code()); |
170 if (source_shared->HasBytecodeArray()) { | 170 if (source_shared->HasBytecodeArray()) { |
171 target_shared->set_function_data(source_shared->bytecode_array()); | 171 target_shared->set_function_data(source_shared->bytecode_array()); |
172 } | 172 } |
173 target_shared->set_scope_info(source_shared->scope_info()); | 173 target_shared->set_scope_info(source_shared->scope_info()); |
174 target_shared->set_length(source_shared->length()); | 174 target_shared->set_length(source_shared->length()); |
175 target_shared->set_feedback_vector(source_shared->feedback_vector()); | 175 target_shared->set_feedback_metadata(source_shared->feedback_metadata()); |
| 176 target_shared->set_num_literals(source_shared->num_literals()); |
176 target_shared->set_internal_formal_parameter_count( | 177 target_shared->set_internal_formal_parameter_count( |
177 source_shared->internal_formal_parameter_count()); | 178 source_shared->internal_formal_parameter_count()); |
178 target_shared->set_start_position_and_type( | 179 target_shared->set_start_position_and_type( |
179 source_shared->start_position_and_type()); | 180 source_shared->start_position_and_type()); |
180 target_shared->set_end_position(source_shared->end_position()); | 181 target_shared->set_end_position(source_shared->end_position()); |
181 bool was_native = target_shared->native(); | 182 bool was_native = target_shared->native(); |
182 target_shared->set_compiler_hints(source_shared->compiler_hints()); | 183 target_shared->set_compiler_hints(source_shared->compiler_hints()); |
183 target_shared->set_opt_count_and_bailout_reason( | 184 target_shared->set_opt_count_and_bailout_reason( |
184 source_shared->opt_count_and_bailout_reason()); | 185 source_shared->opt_count_and_bailout_reason()); |
185 target_shared->set_native(was_native); | 186 target_shared->set_native(was_native); |
186 target_shared->set_profiler_ticks(source_shared->profiler_ticks()); | 187 target_shared->set_profiler_ticks(source_shared->profiler_ticks()); |
187 SharedFunctionInfo::SetScript( | 188 SharedFunctionInfo::SetScript( |
188 target_shared, Handle<Object>(source_shared->script(), isolate)); | 189 target_shared, Handle<Object>(source_shared->script(), isolate)); |
189 | 190 |
190 // Set the code of the target function. | 191 // Set the code of the target function. |
191 target->ReplaceCode(source_shared->code()); | 192 target->ReplaceCode(source_shared->code()); |
192 DCHECK(target->next_function_link()->IsUndefined()); | 193 DCHECK(target->next_function_link()->IsUndefined()); |
193 | 194 |
194 // Make sure we get a fresh copy of the literal vector to avoid cross | |
195 // context contamination. | |
196 Handle<Context> context(source->context()); | 195 Handle<Context> context(source->context()); |
197 target->set_context(*context); | 196 target->set_context(*context); |
198 | 197 |
199 int number_of_literals = source->NumberOfLiterals(); | 198 // Make sure we get a fresh copy of the literal vector to avoid cross |
200 Handle<LiteralsArray> literals = | 199 // context contamination, and that the literal vector makes it's way into |
201 LiteralsArray::New(isolate, handle(target_shared->feedback_vector()), | 200 // the target_shared optimized code map. |
202 number_of_literals, TENURED); | 201 JSFunction::EnsureLiterals(target); |
203 target->set_literals(*literals); | |
204 | 202 |
205 if (isolate->logger()->is_logging_code_events() || | 203 if (isolate->logger()->is_logging_code_events() || |
206 isolate->cpu_profiler()->is_profiling()) { | 204 isolate->cpu_profiler()->is_profiling()) { |
207 isolate->logger()->LogExistingFunction(source_shared, | 205 isolate->logger()->LogExistingFunction(source_shared, |
208 Handle<Code>(source_shared->code())); | 206 Handle<Code>(source_shared->code())); |
209 } | 207 } |
210 | 208 |
211 return *target; | 209 return *target; |
212 } | 210 } |
213 | 211 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 DCHECK_EQ(1, args.length()); | 354 DCHECK_EQ(1, args.length()); |
357 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 355 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
358 return function->IsJSBoundFunction() | 356 return function->IsJSBoundFunction() |
359 ? *JSBoundFunction::ToString( | 357 ? *JSBoundFunction::ToString( |
360 Handle<JSBoundFunction>::cast(function)) | 358 Handle<JSBoundFunction>::cast(function)) |
361 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); | 359 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); |
362 } | 360 } |
363 | 361 |
364 } // namespace internal | 362 } // namespace internal |
365 } // namespace v8 | 363 } // namespace v8 |
OLD | NEW |