OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/deoptimizer.h" | 5 #include "src/deoptimizer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 | 97 |
98 Deoptimizer* Deoptimizer::Grab(Isolate* isolate) { | 98 Deoptimizer* Deoptimizer::Grab(Isolate* isolate) { |
99 Deoptimizer* result = isolate->deoptimizer_data()->current_; | 99 Deoptimizer* result = isolate->deoptimizer_data()->current_; |
100 CHECK_NOT_NULL(result); | 100 CHECK_NOT_NULL(result); |
101 result->DeleteFrameDescriptions(); | 101 result->DeleteFrameDescriptions(); |
102 isolate->deoptimizer_data()->current_ = NULL; | 102 isolate->deoptimizer_data()->current_ = NULL; |
103 return result; | 103 return result; |
104 } | 104 } |
105 | 105 |
106 | |
107 int Deoptimizer::ConvertJSFrameIndexToFrameIndex(int jsframe_index) { | |
108 if (jsframe_index == 0) return 0; | |
109 | |
110 int frame_index = 0; | |
111 while (jsframe_index >= 0) { | |
112 FrameDescription* frame = output_[frame_index]; | |
113 if (frame->GetFrameType() == StackFrame::JAVA_SCRIPT) { | |
114 jsframe_index--; | |
115 } | |
116 frame_index++; | |
117 } | |
118 | |
119 return frame_index - 1; | |
120 } | |
121 | |
122 | |
123 DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame( | 106 DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame( |
124 JavaScriptFrame* frame, | 107 JavaScriptFrame* frame, |
125 int jsframe_index, | 108 int jsframe_index, |
126 Isolate* isolate) { | 109 Isolate* isolate) { |
127 CHECK(frame->is_optimized()); | 110 CHECK(frame->is_optimized()); |
128 | 111 |
129 TranslatedState translated_values(frame); | 112 TranslatedState translated_values(frame); |
130 translated_values.Prepare(false, frame->fp()); | 113 translated_values.Prepare(false, frame->fp()); |
131 | 114 |
132 TranslatedState::iterator frame_it = translated_values.end(); | 115 TranslatedState::iterator frame_it = translated_values.end(); |
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 | 2222 |
2240 // static | 2223 // static |
2241 unsigned Deoptimizer::ComputeOutgoingArgumentSize(Code* code, | 2224 unsigned Deoptimizer::ComputeOutgoingArgumentSize(Code* code, |
2242 unsigned bailout_id) { | 2225 unsigned bailout_id) { |
2243 DeoptimizationInputData* data = | 2226 DeoptimizationInputData* data = |
2244 DeoptimizationInputData::cast(code->deoptimization_data()); | 2227 DeoptimizationInputData::cast(code->deoptimization_data()); |
2245 unsigned height = data->ArgumentsStackHeight(bailout_id)->value(); | 2228 unsigned height = data->ArgumentsStackHeight(bailout_id)->value(); |
2246 return height * kPointerSize; | 2229 return height * kPointerSize; |
2247 } | 2230 } |
2248 | 2231 |
2249 | |
2250 Object* Deoptimizer::ComputeLiteral(int index) const { | |
2251 DeoptimizationInputData* data = | |
2252 DeoptimizationInputData::cast(compiled_code_->deoptimization_data()); | |
2253 FixedArray* literals = data->LiteralArray(); | |
2254 return literals->get(index); | |
2255 } | |
2256 | |
2257 | |
2258 void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, | 2232 void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, |
2259 BailoutType type, | 2233 BailoutType type, |
2260 int max_entry_id) { | 2234 int max_entry_id) { |
2261 // We cannot run this if the serializer is enabled because this will | 2235 // We cannot run this if the serializer is enabled because this will |
2262 // cause us to emit relocation information for the external | 2236 // cause us to emit relocation information for the external |
2263 // references. This is fine because the deoptimizer's code section | 2237 // references. This is fine because the deoptimizer's code section |
2264 // isn't meant to be serialized at all. | 2238 // isn't meant to be serialized at all. |
2265 CHECK(type == EAGER || type == SOFT || type == LAZY); | 2239 CHECK(type == EAGER || type == SOFT || type == LAZY); |
2266 DeoptimizerData* data = isolate->deoptimizer_data(); | 2240 DeoptimizerData* data = isolate->deoptimizer_data(); |
2267 int entry_count = data->deopt_entry_code_entries_[type]; | 2241 int entry_count = data->deopt_entry_code_entries_[type]; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2306 // tagged value. kZapUint32 looks like a valid tagged pointer, but it isn't. | 2280 // tagged value. kZapUint32 looks like a valid tagged pointer, but it isn't. |
2307 SetRegister(r, kZapUint32); | 2281 SetRegister(r, kZapUint32); |
2308 } | 2282 } |
2309 | 2283 |
2310 // Zap all the slots. | 2284 // Zap all the slots. |
2311 for (unsigned o = 0; o < frame_size; o += kPointerSize) { | 2285 for (unsigned o = 0; o < frame_size; o += kPointerSize) { |
2312 SetFrameSlot(o, kZapUint32); | 2286 SetFrameSlot(o, kZapUint32); |
2313 } | 2287 } |
2314 } | 2288 } |
2315 | 2289 |
2316 | |
2317 int FrameDescription::ComputeFixedSize() { | |
2318 if (type_ == StackFrame::INTERPRETED) { | |
2319 return InterpreterFrameConstants::kFixedFrameSize + | |
2320 parameter_count() * kPointerSize; | |
2321 } else { | |
2322 return StandardFrameConstants::kFixedFrameSize + | |
2323 parameter_count() * kPointerSize; | |
2324 } | |
2325 } | |
2326 | |
2327 | |
2328 unsigned FrameDescription::GetOffsetFromSlotIndex(int slot_index) { | |
2329 if (slot_index >= 0) { | |
2330 // Local or spill slots. Skip the fixed part of the frame | |
2331 // including all arguments. | |
2332 unsigned base = GetFrameSize() - ComputeFixedSize(); | |
2333 return base - ((slot_index + 1) * kPointerSize); | |
2334 } else { | |
2335 // Incoming parameter. | |
2336 int arg_size = parameter_count() * kPointerSize; | |
2337 unsigned base = GetFrameSize() - arg_size; | |
2338 return base - ((slot_index + 1) * kPointerSize); | |
2339 } | |
2340 } | |
2341 | |
2342 | |
2343 void TranslationBuffer::Add(int32_t value, Zone* zone) { | 2290 void TranslationBuffer::Add(int32_t value, Zone* zone) { |
2344 // This wouldn't handle kMinInt correctly if it ever encountered it. | 2291 // This wouldn't handle kMinInt correctly if it ever encountered it. |
2345 DCHECK(value != kMinInt); | 2292 DCHECK(value != kMinInt); |
2346 // Encode the sign bit in the least significant bit. | 2293 // Encode the sign bit in the least significant bit. |
2347 bool is_negative = (value < 0); | 2294 bool is_negative = (value < 0); |
2348 uint32_t bits = ((is_negative ? -value : value) << 1) | | 2295 uint32_t bits = ((is_negative ? -value : value) << 1) | |
2349 static_cast<int32_t>(is_negative); | 2296 static_cast<int32_t>(is_negative); |
2350 // Encode the individual bytes using the least significant bit of | 2297 // Encode the individual bytes using the least significant bit of |
2351 // each byte to indicate whether or not more bytes follow. | 2298 // each byte to indicate whether or not more bytes follow. |
2352 do { | 2299 do { |
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4071 CHECK(value_info->IsMaterializedObject()); | 4018 CHECK(value_info->IsMaterializedObject()); |
4072 | 4019 |
4073 value_info->value_ = | 4020 value_info->value_ = |
4074 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4021 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4075 } | 4022 } |
4076 } | 4023 } |
4077 } | 4024 } |
4078 | 4025 |
4079 } // namespace internal | 4026 } // namespace internal |
4080 } // namespace v8 | 4027 } // namespace v8 |
OLD | NEW |