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/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 Handle<Code> optimized_code = deoptimizer->compiled_code(); | 115 Handle<Code> optimized_code = deoptimizer->compiled_code(); |
116 | 116 |
117 DCHECK(optimized_code->kind() == Code::OPTIMIZED_FUNCTION); | 117 DCHECK(optimized_code->kind() == Code::OPTIMIZED_FUNCTION); |
118 DCHECK(type == deoptimizer->bailout_type()); | 118 DCHECK(type == deoptimizer->bailout_type()); |
119 | 119 |
120 // Make sure to materialize objects before causing any allocation. | 120 // Make sure to materialize objects before causing any allocation. |
121 JavaScriptFrameIterator it(isolate); | 121 JavaScriptFrameIterator it(isolate); |
122 deoptimizer->MaterializeHeapObjects(&it); | 122 deoptimizer->MaterializeHeapObjects(&it); |
123 delete deoptimizer; | 123 delete deoptimizer; |
124 | 124 |
125 JavaScriptFrame* frame = it.frame(); | |
126 RUNTIME_ASSERT(frame->function()->IsJSFunction()); | |
127 DCHECK(frame->function() == *function); | |
128 | |
129 // Ensure the context register is updated for materialized objects. | 125 // Ensure the context register is updated for materialized objects. |
130 JavaScriptFrameIterator top_it(isolate); | 126 JavaScriptFrameIterator top_it(isolate); |
131 JavaScriptFrame* top_frame = top_it.frame(); | 127 JavaScriptFrame* top_frame = top_it.frame(); |
132 isolate->set_context(Context::cast(top_frame->context())); | 128 isolate->set_context(Context::cast(top_frame->context())); |
133 | 129 |
134 if (type == Deoptimizer::LAZY) { | 130 if (type == Deoptimizer::LAZY) { |
135 return isolate->heap()->undefined_value(); | 131 return isolate->heap()->undefined_value(); |
136 } | 132 } |
137 | 133 |
138 // Search for other activations of the same function and code. | 134 // Search for other activations of the same optimized code. |
| 135 // At this point {it} is at the topmost frame of all the frames materialized |
| 136 // by the deoptimizer. Note that this frame does not necessarily represent |
| 137 // an activation of {function} because of potential inlined tail-calls. |
139 ActivationsFinder activations_finder(*optimized_code); | 138 ActivationsFinder activations_finder(*optimized_code); |
140 activations_finder.VisitFrames(&it); | 139 activations_finder.VisitFrames(&it); |
141 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); | 140 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); |
142 | 141 |
143 if (!activations_finder.has_code_activations_) { | 142 if (!activations_finder.has_code_activations_) { |
144 if (function->code() == *optimized_code) { | 143 if (function->code() == *optimized_code) { |
145 if (FLAG_trace_deopt) { | 144 if (FLAG_trace_deopt) { |
146 PrintF("[removing optimized code for: "); | 145 PrintF("[removing optimized code for: "); |
147 function->PrintName(); | 146 function->PrintName(); |
148 PrintF("]\n"); | 147 PrintF("]\n"); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 DCHECK(is_valid_language_mode(args.smi_at(3))); | 359 DCHECK(is_valid_language_mode(args.smi_at(3))); |
361 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 360 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
362 DCHECK(args[4]->IsSmi()); | 361 DCHECK(args[4]->IsSmi()); |
363 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 362 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
364 isolate); | 363 isolate); |
365 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 364 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
366 language_mode, args.smi_at(4)); | 365 language_mode, args.smi_at(4)); |
367 } | 366 } |
368 } // namespace internal | 367 } // namespace internal |
369 } // namespace v8 | 368 } // namespace v8 |
OLD | NEW |