48
49 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
50 const int amd64_code_length = VtableStub::pd_code_size_limit(true);
51 VtableStub* s = new(amd64_code_length) VtableStub(true, vtable_index);
52 // Can be NULL if there is no free space in the code cache.
53 if (s == NULL) {
54 return NULL;
55 }
56
57 ResourceMark rm;
58 CodeBuffer cb(s->entry_point(), amd64_code_length);
59 MacroAssembler* masm = new MacroAssembler(&cb);
60
61 #ifndef PRODUCT
62 if (CountCompiledCalls) {
63 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
64 }
65 #endif
66
67 // get receiver (need to skip return address on top of stack)
68 assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
69
70 // Free registers (non-args) are rax, rbx
71
72 // get receiver klass
73 address npe_addr = __ pc();
74 __ load_klass(rax, j_rarg0);
75
76 #ifndef PRODUCT
77 if (DebugVtables) {
78 Label L;
79 // check offset vs vtable length
80 __ cmpl(Address(rax, InstanceKlass::vtable_length_offset() * wordSize),
81 vtable_index * vtableEntry::size());
82 __ jcc(Assembler::greater, L);
83 __ movl(rbx, vtable_index);
84 __ call_VM(noreg,
85 CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), j_rarg0, rbx);
86 __ bind(L);
87 }
88 #endif // PRODUCT
137 }
138
139 ResourceMark rm;
140 CodeBuffer cb(s->entry_point(), amd64_code_length);
141 MacroAssembler* masm = new MacroAssembler(&cb);
142
143 #ifndef PRODUCT
144 if (CountCompiledCalls) {
145 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
146 }
147 #endif
148
149 // Entry arguments:
150 // rax: Interface
151 // j_rarg0: Receiver
152
153 // Free registers (non-args) are rax (interface), rbx
154
155 // get receiver (need to skip return address on top of stack)
156
157 assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
158 // get receiver klass (also an implicit null-check)
159 address npe_addr = __ pc();
160
161 // Most registers are in use; we'll use rax, rbx, r10, r11
162 // (various calling sequences use r[cd]x, r[sd]i, r[89]; stay away from them)
163 __ load_klass(r10, j_rarg0);
164
165 // If we take a trap while this arg is on the stack we will not
166 // be able to walk the stack properly. This is not an issue except
167 // when there are mistakes in this assembly code that could generate
168 // a spurious fault. Ask me how I know...
169
170 const Register method = rbx;
171 Label throw_icce;
172
173 // Get Method* and entrypoint for compiler
174 __ lookup_interface_method(// inputs: rec. class, interface, itable index
175 r10, rax, itable_index,
176 // outputs: method, scan temp. reg
177 method, r11,
|
48
49 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
50 const int amd64_code_length = VtableStub::pd_code_size_limit(true);
51 VtableStub* s = new(amd64_code_length) VtableStub(true, vtable_index);
52 // Can be NULL if there is no free space in the code cache.
53 if (s == NULL) {
54 return NULL;
55 }
56
57 ResourceMark rm;
58 CodeBuffer cb(s->entry_point(), amd64_code_length);
59 MacroAssembler* masm = new MacroAssembler(&cb);
60
61 #ifndef PRODUCT
62 if (CountCompiledCalls) {
63 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
64 }
65 #endif
66
67 // get receiver (need to skip return address on top of stack)
68 assert(VtableStub::receiver_location() == j_rarg0.as_VMReg(), "receiver expected in j_rarg0");
69
70 // Free registers (non-args) are rax, rbx
71
72 // get receiver klass
73 address npe_addr = __ pc();
74 __ load_klass(rax, j_rarg0);
75
76 #ifndef PRODUCT
77 if (DebugVtables) {
78 Label L;
79 // check offset vs vtable length
80 __ cmpl(Address(rax, InstanceKlass::vtable_length_offset() * wordSize),
81 vtable_index * vtableEntry::size());
82 __ jcc(Assembler::greater, L);
83 __ movl(rbx, vtable_index);
84 __ call_VM(noreg,
85 CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), j_rarg0, rbx);
86 __ bind(L);
87 }
88 #endif // PRODUCT
137 }
138
139 ResourceMark rm;
140 CodeBuffer cb(s->entry_point(), amd64_code_length);
141 MacroAssembler* masm = new MacroAssembler(&cb);
142
143 #ifndef PRODUCT
144 if (CountCompiledCalls) {
145 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
146 }
147 #endif
148
149 // Entry arguments:
150 // rax: Interface
151 // j_rarg0: Receiver
152
153 // Free registers (non-args) are rax (interface), rbx
154
155 // get receiver (need to skip return address on top of stack)
156
157 assert(VtableStub::receiver_location() == j_rarg0.as_VMReg(), "receiver expected in j_rarg0");
158 // get receiver klass (also an implicit null-check)
159 address npe_addr = __ pc();
160
161 // Most registers are in use; we'll use rax, rbx, r10, r11
162 // (various calling sequences use r[cd]x, r[sd]i, r[89]; stay away from them)
163 __ load_klass(r10, j_rarg0);
164
165 // If we take a trap while this arg is on the stack we will not
166 // be able to walk the stack properly. This is not an issue except
167 // when there are mistakes in this assembly code that could generate
168 // a spurious fault. Ask me how I know...
169
170 const Register method = rbx;
171 Label throw_icce;
172
173 // Get Method* and entrypoint for compiler
174 __ lookup_interface_method(// inputs: rec. class, interface, itable index
175 r10, rax, itable_index,
176 // outputs: method, scan temp. reg
177 method, r11,
|