OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef V8_BUILTINS_H_ | 5 #ifndef V8_BUILTINS_H_ |
6 #define V8_BUILTINS_H_ | 6 #define V8_BUILTINS_H_ |
7 | 7 |
8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
| 14 namespace compiler { |
| 15 |
| 16 // Forward declarations. |
| 17 class CodeStubAssembler; |
| 18 |
| 19 } // namespace compiler |
| 20 |
14 // Specifies extra arguments required by a C++ builtin. | 21 // Specifies extra arguments required by a C++ builtin. |
15 enum class BuiltinExtraArguments : uint8_t { | 22 enum class BuiltinExtraArguments : uint8_t { |
16 kNone = 0u, | 23 kNone = 0u, |
17 kTarget = 1u << 0, | 24 kTarget = 1u << 0, |
18 kNewTarget = 1u << 1, | 25 kNewTarget = 1u << 1, |
19 kTargetAndNewTarget = kTarget | kNewTarget | 26 kTargetAndNewTarget = kTarget | kNewTarget |
20 }; | 27 }; |
21 | 28 |
22 inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) { | 29 inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) { |
23 return static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs); | 30 return static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 \ | 299 \ |
293 V(OnStackReplacement, BUILTIN, UNINITIALIZED, kNoExtraICState) \ | 300 V(OnStackReplacement, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
294 V(InterruptCheck, BUILTIN, UNINITIALIZED, kNoExtraICState) \ | 301 V(InterruptCheck, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
295 V(StackCheck, BUILTIN, UNINITIALIZED, kNoExtraICState) \ | 302 V(StackCheck, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
296 \ | 303 \ |
297 V(MarkCodeAsToBeExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState) \ | 304 V(MarkCodeAsToBeExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
298 V(MarkCodeAsExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState) \ | 305 V(MarkCodeAsExecutedOnce, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
299 V(MarkCodeAsExecutedTwice, BUILTIN, UNINITIALIZED, kNoExtraICState) \ | 306 V(MarkCodeAsExecutedTwice, BUILTIN, UNINITIALIZED, kNoExtraICState) \ |
300 CODE_AGE_LIST_WITH_ARG(DECLARE_CODE_AGE_BUILTIN, V) | 307 CODE_AGE_LIST_WITH_ARG(DECLARE_CODE_AGE_BUILTIN, V) |
301 | 308 |
| 309 // Define list of builtins implemented in TurboFan (with JS linkage). |
| 310 #define BUILTIN_LIST_T(V) V(MathSqrt, 2) |
| 311 |
302 // Define list of builtin handlers implemented in assembly. | 312 // Define list of builtin handlers implemented in assembly. |
303 #define BUILTIN_LIST_H(V) \ | 313 #define BUILTIN_LIST_H(V) \ |
304 V(LoadIC_Slow, LOAD_IC) \ | 314 V(LoadIC_Slow, LOAD_IC) \ |
305 V(KeyedLoadIC_Slow, KEYED_LOAD_IC) \ | 315 V(KeyedLoadIC_Slow, KEYED_LOAD_IC) \ |
306 V(StoreIC_Slow, STORE_IC) \ | 316 V(StoreIC_Slow, STORE_IC) \ |
307 V(KeyedStoreIC_Slow, KEYED_STORE_IC) \ | 317 V(KeyedStoreIC_Slow, KEYED_STORE_IC) \ |
308 V(LoadIC_Normal, LOAD_IC) \ | 318 V(LoadIC_Normal, LOAD_IC) \ |
309 V(StoreIC_Normal, STORE_IC) | 319 V(StoreIC_Normal, STORE_IC) |
310 | 320 |
311 // Define list of builtins used by the debugger implemented in assembly. | 321 // Define list of builtins used by the debugger implemented in assembly. |
(...skipping 18 matching lines...) Expand all Loading... |
330 | 340 |
331 // Garbage collection support. | 341 // Garbage collection support. |
332 void IterateBuiltins(ObjectVisitor* v); | 342 void IterateBuiltins(ObjectVisitor* v); |
333 | 343 |
334 // Disassembler support. | 344 // Disassembler support. |
335 const char* Lookup(byte* pc); | 345 const char* Lookup(byte* pc); |
336 | 346 |
337 enum Name { | 347 enum Name { |
338 #define DEF_ENUM_C(name, ignore) k##name, | 348 #define DEF_ENUM_C(name, ignore) k##name, |
339 #define DEF_ENUM_A(name, kind, state, extra) k##name, | 349 #define DEF_ENUM_A(name, kind, state, extra) k##name, |
| 350 #define DEF_ENUM_T(name, argc) k##name, |
340 #define DEF_ENUM_H(name, kind) k##name, | 351 #define DEF_ENUM_H(name, kind) k##name, |
341 BUILTIN_LIST_C(DEF_ENUM_C) | 352 BUILTIN_LIST_C(DEF_ENUM_C) BUILTIN_LIST_A(DEF_ENUM_A) |
342 BUILTIN_LIST_A(DEF_ENUM_A) | 353 BUILTIN_LIST_T(DEF_ENUM_T) BUILTIN_LIST_H(DEF_ENUM_H) |
343 BUILTIN_LIST_H(DEF_ENUM_H) | 354 BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) |
344 BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) | |
345 #undef DEF_ENUM_C | 355 #undef DEF_ENUM_C |
346 #undef DEF_ENUM_A | 356 #undef DEF_ENUM_A |
347 builtin_count | 357 #undef DEF_ENUM_T |
| 358 #undef DEF_ENUM_H |
| 359 builtin_count |
348 }; | 360 }; |
349 | 361 |
350 enum CFunctionId { | 362 enum CFunctionId { |
351 #define DEF_ENUM_C(name, ignore) c_##name, | 363 #define DEF_ENUM_C(name, ignore) c_##name, |
352 BUILTIN_LIST_C(DEF_ENUM_C) | 364 BUILTIN_LIST_C(DEF_ENUM_C) |
353 #undef DEF_ENUM_C | 365 #undef DEF_ENUM_C |
354 cfunction_count | 366 cfunction_count |
355 }; | 367 }; |
356 | 368 |
357 #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name(); | 369 #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name(); |
358 #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ | 370 #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ |
359 Handle<Code> name(); | 371 Handle<Code> name(); |
| 372 #define DECLARE_BUILTIN_ACCESSOR_T(name, argc) Handle<Code> name(); |
360 #define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name(); | 373 #define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name(); |
361 BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) | 374 BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) |
362 BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) | 375 BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) |
| 376 BUILTIN_LIST_T(DECLARE_BUILTIN_ACCESSOR_T) |
363 BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H) | 377 BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H) |
364 BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A) | 378 BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A) |
365 #undef DECLARE_BUILTIN_ACCESSOR_C | 379 #undef DECLARE_BUILTIN_ACCESSOR_C |
366 #undef DECLARE_BUILTIN_ACCESSOR_A | 380 #undef DECLARE_BUILTIN_ACCESSOR_A |
| 381 #undef DECLARE_BUILTIN_ACCESSOR_T |
| 382 #undef DECLARE_BUILTIN_ACCESSOR_H |
367 | 383 |
368 // Convenience wrappers. | 384 // Convenience wrappers. |
369 Handle<Code> CallFunction( | 385 Handle<Code> CallFunction( |
370 ConvertReceiverMode = ConvertReceiverMode::kAny, | 386 ConvertReceiverMode = ConvertReceiverMode::kAny, |
371 TailCallMode tail_call_mode = TailCallMode::kDisallow); | 387 TailCallMode tail_call_mode = TailCallMode::kDisallow); |
372 Handle<Code> Call(ConvertReceiverMode = ConvertReceiverMode::kAny, | 388 Handle<Code> Call(ConvertReceiverMode = ConvertReceiverMode::kAny, |
373 TailCallMode tail_call_mode = TailCallMode::kDisallow); | 389 TailCallMode tail_call_mode = TailCallMode::kDisallow); |
374 Handle<Code> CallBoundFunction(TailCallMode tail_call_mode); | 390 Handle<Code> CallBoundFunction(TailCallMode tail_call_mode); |
375 Handle<Code> InterpreterPushArgsAndCall(TailCallMode tail_call_mode); | 391 Handle<Code> InterpreterPushArgsAndCall(TailCallMode tail_call_mode); |
376 | 392 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 enum class MathMaxMinKind { kMax, kMin }; | 583 enum class MathMaxMinKind { kMax, kMin }; |
568 static void Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind); | 584 static void Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind); |
569 // ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values ) | 585 // ES6 section 20.2.2.24 Math.max ( value1, value2 , ...values ) |
570 static void Generate_MathMax(MacroAssembler* masm) { | 586 static void Generate_MathMax(MacroAssembler* masm) { |
571 Generate_MathMaxMin(masm, MathMaxMinKind::kMax); | 587 Generate_MathMaxMin(masm, MathMaxMinKind::kMax); |
572 } | 588 } |
573 // ES6 section 20.2.2.25 Math.min ( value1, value2 , ...values ) | 589 // ES6 section 20.2.2.25 Math.min ( value1, value2 , ...values ) |
574 static void Generate_MathMin(MacroAssembler* masm) { | 590 static void Generate_MathMin(MacroAssembler* masm) { |
575 Generate_MathMaxMin(masm, MathMaxMinKind::kMin); | 591 Generate_MathMaxMin(masm, MathMaxMinKind::kMin); |
576 } | 592 } |
| 593 // ES6 section 20.2.2.32 Math.sqrt ( x ) |
| 594 static void Generate_MathSqrt(compiler::CodeStubAssembler* assembler); |
577 | 595 |
578 // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Call]] case. | 596 // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Call]] case. |
579 static void Generate_NumberConstructor(MacroAssembler* masm); | 597 static void Generate_NumberConstructor(MacroAssembler* masm); |
580 // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Construct]] case. | 598 // ES6 section 20.1.1.1 Number ( [ value ] ) for the [[Construct]] case. |
581 static void Generate_NumberConstructor_ConstructStub(MacroAssembler* masm); | 599 static void Generate_NumberConstructor_ConstructStub(MacroAssembler* masm); |
582 | 600 |
583 static void Generate_StringConstructor(MacroAssembler* masm); | 601 static void Generate_StringConstructor(MacroAssembler* masm); |
584 static void Generate_StringConstructor_ConstructStub(MacroAssembler* masm); | 602 static void Generate_StringConstructor_ConstructStub(MacroAssembler* masm); |
585 static void Generate_OnStackReplacement(MacroAssembler* masm); | 603 static void Generate_OnStackReplacement(MacroAssembler* masm); |
586 static void Generate_InterruptCheck(MacroAssembler* masm); | 604 static void Generate_InterruptCheck(MacroAssembler* masm); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 friend class BuiltinFunctionTable; | 640 friend class BuiltinFunctionTable; |
623 friend class Isolate; | 641 friend class Isolate; |
624 | 642 |
625 DISALLOW_COPY_AND_ASSIGN(Builtins); | 643 DISALLOW_COPY_AND_ASSIGN(Builtins); |
626 }; | 644 }; |
627 | 645 |
628 } // namespace internal | 646 } // namespace internal |
629 } // namespace v8 | 647 } // namespace v8 |
630 | 648 |
631 #endif // V8_BUILTINS_H_ | 649 #endif // V8_BUILTINS_H_ |
OLD | NEW |