OLD | NEW |
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/linkage.h" | 5 #include "src/compiler/linkage.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/builtins/builtins-utils.h" | 8 #include "src/builtins/builtins-utils.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
11 #include "src/compiler/common-operator.h" | 11 #include "src/compiler/common-operator.h" |
12 #include "src/compiler/frame.h" | 12 #include "src/compiler/frame.h" |
13 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
14 #include "src/compiler/osr.h" | 14 #include "src/compiler/osr.h" |
15 #include "src/compiler/pipeline.h" | 15 #include "src/compiler/pipeline.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 namespace compiler { | 19 namespace compiler { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 LinkageLocation regloc(Register reg, MachineType type) { | 23 LinkageLocation regloc(Register reg, MachineType type) { |
24 return LinkageLocation::ForRegister(reg.code(), type); | 24 return LinkageLocation::ForRegister(reg.code(), type); |
25 } | 25 } |
26 | 26 |
27 MachineType reptyp(Representation representation) { | |
28 switch (representation.kind()) { | |
29 case Representation::kInteger8: | |
30 return MachineType::Int8(); | |
31 case Representation::kUInteger8: | |
32 return MachineType::Uint8(); | |
33 case Representation::kInteger16: | |
34 return MachineType::Int16(); | |
35 case Representation::kUInteger16: | |
36 return MachineType::Uint16(); | |
37 case Representation::kInteger32: | |
38 return MachineType::Int32(); | |
39 case Representation::kSmi: | |
40 return MachineType::TaggedSigned(); | |
41 case Representation::kTagged: | |
42 return MachineType::AnyTagged(); | |
43 case Representation::kHeapObject: | |
44 return MachineType::TaggedPointer(); | |
45 case Representation::kDouble: | |
46 return MachineType::Float64(); | |
47 case Representation::kExternal: | |
48 return MachineType::Pointer(); | |
49 case Representation::kNone: | |
50 case Representation::kNumRepresentations: | |
51 break; | |
52 } | |
53 UNREACHABLE(); | |
54 return MachineType::None(); | |
55 } | |
56 | |
57 } // namespace | 27 } // namespace |
58 | 28 |
59 | 29 |
60 std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) { | 30 std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) { |
61 switch (k) { | 31 switch (k) { |
62 case CallDescriptor::kCallCodeObject: | 32 case CallDescriptor::kCallCodeObject: |
63 os << "Code"; | 33 os << "Code"; |
64 break; | 34 break; |
65 case CallDescriptor::kCallJSFunction: | 35 case CallDescriptor::kCallJSFunction: |
66 os << "JS"; | 36 os << "JS"; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 345 } |
376 if (locations.return_count_ > 2) { | 346 if (locations.return_count_ > 2) { |
377 locations.AddReturn(regloc(kReturnRegister2, return_type)); | 347 locations.AddReturn(regloc(kReturnRegister2, return_type)); |
378 } | 348 } |
379 | 349 |
380 // Add parameters in registers and on the stack. | 350 // Add parameters in registers and on the stack. |
381 for (int i = 0; i < js_parameter_count; i++) { | 351 for (int i = 0; i < js_parameter_count; i++) { |
382 if (i < register_parameter_count) { | 352 if (i < register_parameter_count) { |
383 // The first parameters go in registers. | 353 // The first parameters go in registers. |
384 Register reg = descriptor.GetRegisterParameter(i); | 354 Register reg = descriptor.GetRegisterParameter(i); |
385 MachineType type = | 355 MachineType type = descriptor.GetParameterType(i); |
386 reptyp(RepresentationFromType(descriptor.GetParameterType(i))); | |
387 locations.AddParam(regloc(reg, type)); | 356 locations.AddParam(regloc(reg, type)); |
388 } else { | 357 } else { |
389 // The rest of the parameters go on the stack. | 358 // The rest of the parameters go on the stack. |
390 int stack_slot = i - register_parameter_count - stack_parameter_count; | 359 int stack_slot = i - register_parameter_count - stack_parameter_count; |
391 locations.AddParam(LinkageLocation::ForCallerFrameSlot( | 360 locations.AddParam(LinkageLocation::ForCallerFrameSlot( |
392 stack_slot, MachineType::AnyTagged())); | 361 stack_slot, MachineType::AnyTagged())); |
393 } | 362 } |
394 } | 363 } |
395 // Add context. | 364 // Add context. |
396 locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); | 365 locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 const int register_parameter_count = descriptor.GetRegisterParameterCount(); | 414 const int register_parameter_count = descriptor.GetRegisterParameterCount(); |
446 const int parameter_count = register_parameter_count + stack_parameter_count; | 415 const int parameter_count = register_parameter_count + stack_parameter_count; |
447 | 416 |
448 LocationSignature::Builder locations(zone, 0, parameter_count); | 417 LocationSignature::Builder locations(zone, 0, parameter_count); |
449 | 418 |
450 // Add parameters in registers and on the stack. | 419 // Add parameters in registers and on the stack. |
451 for (int i = 0; i < parameter_count; i++) { | 420 for (int i = 0; i < parameter_count; i++) { |
452 if (i < register_parameter_count) { | 421 if (i < register_parameter_count) { |
453 // The first parameters go in registers. | 422 // The first parameters go in registers. |
454 Register reg = descriptor.GetRegisterParameter(i); | 423 Register reg = descriptor.GetRegisterParameter(i); |
455 MachineType type = | 424 MachineType type = descriptor.GetParameterType(i); |
456 reptyp(RepresentationFromType(descriptor.GetParameterType(i))); | |
457 locations.AddParam(regloc(reg, type)); | 425 locations.AddParam(regloc(reg, type)); |
458 } else { | 426 } else { |
459 // The rest of the parameters go on the stack. | 427 // The rest of the parameters go on the stack. |
460 int stack_slot = i - register_parameter_count - stack_parameter_count; | 428 int stack_slot = i - register_parameter_count - stack_parameter_count; |
461 locations.AddParam(LinkageLocation::ForCallerFrameSlot( | 429 locations.AddParam(LinkageLocation::ForCallerFrameSlot( |
462 stack_slot, MachineType::AnyTagged())); | 430 stack_slot, MachineType::AnyTagged())); |
463 } | 431 } |
464 } | 432 } |
465 | 433 |
466 // The target for interpreter dispatches is a code entry address. | 434 // The target for interpreter dispatches is a code entry address. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); | 491 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); |
524 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, | 492 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, |
525 MachineType::AnyTagged()); | 493 MachineType::AnyTagged()); |
526 } | 494 } |
527 } | 495 } |
528 | 496 |
529 | 497 |
530 } // namespace compiler | 498 } // namespace compiler |
531 } // namespace internal | 499 } // namespace internal |
532 } // namespace v8 | 500 } // namespace v8 |
OLD | NEW |