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" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 return GetJSCallDescriptor(zone, info->is_osr(), | 117 return GetJSCallDescriptor(zone, info->is_osr(), |
118 1 + shared->internal_formal_parameter_count(), | 118 1 + shared->internal_formal_parameter_count(), |
119 CallDescriptor::kNoFlags); | 119 CallDescriptor::kNoFlags); |
120 } | 120 } |
121 return nullptr; // TODO(titzer): ? | 121 return nullptr; // TODO(titzer): ? |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 // static | 125 // static |
126 bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) { | 126 bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) { |
127 // Most runtime functions need a FrameState. A few chosen ones that we know | |
128 // not to call into arbitrary JavaScript, not to throw, and not to deoptimize | |
129 // are blacklisted here and can be called without a FrameState. | |
130 switch (function) { | 127 switch (function) { |
| 128 // Most runtime functions need a FrameState. A few chosen ones that we know |
| 129 // not to call into arbitrary JavaScript, not to throw, and not to |
| 130 // deoptimize |
| 131 // are whitelisted here and can be called without a FrameState. |
131 case Runtime::kAbort: | 132 case Runtime::kAbort: |
132 case Runtime::kAllocateInTargetSpace: | 133 case Runtime::kAllocateInTargetSpace: |
133 case Runtime::kCreateIterResultObject: | 134 case Runtime::kCreateIterResultObject: |
134 case Runtime::kDefineGetterPropertyUnchecked: // TODO(jarin): Is it safe? | 135 case Runtime::kDefineGetterPropertyUnchecked: // TODO(jarin): Is it safe? |
135 case Runtime::kDefineSetterPropertyUnchecked: // TODO(jarin): Is it safe? | 136 case Runtime::kDefineSetterPropertyUnchecked: // TODO(jarin): Is it safe? |
136 case Runtime::kGeneratorGetContinuation: | 137 case Runtime::kGeneratorGetContinuation: |
137 case Runtime::kGetSuperConstructor: | 138 case Runtime::kGetSuperConstructor: |
138 case Runtime::kIsFunction: | 139 case Runtime::kIsFunction: |
139 case Runtime::kNewClosure: | 140 case Runtime::kNewClosure: |
140 case Runtime::kNewClosure_Tenured: | 141 case Runtime::kNewClosure_Tenured: |
141 case Runtime::kNewFunctionContext: | 142 case Runtime::kNewFunctionContext: |
142 case Runtime::kPushBlockContext: | 143 case Runtime::kPushBlockContext: |
143 case Runtime::kPushCatchContext: | 144 case Runtime::kPushCatchContext: |
144 case Runtime::kReThrow: | 145 case Runtime::kReThrow: |
145 case Runtime::kStringCompare: | 146 case Runtime::kStringCompare: |
146 case Runtime::kStringEqual: | 147 case Runtime::kStringEqual: |
147 case Runtime::kStringNotEqual: | 148 case Runtime::kStringNotEqual: |
148 case Runtime::kStringLessThan: | 149 case Runtime::kStringLessThan: |
149 case Runtime::kStringLessThanOrEqual: | 150 case Runtime::kStringLessThanOrEqual: |
150 case Runtime::kStringGreaterThan: | 151 case Runtime::kStringGreaterThan: |
151 case Runtime::kStringGreaterThanOrEqual: | 152 case Runtime::kStringGreaterThanOrEqual: |
152 case Runtime::kToFastProperties: // TODO(conradw): Is it safe? | 153 case Runtime::kToFastProperties: // TODO(conradw): Is it safe? |
153 case Runtime::kTraceEnter: | 154 case Runtime::kTraceEnter: |
154 case Runtime::kTraceExit: | 155 case Runtime::kTraceExit: |
155 return false; | 156 return false; |
156 case Runtime::kInlineCall: | 157 |
157 case Runtime::kInlineDeoptimizeNow: | 158 // Some inline intrinsics are also safe to call without a FrameState. |
158 case Runtime::kInlineGetPrototype: | 159 case Runtime::kInlineCreateIterResultObject: |
159 case Runtime::kInlineNewObject: | 160 case Runtime::kInlineFixedArrayGet: |
160 case Runtime::kInlineRegExpConstructResult: | 161 case Runtime::kInlineFixedArraySet: |
161 case Runtime::kInlineRegExpExec: | 162 case Runtime::kInlineGeneratorClose: |
162 case Runtime::kInlineSubString: | 163 case Runtime::kInlineGeneratorGetInputOrDebugPos: |
163 case Runtime::kInlineThrowNotDateError: | 164 case Runtime::kInlineGeneratorGetResumeMode: |
164 case Runtime::kInlineToInteger: | 165 case Runtime::kInlineGetSuperConstructor: |
165 case Runtime::kInlineToLength: | 166 case Runtime::kInlineIsArray: |
166 case Runtime::kInlineToNumber: | 167 case Runtime::kInlineIsJSReceiver: |
167 case Runtime::kInlineToObject: | 168 case Runtime::kInlineIsRegExp: |
168 case Runtime::kInlineToString: | 169 case Runtime::kInlineIsSmi: |
169 return true; | 170 case Runtime::kInlineIsTypedArray: |
| 171 case Runtime::kInlineRegExpFlags: |
| 172 case Runtime::kInlineRegExpSource: |
| 173 return false; |
| 174 |
170 default: | 175 default: |
171 break; | 176 break; |
172 } | 177 } |
173 | 178 |
174 // Most inlined runtime functions (except the ones listed above) can be called | 179 // For safety, default to needing a FrameState unless whitelisted. |
175 // without a FrameState or will be lowered by JSIntrinsicLowering internally. | |
176 const Runtime::Function* const f = Runtime::FunctionForId(function); | |
177 if (f->intrinsic_type == Runtime::IntrinsicType::INLINE) return false; | |
178 | |
179 return true; | 180 return true; |
180 } | 181 } |
181 | 182 |
182 | 183 |
183 bool CallDescriptor::UsesOnlyRegisters() const { | 184 bool CallDescriptor::UsesOnlyRegisters() const { |
184 for (size_t i = 0; i < InputCount(); ++i) { | 185 for (size_t i = 0; i < InputCount(); ++i) { |
185 if (!GetInputLocation(i).IsRegister()) return false; | 186 if (!GetInputLocation(i).IsRegister()) return false; |
186 } | 187 } |
187 for (size_t i = 0; i < ReturnCount(); ++i) { | 188 for (size_t i = 0; i < ReturnCount(); ++i) { |
188 if (!GetReturnLocation(i).IsRegister()) return false; | 189 if (!GetReturnLocation(i).IsRegister()) return false; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); | 492 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); |
492 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, | 493 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, |
493 MachineType::AnyTagged()); | 494 MachineType::AnyTagged()); |
494 } | 495 } |
495 } | 496 } |
496 | 497 |
497 | 498 |
498 } // namespace compiler | 499 } // namespace compiler |
499 } // namespace internal | 500 } // namespace internal |
500 } // namespace v8 | 501 } // namespace v8 |
OLD | NEW |