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/code-factory.h" | 5 #include "src/code-factory.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 16 matching lines...) Expand all Loading... |
27 return stub.GetCode(); | 27 return stub.GetCode(); |
28 } | 28 } |
29 | 29 |
30 // static | 30 // static |
31 Callable CodeFactory::LoadIC(Isolate* isolate) { | 31 Callable CodeFactory::LoadIC(Isolate* isolate) { |
32 return Callable(isolate->builtins()->LoadICTrampoline(), | 32 return Callable(isolate->builtins()->LoadICTrampoline(), |
33 LoadDescriptor(isolate)); | 33 LoadDescriptor(isolate)); |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
| 37 Callable CodeFactory::LoadICProtoArray(Isolate* isolate, |
| 38 bool throw_if_nonexistent) { |
| 39 return Callable( |
| 40 throw_if_nonexistent |
| 41 ? isolate->builtins()->LoadICProtoArrayThrowIfNonexistent() |
| 42 : isolate->builtins()->LoadICProtoArray(), |
| 43 LoadICProtoArrayDescriptor(isolate)); |
| 44 } |
| 45 |
| 46 // static |
37 Callable CodeFactory::ApiGetter(Isolate* isolate) { | 47 Callable CodeFactory::ApiGetter(Isolate* isolate) { |
38 CallApiGetterStub stub(isolate); | 48 CallApiGetterStub stub(isolate); |
39 return make_callable(stub); | 49 return make_callable(stub); |
40 } | 50 } |
41 | 51 |
42 // static | 52 // static |
43 Callable CodeFactory::LoadICInOptimizedCode(Isolate* isolate) { | 53 Callable CodeFactory::LoadICInOptimizedCode(Isolate* isolate) { |
44 return Callable(isolate->builtins()->LoadIC(), | 54 return Callable(isolate->builtins()->LoadIC(), |
45 LoadWithVectorDescriptor(isolate)); | 55 LoadWithVectorDescriptor(isolate)); |
46 } | 56 } |
(...skipping 22 matching lines...) Expand all Loading... |
69 LoadDescriptor(isolate)); | 79 LoadDescriptor(isolate)); |
70 } | 80 } |
71 | 81 |
72 // static | 82 // static |
73 Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) { | 83 Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) { |
74 return Callable(isolate->builtins()->KeyedLoadIC(), | 84 return Callable(isolate->builtins()->KeyedLoadIC(), |
75 LoadWithVectorDescriptor(isolate)); | 85 LoadWithVectorDescriptor(isolate)); |
76 } | 86 } |
77 | 87 |
78 // static | 88 // static |
79 Callable CodeFactory::KeyedLoadIC_Megamorphic(Isolate* isolate) { | |
80 return Callable(isolate->builtins()->KeyedLoadIC_Megamorphic_TF(), | |
81 LoadWithVectorDescriptor(isolate)); | |
82 } | |
83 | |
84 // static | |
85 Callable CodeFactory::CallIC(Isolate* isolate, ConvertReceiverMode mode, | 89 Callable CodeFactory::CallIC(Isolate* isolate, ConvertReceiverMode mode, |
86 TailCallMode tail_call_mode) { | 90 TailCallMode tail_call_mode) { |
87 CallICTrampolineStub stub(isolate, CallICState(mode, tail_call_mode)); | 91 CallICTrampolineStub stub(isolate, CallICState(mode, tail_call_mode)); |
88 return make_callable(stub); | 92 return make_callable(stub); |
89 } | 93 } |
90 | 94 |
91 // static | 95 // static |
92 Callable CodeFactory::CallICInOptimizedCode(Isolate* isolate, | 96 Callable CodeFactory::CallICInOptimizedCode(Isolate* isolate, |
93 ConvertReceiverMode mode, | 97 ConvertReceiverMode mode, |
94 TailCallMode tail_call_mode) { | 98 TailCallMode tail_call_mode) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 LanguageMode language_mode) { | 130 LanguageMode language_mode) { |
127 return Callable(language_mode == STRICT | 131 return Callable(language_mode == STRICT |
128 ? isolate->builtins()->KeyedStoreICStrict() | 132 ? isolate->builtins()->KeyedStoreICStrict() |
129 : isolate->builtins()->KeyedStoreIC(), | 133 : isolate->builtins()->KeyedStoreIC(), |
130 StoreWithVectorDescriptor(isolate)); | 134 StoreWithVectorDescriptor(isolate)); |
131 } | 135 } |
132 | 136 |
133 // static | 137 // static |
134 Callable CodeFactory::KeyedStoreIC_Megamorphic(Isolate* isolate, | 138 Callable CodeFactory::KeyedStoreIC_Megamorphic(Isolate* isolate, |
135 LanguageMode language_mode) { | 139 LanguageMode language_mode) { |
136 return Callable( | 140 return Callable(language_mode == STRICT |
137 language_mode == STRICT | 141 ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict() |
138 ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict_TF() | 142 : isolate->builtins()->KeyedStoreIC_Megamorphic(), |
139 : isolate->builtins()->KeyedStoreIC_Megamorphic_TF(), | 143 StoreWithVectorDescriptor(isolate)); |
140 StoreWithVectorDescriptor(isolate)); | |
141 } | 144 } |
142 | 145 |
143 // static | 146 // static |
144 Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) { | 147 Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) { |
145 CompareICStub stub(isolate, op); | 148 CompareICStub stub(isolate, op); |
146 return make_callable(stub); | 149 return make_callable(stub); |
147 } | 150 } |
148 | 151 |
149 // static | 152 // static |
150 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) { | 153 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) { |
151 BinaryOpICStub stub(isolate, op); | 154 BinaryOpICStub stub(isolate, op); |
152 return make_callable(stub); | 155 return make_callable(stub); |
153 } | 156 } |
154 | 157 |
155 // static | 158 // static |
156 Callable CodeFactory::GetProperty(Isolate* isolate) { | 159 Callable CodeFactory::GetProperty(Isolate* isolate) { |
157 GetPropertyStub stub(isolate); | 160 GetPropertyStub stub(isolate); |
158 return make_callable(stub); | 161 return make_callable(stub); |
159 } | 162 } |
160 | 163 |
161 // static | 164 // static |
162 Callable CodeFactory::ToBoolean(Isolate* isolate) { | |
163 return Callable(isolate->builtins()->ToBoolean(), | |
164 TypeConversionDescriptor(isolate)); | |
165 } | |
166 | |
167 // static | |
168 Callable CodeFactory::ToNumber(Isolate* isolate) { | |
169 return Callable(isolate->builtins()->ToNumber(), | |
170 TypeConversionDescriptor(isolate)); | |
171 } | |
172 | |
173 // static | |
174 Callable CodeFactory::NonNumberToNumber(Isolate* isolate) { | |
175 return Callable(isolate->builtins()->NonNumberToNumber(), | |
176 TypeConversionDescriptor(isolate)); | |
177 } | |
178 | |
179 // static | |
180 Callable CodeFactory::StringToNumber(Isolate* isolate) { | |
181 return Callable(isolate->builtins()->StringToNumber(), | |
182 TypeConversionDescriptor(isolate)); | |
183 } | |
184 | |
185 // static | |
186 Callable CodeFactory::ToName(Isolate* isolate) { | |
187 return Callable(isolate->builtins()->ToName(), | |
188 TypeConversionDescriptor(isolate)); | |
189 } | |
190 | |
191 // static | |
192 Callable CodeFactory::NonPrimitiveToPrimitive(Isolate* isolate, | 165 Callable CodeFactory::NonPrimitiveToPrimitive(Isolate* isolate, |
193 ToPrimitiveHint hint) { | 166 ToPrimitiveHint hint) { |
194 return Callable(isolate->builtins()->NonPrimitiveToPrimitive(hint), | 167 return Callable(isolate->builtins()->NonPrimitiveToPrimitive(hint), |
195 TypeConversionDescriptor(isolate)); | 168 TypeConversionDescriptor(isolate)); |
196 } | 169 } |
197 | 170 |
198 // static | 171 // static |
199 Callable CodeFactory::OrdinaryToPrimitive(Isolate* isolate, | 172 Callable CodeFactory::OrdinaryToPrimitive(Isolate* isolate, |
200 OrdinaryToPrimitiveHint hint) { | 173 OrdinaryToPrimitiveHint hint) { |
201 return Callable(isolate->builtins()->OrdinaryToPrimitive(hint), | 174 return Callable(isolate->builtins()->OrdinaryToPrimitive(hint), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 TFS_BUILTIN(LessThan) | 220 TFS_BUILTIN(LessThan) |
248 TFS_BUILTIN(LessThanOrEqual) | 221 TFS_BUILTIN(LessThanOrEqual) |
249 TFS_BUILTIN(GreaterThan) | 222 TFS_BUILTIN(GreaterThan) |
250 TFS_BUILTIN(GreaterThanOrEqual) | 223 TFS_BUILTIN(GreaterThanOrEqual) |
251 TFS_BUILTIN(Equal) | 224 TFS_BUILTIN(Equal) |
252 TFS_BUILTIN(NotEqual) | 225 TFS_BUILTIN(NotEqual) |
253 TFS_BUILTIN(StrictEqual) | 226 TFS_BUILTIN(StrictEqual) |
254 TFS_BUILTIN(StrictNotEqual) | 227 TFS_BUILTIN(StrictNotEqual) |
255 TFS_BUILTIN(CreateIterResultObject) | 228 TFS_BUILTIN(CreateIterResultObject) |
256 TFS_BUILTIN(HasProperty) | 229 TFS_BUILTIN(HasProperty) |
| 230 TFS_BUILTIN(NonNumberToNumber) |
| 231 TFS_BUILTIN(StringToNumber) |
| 232 TFS_BUILTIN(ToBoolean) |
257 TFS_BUILTIN(ToInteger) | 233 TFS_BUILTIN(ToInteger) |
258 TFS_BUILTIN(ToLength) | 234 TFS_BUILTIN(ToLength) |
| 235 TFS_BUILTIN(ToName) |
| 236 TFS_BUILTIN(ToNumber) |
259 TFS_BUILTIN(ToObject) | 237 TFS_BUILTIN(ToObject) |
260 TFS_BUILTIN(Typeof) | 238 TFS_BUILTIN(Typeof) |
261 TFS_BUILTIN(InstanceOf) | 239 TFS_BUILTIN(InstanceOf) |
262 TFS_BUILTIN(OrdinaryHasInstance) | 240 TFS_BUILTIN(OrdinaryHasInstance) |
263 TFS_BUILTIN(ForInFilter) | 241 TFS_BUILTIN(CopyFastSmiOrObjectElements) |
| 242 TFS_BUILTIN(GrowFastDoubleElements) |
| 243 TFS_BUILTIN(GrowFastSmiOrObjectElements) |
264 TFS_BUILTIN(NewUnmappedArgumentsElements) | 244 TFS_BUILTIN(NewUnmappedArgumentsElements) |
265 TFS_BUILTIN(NewRestParameterElements) | 245 TFS_BUILTIN(NewRestParameterElements) |
| 246 TFS_BUILTIN(FastCloneRegExp) |
| 247 TFS_BUILTIN(FastNewClosure) |
| 248 TFS_BUILTIN(FastNewObject) |
| 249 TFS_BUILTIN(ForInFilter) |
| 250 TFS_BUILTIN(GetSuperConstructor) |
| 251 TFS_BUILTIN(KeyedLoadIC_Megamorphic) |
266 TFS_BUILTIN(PromiseHandleReject) | 252 TFS_BUILTIN(PromiseHandleReject) |
267 TFS_BUILTIN(GetSuperConstructor) | |
268 TFS_BUILTIN(StringCharAt) | 253 TFS_BUILTIN(StringCharAt) |
269 TFS_BUILTIN(StringCharCodeAt) | 254 TFS_BUILTIN(StringCharCodeAt) |
| 255 TFS_BUILTIN(StringEqual) |
| 256 TFS_BUILTIN(StringNotEqual) |
| 257 TFS_BUILTIN(StringLessThan) |
| 258 TFS_BUILTIN(StringLessThanOrEqual) |
| 259 TFS_BUILTIN(StringGreaterThan) |
| 260 TFS_BUILTIN(StringGreaterThanOrEqual) |
270 | 261 |
271 #undef TFS_BUILTIN | 262 #undef TFS_BUILTIN |
272 | 263 |
273 // static | 264 // static |
274 Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags, | 265 Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags, |
275 PretenureFlag pretenure_flag) { | 266 PretenureFlag pretenure_flag) { |
276 StringAddStub stub(isolate, flags, pretenure_flag); | 267 StringAddStub stub(isolate, flags, pretenure_flag); |
277 return make_callable(stub); | 268 return make_callable(stub); |
278 } | 269 } |
279 | 270 |
(...skipping 15 matching lines...) Expand all Loading... |
295 case Token::GTE: | 286 case Token::GTE: |
296 return StringGreaterThanOrEqual(isolate); | 287 return StringGreaterThanOrEqual(isolate); |
297 default: | 288 default: |
298 break; | 289 break; |
299 } | 290 } |
300 UNREACHABLE(); | 291 UNREACHABLE(); |
301 return StringEqual(isolate); | 292 return StringEqual(isolate); |
302 } | 293 } |
303 | 294 |
304 // static | 295 // static |
305 Callable CodeFactory::StringEqual(Isolate* isolate) { | |
306 return Callable(isolate->builtins()->StringEqual(), | |
307 CompareDescriptor(isolate)); | |
308 } | |
309 | |
310 // static | |
311 Callable CodeFactory::StringNotEqual(Isolate* isolate) { | |
312 return Callable(isolate->builtins()->StringNotEqual(), | |
313 CompareDescriptor(isolate)); | |
314 } | |
315 | |
316 // static | |
317 Callable CodeFactory::StringLessThan(Isolate* isolate) { | |
318 return Callable(isolate->builtins()->StringLessThan(), | |
319 CompareDescriptor(isolate)); | |
320 } | |
321 | |
322 // static | |
323 Callable CodeFactory::StringLessThanOrEqual(Isolate* isolate) { | |
324 return Callable(isolate->builtins()->StringLessThanOrEqual(), | |
325 CompareDescriptor(isolate)); | |
326 } | |
327 | |
328 // static | |
329 Callable CodeFactory::StringGreaterThan(Isolate* isolate) { | |
330 return Callable(isolate->builtins()->StringGreaterThan(), | |
331 CompareDescriptor(isolate)); | |
332 } | |
333 | |
334 // static | |
335 Callable CodeFactory::StringGreaterThanOrEqual(Isolate* isolate) { | |
336 return Callable(isolate->builtins()->StringGreaterThanOrEqual(), | |
337 CompareDescriptor(isolate)); | |
338 } | |
339 | |
340 // static | |
341 Callable CodeFactory::SubString(Isolate* isolate) { | 296 Callable CodeFactory::SubString(Isolate* isolate) { |
342 SubStringStub stub(isolate); | 297 SubStringStub stub(isolate); |
343 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); | 298 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
344 } | 299 } |
345 | 300 |
346 // static | 301 // static |
347 Callable CodeFactory::ResumeGenerator(Isolate* isolate) { | 302 Callable CodeFactory::ResumeGenerator(Isolate* isolate) { |
348 return Callable(isolate->builtins()->ResumeGeneratorTrampoline(), | 303 return Callable(isolate->builtins()->ResumeGeneratorTrampoline(), |
349 ResumeGeneratorDescriptor(isolate)); | 304 ResumeGeneratorDescriptor(isolate)); |
350 } | 305 } |
351 | 306 |
352 // static | 307 // static |
353 Callable CodeFactory::FastCloneRegExp(Isolate* isolate) { | |
354 return Callable(isolate->builtins()->FastCloneRegExp(), | |
355 FastCloneRegExpDescriptor(isolate)); | |
356 } | |
357 | |
358 // static | |
359 Callable CodeFactory::FastCloneShallowArray( | 308 Callable CodeFactory::FastCloneShallowArray( |
360 Isolate* isolate, AllocationSiteMode allocation_mode) { | 309 Isolate* isolate, AllocationSiteMode allocation_mode) { |
361 return Callable(isolate->builtins()->NewCloneShallowArray(allocation_mode), | 310 return Callable(isolate->builtins()->NewCloneShallowArray(allocation_mode), |
362 FastCloneShallowArrayDescriptor(isolate)); | 311 FastCloneShallowArrayDescriptor(isolate)); |
363 } | 312 } |
364 | 313 |
365 // static | 314 // static |
366 Callable CodeFactory::FastCloneShallowObject(Isolate* isolate, int length) { | 315 Callable CodeFactory::FastCloneShallowObject(Isolate* isolate, int length) { |
367 return Callable(isolate->builtins()->NewCloneShallowObject(length), | 316 return Callable(isolate->builtins()->NewCloneShallowObject(length), |
368 FastCloneShallowObjectDescriptor(isolate)); | 317 FastCloneShallowObjectDescriptor(isolate)); |
369 } | 318 } |
370 | 319 |
371 // static | 320 // static |
372 Callable CodeFactory::FastNewFunctionContext(Isolate* isolate, | 321 Callable CodeFactory::FastNewFunctionContext(Isolate* isolate, |
373 ScopeType scope_type) { | 322 ScopeType scope_type) { |
374 return Callable(isolate->builtins()->NewFunctionContext(scope_type), | 323 return Callable(isolate->builtins()->NewFunctionContext(scope_type), |
375 FastNewFunctionContextDescriptor(isolate)); | 324 FastNewFunctionContextDescriptor(isolate)); |
376 } | 325 } |
377 | 326 |
378 // static | 327 // static |
379 Callable CodeFactory::FastNewClosure(Isolate* isolate) { | |
380 return Callable(isolate->builtins()->FastNewClosure(), | |
381 FastNewClosureDescriptor(isolate)); | |
382 } | |
383 | |
384 // static | |
385 Callable CodeFactory::FastNewObject(Isolate* isolate) { | |
386 return Callable(isolate->builtins()->FastNewObject(), | |
387 FastNewObjectDescriptor(isolate)); | |
388 } | |
389 | |
390 // static | |
391 Callable CodeFactory::FastNewRestParameter(Isolate* isolate, | 328 Callable CodeFactory::FastNewRestParameter(Isolate* isolate, |
392 bool skip_stub_frame) { | 329 bool skip_stub_frame) { |
393 FastNewRestParameterStub stub(isolate, skip_stub_frame); | 330 FastNewRestParameterStub stub(isolate, skip_stub_frame); |
394 return make_callable(stub); | 331 return make_callable(stub); |
395 } | 332 } |
396 | 333 |
397 // static | 334 // static |
398 Callable CodeFactory::FastNewSloppyArguments(Isolate* isolate, | 335 Callable CodeFactory::FastNewSloppyArguments(Isolate* isolate, |
399 bool skip_stub_frame) { | 336 bool skip_stub_frame) { |
400 FastNewSloppyArgumentsStub stub(isolate, skip_stub_frame); | 337 FastNewSloppyArgumentsStub stub(isolate, skip_stub_frame); |
401 return make_callable(stub); | 338 return make_callable(stub); |
402 } | 339 } |
403 | 340 |
404 // static | 341 // static |
405 Callable CodeFactory::FastNewStrictArguments(Isolate* isolate, | 342 Callable CodeFactory::FastNewStrictArguments(Isolate* isolate, |
406 bool skip_stub_frame) { | 343 bool skip_stub_frame) { |
407 FastNewStrictArgumentsStub stub(isolate, skip_stub_frame); | 344 FastNewStrictArgumentsStub stub(isolate, skip_stub_frame); |
408 return make_callable(stub); | 345 return make_callable(stub); |
409 } | 346 } |
410 | 347 |
411 // static | 348 // static |
412 Callable CodeFactory::CopyFastSmiOrObjectElements(Isolate* isolate) { | |
413 return Callable(isolate->builtins()->CopyFastSmiOrObjectElements(), | |
414 CopyFastSmiOrObjectElementsDescriptor(isolate)); | |
415 } | |
416 | |
417 // static | |
418 Callable CodeFactory::GrowFastDoubleElements(Isolate* isolate) { | |
419 return Callable(isolate->builtins()->GrowFastDoubleElements(), | |
420 GrowArrayElementsDescriptor(isolate)); | |
421 } | |
422 | |
423 // static | |
424 Callable CodeFactory::GrowFastSmiOrObjectElements(Isolate* isolate) { | |
425 return Callable(isolate->builtins()->GrowFastSmiOrObjectElements(), | |
426 GrowArrayElementsDescriptor(isolate)); | |
427 } | |
428 | |
429 // static | |
430 Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) { | 349 Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) { |
431 AllocateHeapNumberStub stub(isolate); | 350 AllocateHeapNumberStub stub(isolate); |
432 return make_callable(stub); | 351 return make_callable(stub); |
433 } | 352 } |
434 | 353 |
435 #define SIMD128_ALLOC(TYPE, Type, type, lane_count, lane_type) \ | 354 #define SIMD128_ALLOC(TYPE, Type, type, lane_count, lane_type) \ |
436 Callable CodeFactory::Allocate##Type(Isolate* isolate) { \ | 355 Callable CodeFactory::Allocate##Type(Isolate* isolate) { \ |
437 Allocate##Type##Stub stub(isolate); \ | 356 Allocate##Type##Stub stub(isolate); \ |
438 return make_callable(stub); \ | 357 return make_callable(stub); \ |
439 } | 358 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 } | 438 } |
520 | 439 |
521 // static | 440 // static |
522 Callable CodeFactory::FunctionPrototypeBind(Isolate* isolate) { | 441 Callable CodeFactory::FunctionPrototypeBind(Isolate* isolate) { |
523 return Callable(isolate->builtins()->FunctionPrototypeBind(), | 442 return Callable(isolate->builtins()->FunctionPrototypeBind(), |
524 BuiltinDescriptor(isolate)); | 443 BuiltinDescriptor(isolate)); |
525 } | 444 } |
526 | 445 |
527 } // namespace internal | 446 } // namespace internal |
528 } // namespace v8 | 447 } // namespace v8 |
OLD | NEW |