| 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 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 | 2771 |
| 2772 fixed_array_map()->set_prototype(null_value()); | 2772 fixed_array_map()->set_prototype(null_value()); |
| 2773 fixed_array_map()->set_constructor(null_value()); | 2773 fixed_array_map()->set_constructor(null_value()); |
| 2774 | 2774 |
| 2775 oddball_map()->set_prototype(null_value()); | 2775 oddball_map()->set_prototype(null_value()); |
| 2776 oddball_map()->set_constructor(null_value()); | 2776 oddball_map()->set_constructor(null_value()); |
| 2777 | 2777 |
| 2778 constant_pool_array_map()->set_prototype(null_value()); | 2778 constant_pool_array_map()->set_prototype(null_value()); |
| 2779 constant_pool_array_map()->set_constructor(null_value()); | 2779 constant_pool_array_map()->set_constructor(null_value()); |
| 2780 | 2780 |
| 2781 { // Map allocation | 2781 { MaybeObject* maybe_obj = |
| 2782 #define ALLOCATE_MAP(instance_type, size, field_name) \ | 2782 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2783 { Map* map; \ | 2783 if (!maybe_obj->ToObject(&obj)) return false; |
| 2784 if (!AllocateMap((instance_type), size)->To(&map)) return false; \ | 2784 } |
| 2785 set_##field_name##_map(map); \ | 2785 set_fixed_cow_array_map(Map::cast(obj)); |
| 2786 ASSERT(fixed_array_map() != fixed_cow_array_map()); |
| 2787 |
| 2788 { MaybeObject* maybe_obj = |
| 2789 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2790 if (!maybe_obj->ToObject(&obj)) return false; |
| 2791 } |
| 2792 set_scope_info_map(Map::cast(obj)); |
| 2793 |
| 2794 { MaybeObject* maybe_obj = AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize); |
| 2795 if (!maybe_obj->ToObject(&obj)) return false; |
| 2796 } |
| 2797 set_heap_number_map(Map::cast(obj)); |
| 2798 |
| 2799 { MaybeObject* maybe_obj = AllocateMap(SYMBOL_TYPE, Symbol::kSize); |
| 2800 if (!maybe_obj->ToObject(&obj)) return false; |
| 2801 } |
| 2802 set_symbol_map(Map::cast(obj)); |
| 2803 |
| 2804 { MaybeObject* maybe_obj = AllocateMap(FOREIGN_TYPE, Foreign::kSize); |
| 2805 if (!maybe_obj->ToObject(&obj)) return false; |
| 2806 } |
| 2807 set_foreign_map(Map::cast(obj)); |
| 2808 |
| 2809 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { |
| 2810 const StringTypeTable& entry = string_type_table[i]; |
| 2811 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); |
| 2812 if (!maybe_obj->ToObject(&obj)) return false; |
| 2786 } | 2813 } |
| 2787 | 2814 roots_[entry.index] = Map::cast(obj); |
| 2788 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ | 2815 } |
| 2789 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) | 2816 |
| 2790 | 2817 { MaybeObject* maybe_obj = AllocateMap(STRING_TYPE, kVariableSizeSentinel); |
| 2791 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, fixed_cow_array) | 2818 if (!maybe_obj->ToObject(&obj)) return false; |
| 2792 ASSERT(fixed_array_map() != fixed_cow_array_map()); | 2819 } |
| 2793 | 2820 set_undetectable_string_map(Map::cast(obj)); |
| 2794 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, scope_info) | 2821 Map::cast(obj)->set_is_undetectable(); |
| 2795 ALLOCATE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number) | 2822 |
| 2796 ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol) | 2823 { MaybeObject* maybe_obj = |
| 2797 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign) | 2824 AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); |
| 2798 | 2825 if (!maybe_obj->ToObject(&obj)) return false; |
| 2799 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { | 2826 } |
| 2800 const StringTypeTable& entry = string_type_table[i]; | 2827 set_undetectable_ascii_string_map(Map::cast(obj)); |
| 2801 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); | 2828 Map::cast(obj)->set_is_undetectable(); |
| 2802 if (!maybe_obj->ToObject(&obj)) return false; | 2829 |
| 2803 } | 2830 { MaybeObject* maybe_obj = |
| 2804 roots_[entry.index] = Map::cast(obj); | 2831 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); |
| 2832 if (!maybe_obj->ToObject(&obj)) return false; |
| 2833 } |
| 2834 set_fixed_double_array_map(Map::cast(obj)); |
| 2835 |
| 2836 { MaybeObject* maybe_obj = |
| 2837 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); |
| 2838 if (!maybe_obj->ToObject(&obj)) return false; |
| 2839 } |
| 2840 set_byte_array_map(Map::cast(obj)); |
| 2841 |
| 2842 { MaybeObject* maybe_obj = |
| 2843 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); |
| 2844 if (!maybe_obj->ToObject(&obj)) return false; |
| 2845 } |
| 2846 set_free_space_map(Map::cast(obj)); |
| 2847 |
| 2848 { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); |
| 2849 if (!maybe_obj->ToObject(&obj)) return false; |
| 2850 } |
| 2851 set_empty_byte_array(ByteArray::cast(obj)); |
| 2852 |
| 2853 { MaybeObject* maybe_obj = |
| 2854 AllocateMap(EXTERNAL_PIXEL_ARRAY_TYPE, ExternalArray::kAlignedSize); |
| 2855 if (!maybe_obj->ToObject(&obj)) return false; |
| 2856 } |
| 2857 set_external_pixel_array_map(Map::cast(obj)); |
| 2858 |
| 2859 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_BYTE_ARRAY_TYPE, |
| 2860 ExternalArray::kAlignedSize); |
| 2861 if (!maybe_obj->ToObject(&obj)) return false; |
| 2862 } |
| 2863 set_external_byte_array_map(Map::cast(obj)); |
| 2864 |
| 2865 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, |
| 2866 ExternalArray::kAlignedSize); |
| 2867 if (!maybe_obj->ToObject(&obj)) return false; |
| 2868 } |
| 2869 set_external_unsigned_byte_array_map(Map::cast(obj)); |
| 2870 |
| 2871 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_SHORT_ARRAY_TYPE, |
| 2872 ExternalArray::kAlignedSize); |
| 2873 if (!maybe_obj->ToObject(&obj)) return false; |
| 2874 } |
| 2875 set_external_short_array_map(Map::cast(obj)); |
| 2876 |
| 2877 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, |
| 2878 ExternalArray::kAlignedSize); |
| 2879 if (!maybe_obj->ToObject(&obj)) return false; |
| 2880 } |
| 2881 set_external_unsigned_short_array_map(Map::cast(obj)); |
| 2882 |
| 2883 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_INT_ARRAY_TYPE, |
| 2884 ExternalArray::kAlignedSize); |
| 2885 if (!maybe_obj->ToObject(&obj)) return false; |
| 2886 } |
| 2887 set_external_int_array_map(Map::cast(obj)); |
| 2888 |
| 2889 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, |
| 2890 ExternalArray::kAlignedSize); |
| 2891 if (!maybe_obj->ToObject(&obj)) return false; |
| 2892 } |
| 2893 set_external_unsigned_int_array_map(Map::cast(obj)); |
| 2894 |
| 2895 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_FLOAT_ARRAY_TYPE, |
| 2896 ExternalArray::kAlignedSize); |
| 2897 if (!maybe_obj->ToObject(&obj)) return false; |
| 2898 } |
| 2899 set_external_float_array_map(Map::cast(obj)); |
| 2900 |
| 2901 { MaybeObject* maybe_obj = |
| 2902 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2903 if (!maybe_obj->ToObject(&obj)) return false; |
| 2904 } |
| 2905 set_non_strict_arguments_elements_map(Map::cast(obj)); |
| 2906 |
| 2907 { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_DOUBLE_ARRAY_TYPE, |
| 2908 ExternalArray::kAlignedSize); |
| 2909 if (!maybe_obj->ToObject(&obj)) return false; |
| 2910 } |
| 2911 set_external_double_array_map(Map::cast(obj)); |
| 2912 |
| 2913 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalByteArray); |
| 2914 if (!maybe_obj->ToObject(&obj)) return false; |
| 2915 } |
| 2916 set_empty_external_byte_array(ExternalArray::cast(obj)); |
| 2917 |
| 2918 { MaybeObject* maybe_obj = |
| 2919 AllocateEmptyExternalArray(kExternalUnsignedByteArray); |
| 2920 if (!maybe_obj->ToObject(&obj)) return false; |
| 2921 } |
| 2922 set_empty_external_unsigned_byte_array(ExternalArray::cast(obj)); |
| 2923 |
| 2924 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalShortArray); |
| 2925 if (!maybe_obj->ToObject(&obj)) return false; |
| 2926 } |
| 2927 set_empty_external_short_array(ExternalArray::cast(obj)); |
| 2928 |
| 2929 { MaybeObject* maybe_obj = AllocateEmptyExternalArray( |
| 2930 kExternalUnsignedShortArray); |
| 2931 if (!maybe_obj->ToObject(&obj)) return false; |
| 2932 } |
| 2933 set_empty_external_unsigned_short_array(ExternalArray::cast(obj)); |
| 2934 |
| 2935 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalIntArray); |
| 2936 if (!maybe_obj->ToObject(&obj)) return false; |
| 2937 } |
| 2938 set_empty_external_int_array(ExternalArray::cast(obj)); |
| 2939 |
| 2940 { MaybeObject* maybe_obj = |
| 2941 AllocateEmptyExternalArray(kExternalUnsignedIntArray); |
| 2942 if (!maybe_obj->ToObject(&obj)) return false; |
| 2943 } |
| 2944 set_empty_external_unsigned_int_array(ExternalArray::cast(obj)); |
| 2945 |
| 2946 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalFloatArray); |
| 2947 if (!maybe_obj->ToObject(&obj)) return false; |
| 2948 } |
| 2949 set_empty_external_float_array(ExternalArray::cast(obj)); |
| 2950 |
| 2951 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalDoubleArray); |
| 2952 if (!maybe_obj->ToObject(&obj)) return false; |
| 2953 } |
| 2954 set_empty_external_double_array(ExternalArray::cast(obj)); |
| 2955 |
| 2956 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalPixelArray); |
| 2957 if (!maybe_obj->ToObject(&obj)) return false; |
| 2958 } |
| 2959 set_empty_external_pixel_array(ExternalArray::cast(obj)); |
| 2960 |
| 2961 { MaybeObject* maybe_obj = AllocateMap(CODE_TYPE, kVariableSizeSentinel); |
| 2962 if (!maybe_obj->ToObject(&obj)) return false; |
| 2963 } |
| 2964 set_code_map(Map::cast(obj)); |
| 2965 |
| 2966 { MaybeObject* maybe_obj = AllocateMap(CELL_TYPE, Cell::kSize); |
| 2967 if (!maybe_obj->ToObject(&obj)) return false; |
| 2968 } |
| 2969 set_cell_map(Map::cast(obj)); |
| 2970 |
| 2971 { MaybeObject* maybe_obj = AllocateMap(PROPERTY_CELL_TYPE, |
| 2972 PropertyCell::kSize); |
| 2973 if (!maybe_obj->ToObject(&obj)) return false; |
| 2974 } |
| 2975 set_global_property_cell_map(Map::cast(obj)); |
| 2976 |
| 2977 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize); |
| 2978 if (!maybe_obj->ToObject(&obj)) return false; |
| 2979 } |
| 2980 set_one_pointer_filler_map(Map::cast(obj)); |
| 2981 |
| 2982 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize); |
| 2983 if (!maybe_obj->ToObject(&obj)) return false; |
| 2984 } |
| 2985 set_two_pointer_filler_map(Map::cast(obj)); |
| 2986 |
| 2987 for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { |
| 2988 const StructTable& entry = struct_table[i]; |
| 2989 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); |
| 2990 if (!maybe_obj->ToObject(&obj)) return false; |
| 2805 } | 2991 } |
| 2806 | 2992 roots_[entry.index] = Map::cast(obj); |
| 2807 ALLOCATE_VARSIZE_MAP(STRING_TYPE, undetectable_string) | 2993 } |
| 2808 undetectable_string_map()->set_is_undetectable(); | 2994 |
| 2809 | 2995 { MaybeObject* maybe_obj = |
| 2810 ALLOCATE_VARSIZE_MAP(ASCII_STRING_TYPE, undetectable_ascii_string); | 2996 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2811 undetectable_ascii_string_map()->set_is_undetectable(); | 2997 if (!maybe_obj->ToObject(&obj)) return false; |
| 2812 | 2998 } |
| 2813 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) | 2999 set_hash_table_map(Map::cast(obj)); |
| 2814 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) | 3000 |
| 2815 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) | 3001 { MaybeObject* maybe_obj = |
| 2816 | 3002 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2817 #define ALLOCATE_EXTERNAL_ARRAY_MAP(TYPE, type) \ | 3003 if (!maybe_obj->ToObject(&obj)) return false; |
| 2818 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kAlignedSize, \ | 3004 } |
| 2819 external_##type##_array) | 3005 set_function_context_map(Map::cast(obj)); |
| 2820 | 3006 |
| 2821 ALLOCATE_EXTERNAL_ARRAY_MAP(PIXEL, pixel) | 3007 { MaybeObject* maybe_obj = |
| 2822 ALLOCATE_EXTERNAL_ARRAY_MAP(BYTE, byte) | 3008 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2823 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_BYTE, unsigned_byte) | 3009 if (!maybe_obj->ToObject(&obj)) return false; |
| 2824 ALLOCATE_EXTERNAL_ARRAY_MAP(SHORT, short) // NOLINT | 3010 } |
| 2825 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_SHORT, unsigned_short) | 3011 set_catch_context_map(Map::cast(obj)); |
| 2826 ALLOCATE_EXTERNAL_ARRAY_MAP(INT, int) | 3012 |
| 2827 ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_INT, unsigned_int) | 3013 { MaybeObject* maybe_obj = |
| 2828 ALLOCATE_EXTERNAL_ARRAY_MAP(FLOAT, float) | 3014 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2829 ALLOCATE_EXTERNAL_ARRAY_MAP(DOUBLE, double) | 3015 if (!maybe_obj->ToObject(&obj)) return false; |
| 2830 #undef ALLOCATE_EXTERNAL_ARRAY_MAP | 3016 } |
| 2831 | 3017 set_with_context_map(Map::cast(obj)); |
| 2832 ALLOCATE_VARSIZE_MAP(FIXED_UINT8_ARRAY_TYPE, fixed_uint8_array) | 3018 |
| 2833 ALLOCATE_VARSIZE_MAP(FIXED_UINT8_CLAMPED_ARRAY_TYPE, | 3019 { MaybeObject* maybe_obj = |
| 2834 fixed_uint8_clamped_array) | 3020 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2835 ALLOCATE_VARSIZE_MAP(FIXED_INT8_ARRAY_TYPE, fixed_int8_array) | 3021 if (!maybe_obj->ToObject(&obj)) return false; |
| 2836 ALLOCATE_VARSIZE_MAP(FIXED_UINT16_ARRAY_TYPE, fixed_uint16_array) | 3022 } |
| 2837 ALLOCATE_VARSIZE_MAP(FIXED_INT16_ARRAY_TYPE, fixed_int16_array) | 3023 set_block_context_map(Map::cast(obj)); |
| 2838 ALLOCATE_VARSIZE_MAP(FIXED_UINT32_ARRAY_TYPE, fixed_uint32_array) | 3024 |
| 2839 ALLOCATE_VARSIZE_MAP(FIXED_INT32_ARRAY_TYPE, fixed_int32_array) | 3025 { MaybeObject* maybe_obj = |
| 2840 ALLOCATE_VARSIZE_MAP(FIXED_FLOAT32_ARRAY_TYPE, fixed_float32_array) | 3026 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2841 ALLOCATE_VARSIZE_MAP(FIXED_FLOAT64_ARRAY_TYPE, fixed_float64_array) | 3027 if (!maybe_obj->ToObject(&obj)) return false; |
| 2842 | 3028 } |
| 2843 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, non_strict_arguments_elements) | 3029 set_module_context_map(Map::cast(obj)); |
| 2844 | 3030 |
| 2845 ALLOCATE_VARSIZE_MAP(CODE_TYPE, code) | 3031 { MaybeObject* maybe_obj = |
| 2846 | 3032 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2847 ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell) | 3033 if (!maybe_obj->ToObject(&obj)) return false; |
| 2848 ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell) | 3034 } |
| 2849 ALLOCATE_MAP(FILLER_TYPE, kPointerSize, one_pointer_filler) | 3035 set_global_context_map(Map::cast(obj)); |
| 2850 ALLOCATE_MAP(FILLER_TYPE, 2 * kPointerSize, two_pointer_filler) | 3036 |
| 2851 | 3037 { MaybeObject* maybe_obj = |
| 2852 | 3038 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2853 for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { | 3039 if (!maybe_obj->ToObject(&obj)) return false; |
| 2854 const StructTable& entry = struct_table[i]; | 3040 } |
| 2855 Map* map; | 3041 Map* native_context_map = Map::cast(obj); |
| 2856 if (!AllocateMap(entry.type, entry.size)->To(&map)) | 3042 native_context_map->set_dictionary_map(true); |
| 2857 return false; | 3043 native_context_map->set_visitor_id(StaticVisitorBase::kVisitNativeContext); |
| 2858 roots_[entry.index] = map; | 3044 set_native_context_map(native_context_map); |
| 2859 } | 3045 |
| 2860 | 3046 { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, |
| 2861 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, hash_table) | 3047 SharedFunctionInfo::kAlignedSize); |
| 2862 | 3048 if (!maybe_obj->ToObject(&obj)) return false; |
| 2863 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, function_context) | 3049 } |
| 2864 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, catch_context) | 3050 set_shared_function_info_map(Map::cast(obj)); |
| 2865 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, with_context) | 3051 |
| 2866 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, block_context) | 3052 { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, |
| 2867 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, module_context) | 3053 JSMessageObject::kSize); |
| 2868 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, global_context) | 3054 if (!maybe_obj->ToObject(&obj)) return false; |
| 2869 | 3055 } |
| 2870 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, native_context) | 3056 set_message_object_map(Map::cast(obj)); |
| 2871 native_context_map()->set_dictionary_map(true); | 3057 |
| 2872 native_context_map()->set_visitor_id( | 3058 Map* external_map; |
| 2873 StaticVisitorBase::kVisitNativeContext); | 3059 { MaybeObject* maybe_obj = |
| 2874 | 3060 AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize); |
| 2875 ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kAlignedSize, | 3061 if (!maybe_obj->To(&external_map)) return false; |
| 2876 shared_function_info) | 3062 } |
| 2877 | 3063 external_map->set_is_extensible(false); |
| 2878 ALLOCATE_MAP(JS_MESSAGE_OBJECT_TYPE, JSMessageObject::kSize, | 3064 set_external_map(external_map); |
| 2879 message_object) | 3065 |
| 2880 ALLOCATE_MAP(JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize, | |
| 2881 external) | |
| 2882 external_map()->set_is_extensible(false); | |
| 2883 #undef ALLOCATE_VARSIZE_MAP | |
| 2884 #undef ALLOCATE_MAP | |
| 2885 } | |
| 2886 | |
| 2887 { // Empty arrays | |
| 2888 { ByteArray* byte_array; | |
| 2889 if (!AllocateByteArray(0, TENURED)->To(&byte_array)) return false; | |
| 2890 set_empty_byte_array(byte_array); | |
| 2891 } | |
| 2892 | |
| 2893 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type) \ | |
| 2894 { ExternalArray* obj; \ | |
| 2895 if (!AllocateEmptyExternalArray(kExternal##Type##Array)->To(&obj)) \ | |
| 2896 return false; \ | |
| 2897 set_empty_external_##type##_array(obj); \ | |
| 2898 } | |
| 2899 | |
| 2900 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Byte, byte) | |
| 2901 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedByte, unsigned_byte) | |
| 2902 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Short, short) // NOLINT | |
| 2903 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedShort, unsigned_short) | |
| 2904 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Int, int) | |
| 2905 ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedInt, unsigned_int) | |
| 2906 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Float, float) | |
| 2907 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Double, double) | |
| 2908 ALLOCATE_EMPTY_EXTERNAL_ARRAY(Pixel, pixel) | |
| 2909 #undef ALLOCATE_EMPTY_EXTERNAL_ARRAY | |
| 2910 } | |
| 2911 ASSERT(!InNewSpace(empty_fixed_array())); | 3066 ASSERT(!InNewSpace(empty_fixed_array())); |
| 2912 return true; | 3067 return true; |
| 2913 } | 3068 } |
| 2914 | 3069 |
| 2915 | 3070 |
| 2916 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { | 3071 MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { |
| 2917 // Statically ensure that it is safe to allocate heap numbers in paged | 3072 // Statically ensure that it is safe to allocate heap numbers in paged |
| 2918 // spaces. | 3073 // spaces. |
| 2919 int size = HeapNumber::kSize; | 3074 int size = HeapNumber::kSize; |
| 2920 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); | 3075 STATIC_ASSERT(HeapNumber::kSize <= Page::kNonCodeObjectAreaSize); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3609 return kExternalDoubleArrayMapRootIndex; | 3764 return kExternalDoubleArrayMapRootIndex; |
| 3610 case kExternalPixelArray: | 3765 case kExternalPixelArray: |
| 3611 return kExternalPixelArrayMapRootIndex; | 3766 return kExternalPixelArrayMapRootIndex; |
| 3612 default: | 3767 default: |
| 3613 UNREACHABLE(); | 3768 UNREACHABLE(); |
| 3614 return kUndefinedValueRootIndex; | 3769 return kUndefinedValueRootIndex; |
| 3615 } | 3770 } |
| 3616 } | 3771 } |
| 3617 | 3772 |
| 3618 | 3773 |
| 3619 Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { | |
| 3620 return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); | |
| 3621 } | |
| 3622 | |
| 3623 | |
| 3624 Heap::RootListIndex Heap::RootIndexForFixedTypedArray( | |
| 3625 ExternalArrayType array_type) { | |
| 3626 switch (array_type) { | |
| 3627 case kExternalByteArray: | |
| 3628 return kFixedInt8ArrayMapRootIndex; | |
| 3629 case kExternalUnsignedByteArray: | |
| 3630 return kFixedUint8ArrayMapRootIndex; | |
| 3631 case kExternalShortArray: | |
| 3632 return kFixedInt16ArrayMapRootIndex; | |
| 3633 case kExternalUnsignedShortArray: | |
| 3634 return kFixedUint16ArrayMapRootIndex; | |
| 3635 case kExternalIntArray: | |
| 3636 return kFixedInt32ArrayMapRootIndex; | |
| 3637 case kExternalUnsignedIntArray: | |
| 3638 return kFixedUint32ArrayMapRootIndex; | |
| 3639 case kExternalFloatArray: | |
| 3640 return kFixedFloat32ArrayMapRootIndex; | |
| 3641 case kExternalDoubleArray: | |
| 3642 return kFixedFloat64ArrayMapRootIndex; | |
| 3643 case kExternalPixelArray: | |
| 3644 return kFixedUint8ClampedArrayMapRootIndex; | |
| 3645 default: | |
| 3646 UNREACHABLE(); | |
| 3647 return kUndefinedValueRootIndex; | |
| 3648 } | |
| 3649 } | |
| 3650 | |
| 3651 | |
| 3652 Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( | 3774 Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( |
| 3653 ElementsKind elementsKind) { | 3775 ElementsKind elementsKind) { |
| 3654 switch (elementsKind) { | 3776 switch (elementsKind) { |
| 3655 case EXTERNAL_BYTE_ELEMENTS: | 3777 case EXTERNAL_BYTE_ELEMENTS: |
| 3656 return kEmptyExternalByteArrayRootIndex; | 3778 return kEmptyExternalByteArrayRootIndex; |
| 3657 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3779 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3658 return kEmptyExternalUnsignedByteArrayRootIndex; | 3780 return kEmptyExternalUnsignedByteArrayRootIndex; |
| 3659 case EXTERNAL_SHORT_ELEMENTS: | 3781 case EXTERNAL_SHORT_ELEMENTS: |
| 3660 return kEmptyExternalShortArrayRootIndex; | 3782 return kEmptyExternalShortArrayRootIndex; |
| 3661 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3783 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3900 | 4022 |
| 3901 reinterpret_cast<ExternalArray*>(result)->set_map_no_write_barrier( | 4023 reinterpret_cast<ExternalArray*>(result)->set_map_no_write_barrier( |
| 3902 MapForExternalArrayType(array_type)); | 4024 MapForExternalArrayType(array_type)); |
| 3903 reinterpret_cast<ExternalArray*>(result)->set_length(length); | 4025 reinterpret_cast<ExternalArray*>(result)->set_length(length); |
| 3904 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( | 4026 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( |
| 3905 external_pointer); | 4027 external_pointer); |
| 3906 | 4028 |
| 3907 return result; | 4029 return result; |
| 3908 } | 4030 } |
| 3909 | 4031 |
| 3910 static void ForFixedTypedArray(ExternalArrayType array_type, | |
| 3911 int* element_size, | |
| 3912 ElementsKind* element_kind) { | |
| 3913 switch (array_type) { | |
| 3914 case kExternalUnsignedByteArray: | |
| 3915 *element_size = 1; | |
| 3916 *element_kind = UINT8_ELEMENTS; | |
| 3917 return; | |
| 3918 case kExternalByteArray: | |
| 3919 *element_size = 1; | |
| 3920 *element_kind = INT8_ELEMENTS; | |
| 3921 return; | |
| 3922 case kExternalUnsignedShortArray: | |
| 3923 *element_size = 2; | |
| 3924 *element_kind = UINT16_ELEMENTS; | |
| 3925 return; | |
| 3926 case kExternalShortArray: | |
| 3927 *element_size = 2; | |
| 3928 *element_kind = INT16_ELEMENTS; | |
| 3929 return; | |
| 3930 case kExternalUnsignedIntArray: | |
| 3931 *element_size = 4; | |
| 3932 *element_kind = UINT32_ELEMENTS; | |
| 3933 return; | |
| 3934 case kExternalIntArray: | |
| 3935 *element_size = 4; | |
| 3936 *element_kind = INT32_ELEMENTS; | |
| 3937 return; | |
| 3938 case kExternalFloatArray: | |
| 3939 *element_size = 4; | |
| 3940 *element_kind = FLOAT32_ELEMENTS; | |
| 3941 return; | |
| 3942 case kExternalDoubleArray: | |
| 3943 *element_size = 8; | |
| 3944 *element_kind = FLOAT64_ELEMENTS; | |
| 3945 return; | |
| 3946 case kExternalPixelArray: | |
| 3947 *element_size = 1; | |
| 3948 *element_kind = UINT8_CLAMPED_ELEMENTS; | |
| 3949 return; | |
| 3950 default: | |
| 3951 *element_size = 0; // Bogus | |
| 3952 *element_kind = UINT8_ELEMENTS; // Bogus | |
| 3953 UNREACHABLE(); | |
| 3954 } | |
| 3955 } | |
| 3956 | |
| 3957 | |
| 3958 MaybeObject* Heap::AllocateFixedTypedArray(int length, | |
| 3959 ExternalArrayType array_type, | |
| 3960 PretenureFlag pretenure) { | |
| 3961 int element_size; | |
| 3962 ElementsKind elements_kind; | |
| 3963 ForFixedTypedArray(array_type, &element_size, &elements_kind); | |
| 3964 int size = OBJECT_POINTER_ALIGN( | |
| 3965 length * element_size + FixedTypedArrayBase::kDataOffset); | |
| 3966 #ifndef V8_HOST_ARCH_64_BIT | |
| 3967 if (array_type == kExternalDoubleArray) { | |
| 3968 size += kPointerSize; | |
| 3969 } | |
| 3970 #endif | |
| 3971 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | |
| 3972 | |
| 3973 HeapObject* object; | |
| 3974 MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE); | |
| 3975 if (!maybe_object->To(&object)) return maybe_object; | |
| 3976 | |
| 3977 if (array_type == kExternalDoubleArray) { | |
| 3978 object = EnsureDoubleAligned(this, object, size); | |
| 3979 } | |
| 3980 | |
| 3981 FixedTypedArrayBase* elements = | |
| 3982 reinterpret_cast<FixedTypedArrayBase*>(object); | |
| 3983 elements->set_map(MapForFixedTypedArray(array_type)); | |
| 3984 elements->set_length(length); | |
| 3985 return elements; | |
| 3986 } | |
| 3987 | |
| 3988 | 4032 |
| 3989 MaybeObject* Heap::CreateCode(const CodeDesc& desc, | 4033 MaybeObject* Heap::CreateCode(const CodeDesc& desc, |
| 3990 Code::Flags flags, | 4034 Code::Flags flags, |
| 3991 Handle<Object> self_reference, | 4035 Handle<Object> self_reference, |
| 3992 bool immovable, | 4036 bool immovable, |
| 3993 bool crankshafted, | 4037 bool crankshafted, |
| 3994 int prologue_offset) { | 4038 int prologue_offset) { |
| 3995 // Allocate ByteArray before the Code object, so that we do not risk | 4039 // Allocate ByteArray before the Code object, so that we do not risk |
| 3996 // leaving uninitialized Code object (and breaking the heap). | 4040 // leaving uninitialized Code object (and breaking the heap). |
| 3997 ByteArray* reloc_info; | 4041 ByteArray* reloc_info; |
| (...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6771 } | 6815 } |
| 6772 | 6816 |
| 6773 | 6817 |
| 6774 void Heap::EnsureWeakObjectToCodeTable() { | 6818 void Heap::EnsureWeakObjectToCodeTable() { |
| 6775 if (!weak_object_to_code_table()->IsHashTable()) { | 6819 if (!weak_object_to_code_table()->IsHashTable()) { |
| 6776 set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16)); | 6820 set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16)); |
| 6777 } | 6821 } |
| 6778 } | 6822 } |
| 6779 | 6823 |
| 6780 | 6824 |
| 6781 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { | |
| 6782 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); | |
| 6783 } | |
| 6784 | |
| 6785 #ifdef DEBUG | 6825 #ifdef DEBUG |
| 6786 | 6826 |
| 6787 class PrintHandleVisitor: public ObjectVisitor { | 6827 class PrintHandleVisitor: public ObjectVisitor { |
| 6788 public: | 6828 public: |
| 6789 void VisitPointers(Object** start, Object** end) { | 6829 void VisitPointers(Object** start, Object** end) { |
| 6790 for (Object** p = start; p < end; p++) | 6830 for (Object** p = start; p < end; p++) |
| 6791 PrintF(" handle %p to %p\n", | 6831 PrintF(" handle %p to %p\n", |
| 6792 reinterpret_cast<void*>(p), | 6832 reinterpret_cast<void*>(p), |
| 6793 reinterpret_cast<void*>(*p)); | 6833 reinterpret_cast<void*>(*p)); |
| 6794 } | 6834 } |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7760 static_cast<int>(object_sizes_last_time_[index])); | 7800 static_cast<int>(object_sizes_last_time_[index])); |
| 7761 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7801 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7762 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7802 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7763 | 7803 |
| 7764 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7804 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7765 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7805 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7766 ClearObjectStats(); | 7806 ClearObjectStats(); |
| 7767 } | 7807 } |
| 7768 | 7808 |
| 7769 } } // namespace v8::internal | 7809 } } // namespace v8::internal |
| OLD | NEW |