• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/v8.h"
6 
7 #include "src/interface-descriptors.h"
8 
9 namespace v8 {
10 namespace internal {
11 
Initialize(int register_parameter_count,Register * registers,Representation * register_param_representations,PlatformInterfaceDescriptor * platform_descriptor)12 void CallInterfaceDescriptorData::Initialize(
13     int register_parameter_count, Register* registers,
14     Representation* register_param_representations,
15     PlatformInterfaceDescriptor* platform_descriptor) {
16   platform_specific_descriptor_ = platform_descriptor;
17   register_param_count_ = register_parameter_count;
18 
19   // An interface descriptor must have a context register.
20   DCHECK(register_parameter_count > 0 &&
21          registers[0].is(CallInterfaceDescriptor::ContextRegister()));
22 
23   // InterfaceDescriptor owns a copy of the registers array.
24   register_params_.Reset(NewArray<Register>(register_parameter_count));
25   for (int i = 0; i < register_parameter_count; i++) {
26     register_params_[i] = registers[i];
27   }
28 
29   // If a representations array is specified, then the descriptor owns that as
30   // well.
31   if (register_param_representations != NULL) {
32     register_param_representations_.Reset(
33         NewArray<Representation>(register_parameter_count));
34     for (int i = 0; i < register_parameter_count; i++) {
35       // If there is a context register, the representation must be tagged.
36       DCHECK(
37           i != 0 ||
38           register_param_representations[i].Equals(Representation::Tagged()));
39       register_param_representations_[i] = register_param_representations[i];
40     }
41   }
42 }
43 
44 
DebugName(Isolate * isolate)45 const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) {
46   CallInterfaceDescriptorData* start = isolate->call_descriptor_data(0);
47   size_t index = data_ - start;
48   DCHECK(index < CallDescriptors::NUMBER_OF_DESCRIPTORS);
49   CallDescriptors::Key key = static_cast<CallDescriptors::Key>(index);
50   switch (key) {
51 #define DEF_CASE(NAME)        \
52   case CallDescriptors::NAME: \
53     return #NAME " Descriptor";
54     INTERFACE_DESCRIPTOR_LIST(DEF_CASE)
55 #undef DEF_CASE
56     case CallDescriptors::NUMBER_OF_DESCRIPTORS:
57       break;
58   }
59   return "";
60 }
61 
62 
Initialize(CallInterfaceDescriptorData * data)63 void LoadDescriptor::Initialize(CallInterfaceDescriptorData* data) {
64   Register registers[] = {ContextRegister(), ReceiverRegister(),
65                           NameRegister()};
66   data->Initialize(arraysize(registers), registers, NULL);
67 }
68 
69 
Initialize(CallInterfaceDescriptorData * data)70 void StoreDescriptor::Initialize(CallInterfaceDescriptorData* data) {
71   Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
72                           ValueRegister()};
73   data->Initialize(arraysize(registers), registers, NULL);
74 }
75 
76 
Initialize(CallInterfaceDescriptorData * data)77 void ElementTransitionAndStoreDescriptor::Initialize(
78     CallInterfaceDescriptorData* data) {
79   Register registers[] = {ContextRegister(), ValueRegister(), MapRegister(),
80                           NameRegister(), ReceiverRegister()};
81   data->Initialize(arraysize(registers), registers, NULL);
82 }
83 
84 
Initialize(CallInterfaceDescriptorData * data)85 void InstanceofDescriptor::Initialize(CallInterfaceDescriptorData* data) {
86   Register registers[] = {ContextRegister(), left(), right()};
87   data->Initialize(arraysize(registers), registers, NULL);
88 }
89 
90 
Initialize(CallInterfaceDescriptorData * data)91 void MathPowTaggedDescriptor::Initialize(CallInterfaceDescriptorData* data) {
92   Register registers[] = {ContextRegister(), exponent()};
93   data->Initialize(arraysize(registers), registers, NULL);
94 }
95 
96 
Initialize(CallInterfaceDescriptorData * data)97 void MathPowIntegerDescriptor::Initialize(CallInterfaceDescriptorData* data) {
98   Register registers[] = {ContextRegister(), exponent()};
99   data->Initialize(arraysize(registers), registers, NULL);
100 }
101 
102 
Initialize(CallInterfaceDescriptorData * data)103 void VectorLoadICTrampolineDescriptor::Initialize(
104     CallInterfaceDescriptorData* data) {
105   Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
106                           SlotRegister()};
107   data->Initialize(arraysize(registers), registers, NULL);
108 }
109 
110 
Initialize(CallInterfaceDescriptorData * data)111 void VectorLoadICDescriptor::Initialize(CallInterfaceDescriptorData* data) {
112   Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
113                           SlotRegister(), VectorRegister()};
114   Representation representations[] = {
115       Representation::Tagged(), Representation::Tagged(),
116       Representation::Tagged(), Representation::Smi(),
117       Representation::Tagged()};
118   data->Initialize(arraysize(registers), registers, representations);
119 }
120 
121 
Initialize(CallInterfaceDescriptorData * data)122 void ApiGetterDescriptor::Initialize(CallInterfaceDescriptorData* data) {
123   Register registers[] = {ContextRegister(), function_address()};
124   Representation representations[] = {Representation::Tagged(),
125                                       Representation::External()};
126   data->Initialize(arraysize(registers), registers, representations);
127 }
128 
129 
Initialize(CallInterfaceDescriptorData * data)130 void ArgumentsAccessReadDescriptor::Initialize(
131     CallInterfaceDescriptorData* data) {
132   Register registers[] = {ContextRegister(), index(), parameter_count()};
133   data->Initialize(arraysize(registers), registers, NULL);
134 }
135 
136 
Initialize(CallInterfaceDescriptorData * data)137 void ContextOnlyDescriptor::Initialize(CallInterfaceDescriptorData* data) {
138   Register registers[] = {ContextRegister()};
139   data->Initialize(arraysize(registers), registers, NULL);
140 }
141 
142 }
143 }  // namespace v8::internal
144