| 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
| 8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 static bool HasImmediateInput(Instruction* instr, int index) { | 104 static bool HasImmediateInput(Instruction* instr, int index) { |
| 105 return instr->InputAt(index)->IsImmediate(); | 105 return instr->InputAt(index)->IsImmediate(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 // Assembles an instruction after register allocation, producing machine code. | 109 // Assembles an instruction after register allocation, producing machine code. |
| 110 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 110 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| 111 IA32OperandConverter i(this, instr); | 111 IA32OperandConverter i(this, instr); |
| 112 | 112 |
| 113 switch (ArchOpcodeField::decode(instr->opcode())) { | 113 switch (ArchOpcodeField::decode(instr->opcode())) { |
| 114 case kArchCallAddress: | |
| 115 if (HasImmediateInput(instr, 0)) { | |
| 116 // TODO(dcarney): wire up EXTERNAL_REFERENCE instead of RUNTIME_ENTRY. | |
| 117 __ call(reinterpret_cast<byte*>(i.InputInt32(0)), | |
| 118 RelocInfo::RUNTIME_ENTRY); | |
| 119 } else { | |
| 120 __ call(i.InputRegister(0)); | |
| 121 } | |
| 122 break; | |
| 123 case kArchCallCodeObject: { | 114 case kArchCallCodeObject: { |
| 124 if (HasImmediateInput(instr, 0)) { | 115 if (HasImmediateInput(instr, 0)) { |
| 125 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 116 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
| 126 __ call(code, RelocInfo::CODE_TARGET); | 117 __ call(code, RelocInfo::CODE_TARGET); |
| 127 } else { | 118 } else { |
| 128 Register reg = i.InputRegister(0); | 119 Register reg = i.InputRegister(0); |
| 129 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); | 120 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); |
| 130 } | 121 } |
| 131 AddSafepointAndDeopt(instr); | 122 AddSafepointAndDeopt(instr); |
| 132 break; | 123 break; |
| 133 } | 124 } |
| 134 case kArchCallJSFunction: { | 125 case kArchCallJSFunction: { |
| 135 Register func = i.InputRegister(0); | 126 Register func = i.InputRegister(0); |
| 136 if (FLAG_debug_code) { | 127 if (FLAG_debug_code) { |
| 137 // Check the function's context matches the context argument. | 128 // Check the function's context matches the context argument. |
| 138 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); | 129 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
| 139 __ Assert(equal, kWrongFunctionContext); | 130 __ Assert(equal, kWrongFunctionContext); |
| 140 } | 131 } |
| 141 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 132 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
| 142 AddSafepointAndDeopt(instr); | 133 AddSafepointAndDeopt(instr); |
| 143 break; | 134 break; |
| 144 } | 135 } |
| 145 case kArchDrop: { | |
| 146 int words = MiscField::decode(instr->opcode()); | |
| 147 __ add(esp, Immediate(kPointerSize * words)); | |
| 148 break; | |
| 149 } | |
| 150 case kArchJmp: | 136 case kArchJmp: |
| 151 __ jmp(code()->GetLabel(i.InputBlock(0))); | 137 __ jmp(code()->GetLabel(i.InputBlock(0))); |
| 152 break; | 138 break; |
| 153 case kArchNop: | 139 case kArchNop: |
| 154 // don't emit code for nops. | 140 // don't emit code for nops. |
| 155 break; | 141 break; |
| 156 case kArchRet: | 142 case kArchRet: |
| 157 AssembleReturn(); | 143 AssembleReturn(); |
| 158 break; | 144 break; |
| 159 case kArchTruncateDoubleToI: | 145 case kArchTruncateDoubleToI: |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 } | 930 } |
| 945 | 931 |
| 946 | 932 |
| 947 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } | 933 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |
| 948 | 934 |
| 949 #undef __ | 935 #undef __ |
| 950 | 936 |
| 951 } // namespace compiler | 937 } // namespace compiler |
| 952 } // namespace internal | 938 } // namespace internal |
| 953 } // namespace v8 | 939 } // namespace v8 |
| OLD | NEW |