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

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

Issue 1205023002: [turbofan] Add basic support for calling to (a subset of) C functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix argument slots. Created 5 years, 6 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
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 Register func = i.InputRegister(0); 345 Register func = i.InputRegister(0);
346 if (FLAG_debug_code) { 346 if (FLAG_debug_code) {
347 // Check the function's context matches the context argument. 347 // Check the function's context matches the context argument.
348 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); 348 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset));
349 __ Assert(equal, kWrongFunctionContext); 349 __ Assert(equal, kWrongFunctionContext);
350 } 350 }
351 AssembleDeconstructActivationRecord(); 351 AssembleDeconstructActivationRecord();
352 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); 352 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset));
353 break; 353 break;
354 } 354 }
355 case kArchPrepareCallCFunction: {
356 int const num_parameters = MiscField::decode(instr->opcode());
357 __ PrepareCallCFunction(num_parameters, i.TempRegister(0));
358 break;
359 }
360 case kArchCallCFunction: {
361 int const num_parameters = MiscField::decode(instr->opcode());
362 if (HasImmediateInput(instr, 0)) {
363 ExternalReference ref = i.InputExternalReference(0);
364 __ CallCFunction(ref, num_parameters);
365 } else {
366 Register func = i.InputRegister(0);
367 __ CallCFunction(func, num_parameters);
368 }
369 break;
370 }
355 case kArchJmp: 371 case kArchJmp:
356 AssembleArchJump(i.InputRpo(0)); 372 AssembleArchJump(i.InputRpo(0));
357 break; 373 break;
358 case kArchLookupSwitch: 374 case kArchLookupSwitch:
359 AssembleArchLookupSwitch(instr); 375 AssembleArchLookupSwitch(instr);
360 break; 376 break;
361 case kArchTableSwitch: 377 case kArchTableSwitch:
362 AssembleArchTableSwitch(instr); 378 AssembleArchTableSwitch(instr);
363 break; 379 break;
364 case kArchNop: 380 case kArchNop:
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 } 879 }
864 break; 880 break;
865 } 881 }
866 case kIA32Push: 882 case kIA32Push:
867 if (HasImmediateInput(instr, 0)) { 883 if (HasImmediateInput(instr, 0)) {
868 __ push(i.InputImmediate(0)); 884 __ push(i.InputImmediate(0));
869 } else { 885 } else {
870 __ push(i.InputOperand(0)); 886 __ push(i.InputOperand(0));
871 } 887 }
872 break; 888 break;
889 case kIA32Poke: {
890 int const slot = MiscField::decode(instr->opcode());
891 if (HasImmediateInput(instr, 0)) {
892 __ mov(Operand(esp, slot * kPointerSize), i.InputImmediate(0));
893 } else {
894 __ mov(Operand(esp, slot * kPointerSize), i.InputRegister(0));
895 }
896 break;
897 }
873 case kIA32StoreWriteBarrier: { 898 case kIA32StoreWriteBarrier: {
874 Register object = i.InputRegister(0); 899 Register object = i.InputRegister(0);
875 Register value = i.InputRegister(2); 900 Register value = i.InputRegister(2);
876 SaveFPRegsMode mode = 901 SaveFPRegsMode mode =
877 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; 902 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs;
878 if (HasImmediateInput(instr, 1)) { 903 if (HasImmediateInput(instr, 1)) {
879 int index = i.InputInt32(1); 904 int index = i.InputInt32(1);
880 Register scratch = i.TempRegister(1); 905 Register scratch = i.TempRegister(1);
881 __ mov(Operand(object, index), value); 906 __ mov(Operand(object, index), value);
882 __ RecordWriteContextSlot(object, index, value, scratch, mode); 907 __ RecordWriteContextSlot(object, index, value, scratch, mode);
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 __ Nop(padding_size); 1536 __ Nop(padding_size);
1512 } 1537 }
1513 } 1538 }
1514 } 1539 }
1515 1540
1516 #undef __ 1541 #undef __
1517 1542
1518 } // namespace compiler 1543 } // namespace compiler
1519 } // namespace internal 1544 } // namespace internal
1520 } // namespace v8 1545 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698