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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 125 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
126 __ call(code, RelocInfo::CODE_TARGET); | 126 __ call(code, RelocInfo::CODE_TARGET); |
127 } else { | 127 } else { |
128 Register reg = i.InputRegister(0); | 128 Register reg = i.InputRegister(0); |
129 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); | 129 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); |
130 } | 130 } |
131 AddSafepointAndDeopt(instr); | 131 AddSafepointAndDeopt(instr); |
132 break; | 132 break; |
133 } | 133 } |
134 case kArchCallJSFunction: { | 134 case kArchCallJSFunction: { |
135 // TODO(jarin) The load of the context should be separated from the call. | |
136 Register func = i.InputRegister(0); | 135 Register func = i.InputRegister(0); |
137 __ mov(esi, FieldOperand(func, JSFunction::kContextOffset)); | 136 if (FLAG_debug_code) { |
| 137 // Check the function's context matches the context argument. |
| 138 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
| 139 __ Assert(equal, kWrongFunctionContext); |
| 140 } |
138 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 141 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
139 AddSafepointAndDeopt(instr); | 142 AddSafepointAndDeopt(instr); |
140 break; | 143 break; |
141 } | 144 } |
142 case kArchDrop: { | 145 case kArchDrop: { |
143 int words = MiscField::decode(instr->opcode()); | 146 int words = MiscField::decode(instr->opcode()); |
144 __ add(esp, Immediate(kPointerSize * words)); | 147 __ add(esp, Immediate(kPointerSize * words)); |
145 break; | 148 break; |
146 } | 149 } |
147 case kArchJmp: | 150 case kArchJmp: |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 __ ret(0); | 785 __ ret(0); |
783 } else { | 786 } else { |
784 // No saved registers. | 787 // No saved registers. |
785 __ mov(esp, ebp); // Move stack pointer back to frame pointer. | 788 __ mov(esp, ebp); // Move stack pointer back to frame pointer. |
786 __ pop(ebp); // Pop caller's frame pointer. | 789 __ pop(ebp); // Pop caller's frame pointer. |
787 __ ret(0); | 790 __ ret(0); |
788 } | 791 } |
789 } else { | 792 } else { |
790 __ mov(esp, ebp); // Move stack pointer back to frame pointer. | 793 __ mov(esp, ebp); // Move stack pointer back to frame pointer. |
791 __ pop(ebp); // Pop caller's frame pointer. | 794 __ pop(ebp); // Pop caller's frame pointer. |
792 int pop_count = | 795 int pop_count = descriptor->IsJSFunctionCall() |
793 descriptor->IsJSFunctionCall() ? descriptor->ParameterCount() : 0; | 796 ? static_cast<int>(descriptor->JSParameterCount()) |
| 797 : 0; |
794 __ ret(pop_count * kPointerSize); | 798 __ ret(pop_count * kPointerSize); |
795 } | 799 } |
796 } | 800 } |
797 | 801 |
798 | 802 |
799 void CodeGenerator::AssembleMove(InstructionOperand* source, | 803 void CodeGenerator::AssembleMove(InstructionOperand* source, |
800 InstructionOperand* destination) { | 804 InstructionOperand* destination) { |
801 IA32OperandConverter g(this, NULL); | 805 IA32OperandConverter g(this, NULL); |
802 // Dispatch on the source and destination operand kinds. Not all | 806 // Dispatch on the source and destination operand kinds. Not all |
803 // combinations are possible. | 807 // combinations are possible. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 } | 945 } |
942 | 946 |
943 | 947 |
944 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } | 948 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |
945 | 949 |
946 #undef __ | 950 #undef __ |
947 | 951 |
948 } // namespace compiler | 952 } // namespace compiler |
949 } // namespace internal | 953 } // namespace internal |
950 } // namespace v8 | 954 } // namespace v8 |
OLD | NEW |