| 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/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 Environment* current = deopt_env_; | 55 Environment* current = deopt_env_; |
| 56 | 56 |
| 57 // Emit all kMaterializeObject instructions describing objects to be | 57 // Emit all kMaterializeObject instructions describing objects to be |
| 58 // materialized on the deoptimization as a prefix to the deoptimization info. | 58 // materialized on the deoptimization as a prefix to the deoptimization info. |
| 59 EmitMaterializations(deopt_env_, builder); | 59 EmitMaterializations(deopt_env_, builder); |
| 60 | 60 |
| 61 // The real frame starts here. | 61 // The real frame starts here. |
| 62 builder->MarkFrameStart(); | 62 builder->MarkFrameStart(); |
| 63 | 63 |
| 64 // Current PP, FP, and PC. | 64 // Current PP, FP, and PC. |
| 65 builder->AddPp(current->function(), slot_ix++); | 65 builder->AddPp(current->code(), slot_ix++); |
| 66 builder->AddPcMarker(Function::Handle(), slot_ix++); | 66 builder->AddPcMarker(Code::Handle(), slot_ix++); |
| 67 builder->AddCallerFp(slot_ix++); | 67 builder->AddCallerFp(slot_ix++); |
| 68 builder->AddReturnAddress(current->function(), deopt_id(), slot_ix++); | 68 builder->AddReturnAddress(current->code(), deopt_id(), slot_ix++); |
| 69 | 69 |
| 70 // Emit all values that are needed for materialization as a part of the | 70 // Emit all values that are needed for materialization as a part of the |
| 71 // expression stack for the bottom-most frame. This guarantees that GC | 71 // expression stack for the bottom-most frame. This guarantees that GC |
| 72 // will be able to find them during materialization. | 72 // will be able to find them during materialization. |
| 73 slot_ix = builder->EmitMaterializationArguments(slot_ix); | 73 slot_ix = builder->EmitMaterializationArguments(slot_ix); |
| 74 | 74 |
| 75 // For the innermost environment, set outgoing arguments and the locals. | 75 // For the innermost environment, set outgoing arguments and the locals. |
| 76 for (intptr_t i = current->Length() - 1; | 76 for (intptr_t i = current->Length() - 1; |
| 77 i >= current->fixed_parameter_count(); | 77 i >= current->fixed_parameter_count(); |
| 78 i--) { | 78 i--) { |
| 79 builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++); | 79 builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++); |
| 80 } | 80 } |
| 81 | 81 |
| 82 Environment* previous = current; | 82 Environment* previous = current; |
| 83 current = current->outer(); | 83 current = current->outer(); |
| 84 while (current != NULL) { | 84 while (current != NULL) { |
| 85 // PP, FP, and PC. | 85 // PP, FP, and PC. |
| 86 builder->AddPp(current->function(), slot_ix++); | 86 builder->AddPp(current->code(), slot_ix++); |
| 87 builder->AddPcMarker(previous->function(), slot_ix++); | 87 builder->AddPcMarker(previous->code(), slot_ix++); |
| 88 builder->AddCallerFp(slot_ix++); | 88 builder->AddCallerFp(slot_ix++); |
| 89 | 89 |
| 90 // For any outer environment the deopt id is that of the call instruction | 90 // For any outer environment the deopt id is that of the call instruction |
| 91 // which is recorded in the outer environment. | 91 // which is recorded in the outer environment. |
| 92 builder->AddReturnAddress(current->function(), | 92 builder->AddReturnAddress(current->code(), |
| 93 Isolate::ToDeoptAfter(current->deopt_id()), | 93 Isolate::ToDeoptAfter(current->deopt_id()), |
| 94 slot_ix++); | 94 slot_ix++); |
| 95 | 95 |
| 96 // The values of outgoing arguments can be changed from the inlined call so | 96 // The values of outgoing arguments can be changed from the inlined call so |
| 97 // we must read them from the previous environment. | 97 // we must read them from the previous environment. |
| 98 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { | 98 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { |
| 99 builder->AddCopy(previous->ValueAt(i), | 99 builder->AddCopy(previous->ValueAt(i), |
| 100 previous->LocationAt(i), | 100 previous->LocationAt(i), |
| 101 slot_ix++); | 101 slot_ix++); |
| 102 } | 102 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 113 // Iterate on the outer environment. | 113 // Iterate on the outer environment. |
| 114 previous = current; | 114 previous = current; |
| 115 current = current->outer(); | 115 current = current->outer(); |
| 116 } | 116 } |
| 117 // The previous pointer is now the outermost environment. | 117 // The previous pointer is now the outermost environment. |
| 118 ASSERT(previous != NULL); | 118 ASSERT(previous != NULL); |
| 119 | 119 |
| 120 // For the outermost environment, set caller PC, caller PP, and caller FP. | 120 // For the outermost environment, set caller PC, caller PP, and caller FP. |
| 121 builder->AddCallerPp(slot_ix++); | 121 builder->AddCallerPp(slot_ix++); |
| 122 // PC marker. | 122 // PC marker. |
| 123 builder->AddPcMarker(previous->function(), slot_ix++); | 123 builder->AddPcMarker(previous->code(), slot_ix++); |
| 124 builder->AddCallerFp(slot_ix++); | 124 builder->AddCallerFp(slot_ix++); |
| 125 builder->AddCallerPc(slot_ix++); | 125 builder->AddCallerPc(slot_ix++); |
| 126 | 126 |
| 127 // For the outermost environment, set the incoming arguments. | 127 // For the outermost environment, set the incoming arguments. |
| 128 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { | 128 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { |
| 129 builder->AddCopy(previous->ValueAt(i), previous->LocationAt(i), slot_ix++); | 129 builder->AddCopy(previous->ValueAt(i), previous->LocationAt(i), slot_ix++); |
| 130 } | 130 } |
| 131 | 131 |
| 132 const DeoptInfo& deopt_info = | 132 const DeoptInfo& deopt_info = |
| 133 DeoptInfo::Handle(builder->CreateDeoptInfo(deopt_table)); | 133 DeoptInfo::Handle(builder->CreateDeoptInfo(deopt_table)); |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); | 1431 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); |
| 1432 __ movq(RBX, FieldAddress(RAX, Function::code_offset())); | 1432 __ movq(RBX, FieldAddress(RAX, Function::code_offset())); |
| 1433 if (FLAG_collect_code) { | 1433 if (FLAG_collect_code) { |
| 1434 // If we are collecting code, the code object may be null. | 1434 // If we are collecting code, the code object may be null. |
| 1435 Label is_compiled; | 1435 Label is_compiled; |
| 1436 const Immediate& raw_null = | 1436 const Immediate& raw_null = |
| 1437 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1437 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1438 __ cmpq(RBX, raw_null); | 1438 __ cmpq(RBX, raw_null); |
| 1439 __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump); | 1439 __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump); |
| 1440 __ call(&StubCode::CompileFunctionRuntimeCallLabel()); | 1440 __ call(&StubCode::CompileFunctionRuntimeCallLabel()); |
| 1441 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, |
| 1442 Isolate::kNoDeoptId, |
| 1443 token_pos); |
| 1444 RecordSafepoint(locs); |
| 1441 __ movq(RBX, FieldAddress(RAX, Function::code_offset())); | 1445 __ movq(RBX, FieldAddress(RAX, Function::code_offset())); |
| 1442 __ Bind(&is_compiled); | 1446 __ Bind(&is_compiled); |
| 1443 } | 1447 } |
| 1444 __ movq(RAX, FieldAddress(RBX, Code::instructions_offset())); | 1448 __ movq(RAX, FieldAddress(RBX, Code::instructions_offset())); |
| 1445 __ LoadObject(RBX, ic_data, PP); | 1449 __ LoadObject(RBX, ic_data, PP); |
| 1446 __ LoadObject(R10, arguments_descriptor, PP); | 1450 __ LoadObject(R10, arguments_descriptor, PP); |
| 1447 __ AddImmediate( | 1451 __ AddImmediate( |
| 1448 RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP); | 1452 RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP); |
| 1449 __ call(RAX); | 1453 __ call(RAX); |
| 1450 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); | 1454 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 __ movups(reg, Address(RSP, 0)); | 1902 __ movups(reg, Address(RSP, 0)); |
| 1899 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1903 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
| 1900 } | 1904 } |
| 1901 | 1905 |
| 1902 | 1906 |
| 1903 #undef __ | 1907 #undef __ |
| 1904 | 1908 |
| 1905 } // namespace dart | 1909 } // namespace dart |
| 1906 | 1910 |
| 1907 #endif // defined TARGET_ARCH_X64 | 1911 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |