Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: src/compiler/ia32/code-generator-ia32.cc

Issue 892513003: [turbofan] Initial support for Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Wuschelstudio build. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/instruction-codes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ia32/assembler-ia32.h" 10 #include "src/ia32/assembler-ia32.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); 303 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset));
304 __ Assert(equal, kWrongFunctionContext); 304 __ Assert(equal, kWrongFunctionContext);
305 } 305 }
306 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); 306 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset));
307 AddSafepointAndDeopt(instr); 307 AddSafepointAndDeopt(instr);
308 break; 308 break;
309 } 309 }
310 case kArchJmp: 310 case kArchJmp:
311 AssembleArchJump(i.InputRpo(0)); 311 AssembleArchJump(i.InputRpo(0));
312 break; 312 break;
313 case kArchSwitch:
314 AssembleArchSwitch(instr);
315 break;
313 case kArchNop: 316 case kArchNop:
314 // don't emit code for nops. 317 // don't emit code for nops.
315 break; 318 break;
316 case kArchRet: 319 case kArchRet:
317 AssembleReturn(); 320 AssembleReturn();
318 break; 321 break;
319 case kArchStackPointer: 322 case kArchStackPointer:
320 __ mov(i.OutputRegister(), esp); 323 __ mov(i.OutputRegister(), esp);
321 break; 324 break;
322 case kArchTruncateDoubleToI: { 325 case kArchTruncateDoubleToI: {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 // Add a jump if not falling through to the next block. 754 // Add a jump if not falling through to the next block.
752 if (!branch->fallthru) __ jmp(flabel); 755 if (!branch->fallthru) __ jmp(flabel);
753 } 756 }
754 757
755 758
756 void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) { 759 void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) {
757 if (!IsNextInAssemblyOrder(target)) __ jmp(GetLabel(target)); 760 if (!IsNextInAssemblyOrder(target)) __ jmp(GetLabel(target));
758 } 761 }
759 762
760 763
764 void CodeGenerator::AssembleArchSwitch(Instruction* instr) {
765 IA32OperandConverter i(this, instr);
766 size_t const label_count = instr->InputCount() - 1;
767 Label** labels = zone()->NewArray<Label*>(label_count);
768 for (size_t index = 0; index < label_count; ++index) {
769 labels[index] = GetLabel(i.InputRpo(index + 1));
770 }
771 Label* const table = AddJumpTable(labels, label_count);
772 __ jmp(Operand::JumpTable(i.InputRegister(0), times_4, table));
773 }
774
775
761 // Assembles boolean materializations after an instruction. 776 // Assembles boolean materializations after an instruction.
762 void CodeGenerator::AssembleArchBoolean(Instruction* instr, 777 void CodeGenerator::AssembleArchBoolean(Instruction* instr,
763 FlagsCondition condition) { 778 FlagsCondition condition) {
764 IA32OperandConverter i(this, instr); 779 IA32OperandConverter i(this, instr);
765 Label done; 780 Label done;
766 781
767 // Materialize a full 32-bit 1 or 0 value. The result register is always the 782 // Materialize a full 32-bit 1 or 0 value. The result register is always the
768 // last output of the instruction. 783 // last output of the instruction.
769 Label check; 784 Label check;
770 DCHECK_NE(0u, instr->OutputCount()); 785 DCHECK_NE(0u, instr->OutputCount());
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 __ push(src1); 1222 __ push(src1);
1208 __ pop(dst1); 1223 __ pop(dst1);
1209 __ movsd(src0, xmm0); 1224 __ movsd(src0, xmm0);
1210 } else { 1225 } else {
1211 // No other combinations are possible. 1226 // No other combinations are possible.
1212 UNREACHABLE(); 1227 UNREACHABLE();
1213 } 1228 }
1214 } 1229 }
1215 1230
1216 1231
1232 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) {
1233 for (size_t index = 0; index < target_count; ++index) {
1234 __ dd(targets[index]);
1235 }
1236 }
1237
1238
1217 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } 1239 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); }
1218 1240
1219 1241
1220 void CodeGenerator::EnsureSpaceForLazyDeopt() { 1242 void CodeGenerator::EnsureSpaceForLazyDeopt() {
1221 int space_needed = Deoptimizer::patch_size(); 1243 int space_needed = Deoptimizer::patch_size();
1222 if (!info()->IsStub()) { 1244 if (!info()->IsStub()) {
1223 // Ensure that we have enough space after the previous lazy-bailout 1245 // Ensure that we have enough space after the previous lazy-bailout
1224 // instruction for patching the code here. 1246 // instruction for patching the code here.
1225 int current_pc = masm()->pc_offset(); 1247 int current_pc = masm()->pc_offset();
1226 if (current_pc < last_lazy_deopt_pc_ + space_needed) { 1248 if (current_pc < last_lazy_deopt_pc_ + space_needed) {
1227 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 1249 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
1228 __ Nop(padding_size); 1250 __ Nop(padding_size);
1229 } 1251 }
1230 } 1252 }
1231 MarkLazyDeoptSite(); 1253 MarkLazyDeoptSite();
1232 } 1254 }
1233 1255
1234 #undef __ 1256 #undef __
1235 1257
1236 } // namespace compiler 1258 } // namespace compiler
1237 } // namespace internal 1259 } // namespace internal
1238 } // namespace v8 1260 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/instruction-codes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698