OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 const Function& function = Function::Handle(code.function()); | 1235 const Function& function = Function::Handle(code.function()); |
1236 ASSERT(!function.IsNull()); | 1236 ASSERT(!function.IsNull()); |
1237 // Since the code is referenced from the frame and the ZoneHandle, | 1237 // Since the code is referenced from the frame and the ZoneHandle, |
1238 // it cannot have been removed from the function. | 1238 // it cannot have been removed from the function. |
1239 ASSERT(function.HasCode()); | 1239 ASSERT(function.HasCode()); |
1240 // Don't do OSR on intrinsified functions: The intrinsic code expects to be | 1240 // Don't do OSR on intrinsified functions: The intrinsic code expects to be |
1241 // called like a regular function and can't be entered via OSR. | 1241 // called like a regular function and can't be entered via OSR. |
1242 if (!CanOptimizeFunction(function, isolate) || function.is_intrinsic()) { | 1242 if (!CanOptimizeFunction(function, isolate) || function.is_intrinsic()) { |
1243 return; | 1243 return; |
1244 } | 1244 } |
| 1245 ASSERT(function.unoptimized_code() != Object::null()); |
1245 intptr_t osr_id = | 1246 intptr_t osr_id = |
1246 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc()); | 1247 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc()); |
| 1248 ASSERT(osr_id != Isolate::kNoDeoptId); |
1247 if (FLAG_trace_osr) { | 1249 if (FLAG_trace_osr) { |
1248 OS::Print("Attempting OSR for %s at id=%" Pd ", count=%" Pd "\n", | 1250 OS::Print("Attempting OSR for %s at id=%" Pd ", count=%" Pd "\n", |
1249 function.ToFullyQualifiedCString(), | 1251 function.ToFullyQualifiedCString(), |
1250 osr_id, | 1252 osr_id, |
1251 function.usage_counter()); | 1253 function.usage_counter()); |
1252 } | 1254 } |
1253 | 1255 |
1254 const Code& original_code = Code::Handle(function.CurrentCode()); | 1256 const Code& original_code = Code::Handle(function.CurrentCode()); |
1255 // Since the code is referenced from the frame and the ZoneHandle, | 1257 // Since the code is referenced from the frame and the ZoneHandle, |
1256 // it cannot have been removed from the function. | 1258 // it cannot have been removed from the function. |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 const Code& code = Code::Handle(deopt_context->code()); | 1568 const Code& code = Code::Handle(deopt_context->code()); |
1567 | 1569 |
1568 // The code from our frame. | 1570 // The code from our frame. |
1569 const Code& optimized_code = Code::Handle(caller_frame->LookupDartCode()); | 1571 const Code& optimized_code = Code::Handle(caller_frame->LookupDartCode()); |
1570 const Function& function = Function::Handle(optimized_code.function()); | 1572 const Function& function = Function::Handle(optimized_code.function()); |
1571 ASSERT(!function.IsNull()); | 1573 ASSERT(!function.IsNull()); |
1572 | 1574 |
1573 // The code will be the same as before. | 1575 // The code will be the same as before. |
1574 ASSERT(code.raw() == optimized_code.raw()); | 1576 ASSERT(code.raw() == optimized_code.raw()); |
1575 | 1577 |
1576 // Some sanity checking of the optimized/unoptimized code. | 1578 // Some sanity checking of the optimized code. |
1577 ASSERT(!optimized_code.IsNull() && optimized_code.is_optimized()); | 1579 ASSERT(!optimized_code.IsNull() && optimized_code.is_optimized()); |
1578 } | 1580 } |
1579 #endif | 1581 #endif |
1580 | 1582 |
1581 // TODO(turnidge): Compute the start of the dest frame in the | 1583 // TODO(turnidge): Compute the start of the dest frame in the |
1582 // DeoptContext instead of passing it in here. | 1584 // DeoptContext instead of passing it in here. |
1583 intptr_t* start = reinterpret_cast<intptr_t*>( | 1585 intptr_t* start = reinterpret_cast<intptr_t*>( |
1584 caller_frame->sp() - (kDartFrameFixedSize * kWordSize)); | 1586 caller_frame->sp() - (kDartFrameFixedSize * kWordSize)); |
1585 deopt_context->set_dest_frame(start); | 1587 deopt_context->set_dest_frame(start); |
1586 deopt_context->FillDestFrame(); | 1588 deopt_context->FillDestFrame(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1674 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
1673 const TypedData& new_data = | 1675 const TypedData& new_data = |
1674 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1676 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
1675 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1677 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
1676 typed_data_cell.SetAt(0, new_data); | 1678 typed_data_cell.SetAt(0, new_data); |
1677 arguments.SetReturn(new_data); | 1679 arguments.SetReturn(new_data); |
1678 } | 1680 } |
1679 | 1681 |
1680 | 1682 |
1681 } // namespace dart | 1683 } // namespace dart |
OLD | NEW |