| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #include "src/compiler/linkage.h" | 
|  | 6 | 
|  | 7 #include "src/code-stubs.h" | 
|  | 8 #include "src/compiler.h" | 
|  | 9 #include "src/compiler/node.h" | 
|  | 10 #include "src/compiler/pipeline.h" | 
|  | 11 #include "src/scopes.h" | 
|  | 12 | 
|  | 13 namespace v8 { | 
|  | 14 namespace internal { | 
|  | 15 namespace compiler { | 
|  | 16 | 
|  | 17 | 
|  | 18 OStream& operator<<(OStream& os, const CallDescriptor::Kind& k) { | 
|  | 19   switch (k) { | 
|  | 20     case CallDescriptor::kCallCodeObject: | 
|  | 21       os << "Code"; | 
|  | 22       break; | 
|  | 23     case CallDescriptor::kCallJSFunction: | 
|  | 24       os << "JS"; | 
|  | 25       break; | 
|  | 26     case CallDescriptor::kCallAddress: | 
|  | 27       os << "Addr"; | 
|  | 28       break; | 
|  | 29   } | 
|  | 30   return os; | 
|  | 31 } | 
|  | 32 | 
|  | 33 | 
|  | 34 OStream& operator<<(OStream& os, const CallDescriptor& d) { | 
|  | 35   // TODO(svenpanne) Output properties etc. and be less cryptic. | 
|  | 36   return os << d.kind() << ":" << d.debug_name() << ":r" << d.ReturnCount() | 
|  | 37             << "p" << d.ParameterCount() << "i" << d.InputCount() | 
|  | 38             << (d.CanLazilyDeoptimize() ? "deopt" : ""); | 
|  | 39 } | 
|  | 40 | 
|  | 41 | 
|  | 42 Linkage::Linkage(CompilationInfo* info) : info_(info) { | 
|  | 43   if (info->function() != NULL) { | 
|  | 44     // If we already have the function literal, use the number of parameters | 
|  | 45     // plus the receiver. | 
|  | 46     incoming_ = GetJSCallDescriptor(1 + info->function()->parameter_count()); | 
|  | 47   } else if (!info->closure().is_null()) { | 
|  | 48     // If we are compiling a JS function, use a JS call descriptor, | 
|  | 49     // plus the receiver. | 
|  | 50     SharedFunctionInfo* shared = info->closure()->shared(); | 
|  | 51     incoming_ = GetJSCallDescriptor(1 + shared->formal_parameter_count()); | 
|  | 52   } else if (info->code_stub() != NULL) { | 
|  | 53     // Use the code stub interface descriptor. | 
|  | 54     HydrogenCodeStub* stub = info->code_stub(); | 
|  | 55     CodeStubInterfaceDescriptor* descriptor = | 
|  | 56         info_->isolate()->code_stub_interface_descriptor(stub->MajorKey()); | 
|  | 57     incoming_ = GetStubCallDescriptor(descriptor); | 
|  | 58   } else { | 
|  | 59     incoming_ = NULL;  // TODO(titzer): ? | 
|  | 60   } | 
|  | 61 } | 
|  | 62 | 
|  | 63 | 
|  | 64 FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame, int extra) { | 
|  | 65   if (frame->GetSpillSlotCount() > 0 || incoming_->IsJSFunctionCall() || | 
|  | 66       incoming_->kind() == CallDescriptor::kCallAddress) { | 
|  | 67     int offset; | 
|  | 68     int register_save_area_size = frame->GetRegisterSaveAreaSize(); | 
|  | 69     if (spill_slot >= 0) { | 
|  | 70       // Local or spill slot. Skip the frame pointer, function, and | 
|  | 71       // context in the fixed part of the frame. | 
|  | 72       offset = | 
|  | 73           -(spill_slot + 1) * kPointerSize - register_save_area_size + extra; | 
|  | 74     } else { | 
|  | 75       // Incoming parameter. Skip the return address. | 
|  | 76       offset = -(spill_slot + 1) * kPointerSize + kFPOnStackSize + | 
|  | 77                kPCOnStackSize + extra; | 
|  | 78     } | 
|  | 79     return FrameOffset::FromFramePointer(offset); | 
|  | 80   } else { | 
|  | 81     // No frame. Retrieve all parameters relative to stack pointer. | 
|  | 82     ASSERT(spill_slot < 0);  // Must be a parameter. | 
|  | 83     int register_save_area_size = frame->GetRegisterSaveAreaSize(); | 
|  | 84     int offset = register_save_area_size - (spill_slot + 1) * kPointerSize + | 
|  | 85                  kPCOnStackSize + extra; | 
|  | 86     return FrameOffset::FromStackPointer(offset); | 
|  | 87   } | 
|  | 88 } | 
|  | 89 | 
|  | 90 | 
|  | 91 CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count) { | 
|  | 92   return GetJSCallDescriptor(parameter_count, this->info_->zone()); | 
|  | 93 } | 
|  | 94 | 
|  | 95 | 
|  | 96 CallDescriptor* Linkage::GetRuntimeCallDescriptor( | 
|  | 97     Runtime::FunctionId function, int parameter_count, | 
|  | 98     Operator::Property properties, | 
|  | 99     CallDescriptor::DeoptimizationSupport can_deoptimize) { | 
|  | 100   return GetRuntimeCallDescriptor(function, parameter_count, properties, | 
|  | 101                                   can_deoptimize, this->info_->zone()); | 
|  | 102 } | 
|  | 103 | 
|  | 104 | 
|  | 105 //============================================================================== | 
|  | 106 // Provide unimplemented methods on unsupported architectures, to at least link. | 
|  | 107 //============================================================================== | 
|  | 108 #if !V8_TURBOFAN_TARGET | 
|  | 109 CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) { | 
|  | 110   UNIMPLEMENTED(); | 
|  | 111   return NULL; | 
|  | 112 } | 
|  | 113 | 
|  | 114 | 
|  | 115 CallDescriptor* Linkage::GetRuntimeCallDescriptor( | 
|  | 116     Runtime::FunctionId function, int parameter_count, | 
|  | 117     Operator::Property properties, | 
|  | 118     CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) { | 
|  | 119   UNIMPLEMENTED(); | 
|  | 120   return NULL; | 
|  | 121 } | 
|  | 122 | 
|  | 123 | 
|  | 124 CallDescriptor* Linkage::GetStubCallDescriptor( | 
|  | 125     CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count) { | 
|  | 126   UNIMPLEMENTED(); | 
|  | 127   return NULL; | 
|  | 128 } | 
|  | 129 | 
|  | 130 | 
|  | 131 CallDescriptor* Linkage::GetSimplifiedCDescriptor( | 
|  | 132     Zone* zone, int num_params, MachineRepresentation return_type, | 
|  | 133     MachineRepresentation* param_types) { | 
|  | 134   UNIMPLEMENTED(); | 
|  | 135   return NULL; | 
|  | 136 } | 
|  | 137 #endif  // !V8_TURBOFAN_TARGET | 
|  | 138 } | 
|  | 139 } | 
|  | 140 }  // namespace v8::internal::compiler | 
| OLD | NEW | 
|---|