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 #ifndef V8_FACTORY_H_ | 5 #ifndef V8_FACTORY_H_ |
6 #define V8_FACTORY_H_ | 6 #define V8_FACTORY_H_ |
7 | 7 |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/type-feedback-vector.h" | 10 #include "src/type-feedback-vector.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
| 15 enum FunctionMode { |
| 16 // With prototype. |
| 17 FUNCTION_WITH_WRITEABLE_PROTOTYPE, |
| 18 FUNCTION_WITH_READONLY_PROTOTYPE, |
| 19 // Without prototype. |
| 20 FUNCTION_WITHOUT_PROTOTYPE |
| 21 }; |
| 22 |
15 // Interface for handle based allocation. | 23 // Interface for handle based allocation. |
16 class Factory final { | 24 class Factory final { |
17 public: | 25 public: |
18 Handle<Oddball> NewOddball(Handle<Map> map, const char* to_string, | 26 Handle<Oddball> NewOddball(Handle<Map> map, const char* to_string, |
19 Handle<Object> to_number, bool to_boolean, | 27 Handle<Object> to_number, bool to_boolean, |
20 const char* type_of, byte kind); | 28 const char* type_of, byte kind); |
21 | 29 |
22 // Allocates a fixed array initialized with undefined values. | 30 // Allocates a fixed array initialized with undefined values. |
23 Handle<FixedArray> NewFixedArray( | 31 Handle<FixedArray> NewFixedArray( |
24 int size, | 32 int size, |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 #undef SYMBOL_ACCESSOR | 645 #undef SYMBOL_ACCESSOR |
638 | 646 |
639 // Allocates a new SharedFunctionInfo object. | 647 // Allocates a new SharedFunctionInfo object. |
640 Handle<SharedFunctionInfo> NewSharedFunctionInfo( | 648 Handle<SharedFunctionInfo> NewSharedFunctionInfo( |
641 Handle<String> name, int number_of_literals, FunctionKind kind, | 649 Handle<String> name, int number_of_literals, FunctionKind kind, |
642 Handle<Code> code, Handle<ScopeInfo> scope_info); | 650 Handle<Code> code, Handle<ScopeInfo> scope_info); |
643 Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name, | 651 Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name, |
644 MaybeHandle<Code> code, | 652 MaybeHandle<Code> code, |
645 bool is_constructor); | 653 bool is_constructor); |
646 | 654 |
| 655 static bool IsFunctionModeWithPrototype(FunctionMode function_mode) { |
| 656 return (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE || |
| 657 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE); |
| 658 } |
| 659 |
| 660 Handle<Map> CreateSloppyFunctionMap(FunctionMode function_mode); |
| 661 |
| 662 Handle<Map> CreateStrictFunctionMap(FunctionMode function_mode, |
| 663 Handle<JSFunction> empty_function); |
| 664 |
647 // Allocates a new JSMessageObject object. | 665 // Allocates a new JSMessageObject object. |
648 Handle<JSMessageObject> NewJSMessageObject(MessageTemplate::Template message, | 666 Handle<JSMessageObject> NewJSMessageObject(MessageTemplate::Template message, |
649 Handle<Object> argument, | 667 Handle<Object> argument, |
650 int start_position, | 668 int start_position, |
651 int end_position, | 669 int end_position, |
652 Handle<Object> script, | 670 Handle<Object> script, |
653 Handle<Object> stack_frames); | 671 Handle<Object> stack_frames); |
654 | 672 |
655 Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); | 673 Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); |
656 | 674 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // Attempt to find the number in a small cache. If we finds it, return | 728 // Attempt to find the number in a small cache. If we finds it, return |
711 // the string representation of the number. Otherwise return undefined. | 729 // the string representation of the number. Otherwise return undefined. |
712 Handle<Object> GetNumberStringCache(Handle<Object> number); | 730 Handle<Object> GetNumberStringCache(Handle<Object> number); |
713 | 731 |
714 // Update the cache with a new number-string pair. | 732 // Update the cache with a new number-string pair. |
715 void SetNumberStringCache(Handle<Object> number, Handle<String> string); | 733 void SetNumberStringCache(Handle<Object> number, Handle<String> string); |
716 | 734 |
717 // Create a JSArray with no elements and no length. | 735 // Create a JSArray with no elements and no length. |
718 Handle<JSArray> NewJSArray(ElementsKind elements_kind, | 736 Handle<JSArray> NewJSArray(ElementsKind elements_kind, |
719 PretenureFlag pretenure = NOT_TENURED); | 737 PretenureFlag pretenure = NOT_TENURED); |
| 738 |
| 739 void SetFunctionInstanceDescriptor(Handle<Map> map, |
| 740 FunctionMode function_mode); |
| 741 |
| 742 void SetStrictFunctionInstanceDescriptor(Handle<Map> map, |
| 743 FunctionMode function_mode); |
720 }; | 744 }; |
721 | 745 |
722 } // namespace internal | 746 } // namespace internal |
723 } // namespace v8 | 747 } // namespace v8 |
724 | 748 |
725 #endif // V8_FACTORY_H_ | 749 #endif // V8_FACTORY_H_ |
OLD | NEW |