Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: src/heap/heap.cc

Issue 1230753004: [Interpreter] Add BytecodeArray class and add to SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Additional object methods for BytecodeArray. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 2962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 2973
2974 { // Create a separate external one byte string map for native sources. 2974 { // Create a separate external one byte string map for native sources.
2975 AllocationResult allocation = AllocateMap(EXTERNAL_ONE_BYTE_STRING_TYPE, 2975 AllocationResult allocation = AllocateMap(EXTERNAL_ONE_BYTE_STRING_TYPE,
2976 ExternalOneByteString::kSize); 2976 ExternalOneByteString::kSize);
2977 if (!allocation.To(&obj)) return false; 2977 if (!allocation.To(&obj)) return false;
2978 set_native_source_string_map(Map::cast(obj)); 2978 set_native_source_string_map(Map::cast(obj));
2979 } 2979 }
2980 2980
2981 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) 2981 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array)
2982 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) 2982 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array)
2983 ALLOCATE_VARSIZE_MAP(BYTECODE_ARRAY_TYPE, bytecode_array)
2983 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) 2984 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space)
2984 2985
2985 #define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ 2986 #define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \
2986 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kSize, \ 2987 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kSize, \
2987 external_##type##_array) 2988 external_##type##_array)
2988 2989
2989 TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP) 2990 TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP)
2990 #undef ALLOCATE_EXTERNAL_ARRAY_MAP 2991 #undef ALLOCATE_EXTERNAL_ARRAY_MAP
2991 2992
2992 #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \ 2993 #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 external_map()->set_is_extensible(false); 3038 external_map()->set_is_extensible(false);
3038 #undef ALLOCATE_VARSIZE_MAP 3039 #undef ALLOCATE_VARSIZE_MAP
3039 #undef ALLOCATE_MAP 3040 #undef ALLOCATE_MAP
3040 } 3041 }
3041 3042
3042 { // Empty arrays 3043 { // Empty arrays
3043 { 3044 {
3044 ByteArray* byte_array; 3045 ByteArray* byte_array;
3045 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false; 3046 if (!AllocateByteArray(0, TENURED).To(&byte_array)) return false;
3046 set_empty_byte_array(byte_array); 3047 set_empty_byte_array(byte_array);
3048
3049 BytecodeArray* bytecode_array;
3050 if (!AllocateBytecodeArray(0, nullptr, TENURED).To(&bytecode_array)) {
3051 return false;
3052 }
3053 set_empty_bytecode_array(bytecode_array);
3047 } 3054 }
3048 3055
3049 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ 3056 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \
3050 { \ 3057 { \
3051 ExternalArray* obj; \ 3058 ExternalArray* obj; \
3052 if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \ 3059 if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \
3053 return false; \ 3060 return false; \
3054 set_empty_external_##type##_array(obj); \ 3061 set_empty_external_##type##_array(obj); \
3055 } 3062 }
3056 3063
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
3782 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 3789 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
3783 if (!allocation.To(&result)) return allocation; 3790 if (!allocation.To(&result)) return allocation;
3784 } 3791 }
3785 3792
3786 result->set_map_no_write_barrier(byte_array_map()); 3793 result->set_map_no_write_barrier(byte_array_map());
3787 ByteArray::cast(result)->set_length(length); 3794 ByteArray::cast(result)->set_length(length);
3788 return result; 3795 return result;
3789 } 3796 }
3790 3797
3791 3798
3799 AllocationResult Heap::AllocateBytecodeArray(int length,
3800 const byte* const raw_bytecodes,
3801 PretenureFlag pretenure) {
3802 if (length < 0 || length > BytecodeArray::kMaxLength) {
3803 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true);
3804 }
3805 int size = BytecodeArray::SizeFor(length);
3806 AllocationSpace space = SelectSpace(size, pretenure);
3807 HeapObject* result;
3808 {
3809 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
3810 if (!allocation.To(&result)) return allocation;
3811 }
3812
3813 BytecodeArray* instance = BytecodeArray::cast(result);
3814 instance->set_length(length);
3815 CopyBytes(instance->GetDataStartAddress(), raw_bytecodes, length);
3816 result->set_map_no_write_barrier(byte_array_map());
3817 return result;
3818 }
3819
3820
3792 void Heap::CreateFillerObjectAt(Address addr, int size) { 3821 void Heap::CreateFillerObjectAt(Address addr, int size) {
3793 if (size == 0) return; 3822 if (size == 0) return;
3794 HeapObject* filler = HeapObject::FromAddress(addr); 3823 HeapObject* filler = HeapObject::FromAddress(addr);
3795 if (size == kPointerSize) { 3824 if (size == kPointerSize) {
3796 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); 3825 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map());
3797 } else if (size == 2 * kPointerSize) { 3826 } else if (size == 2 * kPointerSize) {
3798 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); 3827 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map());
3799 } else { 3828 } else {
3800 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); 3829 filler->set_map_no_write_barrier(raw_unchecked_free_space_map());
3801 FreeSpace::cast(filler)->nobarrier_set_size(size); 3830 FreeSpace::cast(filler)->nobarrier_set_size(size);
(...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after
6886 *object_type = "CODE_TYPE"; \ 6915 *object_type = "CODE_TYPE"; \
6887 *object_sub_type = "CODE_AGE/" #name; \ 6916 *object_sub_type = "CODE_AGE/" #name; \
6888 return true; 6917 return true;
6889 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6918 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6890 #undef COMPARE_AND_RETURN_NAME 6919 #undef COMPARE_AND_RETURN_NAME
6891 } 6920 }
6892 return false; 6921 return false;
6893 } 6922 }
6894 } // namespace internal 6923 } // namespace internal
6895 } // namespace v8 6924 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698