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

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

Issue 12646012: Improve code (less code, slightly faster) for polymorphic calls, by loading the argument descriptor… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_patcher_ia32.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 RawObject* ic_data() const { return immediate_one(); } 80 RawObject* ic_data() const { return immediate_one(); }
81 RawObject* arguments_descriptor() const { return immediate_two(); } 81 RawObject* arguments_descriptor() const { return immediate_two(); }
82 82
83 private: 83 private:
84 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall); 84 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall);
85 }; 85 };
86 86
87 87
88 // The expected pattern of a dart static call: 88 // The expected pattern of a dart static call:
89 // mov R10, arguments_descriptor_array (10 bytes) 89 // mov R10, arguments_descriptor_array (10 bytes) (optional in polym. calls)
90 // mov R11, target_address (10 bytes) 90 // mov R11, target_address (10 bytes)
91 // call R11 (3 bytes) 91 // call R11 (3 bytes)
92 // <- return address 92 // <- return address
93 class StaticCall : public ValueObject { 93 class StaticCall : public ValueObject {
94 public: 94 public:
95 explicit StaticCall(uword return_address) 95 explicit StaticCall(uword return_address)
96 : start_(return_address - kCallPatternSize) { 96 : start_(return_address - kCallPatternSize) {
97 ASSERT(IsValid(return_address)); 97 ASSERT(IsValid(return_address));
98 ASSERT((kCallPatternSize - 10) == Assembler::kCallExternalLabelSize); 98 ASSERT(kCallPatternSize == Assembler::kCallExternalLabelSize);
99 } 99 }
100 100
101 static const int kCallPatternSize = 23; 101 static const int kCallPatternSize = 13;
102 102
103 static bool IsValid(uword return_address) { 103 static bool IsValid(uword return_address) {
104 uint8_t* code_bytes = 104 uint8_t* code_bytes =
105 reinterpret_cast<uint8_t*>(return_address - kCallPatternSize); 105 reinterpret_cast<uint8_t*>(return_address - kCallPatternSize);
106 return (code_bytes[00] == 0x49) && (code_bytes[01] == 0xBA) && 106 return (code_bytes[00] == 0x49) && (code_bytes[01] == 0xBB) &&
107 (code_bytes[10] == 0x49) && (code_bytes[11] == 0xBB) && 107 (code_bytes[10] == 0x41) && (code_bytes[11] == 0xFF) &&
108 (code_bytes[20] == 0x41) && (code_bytes[21] == 0xFF) && 108 (code_bytes[12] == 0xD3);
109 (code_bytes[22] == 0xD3);
110 } 109 }
111 110
112 uword target() const { 111 uword target() const {
113 return *reinterpret_cast<uword*>(start_ + 10 + 2); 112 return *reinterpret_cast<uword*>(start_ + 2);
114 } 113 }
115 114
116 void set_target(uword target) const { 115 void set_target(uword target) const {
117 uword* target_addr = reinterpret_cast<uword*>(start_ + 10 + 2); 116 uword* target_addr = reinterpret_cast<uword*>(start_ + 2);
118 *target_addr = target; 117 *target_addr = target;
119 CPU::FlushICache(start_ + 10, 2 + 8); 118 CPU::FlushICache(start_, 2 + 8);
120 } 119 }
121 120
122 private: 121 private:
123 uword start_; 122 uword start_;
124 123
125 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); 124 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall);
126 }; 125 };
127 126
128 127
129 uword CodePatcher::GetStaticCallTargetAt(uword return_address, 128 uword CodePatcher::GetStaticCallTargetAt(uword return_address,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 *reinterpret_cast<uint8_t*>(start) = 0xE8; 176 *reinterpret_cast<uint8_t*>(start) = 0xE8;
178 ShortCallPattern call(start); 177 ShortCallPattern call(start);
179 call.SetTargetAddress(target); 178 call.SetTargetAddress(target);
180 CPU::FlushICache(start, ShortCallPattern::InstructionLength()); 179 CPU::FlushICache(start, ShortCallPattern::InstructionLength());
181 } 180 }
182 181
183 182
184 } // namespace dart 183 } // namespace dart
185 184
186 #endif // defined TARGET_ARCH_X64 185 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_ia32.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698