| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 intptr_t slot_ix = 0; | 57 intptr_t slot_ix = 0; |
| 58 Environment* current = deopt_env_; | 58 Environment* current = deopt_env_; |
| 59 | 59 |
| 60 // Emit all kMaterializeObject instructions describing objects to be | 60 // Emit all kMaterializeObject instructions describing objects to be |
| 61 // materialized on the deoptimization as a prefix to the deoptimization info. | 61 // materialized on the deoptimization as a prefix to the deoptimization info. |
| 62 EmitMaterializations(deopt_env_, builder); | 62 EmitMaterializations(deopt_env_, builder); |
| 63 | 63 |
| 64 // The real frame starts here. | 64 // The real frame starts here. |
| 65 builder->MarkFrameStart(); | 65 builder->MarkFrameStart(); |
| 66 | 66 |
| 67 // Callee's PC marker is not used anymore. Pass Function::null() to set to 0. | 67 // Callee's PC marker is not used anymore. Pass Code::null() to set to 0. |
| 68 builder->AddPcMarker(Function::Handle(), slot_ix++); | 68 builder->AddPcMarker(Code::Handle(), slot_ix++); |
| 69 | 69 |
| 70 // Current FP and PC. | 70 // Current FP and PC. |
| 71 builder->AddCallerFp(slot_ix++); | 71 builder->AddCallerFp(slot_ix++); |
| 72 builder->AddReturnAddress(current->function(), deopt_id(), slot_ix++); | 72 builder->AddReturnAddress(current->code(), deopt_id(), slot_ix++); |
| 73 | 73 |
| 74 // Emit all values that are needed for materialization as a part of the | 74 // Emit all values that are needed for materialization as a part of the |
| 75 // expression stack for the bottom-most frame. This guarantees that GC | 75 // expression stack for the bottom-most frame. This guarantees that GC |
| 76 // will be able to find them during materialization. | 76 // will be able to find them during materialization. |
| 77 slot_ix = builder->EmitMaterializationArguments(slot_ix); | 77 slot_ix = builder->EmitMaterializationArguments(slot_ix); |
| 78 | 78 |
| 79 // For the innermost environment, set outgoing arguments and the locals. | 79 // For the innermost environment, set outgoing arguments and the locals. |
| 80 for (intptr_t i = current->Length() - 1; | 80 for (intptr_t i = current->Length() - 1; |
| 81 i >= current->fixed_parameter_count(); | 81 i >= current->fixed_parameter_count(); |
| 82 i--) { | 82 i--) { |
| 83 builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++); | 83 builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Current PC marker and caller FP. | 86 // Current PC marker and caller FP. |
| 87 builder->AddPcMarker(current->function(), slot_ix++); | 87 builder->AddPcMarker(current->code(), slot_ix++); |
| 88 builder->AddCallerFp(slot_ix++); | 88 builder->AddCallerFp(slot_ix++); |
| 89 | 89 |
| 90 Environment* previous = current; | 90 Environment* previous = current; |
| 91 current = current->outer(); | 91 current = current->outer(); |
| 92 while (current != NULL) { | 92 while (current != NULL) { |
| 93 // For any outer environment the deopt id is that of the call instruction | 93 // For any outer environment the deopt id is that of the call instruction |
| 94 // which is recorded in the outer environment. | 94 // which is recorded in the outer environment. |
| 95 builder->AddReturnAddress(current->function(), | 95 builder->AddReturnAddress(current->code(), |
| 96 Isolate::ToDeoptAfter(current->deopt_id()), | 96 Isolate::ToDeoptAfter(current->deopt_id()), |
| 97 slot_ix++); | 97 slot_ix++); |
| 98 | 98 |
| 99 // The values of outgoing arguments can be changed from the inlined call so | 99 // The values of outgoing arguments can be changed from the inlined call so |
| 100 // we must read them from the previous environment. | 100 // we must read them from the previous environment. |
| 101 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { | 101 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { |
| 102 builder->AddCopy(previous->ValueAt(i), | 102 builder->AddCopy(previous->ValueAt(i), |
| 103 previous->LocationAt(i), | 103 previous->LocationAt(i), |
| 104 slot_ix++); | 104 slot_ix++); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Set the locals, note that outgoing arguments are not in the environment. | 107 // Set the locals, note that outgoing arguments are not in the environment. |
| 108 for (intptr_t i = current->Length() - 1; | 108 for (intptr_t i = current->Length() - 1; |
| 109 i >= current->fixed_parameter_count(); | 109 i >= current->fixed_parameter_count(); |
| 110 i--) { | 110 i--) { |
| 111 builder->AddCopy(current->ValueAt(i), | 111 builder->AddCopy(current->ValueAt(i), |
| 112 current->LocationAt(i), | 112 current->LocationAt(i), |
| 113 slot_ix++); | 113 slot_ix++); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // PC marker and caller FP. | 116 // PC marker and caller FP. |
| 117 builder->AddPcMarker(current->function(), slot_ix++); | 117 builder->AddPcMarker(current->code(), slot_ix++); |
| 118 builder->AddCallerFp(slot_ix++); | 118 builder->AddCallerFp(slot_ix++); |
| 119 | 119 |
| 120 // Iterate on the outer environment. | 120 // Iterate on the outer environment. |
| 121 previous = current; | 121 previous = current; |
| 122 current = current->outer(); | 122 current = current->outer(); |
| 123 } | 123 } |
| 124 // The previous pointer is now the outermost environment. | 124 // The previous pointer is now the outermost environment. |
| 125 ASSERT(previous != NULL); | 125 ASSERT(previous != NULL); |
| 126 | 126 |
| 127 // For the outermost environment, set caller PC. | 127 // For the outermost environment, set caller PC. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 139 | 139 |
| 140 | 140 |
| 141 void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler, | 141 void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler, |
| 142 intptr_t stub_ix) { | 142 intptr_t stub_ix) { |
| 143 // Calls do not need stubs, they share a deoptimization trampoline. | 143 // Calls do not need stubs, they share a deoptimization trampoline. |
| 144 ASSERT(reason() != kDeoptAtCall); | 144 ASSERT(reason() != kDeoptAtCall); |
| 145 Assembler* assem = compiler->assembler(); | 145 Assembler* assem = compiler->assembler(); |
| 146 #define __ assem-> | 146 #define __ assem-> |
| 147 __ Comment("Deopt stub for id %" Pd "", deopt_id()); | 147 __ Comment("Deopt stub for id %" Pd "", deopt_id()); |
| 148 __ Bind(entry_label()); | 148 __ Bind(entry_label()); |
| 149 if (FLAG_trap_on_deoptimization) __ int3(); | 149 if (FLAG_trap_on_deoptimization) { |
| 150 __ int3(); |
| 151 } |
| 150 | 152 |
| 151 ASSERT(deopt_env() != NULL); | 153 ASSERT(deopt_env() != NULL); |
| 152 | 154 |
| 153 __ call(&StubCode::DeoptimizeLabel()); | 155 __ call(&StubCode::DeoptimizeLabel()); |
| 154 set_pc_offset(assem->CodeSize()); | 156 set_pc_offset(assem->CodeSize()); |
| 155 __ int3(); | 157 __ int3(); |
| 156 #undef __ | 158 #undef __ |
| 157 } | 159 } |
| 158 | 160 |
| 159 | 161 |
| (...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); | 1401 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); |
| 1400 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); | 1402 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
| 1401 if (FLAG_collect_code) { | 1403 if (FLAG_collect_code) { |
| 1402 // If we are collecting code, the code object may be null. | 1404 // If we are collecting code, the code object may be null. |
| 1403 Label is_compiled; | 1405 Label is_compiled; |
| 1404 const Immediate& raw_null = | 1406 const Immediate& raw_null = |
| 1405 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1407 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1406 __ cmpl(EBX, raw_null); | 1408 __ cmpl(EBX, raw_null); |
| 1407 __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump); | 1409 __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump); |
| 1408 __ call(&StubCode::CompileFunctionRuntimeCallLabel()); | 1410 __ call(&StubCode::CompileFunctionRuntimeCallLabel()); |
| 1411 AddCurrentDescriptor(PcDescriptors::kRuntimeCall, |
| 1412 Isolate::kNoDeoptId, |
| 1413 token_pos); |
| 1414 RecordSafepoint(locs); |
| 1409 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); | 1415 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
| 1410 __ Bind(&is_compiled); | 1416 __ Bind(&is_compiled); |
| 1411 } | 1417 } |
| 1412 __ movl(EAX, FieldAddress(EBX, Code::instructions_offset())); | 1418 __ movl(EAX, FieldAddress(EBX, Code::instructions_offset())); |
| 1413 __ LoadObject(ECX, ic_data); | 1419 __ LoadObject(ECX, ic_data); |
| 1414 __ LoadObject(EDX, arguments_descriptor); | 1420 __ LoadObject(EDX, arguments_descriptor); |
| 1415 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1421 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1416 __ call(EAX); | 1422 __ call(EAX); |
| 1417 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); | 1423 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); |
| 1418 RecordSafepoint(locs); | 1424 RecordSafepoint(locs); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 __ movups(reg, Address(ESP, 0)); | 1884 __ movups(reg, Address(ESP, 0)); |
| 1879 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1885 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1880 } | 1886 } |
| 1881 | 1887 |
| 1882 | 1888 |
| 1883 #undef __ | 1889 #undef __ |
| 1884 | 1890 |
| 1885 } // namespace dart | 1891 } // namespace dart |
| 1886 | 1892 |
| 1887 #endif // defined TARGET_ARCH_IA32 | 1893 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |