Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/runtime/runtime-function.cc

Issue 1642613002: Reland of Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: %SetCode failed to install literals in cache. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-compiler.cc ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 DCHECK(target_shared->code()->gc_metadata() == NULL); 161 DCHECK(target_shared->code()->gc_metadata() == NULL);
162 DCHECK(source_shared->code()->gc_metadata() == NULL); 162 DCHECK(source_shared->code()->gc_metadata() == NULL);
163 target_shared->set_dont_flush(true); 163 target_shared->set_dont_flush(true);
164 source_shared->set_dont_flush(true); 164 source_shared->set_dont_flush(true);
165 165
166 // Set the code, scope info, formal parameter count, and the length 166 // Set the code, scope info, formal parameter count, and the length
167 // of the target shared function info. 167 // of the target shared function info.
168 target_shared->ReplaceCode(source_shared->code()); 168 target_shared->ReplaceCode(source_shared->code());
169 target_shared->set_scope_info(source_shared->scope_info()); 169 target_shared->set_scope_info(source_shared->scope_info());
170 target_shared->set_length(source_shared->length()); 170 target_shared->set_length(source_shared->length());
171 target_shared->set_feedback_vector(source_shared->feedback_vector()); 171 target_shared->set_feedback_metadata(source_shared->feedback_metadata());
172 target_shared->set_num_literals(source_shared->num_literals());
172 target_shared->set_internal_formal_parameter_count( 173 target_shared->set_internal_formal_parameter_count(
173 source_shared->internal_formal_parameter_count()); 174 source_shared->internal_formal_parameter_count());
174 target_shared->set_start_position_and_type( 175 target_shared->set_start_position_and_type(
175 source_shared->start_position_and_type()); 176 source_shared->start_position_and_type());
176 target_shared->set_end_position(source_shared->end_position()); 177 target_shared->set_end_position(source_shared->end_position());
177 bool was_native = target_shared->native(); 178 bool was_native = target_shared->native();
178 target_shared->set_compiler_hints(source_shared->compiler_hints()); 179 target_shared->set_compiler_hints(source_shared->compiler_hints());
179 target_shared->set_opt_count_and_bailout_reason( 180 target_shared->set_opt_count_and_bailout_reason(
180 source_shared->opt_count_and_bailout_reason()); 181 source_shared->opt_count_and_bailout_reason());
181 target_shared->set_native(was_native); 182 target_shared->set_native(was_native);
182 target_shared->set_profiler_ticks(source_shared->profiler_ticks()); 183 target_shared->set_profiler_ticks(source_shared->profiler_ticks());
183 SharedFunctionInfo::SetScript( 184 SharedFunctionInfo::SetScript(
184 target_shared, Handle<Object>(source_shared->script(), isolate)); 185 target_shared, Handle<Object>(source_shared->script(), isolate));
185 186
186 // Set the code of the target function. 187 // Set the code of the target function.
187 target->ReplaceCode(source_shared->code()); 188 target->ReplaceCode(source_shared->code());
188 DCHECK(target->next_function_link()->IsUndefined()); 189 DCHECK(target->next_function_link()->IsUndefined());
189 190
190 // Make sure we get a fresh copy of the literal vector to avoid cross
191 // context contamination.
192 Handle<Context> context(source->context()); 191 Handle<Context> context(source->context());
193 target->set_context(*context); 192 target->set_context(*context);
194 193
195 int number_of_literals = source->NumberOfLiterals(); 194 // Make sure we get a fresh copy of the literal vector to avoid cross
196 Handle<LiteralsArray> literals = 195 // context contamination, and that the literal vector makes it's way into
197 LiteralsArray::New(isolate, handle(target_shared->feedback_vector()), 196 // the target_shared optimized code map.
198 number_of_literals, TENURED); 197 JSFunction::EnsureLiterals(target);
199 target->set_literals(*literals);
200 198
201 if (isolate->logger()->is_logging_code_events() || 199 if (isolate->logger()->is_logging_code_events() ||
202 isolate->cpu_profiler()->is_profiling()) { 200 isolate->cpu_profiler()->is_profiling()) {
203 isolate->logger()->LogExistingFunction(source_shared, 201 isolate->logger()->LogExistingFunction(source_shared,
204 Handle<Code>(source_shared->code())); 202 Handle<Code>(source_shared->code()));
205 } 203 }
206 204
207 return *target; 205 return *target;
208 } 206 }
209 207
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 DCHECK_EQ(1, args.length()); 350 DCHECK_EQ(1, args.length());
353 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); 351 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
354 return function->IsJSBoundFunction() 352 return function->IsJSBoundFunction()
355 ? *JSBoundFunction::ToString( 353 ? *JSBoundFunction::ToString(
356 Handle<JSBoundFunction>::cast(function)) 354 Handle<JSBoundFunction>::cast(function))
357 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); 355 : *JSFunction::ToString(Handle<JSFunction>::cast(function));
358 } 356 }
359 357
360 } // namespace internal 358 } // namespace internal
361 } // namespace v8 359 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-compiler.cc ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698