1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
241 dcon->type = type;
242 return dcon;
243 }
244 }
245 }
246 // If this assert is hit (in pre-integration testing!) then re-evaluate
247 // the comment on the definition of DC_LIMIT.
248 guarantee(false, "too many delayed constants");
249 return NULL;
250 }
251
252 void DelayedConstant::update_all() {
253 for (int i = 0; i < DC_LIMIT; i++) {
254 DelayedConstant* dcon = &delayed_constants[i];
255 if (dcon->value_fn != NULL && dcon->value == 0) {
256 typedef int (*int_fn_t)();
257 typedef address (*address_fn_t)();
258 switch (dcon->type) {
259 case T_INT: dcon->value = (intptr_t) ((int_fn_t) dcon->value_fn)(); break;
260 case T_ADDRESS: dcon->value = (intptr_t) ((address_fn_t)dcon->value_fn)(); break;
261 }
262 }
263 }
264 }
265
266 RegisterOrConstant AbstractAssembler::delayed_value(int(*value_fn)(), Register tmp, int offset) {
267 intptr_t val = (intptr_t) (*value_fn)();
268 if (val != 0) return val + offset;
269 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
270 }
271 RegisterOrConstant AbstractAssembler::delayed_value(address(*value_fn)(), Register tmp, int offset) {
272 intptr_t val = (intptr_t) (*value_fn)();
273 if (val != 0) return val + offset;
274 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
275 }
276 intptr_t* AbstractAssembler::delayed_value_addr(int(*value_fn)()) {
277 DelayedConstant* dcon = DelayedConstant::add(T_INT, (DelayedConstant::value_fn_t) value_fn);
278 return &dcon->value;
279 }
280 intptr_t* AbstractAssembler::delayed_value_addr(address(*value_fn)()) {
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
241 dcon->type = type;
242 return dcon;
243 }
244 }
245 }
246 // If this assert is hit (in pre-integration testing!) then re-evaluate
247 // the comment on the definition of DC_LIMIT.
248 guarantee(false, "too many delayed constants");
249 return NULL;
250 }
251
252 void DelayedConstant::update_all() {
253 for (int i = 0; i < DC_LIMIT; i++) {
254 DelayedConstant* dcon = &delayed_constants[i];
255 if (dcon->value_fn != NULL && dcon->value == 0) {
256 typedef int (*int_fn_t)();
257 typedef address (*address_fn_t)();
258 switch (dcon->type) {
259 case T_INT: dcon->value = (intptr_t) ((int_fn_t) dcon->value_fn)(); break;
260 case T_ADDRESS: dcon->value = (intptr_t) ((address_fn_t)dcon->value_fn)(); break;
261 default: break;
262 }
263 }
264 }
265 }
266
267 RegisterOrConstant AbstractAssembler::delayed_value(int(*value_fn)(), Register tmp, int offset) {
268 intptr_t val = (intptr_t) (*value_fn)();
269 if (val != 0) return val + offset;
270 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
271 }
272 RegisterOrConstant AbstractAssembler::delayed_value(address(*value_fn)(), Register tmp, int offset) {
273 intptr_t val = (intptr_t) (*value_fn)();
274 if (val != 0) return val + offset;
275 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset);
276 }
277 intptr_t* AbstractAssembler::delayed_value_addr(int(*value_fn)()) {
278 DelayedConstant* dcon = DelayedConstant::add(T_INT, (DelayedConstant::value_fn_t) value_fn);
279 return &dcon->value;
280 }
281 intptr_t* AbstractAssembler::delayed_value_addr(address(*value_fn)()) {
|