OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2711 | 2711 |
2712 fixed_array_map()->set_prototype(null_value()); | 2712 fixed_array_map()->set_prototype(null_value()); |
2713 fixed_array_map()->set_constructor(null_value()); | 2713 fixed_array_map()->set_constructor(null_value()); |
2714 | 2714 |
2715 oddball_map()->set_prototype(null_value()); | 2715 oddball_map()->set_prototype(null_value()); |
2716 oddball_map()->set_constructor(null_value()); | 2716 oddball_map()->set_constructor(null_value()); |
2717 | 2717 |
2718 constant_pool_array_map()->set_prototype(null_value()); | 2718 constant_pool_array_map()->set_prototype(null_value()); |
2719 constant_pool_array_map()->set_constructor(null_value()); | 2719 constant_pool_array_map()->set_constructor(null_value()); |
2720 | 2720 |
2721 { MaybeObject* maybe_obj = | 2721 { // Map allocation |
2722 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2722 #define ALLOCATE_MAP(instance_type, size, field_name) \ |
2723 if (!maybe_obj->ToObject(&obj)) return false; | 2723 { Map* map; \ |
2724 } | 2724 if (!AllocateMap((instance_type), size)->To(&map)) return false; \ |
2725 set_fixed_cow_array_map(Map::cast(obj)); | 2725 set_##field_name##_map(map); \ |
2726 ASSERT(fixed_array_map() != fixed_cow_array_map()); | 2726 } |
2727 | 2727 |
2728 { MaybeObject* maybe_obj = | 2728 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ |
2729 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2729 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) |
2730 if (!maybe_obj->ToObject(&obj)) return false; | |
2731 } | |
2732 set_scope_info_map(Map::cast(obj)); | |
2733 | 2730 |
2734 { MaybeObject* maybe_obj = AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize); | 2731 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, fixed_cow_array) |
2735 if (!maybe_obj->ToObject(&obj)) return false; | 2732 ASSERT(fixed_array_map() != fixed_cow_array_map()); |
2736 } | |
2737 set_heap_number_map(Map::cast(obj)); | |
2738 | 2733 |
2739 { MaybeObject* maybe_obj = AllocateMap(SYMBOL_TYPE, Symbol::kSize); | 2734 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, scope_info) |
2740 if (!maybe_obj->ToObject(&obj)) return false; | 2735 ALLOCATE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number) |
2741 } | 2736 ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol) |
2742 set_symbol_map(Map::cast(obj)); | 2737 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign) |
2743 | 2738 |
2744 { MaybeObject* maybe_obj = AllocateMap(FOREIGN_TYPE, Foreign::kSize); | 2739 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { |
2745 if (!maybe_obj->ToObject(&obj)) return false; | 2740 const StringTypeTable& entry = string_type_table[i]; |
2746 } | 2741 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); |
2747 set_foreign_map(Map::cast(obj)); | 2742 if (!maybe_obj->ToObject(&obj)) return false; |
| 2743 } |
| 2744 roots_[entry.index] = Map::cast(obj); |
| 2745 } |
2748 | 2746 |
2749 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { | 2747 ALLOCATE_VARSIZE_MAP(STRING_TYPE, undetectable_string) |
2750 const StringTypeTable& entry = string_type_table[i]; | 2748 undetectable_string_map()->set_is_undetectable(); |
2751 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); | 2749 |
2752 if (!maybe_obj->ToObject(&obj)) return false; | 2750 ALLOCATE_VARSIZE_MAP(ASCII_STRING_TYPE, undetectable_ascii_string); |
| 2751 undetectable_ascii_string_map()->set_is_undetectable(); |
| 2752 |
| 2753 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) |
| 2754 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) |
| 2755 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) |
| 2756 |
| 2757 #define ALLOCATE_EXTERNAL_ARRAY_MAP(TYPE, type) \ |
| 2758 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kAlignedSize, \ |
| 2759 external_##type##_array) |
| 2760 |
| 2761 ALLOCATE_EXTERNAL_ARRAY_MAP(PIXEL, pixel) |
| 2762 ALLOCATE_EXTERNAL_ARRAY_MAP(BYTE, byte) |
| 2763 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_BYTE, unsigned_byte) |
| 2764 ALLOCATE_EXTERNAL_ARRAY_MAP(SHORT, short) // NOLINT |
| 2765 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_SHORT, unsigned_short) |
| 2766 ALLOCATE_EXTERNAL_ARRAY_MAP(INT, int) |
| 2767 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_INT, unsigned_int) |
| 2768 ALLOCATE_EXTERNAL_ARRAY_MAP(FLOAT, float) |
| 2769 ALLOCATE_EXTERNAL_ARRAY_MAP(DOUBLE, double) |
| 2770 #undef ALLOCATE_EXTERNAL_ARRAY_MAP |
| 2771 |
| 2772 ALLOCATE_VARSIZE_MAP(FIXED_UINT8_ARRAY_TYPE, fixed_uint8_array) |
| 2773 ALLOCATE_VARSIZE_MAP(FIXED_UINT8_CLAMPED_ARRAY_TYPE, |
| 2774 fixed_uint8_clamped_array) |
| 2775 ALLOCATE_VARSIZE_MAP(FIXED_INT8_ARRAY_TYPE, fixed_int8_array) |
| 2776 ALLOCATE_VARSIZE_MAP(FIXED_UINT16_ARRAY_TYPE, fixed_uint16_array) |
| 2777 ALLOCATE_VARSIZE_MAP(FIXED_INT16_ARRAY_TYPE, fixed_int16_array) |
| 2778 ALLOCATE_VARSIZE_MAP(FIXED_UINT32_ARRAY_TYPE, fixed_uint32_array) |
| 2779 ALLOCATE_VARSIZE_MAP(FIXED_INT32_ARRAY_TYPE, fixed_int32_array) |
| 2780 ALLOCATE_VARSIZE_MAP(FIXED_FLOAT32_ARRAY_TYPE, fixed_float32_array) |
| 2781 ALLOCATE_VARSIZE_MAP(FIXED_FLOAT64_ARRAY_TYPE, fixed_float64_array) |
| 2782 |
| 2783 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, non_strict_arguments_elements) |
| 2784 |
| 2785 ALLOCATE_VARSIZE_MAP(CODE_TYPE, code) |
| 2786 |
| 2787 ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell) |
| 2788 ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell) |
| 2789 ALLOCATE_MAP(FILLER_TYPE, kPointerSize, one_pointer_filler) |
| 2790 ALLOCATE_MAP(FILLER_TYPE, 2 * kPointerSize, two_pointer_filler) |
| 2791 |
| 2792 |
| 2793 for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { |
| 2794 const StructTable& entry = struct_table[i]; |
| 2795 Map* map; |
| 2796 if (!AllocateMap(entry.type, entry.size)->To(&map)) |
| 2797 return false; |
| 2798 roots_[entry.index] = map; |
2753 } | 2799 } |
2754 roots_[entry.index] = Map::cast(obj); | 2800 |
| 2801 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, hash_table) |
| 2802 |
| 2803 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, function_context) |
| 2804 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, catch_context) |
| 2805 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, with_context) |
| 2806 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, block_context) |
| 2807 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, module_context) |
| 2808 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, global_context) |
| 2809 |
| 2810 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, native_context) |
| 2811 native_context_map()->set_dictionary_map(true); |
| 2812 native_context_map()->set_visitor_id( |
| 2813 StaticVisitorBase::kVisitNativeContext); |
| 2814 |
| 2815 ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kAlignedSize, |
| 2816 shared_function_info) |
| 2817 |
| 2818 ALLOCATE_MAP(JS_MESSAGE_OBJECT_TYPE, JSMessageObject::kSize, |
| 2819 message_object) |
| 2820 ALLOCATE_MAP(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize, |
| 2821 external) |
| 2822 external_map()->set_is_extensible(false); |
| 2823 #undef ALLOCATE_VARSIZE_MAP |
| 2824 #undef ALLOCATE_MAP |
2755 } | 2825 } |
2756 | 2826 |
2757 { MaybeObject* maybe_obj = AllocateMap(STRING_TYPE, kVariableSizeSentinel); | 2827 { // Empty arrays |
2758 if (!maybe_obj->ToObject(&obj)) return false; | 2828 { ByteArray* byte_array; |
| 2829 if (!AllocateByteArray(0, TENURED)->To(&byte_array)) return false; |
| 2830 set_empty_byte_array(byte_array); |
| 2831 } |
| 2832 |
| 2833 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type) \ |
| 2834 { ExternalArray* obj; \ |
| 2835 if (!AllocateEmptyExternalArray(kExternal##Type##Array)->To(&obj)) \ |
| 2836 return false; \ |
| 2837 set_empty_external_##type##_array(obj); \ |
| 2838 } |
| 2839 |
| 2840 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Byte, byte) |
| 2841 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedByte, unsigned_byte) |
| 2842 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Short, short) // NOLINT |
| 2843 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedShort, unsigned_short) |
| 2844 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Int, int) |
| 2845 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedInt, unsigned_int) |
| 2846 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Float, float) |
| 2847 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Double, double) |
| 2848 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Pixel, pixel) |
| 2849 #undef ALLOCATE_EMPTY_EXTERNAL_ARRAY |
2759 } | 2850 } |
2760 set_undetectable_string_map(Map::cast(obj)); | |
2761 Map::cast(obj)->set_is_undetectable(); | |
2762 | |
2763 { MaybeObject* maybe_obj = | |
2764 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); | |
2765 if (!maybe_obj->ToObject(&obj)) return false; | |
2766 } | |
2767 set_undetectable_ascii_string_map(Map::cast(obj)); | |
2768 Map::cast(obj)->set_is_undetectable(); | |
2769 | |
2770 { MaybeObject* maybe_obj = | |
2771 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); | |
2772 if (!maybe_obj->ToObject(&obj)) return false; | |
2773 } | |
2774 set_fixed_double_array_map(Map::cast(obj)); | |
2775 | |
2776 { MaybeObject* maybe_obj = | |
2777 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); | |
2778 if (!maybe_obj->ToObject(&obj)) return false; | |
2779 } | |
2780 set_byte_array_map(Map::cast(obj)); | |
2781 | |
2782 { MaybeObject* maybe_obj = | |
2783 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); | |
2784 if (!maybe_obj->ToObject(&obj)) return false; | |
2785 } | |
2786 set_free_space_map(Map::cast(obj)); | |
2787 | |
2788 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); | |
2789 if (!maybe_obj->ToObject(&obj)) return false; | |
2790 } | |
2791 set_empty_byte_array(ByteArray::cast(obj)); | |
2792 | |
2793 { MaybeObject* maybe_obj = | |
2794 AllocateMap(EXTERNAL_PIXEL_ARRAY_TYPE, ExternalArray::kAlignedSize); | |
2795 if (!maybe_obj->ToObject(&obj)) return false; | |
2796 } | |
2797 set_external_pixel_array_map(Map::cast(obj)); | |
2798 | |
2799 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_BYTE_ARRAY_TYPE, | |
2800 ExternalArray::kAlignedSize); | |
2801 if (!maybe_obj->ToObject(&obj)) return false; | |
2802 } | |
2803 set_external_byte_array_map(Map::cast(obj)); | |
2804 | |
2805 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | |
2806 ExternalArray::kAlignedSize); | |
2807 if (!maybe_obj->ToObject(&obj)) return false; | |
2808 } | |
2809 set_external_unsigned_byte_array_map(Map::cast(obj)); | |
2810 | |
2811 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_SHORT_ARRAY_TYPE, | |
2812 ExternalArray::kAlignedSize); | |
2813 if (!maybe_obj->ToObject(&obj)) return false; | |
2814 } | |
2815 set_external_short_array_map(Map::cast(obj)); | |
2816 | |
2817 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | |
2818 ExternalArray::kAlignedSize); | |
2819 if (!maybe_obj->ToObject(&obj)) return false; | |
2820 } | |
2821 set_external_unsigned_short_array_map(Map::cast(obj)); | |
2822 | |
2823 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_INT_ARRAY_TYPE, | |
2824 ExternalArray::kAlignedSize); | |
2825 if (!maybe_obj->ToObject(&obj)) return false; | |
2826 } | |
2827 set_external_int_array_map(Map::cast(obj)); | |
2828 | |
2829 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | |
2830 ExternalArray::kAlignedSize); | |
2831 if (!maybe_obj->ToObject(&obj)) return false; | |
2832 } | |
2833 set_external_unsigned_int_array_map(Map::cast(obj)); | |
2834 | |
2835 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_FLOAT_ARRAY_TYPE, | |
2836 ExternalArray::kAlignedSize); | |
2837 if (!maybe_obj->ToObject(&obj)) return false; | |
2838 } | |
2839 set_external_float_array_map(Map::cast(obj)); | |
2840 | |
2841 { MaybeObject* maybe_obj = | |
2842 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2843 if (!maybe_obj->ToObject(&obj)) return false; | |
2844 } | |
2845 set_non_strict_arguments_elements_map(Map::cast(obj)); | |
2846 | |
2847 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_DOUBLE_ARRAY_TYPE, | |
2848 ExternalArray::kAlignedSize); | |
2849 if (!maybe_obj->ToObject(&obj)) return false; | |
2850 } | |
2851 set_external_double_array_map(Map::cast(obj)); | |
2852 | |
2853 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalByteArray); | |
2854 if (!maybe_obj->ToObject(&obj)) return false; | |
2855 } | |
2856 set_empty_external_byte_array(ExternalArray::cast(obj)); | |
2857 | |
2858 { MaybeObject* maybe_obj = | |
2859 AllocateEmptyExternalArray(kExternalUnsignedByteArray); | |
2860 if (!maybe_obj->ToObject(&obj)) return false; | |
2861 } | |
2862 set_empty_external_unsigned_byte_array(ExternalArray::cast(obj)); | |
2863 | |
2864 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalShortArray); | |
2865 if (!maybe_obj->ToObject(&obj)) return false; | |
2866 } | |
2867 set_empty_external_short_array(ExternalArray::cast(obj)); | |
2868 | |
2869 { MaybeObject* maybe_obj = AllocateEmptyExternalArray( | |
2870 kExternalUnsignedShortArray); | |
2871 if (!maybe_obj->ToObject(&obj)) return false; | |
2872 } | |
2873 set_empty_external_unsigned_short_array(ExternalArray::cast(obj)); | |
2874 | |
2875 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalIntArray); | |
2876 if (!maybe_obj->ToObject(&obj)) return false; | |
2877 } | |
2878 set_empty_external_int_array(ExternalArray::cast(obj)); | |
2879 | |
2880 { MaybeObject* maybe_obj = | |
2881 AllocateEmptyExternalArray(kExternalUnsignedIntArray); | |
2882 if (!maybe_obj->ToObject(&obj)) return false; | |
2883 } | |
2884 set_empty_external_unsigned_int_array(ExternalArray::cast(obj)); | |
2885 | |
2886 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalFloatArray); | |
2887 if (!maybe_obj->ToObject(&obj)) return false; | |
2888 } | |
2889 set_empty_external_float_array(ExternalArray::cast(obj)); | |
2890 | |
2891 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalDoubleArray); | |
2892 if (!maybe_obj->ToObject(&obj)) return false; | |
2893 } | |
2894 set_empty_external_double_array(ExternalArray::cast(obj)); | |
2895 | |
2896 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalPixelArray); | |
2897 if (!maybe_obj->ToObject(&obj)) return false; | |
2898 } | |
2899 set_empty_external_pixel_array(ExternalArray::cast(obj)); | |
2900 | |
2901 { MaybeObject* maybe_obj = AllocateMap(CODE_TYPE, kVariableSizeSentinel); | |
2902 if (!maybe_obj->ToObject(&obj)) return false; | |
2903 } | |
2904 set_code_map(Map::cast(obj)); | |
2905 | |
2906 { MaybeObject* maybe_obj = AllocateMap(CELL_TYPE, Cell::kSize); | |
2907 if (!maybe_obj->ToObject(&obj)) return false; | |
2908 } | |
2909 set_cell_map(Map::cast(obj)); | |
2910 | |
2911 { MaybeObject* maybe_obj = AllocateMap(PROPERTY_CELL_TYPE, | |
2912 PropertyCell::kSize); | |
2913 if (!maybe_obj->ToObject(&obj)) return false; | |
2914 } | |
2915 set_global_property_cell_map(Map::cast(obj)); | |
2916 | |
2917 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize); | |
2918 if (!maybe_obj->ToObject(&obj)) return false; | |
2919 } | |
2920 set_one_pointer_filler_map(Map::cast(obj)); | |
2921 | |
2922 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize); | |
2923 if (!maybe_obj->ToObject(&obj)) return false; | |
2924 } | |
2925 set_two_pointer_filler_map(Map::cast(obj)); | |
2926 | |
2927 for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { | |
2928 const StructTable& entry = struct_table[i]; | |
2929 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); | |
2930 if (!maybe_obj->ToObject(&obj)) return false; | |
2931 } | |
2932 roots_[entry.index] = Map::cast(obj); | |
2933 } | |
2934 | |
2935 { MaybeObject* maybe_obj = | |
2936 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2937 if (!maybe_obj->ToObject(&obj)) return false; | |
2938 } | |
2939 set_hash_table_map(Map::cast(obj)); | |
2940 | |
2941 { MaybeObject* maybe_obj = | |
2942 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2943 if (!maybe_obj->ToObject(&obj)) return false; | |
2944 } | |
2945 set_function_context_map(Map::cast(obj)); | |
2946 | |
2947 { MaybeObject* maybe_obj = | |
2948 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2949 if (!maybe_obj->ToObject(&obj)) return false; | |
2950 } | |
2951 set_catch_context_map(Map::cast(obj)); | |
2952 | |
2953 { MaybeObject* maybe_obj = | |
2954 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2955 if (!maybe_obj->ToObject(&obj)) return false; | |
2956 } | |
2957 set_with_context_map(Map::cast(obj)); | |
2958 | |
2959 { MaybeObject* maybe_obj = | |
2960 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2961 if (!maybe_obj->ToObject(&obj)) return false; | |
2962 } | |
2963 set_block_context_map(Map::cast(obj)); | |
2964 | |
2965 { MaybeObject* maybe_obj = | |
2966 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2967 if (!maybe_obj->ToObject(&obj)) return false; | |
2968 } | |
2969 set_module_context_map(Map::cast(obj)); | |
2970 | |
2971 { MaybeObject* maybe_obj = | |
2972 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2973 if (!maybe_obj->ToObject(&obj)) return false; | |
2974 } | |
2975 set_global_context_map(Map::cast(obj)); | |
2976 | |
2977 { MaybeObject* maybe_obj = | |
2978 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | |
2979 if (!maybe_obj->ToObject(&obj)) return false; | |
2980 } | |
2981 Map* native_context_map = Map::cast(obj); | |
2982 native_context_map->set_dictionary_map(true); | |
2983 native_context_map->set_visitor_id(StaticVisitorBase::kVisitNativeContext); | |
2984 set_native_context_map(native_context_map); | |
2985 | |
2986 { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, | |
2987 SharedFunctionInfo::kAlignedSize); | |
2988 if (!maybe_obj->ToObject(&obj)) return false; | |
2989 } | |
2990 set_shared_function_info_map(Map::cast(obj)); | |
2991 | |
2992 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, | |
2993 JSMessageObject::kSize); | |
2994 if (!maybe_obj->ToObject(&obj)) return false; | |
2995 } | |
2996 set_message_object_map(Map::cast(obj)); | |
2997 | |
2998 Map* external_map; | |
2999 { MaybeObject* maybe_obj = | |
3000 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize); | |
3001 if (!maybe_obj->To(&external_map)) return false; | |
3002 } | |
3003 external_map->set_is_extensible(false); | |
3004 set_external_map(external_map); | |
3005 | |
3006 ASSERT(!InNewSpace(empty_fixed_array())); | 2851 ASSERT(!InNewSpace(empty_fixed_array())); |
3007 return true; | 2852 return true; |
3008 } | 2853 } |
3009 | 2854 |
3010 | 2855 |
3011 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { | 2856 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { |
3012 // Statically ensure that it is safe to allocate heap numbers in paged | 2857 // Statically ensure that it is safe to allocate heap numbers in paged |
3013 // spaces. | 2858 // spaces. |
3014 int size = HeapNumber::kSize; | 2859 int size = HeapNumber::kSize; |
3015 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); | 2860 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3699 return kExternalDoubleArrayMapRootIndex; | 3544 return kExternalDoubleArrayMapRootIndex; |
3700 case kExternalPixelArray: | 3545 case kExternalPixelArray: |
3701 return kExternalPixelArrayMapRootIndex; | 3546 return kExternalPixelArrayMapRootIndex; |
3702 default: | 3547 default: |
3703 UNREACHABLE(); | 3548 UNREACHABLE(); |
3704 return kUndefinedValueRootIndex; | 3549 return kUndefinedValueRootIndex; |
3705 } | 3550 } |
3706 } | 3551 } |
3707 | 3552 |
3708 | 3553 |
| 3554 Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { |
| 3555 return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); |
| 3556 } |
| 3557 |
| 3558 |
| 3559 Heap::RootListIndex Heap::RootIndexForFixedTypedArray( |
| 3560 ExternalArrayType array_type) { |
| 3561 switch (array_type) { |
| 3562 case kExternalByteArray: |
| 3563 return kFixedInt8ArrayMapRootIndex; |
| 3564 case kExternalUnsignedByteArray: |
| 3565 return kFixedUint8ArrayMapRootIndex; |
| 3566 case kExternalShortArray: |
| 3567 return kFixedInt16ArrayMapRootIndex; |
| 3568 case kExternalUnsignedShortArray: |
| 3569 return kFixedUint16ArrayMapRootIndex; |
| 3570 case kExternalIntArray: |
| 3571 return kFixedInt32ArrayMapRootIndex; |
| 3572 case kExternalUnsignedIntArray: |
| 3573 return kFixedUint32ArrayMapRootIndex; |
| 3574 case kExternalFloatArray: |
| 3575 return kFixedFloat32ArrayMapRootIndex; |
| 3576 case kExternalDoubleArray: |
| 3577 return kFixedFloat64ArrayMapRootIndex; |
| 3578 case kExternalPixelArray: |
| 3579 return kFixedUint8ClampedArrayMapRootIndex; |
| 3580 default: |
| 3581 UNREACHABLE(); |
| 3582 return kUndefinedValueRootIndex; |
| 3583 } |
| 3584 } |
| 3585 |
| 3586 |
3709 Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( | 3587 Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( |
3710 ElementsKind elementsKind) { | 3588 ElementsKind elementsKind) { |
3711 switch (elementsKind) { | 3589 switch (elementsKind) { |
3712 case EXTERNAL_BYTE_ELEMENTS: | 3590 case EXTERNAL_BYTE_ELEMENTS: |
3713 return kEmptyExternalByteArrayRootIndex; | 3591 return kEmptyExternalByteArrayRootIndex; |
3714 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3592 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3715 return kEmptyExternalUnsignedByteArrayRootIndex; | 3593 return kEmptyExternalUnsignedByteArrayRootIndex; |
3716 case EXTERNAL_SHORT_ELEMENTS: | 3594 case EXTERNAL_SHORT_ELEMENTS: |
3717 return kEmptyExternalShortArrayRootIndex; | 3595 return kEmptyExternalShortArrayRootIndex; |
3718 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3596 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3957 | 3835 |
3958 reinterpret_cast<ExternalArray*>(result)->set_map_no_write_barrier( | 3836 reinterpret_cast<ExternalArray*>(result)->set_map_no_write_barrier( |
3959 MapForExternalArrayType(array_type)); | 3837 MapForExternalArrayType(array_type)); |
3960 reinterpret_cast<ExternalArray*>(result)->set_length(length); | 3838 reinterpret_cast<ExternalArray*>(result)->set_length(length); |
3961 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( | 3839 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( |
3962 external_pointer); | 3840 external_pointer); |
3963 | 3841 |
3964 return result; | 3842 return result; |
3965 } | 3843 } |
3966 | 3844 |
| 3845 static void ForFixedTypedArray(ExternalArrayType array_type, |
| 3846 int* element_size, |
| 3847 ElementsKind* element_kind) { |
| 3848 switch (array_type) { |
| 3849 case kExternalUnsignedByteArray: |
| 3850 *element_size = 1; |
| 3851 *element_kind = UINT8_ELEMENTS; |
| 3852 return; |
| 3853 case kExternalByteArray: |
| 3854 *element_size = 1; |
| 3855 *element_kind = INT8_ELEMENTS; |
| 3856 return; |
| 3857 case kExternalUnsignedShortArray: |
| 3858 *element_size = 2; |
| 3859 *element_kind = UINT16_ELEMENTS; |
| 3860 return; |
| 3861 case kExternalShortArray: |
| 3862 *element_size = 2; |
| 3863 *element_kind = INT16_ELEMENTS; |
| 3864 return; |
| 3865 case kExternalUnsignedIntArray: |
| 3866 *element_size = 4; |
| 3867 *element_kind = UINT32_ELEMENTS; |
| 3868 return; |
| 3869 case kExternalIntArray: |
| 3870 *element_size = 4; |
| 3871 *element_kind = INT32_ELEMENTS; |
| 3872 return; |
| 3873 case kExternalFloatArray: |
| 3874 *element_size = 4; |
| 3875 *element_kind = FLOAT32_ELEMENTS; |
| 3876 return; |
| 3877 case kExternalDoubleArray: |
| 3878 *element_size = 8; |
| 3879 *element_kind = FLOAT64_ELEMENTS; |
| 3880 return; |
| 3881 case kExternalPixelArray: |
| 3882 *element_size = 1; |
| 3883 *element_kind = UINT8_CLAMPED_ELEMENTS; |
| 3884 return; |
| 3885 default: |
| 3886 *element_size = 0; // Bogus |
| 3887 *element_kind = UINT8_ELEMENTS; // Bogus |
| 3888 UNREACHABLE(); |
| 3889 } |
| 3890 } |
| 3891 |
| 3892 |
| 3893 MaybeObject* Heap::AllocateFixedTypedArray(int length, |
| 3894 ExternalArrayType array_type, |
| 3895 PretenureFlag pretenure) { |
| 3896 int element_size; |
| 3897 ElementsKind elements_kind; |
| 3898 ForFixedTypedArray(array_type, &element_size, &elements_kind); |
| 3899 int size = OBJECT_POINTER_ALIGN( |
| 3900 length * element_size + FixedTypedArrayBase::kDataOffset); |
| 3901 #ifndef V8_HOST_ARCH_64_BIT |
| 3902 if (array_type == kExternalDoubleArray) { |
| 3903 size += kPointerSize; |
| 3904 } |
| 3905 #endif |
| 3906 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 3907 |
| 3908 HeapObject* object; |
| 3909 MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 3910 if (!maybe_object->To(&object)) return maybe_object; |
| 3911 |
| 3912 if (array_type == kExternalDoubleArray) { |
| 3913 object = EnsureDoubleAligned(this, object, size); |
| 3914 } |
| 3915 |
| 3916 FixedTypedArrayBase* elements = |
| 3917 reinterpret_cast<FixedTypedArrayBase*>(object); |
| 3918 elements->set_map(MapForFixedTypedArray(array_type)); |
| 3919 elements->set_length(length); |
| 3920 return elements; |
| 3921 } |
| 3922 |
3967 | 3923 |
3968 MaybeObject* Heap::CreateCode(const CodeDesc& desc, | 3924 MaybeObject* Heap::CreateCode(const CodeDesc& desc, |
3969 Code::Flags flags, | 3925 Code::Flags flags, |
3970 Handle<Object> self_reference, | 3926 Handle<Object> self_reference, |
3971 bool immovable, | 3927 bool immovable, |
3972 bool crankshafted, | 3928 bool crankshafted, |
3973 int prologue_offset) { | 3929 int prologue_offset) { |
3974 // Allocate ByteArray before the Code object, so that we do not risk | 3930 // Allocate ByteArray before the Code object, so that we do not risk |
3975 // leaving uninitialized Code object (and breaking the heap). | 3931 // leaving uninitialized Code object (and breaking the heap). |
3976 ByteArray* reloc_info; | 3932 ByteArray* reloc_info; |
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6750 } | 6706 } |
6751 | 6707 |
6752 | 6708 |
6753 void Heap::EnsureWeakObjectToCodeTable() { | 6709 void Heap::EnsureWeakObjectToCodeTable() { |
6754 if (!weak_object_to_code_table()->IsHashTable()) { | 6710 if (!weak_object_to_code_table()->IsHashTable()) { |
6755 set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16)); | 6711 set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16)); |
6756 } | 6712 } |
6757 } | 6713 } |
6758 | 6714 |
6759 | 6715 |
| 6716 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
| 6717 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); |
| 6718 } |
| 6719 |
6760 #ifdef DEBUG | 6720 #ifdef DEBUG |
6761 | 6721 |
6762 class PrintHandleVisitor: public ObjectVisitor { | 6722 class PrintHandleVisitor: public ObjectVisitor { |
6763 public: | 6723 public: |
6764 void VisitPointers(Object** start, Object** end) { | 6724 void VisitPointers(Object** start, Object** end) { |
6765 for (Object** p = start; p < end; p++) | 6725 for (Object** p = start; p < end; p++) |
6766 PrintF(" handle %p to %p\n", | 6726 PrintF(" handle %p to %p\n", |
6767 reinterpret_cast<void*>(p), | 6727 reinterpret_cast<void*>(p), |
6768 reinterpret_cast<void*>(*p)); | 6728 reinterpret_cast<void*>(*p)); |
6769 } | 6729 } |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7735 static_cast<int>(object_sizes_last_time_[index])); | 7695 static_cast<int>(object_sizes_last_time_[index])); |
7736 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7696 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
7737 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7697 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7738 | 7698 |
7739 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7699 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7740 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7700 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7741 ClearObjectStats(); | 7701 ClearObjectStats(); |
7742 } | 7702 } |
7743 | 7703 |
7744 } } // namespace v8::internal | 7704 } } // namespace v8::internal |
OLD | NEW |