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

Side by Side Diff: runtime/lib/object.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 | « no previous file | runtime/lib/object_patch.dart » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 24 matching lines...) Expand all
35 // Implemented in the flow graph builder. 35 // Implemented in the flow graph builder.
36 UNREACHABLE(); 36 UNREACHABLE();
37 return Object::null(); 37 return Object::null();
38 } 38 }
39 39
40 40
41 DEFINE_NATIVE_ENTRY(Object_getHash, 1) { 41 DEFINE_NATIVE_ENTRY(Object_getHash, 1) {
42 // Please note that no handle is created for the argument. 42 // Please note that no handle is created for the argument.
43 // This is safe since the argument is only used in a tail call. 43 // This is safe since the argument is only used in a tail call.
44 // The performance benefit is more than 5% when using hashCode. 44 // The performance benefit is more than 5% when using hashCode.
45 #if defined(HASH_IN_OBJECT_HEADER)
46 return Smi::New(Object::GetCachedHash(arguments->NativeArgAt(0)));
47 #else
45 Heap* heap = isolate->heap(); 48 Heap* heap = isolate->heap();
46 ASSERT(arguments->NativeArgAt(0)->IsDartInstance()); 49 ASSERT(arguments->NativeArgAt(0)->IsDartInstance());
47 return Smi::New(heap->GetHash(arguments->NativeArgAt(0))); 50 return Smi::New(heap->GetHash(arguments->NativeArgAt(0)));
51 #endif
48 } 52 }
49 53
50 54
51 DEFINE_NATIVE_ENTRY(Object_setHash, 2) { 55 DEFINE_NATIVE_ENTRY(Object_setHash, 2) {
56 GET_NON_NULL_NATIVE_ARGUMENT(Smi, hash, arguments->NativeArgAt(1));
57 #if defined(HASH_IN_OBJECT_HEADER)
58 Object::SetCachedHash(arguments->NativeArgAt(0), hash.Value());
59 #else
52 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 60 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
53 GET_NON_NULL_NATIVE_ARGUMENT(Smi, hash, arguments->NativeArgAt(1));
54 Heap* heap = isolate->heap(); 61 Heap* heap = isolate->heap();
55 heap->SetHash(instance.raw(), hash.Value()); 62 heap->SetHash(instance.raw(), hash.Value());
63 #endif
56 return Object::null(); 64 return Object::null();
57 } 65 }
58 66
59 67
60 DEFINE_NATIVE_ENTRY(Object_toString, 1) { 68 DEFINE_NATIVE_ENTRY(Object_toString, 1) {
61 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 69 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
62 if (instance.IsString()) { 70 if (instance.IsString()) {
63 return instance.raw(); 71 return instance.raw();
64 } 72 }
65 const char* c_str = instance.ToCString(); 73 const char* c_str = instance.ToCString();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 362
355 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) { 363 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) {
356 #if defined(ARCH_IS_64_BIT) 364 #if defined(ARCH_IS_64_BIT)
357 return Bool::True().raw(); 365 return Bool::True().raw();
358 #else 366 #else
359 return Bool::False().raw(); 367 return Bool::False().raw();
360 #endif // defined(ARCH_IS_64_BIT) 368 #endif // defined(ARCH_IS_64_BIT)
361 } 369 }
362 370
363 } // namespace dart 371 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698