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

Side by Side Diff: src/compiler/arm64/instruction-selector-arm64.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, 5 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/instruction-selector-impl.h" 5 #include "src/compiler/instruction-selector-impl.h"
6 #include "src/compiler/node-matchers.h" 6 #include "src/compiler/node-matchers.h"
7 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 frame_state_descriptor = GetFrameStateDescriptor( 1338 frame_state_descriptor = GetFrameStateDescriptor(
1339 node->InputAt(static_cast<int>(descriptor->InputCount()))); 1339 node->InputAt(static_cast<int>(descriptor->InputCount())));
1340 } 1340 }
1341 1341
1342 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); 1342 CallBuffer buffer(zone(), descriptor, frame_state_descriptor);
1343 1343
1344 // Compute InstructionOperands for inputs and outputs. 1344 // Compute InstructionOperands for inputs and outputs.
1345 // TODO(turbofan): on ARM64 it's probably better to use the code object in a 1345 // TODO(turbofan): on ARM64 it's probably better to use the code object in a
1346 // register if there are multiple uses of it. Improve constant pool and the 1346 // register if there are multiple uses of it. Improve constant pool and the
1347 // heuristics in the register allocator for where to emit constants. 1347 // heuristics in the register allocator for where to emit constants.
1348 InitializeCallBuffer(node, &buffer, true, false); 1348 InitializeCallBuffer(node, &buffer, true, true);
1349 1349
1350 // Push the arguments to the stack. 1350 // Push the arguments to the stack.
1351 int aligned_push_count = static_cast<int>(buffer.pushed_nodes.size()); 1351 int aligned_push_count = static_cast<int>(buffer.pushed_nodes.size());
1352 bool pushed_count_uneven = aligned_push_count & 1; 1352 bool pushed_count_uneven = aligned_push_count & 1;
1353 // TODO(dcarney): claim and poke probably take small immediates, 1353 // TODO(dcarney): claim and poke probably take small immediates,
1354 // loop here or whatever. 1354 // loop here or whatever.
1355 // Bump the stack pointer(s). 1355 // Bump the stack pointer(s).
1356 if (aligned_push_count > 0) { 1356 if (aligned_push_count > 0) {
1357 // TODO(dcarney): it would be better to bump the csp here only 1357 // TODO(dcarney): it would be better to bump the csp here only
1358 // and emit paired stores with increment for non c frames. 1358 // and emit paired stores with increment for non c frames.
(...skipping 26 matching lines...) Expand all
1385 if (hint == IfExceptionHint::kLocallyCaught) { 1385 if (hint == IfExceptionHint::kLocallyCaught) {
1386 flags |= CallDescriptor::kHasLocalCatchHandler; 1386 flags |= CallDescriptor::kHasLocalCatchHandler;
1387 } 1387 }
1388 flags |= CallDescriptor::kHasExceptionHandler; 1388 flags |= CallDescriptor::kHasExceptionHandler;
1389 buffer.instruction_args.push_back(g.Label(handler)); 1389 buffer.instruction_args.push_back(g.Label(handler));
1390 } 1390 }
1391 1391
1392 // Select the appropriate opcode based on the call type. 1392 // Select the appropriate opcode based on the call type.
1393 InstructionCode opcode; 1393 InstructionCode opcode;
1394 switch (descriptor->kind()) { 1394 switch (descriptor->kind()) {
1395 case CallDescriptor::kCallCodeObject: { 1395 case CallDescriptor::kCallAddress:
1396 opcode = kArchCallCodeObject; 1396 opcode =
1397 kArchCallCFunction |
1398 MiscField::encode(static_cast<int>(descriptor->CParameterCount()));
1397 break; 1399 break;
1398 } 1400 case CallDescriptor::kCallCodeObject:
1401 opcode = kArchCallCodeObject | MiscField::encode(flags);
1402 break;
1399 case CallDescriptor::kCallJSFunction: 1403 case CallDescriptor::kCallJSFunction:
1400 opcode = kArchCallJSFunction; 1404 opcode = kArchCallJSFunction | MiscField::encode(flags);
1401 break; 1405 break;
1402 default: 1406 default:
1403 UNREACHABLE(); 1407 UNREACHABLE();
1404 return; 1408 return;
1405 } 1409 }
1406 opcode |= MiscField::encode(flags);
1407 1410
1408 // Emit the call instruction. 1411 // Emit the call instruction.
1409 size_t const output_count = buffer.outputs.size(); 1412 size_t const output_count = buffer.outputs.size();
1410 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; 1413 auto* outputs = output_count ? &buffer.outputs.front() : nullptr;
1411 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), 1414 Emit(opcode, output_count, outputs, buffer.instruction_args.size(),
1412 &buffer.instruction_args.front())->MarkAsCall(); 1415 &buffer.instruction_args.front())->MarkAsCall();
1413 } 1416 }
1414 1417
1415 1418
1416 void InstructionSelector::VisitTailCall(Node* node) { 1419 void InstructionSelector::VisitTailCall(Node* node) {
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 MachineOperatorBuilder::kFloat64RoundTruncate | 2008 MachineOperatorBuilder::kFloat64RoundTruncate |
2006 MachineOperatorBuilder::kFloat64RoundTiesAway | 2009 MachineOperatorBuilder::kFloat64RoundTiesAway |
2007 MachineOperatorBuilder::kWord32ShiftIsSafe | 2010 MachineOperatorBuilder::kWord32ShiftIsSafe |
2008 MachineOperatorBuilder::kInt32DivIsSafe | 2011 MachineOperatorBuilder::kInt32DivIsSafe |
2009 MachineOperatorBuilder::kUint32DivIsSafe; 2012 MachineOperatorBuilder::kUint32DivIsSafe;
2010 } 2013 }
2011 2014
2012 } // namespace compiler 2015 } // namespace compiler
2013 } // namespace internal 2016 } // namespace internal
2014 } // namespace v8 2017 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698