| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 NOT_EXECUTABLE, | 49 NOT_EXECUTABLE, |
| 50 #else | 50 #else |
| 51 EXECUTABLE, | 51 EXECUTABLE, |
| 52 #endif | 52 #endif |
| 53 NULL); | 53 NULL); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 DeoptimizerData::DeoptimizerData(MemoryAllocator* allocator) | 57 DeoptimizerData::DeoptimizerData(MemoryAllocator* allocator) |
| 58 : allocator_(allocator), | 58 : allocator_(allocator), |
| 59 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 60 deoptimized_frame_info_(NULL), | 59 deoptimized_frame_info_(NULL), |
| 61 #endif | |
| 62 current_(NULL) { | 60 current_(NULL) { |
| 63 for (int i = 0; i < Deoptimizer::kBailoutTypesWithCodeEntry; ++i) { | 61 for (int i = 0; i < Deoptimizer::kBailoutTypesWithCodeEntry; ++i) { |
| 64 deopt_entry_code_entries_[i] = -1; | 62 deopt_entry_code_entries_[i] = -1; |
| 65 deopt_entry_code_[i] = AllocateCodeChunk(allocator); | 63 deopt_entry_code_[i] = AllocateCodeChunk(allocator); |
| 66 } | 64 } |
| 67 } | 65 } |
| 68 | 66 |
| 69 | 67 |
| 70 DeoptimizerData::~DeoptimizerData() { | 68 DeoptimizerData::~DeoptimizerData() { |
| 71 for (int i = 0; i < Deoptimizer::kBailoutTypesWithCodeEntry; ++i) { | 69 for (int i = 0; i < Deoptimizer::kBailoutTypesWithCodeEntry; ++i) { |
| 72 allocator_->Free(deopt_entry_code_[i]); | 70 allocator_->Free(deopt_entry_code_[i]); |
| 73 deopt_entry_code_[i] = NULL; | 71 deopt_entry_code_[i] = NULL; |
| 74 } | 72 } |
| 75 } | 73 } |
| 76 | 74 |
| 77 | 75 |
| 78 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 79 void DeoptimizerData::Iterate(ObjectVisitor* v) { | 76 void DeoptimizerData::Iterate(ObjectVisitor* v) { |
| 80 if (deoptimized_frame_info_ != NULL) { | 77 if (deoptimized_frame_info_ != NULL) { |
| 81 deoptimized_frame_info_->Iterate(v); | 78 deoptimized_frame_info_->Iterate(v); |
| 82 } | 79 } |
| 83 } | 80 } |
| 84 #endif | |
| 85 | 81 |
| 86 | 82 |
| 87 Code* Deoptimizer::FindDeoptimizingCode(Address addr) { | 83 Code* Deoptimizer::FindDeoptimizingCode(Address addr) { |
| 88 if (function_->IsHeapObject()) { | 84 if (function_->IsHeapObject()) { |
| 89 // Search all deoptimizing code in the native context of the function. | 85 // Search all deoptimizing code in the native context of the function. |
| 90 Context* native_context = function_->context()->native_context(); | 86 Context* native_context = function_->context()->native_context(); |
| 91 Object* element = native_context->DeoptimizedCodeListHead(); | 87 Object* element = native_context->DeoptimizedCodeListHead(); |
| 92 while (!element->IsUndefined()) { | 88 while (!element->IsUndefined()) { |
| 93 Code* code = Code::cast(element); | 89 Code* code = Code::cast(element); |
| 94 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 90 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (frame->GetFrameType() == StackFrame::JAVA_SCRIPT) { | 149 if (frame->GetFrameType() == StackFrame::JAVA_SCRIPT) { |
| 154 jsframe_index--; | 150 jsframe_index--; |
| 155 } | 151 } |
| 156 frame_index++; | 152 frame_index++; |
| 157 } | 153 } |
| 158 | 154 |
| 159 return frame_index - 1; | 155 return frame_index - 1; |
| 160 } | 156 } |
| 161 | 157 |
| 162 | 158 |
| 163 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 164 DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame( | 159 DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame( |
| 165 JavaScriptFrame* frame, | 160 JavaScriptFrame* frame, |
| 166 int jsframe_index, | 161 int jsframe_index, |
| 167 Isolate* isolate) { | 162 Isolate* isolate) { |
| 168 ASSERT(frame->is_optimized()); | 163 ASSERT(frame->is_optimized()); |
| 169 ASSERT(isolate->deoptimizer_data()->deoptimized_frame_info_ == NULL); | 164 ASSERT(isolate->deoptimizer_data()->deoptimized_frame_info_ == NULL); |
| 170 | 165 |
| 171 // Get the function and code from the frame. | 166 // Get the function and code from the frame. |
| 172 JSFunction* function = frame->function(); | 167 JSFunction* function = frame->function(); |
| 173 Code* code = frame->LookupCode(); | 168 Code* code = frame->LookupCode(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return info; | 243 return info; |
| 249 } | 244 } |
| 250 | 245 |
| 251 | 246 |
| 252 void Deoptimizer::DeleteDebuggerInspectableFrame(DeoptimizedFrameInfo* info, | 247 void Deoptimizer::DeleteDebuggerInspectableFrame(DeoptimizedFrameInfo* info, |
| 253 Isolate* isolate) { | 248 Isolate* isolate) { |
| 254 ASSERT(isolate->deoptimizer_data()->deoptimized_frame_info_ == info); | 249 ASSERT(isolate->deoptimizer_data()->deoptimized_frame_info_ == info); |
| 255 delete info; | 250 delete info; |
| 256 isolate->deoptimizer_data()->deoptimized_frame_info_ = NULL; | 251 isolate->deoptimizer_data()->deoptimized_frame_info_ = NULL; |
| 257 } | 252 } |
| 258 #endif | 253 |
| 259 | 254 |
| 260 void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm, | 255 void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm, |
| 261 int count, | 256 int count, |
| 262 BailoutType type) { | 257 BailoutType type) { |
| 263 TableEntryGenerator generator(masm, type, count); | 258 TableEntryGenerator generator(masm, type, count); |
| 264 generator.Generate(); | 259 generator.Generate(); |
| 265 } | 260 } |
| 266 | 261 |
| 267 | 262 |
| 268 void Deoptimizer::VisitAllOptimizedFunctionsForContext( | 263 void Deoptimizer::VisitAllOptimizedFunctionsForContext( |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 ASSERT(materialization_object_index_ == materialized_objects_->length()); | 2005 ASSERT(materialization_object_index_ == materialized_objects_->length()); |
| 2011 ASSERT(materialization_value_index_ == materialized_values_->length()); | 2006 ASSERT(materialization_value_index_ == materialized_values_->length()); |
| 2012 } | 2007 } |
| 2013 | 2008 |
| 2014 if (prev_materialized_count_ > 0) { | 2009 if (prev_materialized_count_ > 0) { |
| 2015 materialized_store->Remove(stack_fp_); | 2010 materialized_store->Remove(stack_fp_); |
| 2016 } | 2011 } |
| 2017 } | 2012 } |
| 2018 | 2013 |
| 2019 | 2014 |
| 2020 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 2021 void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( | 2015 void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( |
| 2022 Address parameters_top, | 2016 Address parameters_top, |
| 2023 uint32_t parameters_size, | 2017 uint32_t parameters_size, |
| 2024 Address expressions_top, | 2018 Address expressions_top, |
| 2025 uint32_t expressions_size, | 2019 uint32_t expressions_size, |
| 2026 DeoptimizedFrameInfo* info) { | 2020 DeoptimizedFrameInfo* info) { |
| 2027 ASSERT_EQ(DEBUGGER, bailout_type_); | 2021 ASSERT_EQ(DEBUGGER, bailout_type_); |
| 2028 Address parameters_bottom = parameters_top + parameters_size; | 2022 Address parameters_bottom = parameters_top + parameters_size; |
| 2029 Address expressions_bottom = expressions_top + expressions_size; | 2023 Address expressions_bottom = expressions_top + expressions_size; |
| 2030 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { | 2024 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2063 reinterpret_cast<void*>(*num), | 2057 reinterpret_cast<void*>(*num), |
| 2064 d.value(), | 2058 d.value(), |
| 2065 d.destination(), | 2059 d.destination(), |
| 2066 index); | 2060 index); |
| 2067 } | 2061 } |
| 2068 | 2062 |
| 2069 info->SetExpression(index, *num); | 2063 info->SetExpression(index, *num); |
| 2070 } | 2064 } |
| 2071 } | 2065 } |
| 2072 } | 2066 } |
| 2073 #endif | |
| 2074 | 2067 |
| 2075 | 2068 |
| 2076 static const char* TraceValueType(bool is_smi) { | 2069 static const char* TraceValueType(bool is_smi) { |
| 2077 if (is_smi) { | 2070 if (is_smi) { |
| 2078 return "smi"; | 2071 return "smi"; |
| 2079 } | 2072 } |
| 2080 | 2073 |
| 2081 return "heap number"; | 2074 return "heap number"; |
| 2082 } | 2075 } |
| 2083 | 2076 |
| (...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3496 for (int i = 0; i < array->length(); i++) { | 3489 for (int i = 0; i < array->length(); i++) { |
| 3497 new_array->set(i, array->get(i)); | 3490 new_array->set(i, array->get(i)); |
| 3498 } | 3491 } |
| 3499 for (int i = array->length(); i < length; i++) { | 3492 for (int i = array->length(); i < length; i++) { |
| 3500 new_array->set(i, isolate()->heap()->undefined_value()); | 3493 new_array->set(i, isolate()->heap()->undefined_value()); |
| 3501 } | 3494 } |
| 3502 isolate()->heap()->public_set_materialized_objects(*new_array); | 3495 isolate()->heap()->public_set_materialized_objects(*new_array); |
| 3503 return new_array; | 3496 return new_array; |
| 3504 } | 3497 } |
| 3505 | 3498 |
| 3506 #ifdef ENABLE_DEBUGGER_SUPPORT | |
| 3507 | 3499 |
| 3508 DeoptimizedFrameInfo::DeoptimizedFrameInfo(Deoptimizer* deoptimizer, | 3500 DeoptimizedFrameInfo::DeoptimizedFrameInfo(Deoptimizer* deoptimizer, |
| 3509 int frame_index, | 3501 int frame_index, |
| 3510 bool has_arguments_adaptor, | 3502 bool has_arguments_adaptor, |
| 3511 bool has_construct_stub) { | 3503 bool has_construct_stub) { |
| 3512 FrameDescription* output_frame = deoptimizer->output_[frame_index]; | 3504 FrameDescription* output_frame = deoptimizer->output_[frame_index]; |
| 3513 function_ = output_frame->GetFunction(); | 3505 function_ = output_frame->GetFunction(); |
| 3514 has_construct_stub_ = has_construct_stub; | 3506 has_construct_stub_ = has_construct_stub; |
| 3515 expression_count_ = output_frame->GetExpressionCount(); | 3507 expression_count_ = output_frame->GetExpressionCount(); |
| 3516 expression_stack_ = new Object*[expression_count_]; | 3508 expression_stack_ = new Object*[expression_count_]; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3541 delete[] parameters_; | 3533 delete[] parameters_; |
| 3542 } | 3534 } |
| 3543 | 3535 |
| 3544 | 3536 |
| 3545 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 3537 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
| 3546 v->VisitPointer(BitCast<Object**>(&function_)); | 3538 v->VisitPointer(BitCast<Object**>(&function_)); |
| 3547 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 3539 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
| 3548 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 3540 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
| 3549 } | 3541 } |
| 3550 | 3542 |
| 3551 #endif // ENABLE_DEBUGGER_SUPPORT | |
| 3552 | |
| 3553 } } // namespace v8::internal | 3543 } } // namespace v8::internal |
| OLD | NEW |