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

Side by Side Diff: src/compiler/x64/code-generator-x64.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/scopes.h" 10 #include "src/scopes.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 Register func = i.InputRegister(0); 595 Register func = i.InputRegister(0);
596 if (FLAG_debug_code) { 596 if (FLAG_debug_code) {
597 // Check the function's context matches the context argument. 597 // Check the function's context matches the context argument.
598 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); 598 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset));
599 __ Assert(equal, kWrongFunctionContext); 599 __ Assert(equal, kWrongFunctionContext);
600 } 600 }
601 AssembleDeconstructActivationRecord(); 601 AssembleDeconstructActivationRecord();
602 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); 602 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset));
603 break; 603 break;
604 } 604 }
605 case kArchPrepareCallCFunction: {
606 int const num_parameters = MiscField::decode(instr->opcode());
607 __ PrepareCallCFunction(num_parameters);
608 break;
609 }
610 case kArchCallCFunction: {
611 int const num_parameters = MiscField::decode(instr->opcode());
612 if (HasImmediateInput(instr, 0)) {
613 ExternalReference ref = i.InputExternalReference(0);
614 __ CallCFunction(ref, num_parameters);
615 } else {
616 Register func = i.InputRegister(0);
617 __ CallCFunction(func, num_parameters);
618 }
619 break;
620 }
605 case kArchJmp: 621 case kArchJmp:
606 AssembleArchJump(i.InputRpo(0)); 622 AssembleArchJump(i.InputRpo(0));
607 break; 623 break;
608 case kArchLookupSwitch: 624 case kArchLookupSwitch:
609 AssembleArchLookupSwitch(instr); 625 AssembleArchLookupSwitch(instr);
610 break; 626 break;
611 case kArchTableSwitch: 627 case kArchTableSwitch:
612 AssembleArchTableSwitch(instr); 628 AssembleArchTableSwitch(instr);
613 break; 629 break;
614 case kArchNop: 630 case kArchNop:
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 if (HasImmediateInput(instr, 0)) { 1224 if (HasImmediateInput(instr, 0)) {
1209 __ pushq(i.InputImmediate(0)); 1225 __ pushq(i.InputImmediate(0));
1210 } else { 1226 } else {
1211 if (instr->InputAt(0)->IsRegister()) { 1227 if (instr->InputAt(0)->IsRegister()) {
1212 __ pushq(i.InputRegister(0)); 1228 __ pushq(i.InputRegister(0));
1213 } else { 1229 } else {
1214 __ pushq(i.InputOperand(0)); 1230 __ pushq(i.InputOperand(0));
1215 } 1231 }
1216 } 1232 }
1217 break; 1233 break;
1234 case kX64Poke: {
1235 int const slot = MiscField::decode(instr->opcode());
1236 if (HasImmediateInput(instr, 0)) {
1237 __ movq(Operand(rsp, slot * kPointerSize), i.InputImmediate(0));
1238 } else {
1239 __ movq(Operand(rsp, slot * kPointerSize), i.InputRegister(0));
1240 }
1241 break;
1242 }
1218 case kX64StoreWriteBarrier: { 1243 case kX64StoreWriteBarrier: {
1219 Register object = i.InputRegister(0); 1244 Register object = i.InputRegister(0);
1220 Register value = i.InputRegister(2); 1245 Register value = i.InputRegister(2);
1221 SaveFPRegsMode mode = 1246 SaveFPRegsMode mode =
1222 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; 1247 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs;
1223 if (HasImmediateInput(instr, 1)) { 1248 if (HasImmediateInput(instr, 1)) {
1224 int index = i.InputInt32(1); 1249 int index = i.InputInt32(1);
1225 Register scratch = i.TempRegister(1); 1250 Register scratch = i.TempRegister(1);
1226 __ movq(Operand(object, index), value); 1251 __ movq(Operand(object, index), value);
1227 __ RecordWriteContextSlot(object, index, value, scratch, mode); 1252 __ RecordWriteContextSlot(object, index, value, scratch, mode);
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 __ Nop(padding_size); 1737 __ Nop(padding_size);
1713 } 1738 }
1714 } 1739 }
1715 } 1740 }
1716 1741
1717 #undef __ 1742 #undef __
1718 1743
1719 } // namespace internal 1744 } // namespace internal
1720 } // namespace compiler 1745 } // namespace compiler
1721 } // namespace v8 1746 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698