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

Side by Side Diff: runtime/vm/simulator_dbc.cc

Issue 2912863006: Inline instance object hash code into object header on 64 bit. (Closed)
Patch Set: Add assembler tests and other feedback from Ryan Created 3 years, 6 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
« no previous file with comments | « runtime/vm/simulator_arm64.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <setjmp.h> // NOLINT 5 #include <setjmp.h> // NOLINT
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #if defined(TARGET_ARCH_DBC) 9 #if defined(TARGET_ARCH_DBC)
10 10
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 return true; 315 return true;
316 } 316 }
317 317
318 static RawObject* AllocateDouble(Thread* thread, double value) { 318 static RawObject* AllocateDouble(Thread* thread, double value) {
319 const intptr_t instance_size = Double::InstanceSize(); 319 const intptr_t instance_size = Double::InstanceSize();
320 const uword start = thread->heap()->new_space()->TryAllocate(instance_size); 320 const uword start = thread->heap()->new_space()->TryAllocate(instance_size);
321 if (LIKELY(start != 0)) { 321 if (LIKELY(start != 0)) {
322 uword tags = 0; 322 uword tags = 0;
323 tags = RawObject::ClassIdTag::update(kDoubleCid, tags); 323 tags = RawObject::ClassIdTag::update(kDoubleCid, tags);
324 tags = RawObject::SizeTag::update(instance_size, tags); 324 tags = RawObject::SizeTag::update(instance_size, tags);
325 // Also writes zero in the hash_ field.
325 *reinterpret_cast<uword*>(start + Double::tags_offset()) = tags; 326 *reinterpret_cast<uword*>(start + Double::tags_offset()) = tags;
326 *reinterpret_cast<double*>(start + Double::value_offset()) = value; 327 *reinterpret_cast<double*>(start + Double::value_offset()) = value;
327 return reinterpret_cast<RawObject*>(start + kHeapObjectTag); 328 return reinterpret_cast<RawObject*>(start + kHeapObjectTag);
328 } 329 }
329 return NULL; 330 return NULL;
330 } 331 }
331 332
332 static bool Double_add(Thread* thread, RawObject** FP, RawObject** result) { 333 static bool Double_add(Thread* thread, RawObject** FP, RawObject** result) {
333 double d1, d2; 334 double d1, d2;
334 if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { 335 if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) {
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 } 2849 }
2849 2850
2850 // TODO(vegorov) allocation bytecodes can benefit from the new-space 2851 // TODO(vegorov) allocation bytecodes can benefit from the new-space
2851 // allocation fast-path that does not transition into the runtime system. 2852 // allocation fast-path that does not transition into the runtime system.
2852 { 2853 {
2853 BYTECODE(AllocateUninitializedContext, A_D); 2854 BYTECODE(AllocateUninitializedContext, A_D);
2854 const uint16_t num_context_variables = rD; 2855 const uint16_t num_context_variables = rD;
2855 const intptr_t instance_size = Context::InstanceSize(num_context_variables); 2856 const intptr_t instance_size = Context::InstanceSize(num_context_variables);
2856 const uword start = thread->heap()->new_space()->TryAllocate(instance_size); 2857 const uword start = thread->heap()->new_space()->TryAllocate(instance_size);
2857 if (LIKELY(start != 0)) { 2858 if (LIKELY(start != 0)) {
2858 uword tags = 0; 2859 uint32_t tags = 0;
2859 tags = RawObject::ClassIdTag::update(kContextCid, tags); 2860 tags = RawObject::ClassIdTag::update(kContextCid, tags);
2860 tags = RawObject::SizeTag::update(instance_size, tags); 2861 tags = RawObject::SizeTag::update(instance_size, tags);
2862 // Also writes 0 in the hash_ field of the header.
2861 *reinterpret_cast<uword*>(start + Array::tags_offset()) = tags; 2863 *reinterpret_cast<uword*>(start + Array::tags_offset()) = tags;
2862 *reinterpret_cast<uword*>(start + Context::num_variables_offset()) = 2864 *reinterpret_cast<uword*>(start + Context::num_variables_offset()) =
2863 num_context_variables; 2865 num_context_variables;
2864 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag); 2866 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag);
2865 pc += 2; 2867 pc += 2;
2866 } 2868 }
2867 DISPATCH(); 2869 DISPATCH();
2868 } 2870 }
2869 2871
2870 { 2872 {
(...skipping 20 matching lines...) Expand all
2891 DISPATCH(); 2893 DISPATCH();
2892 } 2894 }
2893 2895
2894 { 2896 {
2895 BYTECODE(AllocateOpt, A_D); 2897 BYTECODE(AllocateOpt, A_D);
2896 const uword tags = 2898 const uword tags =
2897 static_cast<uword>(Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(rD)))); 2899 static_cast<uword>(Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(rD))));
2898 const intptr_t instance_size = RawObject::SizeTag::decode(tags); 2900 const intptr_t instance_size = RawObject::SizeTag::decode(tags);
2899 const uword start = thread->heap()->new_space()->TryAllocate(instance_size); 2901 const uword start = thread->heap()->new_space()->TryAllocate(instance_size);
2900 if (LIKELY(start != 0)) { 2902 if (LIKELY(start != 0)) {
2903 // Writes both the tags and the initial identity hash on 64 bit platforms.
2901 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags; 2904 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags;
2902 for (intptr_t current_offset = sizeof(RawInstance); 2905 for (intptr_t current_offset = sizeof(RawInstance);
2903 current_offset < instance_size; current_offset += kWordSize) { 2906 current_offset < instance_size; current_offset += kWordSize) {
2904 *reinterpret_cast<RawObject**>(start + current_offset) = null_value; 2907 *reinterpret_cast<RawObject**>(start + current_offset) = null_value;
2905 } 2908 }
2906 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag); 2909 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag);
2907 pc += 2; 2910 pc += 2;
2908 } 2911 }
2909 DISPATCH(); 2912 DISPATCH();
2910 } 2913 }
(...skipping 11 matching lines...) Expand all
2922 } 2925 }
2923 2926
2924 { 2927 {
2925 BYTECODE(AllocateTOpt, A_D); 2928 BYTECODE(AllocateTOpt, A_D);
2926 const uword tags = Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(rD))); 2929 const uword tags = Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(rD)));
2927 const intptr_t instance_size = RawObject::SizeTag::decode(tags); 2930 const intptr_t instance_size = RawObject::SizeTag::decode(tags);
2928 const uword start = thread->heap()->new_space()->TryAllocate(instance_size); 2931 const uword start = thread->heap()->new_space()->TryAllocate(instance_size);
2929 if (LIKELY(start != 0)) { 2932 if (LIKELY(start != 0)) {
2930 RawObject* type_args = SP[0]; 2933 RawObject* type_args = SP[0];
2931 const intptr_t type_args_offset = Bytecode::DecodeD(*pc); 2934 const intptr_t type_args_offset = Bytecode::DecodeD(*pc);
2935 // Writes both the tags and the initial identity hash on 64 bit platforms.
2932 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags; 2936 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags;
2933 for (intptr_t current_offset = sizeof(RawInstance); 2937 for (intptr_t current_offset = sizeof(RawInstance);
2934 current_offset < instance_size; current_offset += kWordSize) { 2938 current_offset < instance_size; current_offset += kWordSize) {
2935 *reinterpret_cast<RawObject**>(start + current_offset) = null_value; 2939 *reinterpret_cast<RawObject**>(start + current_offset) = null_value;
2936 } 2940 }
2937 *reinterpret_cast<RawObject**>(start + type_args_offset) = type_args; 2941 *reinterpret_cast<RawObject**>(start + type_args_offset) = type_args;
2938 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag); 2942 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag);
2939 SP -= 1; // Consume the type arguments on the stack. 2943 SP -= 1; // Consume the type arguments on the stack.
2940 pc += 4; 2944 pc += 4;
2941 } 2945 }
(...skipping 23 matching lines...) Expand all
2965 ~(kObjectAlignment - 1); 2969 ~(kObjectAlignment - 1);
2966 const uword start = 2970 const uword start =
2967 thread->heap()->new_space()->TryAllocate(instance_size); 2971 thread->heap()->new_space()->TryAllocate(instance_size);
2968 if (LIKELY(start != 0)) { 2972 if (LIKELY(start != 0)) {
2969 const intptr_t cid = kArrayCid; 2973 const intptr_t cid = kArrayCid;
2970 uword tags = 0; 2974 uword tags = 0;
2971 if (LIKELY(instance_size <= RawObject::SizeTag::kMaxSizeTag)) { 2975 if (LIKELY(instance_size <= RawObject::SizeTag::kMaxSizeTag)) {
2972 tags = RawObject::SizeTag::update(instance_size, tags); 2976 tags = RawObject::SizeTag::update(instance_size, tags);
2973 } 2977 }
2974 tags = RawObject::ClassIdTag::update(cid, tags); 2978 tags = RawObject::ClassIdTag::update(cid, tags);
2979 // Writes both the tags and the initial identity hash on 64 bit
2980 // platforms.
2975 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags; 2981 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags;
2976 *reinterpret_cast<RawObject**>(start + Array::length_offset()) = 2982 *reinterpret_cast<RawObject**>(start + Array::length_offset()) =
2977 FP[rB]; 2983 FP[rB];
2978 *reinterpret_cast<RawObject**>( 2984 *reinterpret_cast<RawObject**>(
2979 start + Array::type_arguments_offset()) = FP[rC]; 2985 start + Array::type_arguments_offset()) = FP[rC];
2980 RawObject** data = 2986 RawObject** data =
2981 reinterpret_cast<RawObject**>(start + Array::data_offset()); 2987 reinterpret_cast<RawObject**>(start + Array::data_offset());
2982 for (intptr_t i = 0; i < length; i++) { 2988 for (intptr_t i = 0; i < length; i++) {
2983 data[i] = null_value; 2989 data[i] = null_value;
2984 } 2990 }
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
3900 pc_ = pc; 3906 pc_ = pc;
3901 } 3907 }
3902 3908
3903 buf->Longjmp(); 3909 buf->Longjmp();
3904 UNREACHABLE(); 3910 UNREACHABLE();
3905 } 3911 }
3906 3912
3907 } // namespace dart 3913 } // namespace dart
3908 3914
3909 #endif // defined TARGET_ARCH_DBC 3915 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/simulator_arm64.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698